21constexpr double SX[8] = {-1., 1., 1., -1., -1., 1., 1., -1.};
22constexpr double SY[8] = {-1., -1., 1., 1., -1., -1., 1., 1.};
23constexpr double SZ[8] = {-1., -1., -1., -1., 1., 1., 1., 1.};
36 return 8. * getJacobian(
util::Point(0., 0., 0.), nodes,
nullptr);
38 for (
const auto &qd : d_quads)
39 vol += qd.d_w * getJacobian(qd.d_p, nodes,
nullptr);
44 std::vector<double> N(8);
45 for (
size_t i = 0; i < 8; ++i)
46 N[i] = 0.125 * (1. + SX[i] * p.
d_x) * (1. + SY[i] * p.
d_y) *
51std::vector<std::vector<double>>
53 std::vector<std::vector<double>> r(8, std::vector<double>(3, 0.));
54 for (
size_t i = 0; i < 8; ++i) {
55 r[i][0] = 0.125 * SX[i] * (1. + SY[i] * p.
d_y) * (1. + SZ[i] * p.
d_z);
56 r[i][1] = 0.125 * SY[i] * (1. + SX[i] * p.
d_x) * (1. + SZ[i] * p.
d_z);
57 r[i][2] = 0.125 * SZ[i] * (1. + SX[i] * p.
d_x) * (1. + SY[i] * p.
d_y);
63 const std::vector<util::Point> &nodes,
64 std::vector<std::vector<double>> *J) {
65 auto der = getDerShapes(p);
66 std::vector<std::vector<double>> Jloc(3, std::vector<double>(3, 0.));
67 for (
size_t a = 0; a < 8; ++a) {
68 Jloc[0][0] += der[a][0] * nodes[a].d_x;
69 Jloc[0][1] += der[a][0] * nodes[a].d_y;
70 Jloc[0][2] += der[a][0] * nodes[a].d_z;
71 Jloc[1][0] += der[a][1] * nodes[a].d_x;
72 Jloc[1][1] += der[a][1] * nodes[a].d_y;
73 Jloc[1][2] += der[a][1] * nodes[a].d_z;
74 Jloc[2][0] += der[a][2] * nodes[a].d_x;
75 Jloc[2][1] += der[a][2] * nodes[a].d_y;
76 Jloc[2][2] += der[a][2] * nodes[a].d_z;
87 if (d_quadOrder == 0) {
92 std::vector<std::vector<double>> ident(3, std::vector<double>(3, 0.));
93 ident[0][0] = ident[1][1] = ident[2][2] = 1.;
95 std::vector<double> x;
96 std::vector<double> w;
97 if (d_quadOrder == 1) {
100 }
else if (d_quadOrder == 2) {
101 x = {-1. / std::sqrt(3.), 1. / std::sqrt(3.)};
105 x = {-std::sqrt(3.) / std::sqrt(5.), 0., std::sqrt(3.) / std::sqrt(5.)};
106 w = {5. / 9., 8. / 9., 5. / 9.};
109 const size_t npts = x.size();
111 d_quads.reserve(npts * npts * npts);
112 for (
size_t i = 0; i < npts; ++i)
113 for (
size_t j = 0; j < npts; ++j)
114 for (
size_t k = 0; k < npts; ++k) {
116 qd.
d_w = w[i] * w[j] * w[k];
122 d_quads.push_back(qd);
A base class which provides methods to map points to/from reference element and to compute quadrature...
double getJacobian(const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
Computes Jacobian of map from reference element to given element .
std::vector< double > getShapes(const util::Point &p) override
Returns the values of shape function at point p on reference element.
std::vector< std::vector< double > > getDerShapes(const util::Point &p) override
Returns the values of derivative of shape function at point p on reference element.
double elemSize(const std::vector< util::Point > &nodes) override
Returns the size of element (length in 1-d, area in 2-d, volume in 3-d element)
void init() override
Compute the quadrature points.
Collection of methods useful in simulation.
double det(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
A struct to store the quadrature data. List of data are.
std::vector< double > d_shapes
Value of shape functions at quad point p.
std::vector< std::vector< double > > d_derShapes
Derivatives of shape functions at the quad point.
double d_w
Quadrature weight.
util::Point d_p
Quadrature point in 1-d, 2-d or 3-d.
std::vector< std::vector< double > > d_J
Jacobian of the map from reference element to the element.
double d_detJ
Determinant of the Jacobian of the map from reference element to the element.
A structure to represent 3d vectors.
double d_y
the y coordinate
double d_z
the z coordinate
double d_x
the x coordinate