21void checkPoint(
const std::vector<double> &p,
const std::vector<util::Point> &nodes) {
47 std::cerr <<
"Error: Point p = ("
48 << p[0] <<
", " << p[1] <<
", " << p[2]
49 <<
") does not belong to reference tet element = {("
50 << nodes[0].d_x <<
", " << nodes[0].d_y <<
", " << nodes[0].d_z
52 << nodes[1].d_x <<
"," << nodes[1].d_y <<
", " << nodes[1].d_z
54 << nodes[2].d_x <<
"," << nodes[2].d_y <<
", " << nodes[2].d_z
56 << nodes[3].d_x <<
"," << nodes[3].d_y <<
", " << nodes[3].d_z
58 <<
"Coordinates in reference element are: "
61 <<
", zeta = " << p[2] <<
"\n";
72 std::cout <<
"Error: For linear tet element, we only support upto 3 quad "
73 "order approximation.\n";
84 auto a = nodes[1] - nodes[0];
85 auto b = nodes[2] - nodes[0];
86 auto c = nodes[3] - nodes[0];
87 return (1. / 6.) * a * (b.cross(c));
91 const util::Point &p,
const std::vector<util::Point> &nodes) {
92 return getShapes(mapPointToRefElem(p, nodes));
96 const util::Point &p,
const std::vector<util::Point> &nodes) {
99 auto ders_ref = getDerShapes(mapPointToRefElem(p, nodes));
102 std::vector<std::vector<double>> J;
103 auto detJ = getJacobian(p, nodes, &J);
108 std::vector<std::vector<double>> ders(ders_ref.size(),
109 std::vector<double>(3, 0.));
112 for (
size_t i = 0; i < 4; i++)
119 const std::vector<util::Point> &nodes) {
125 for (
auto &qd : qds) {
128 qd.d_detJ = getJacobian(qd.d_p, nodes, &(qd.d_J));
135 for (
size_t i=0; i<4; i++) {
136 qd.d_p.d_x += qd.d_shapes[i] * nodes[i].d_x;
137 qd.d_p.d_y += qd.d_shapes[i] * nodes[i].d_y;
138 qd.d_p.d_z += qd.d_shapes[i] * nodes[i].d_z;
145 std::vector<std::vector<double>> ders(qd.d_derShapes.size(),
146 std::vector<double>(3, 0.));
149 for (
size_t i = 0; i < 4; i++)
150 ders[i] =
util::dot(J_inv, qd.d_derShapes[i]);
152 qd.d_derShapes = ders;
159 const std::vector<util::Point> &nodes) {
164 for (
auto &qd : qds) {
167 qd.d_w *= getJacobian(qd.d_p, nodes,
nullptr);
171 for (
size_t i=0; i<4; i++) {
172 qd.d_p.d_x += qd.d_shapes[i] * nodes[i].d_x;
173 qd.d_p.d_y += qd.d_shapes[i] * nodes[i].d_y;
174 qd.d_p.d_z += qd.d_shapes[i] * nodes[i].d_z;
193 std::vector<std::vector<double>> r;
194 r.push_back(std::vector<double>{-1., -1., -1.});
195 r.push_back(std::vector<double>{1., 0., 0.});
196 r.push_back(std::vector<double>{0., 1., 0.});
197 r.push_back(std::vector<double>{0., 0., 1.});
204 const util::Point &p,
const std::vector<util::Point> &nodes) {
207 std::vector<std::vector<double>> J(3, std::vector<double>(3, 0.));
208 auto detJ = getJacobian(p, nodes, &J);
218 std::vector<double> vec_p = {p.
d_x - nodes[0].d_x,
219 p.
d_y - nodes[0].d_y,
220 p.
d_z - nodes[0].d_z};
225 checkPoint(p_ref, nodes);
238 const std::vector<util::Point> &nodes,
239 std::vector<std::vector<double>> *J) {
242 (*J)[0] = std::vector<double>{nodes[1].d_x - nodes[0].d_x,
243 nodes[1].d_y - nodes[0].d_y,
244 nodes[1].d_z - nodes[0].d_z};
245 (*J)[1] = std::vector<double>{nodes[2].d_x - nodes[0].d_x,
246 nodes[2].d_y - nodes[0].d_y,
247 nodes[2].d_z - nodes[0].d_z};
248 (*J)[2] = std::vector<double>{nodes[3].d_x - nodes[0].d_x,
249 nodes[3].d_y - nodes[0].d_y,
250 nodes[3].d_z - nodes[0].d_z};
254 std::vector<std::vector<double>> J_local;
256 J_local[0] = std::vector<double>{nodes[1].d_x - nodes[0].d_x,
257 nodes[1].d_y - nodes[0].d_y,
258 nodes[1].d_z - nodes[0].d_z};
259 J_local[1] = std::vector<double>{nodes[2].d_x - nodes[0].d_x,
260 nodes[2].d_y - nodes[0].d_y,
261 nodes[2].d_z - nodes[0].d_z};
262 J_local[2] = std::vector<double>{nodes[3].d_x - nodes[0].d_x,
263 nodes[3].d_y - nodes[0].d_y,
264 nodes[3].d_z - nodes[0].d_z};
276 if (!d_quads.empty())
return;
279 if (d_quadOrder == 0) {
284 std::vector<std::vector<double>> ident_mat;
285 ident_mat.push_back(std::vector<double>{1., 0., 0.});
286 ident_mat.push_back(std::vector<double>{0., 1., 0.});
287 ident_mat.push_back(std::vector<double>{0., 0., 1.});
296 if (d_quadOrder == 1) {
308 d_quads.push_back(qd);
314 if (d_quadOrder == 2) {
319 double a = 0.585410196624969;
320 double b = 0.138196601125011;
328 d_quads.push_back(qd);
336 d_quads.push_back(qd);
344 d_quads.push_back(qd);
352 d_quads.push_back(qd);
358 if (d_quadOrder == 3) {
362 double w1 = -2. / 15.;
376 d_quads.push_back(qd);
384 d_quads.push_back(qd);
392 d_quads.push_back(qd);
400 d_quads.push_back(qd);
408 d_quads.push_back(qd);
A base class which provides methods to map points to/from reference element and to compute quadrature...
size_t d_quadOrder
Order of quadrature point integration approximation.
void init() override
Compute the quadrature points for triangle element.
std::vector< std::vector< double > > getDerShapes(const util::Point &p, const std::vector< util::Point > &nodes) override
Returns the values of derivative of shape function at point p.
TetElem(size_t order)
Constructor.
std::vector< fe::QuadData > getQuadDatas(const std::vector< util::Point > &nodes) override
Get vector of quadrature data.
std::vector< fe::QuadData > getQuadPoints(const std::vector< util::Point > &nodes) override
Get vector of quadrature data.
double elemSize(const std::vector< util::Point > &nodes) override
Returns the volume of element.
double getJacobian(const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
Computes the Jacobian of map .
util::Point mapPointToRefElem(const util::Point &p, const std::vector< util::Point > &nodes) override
Maps point p in a given element to the reference element.
std::vector< double > getShapes(const util::Point &p, const std::vector< util::Point > &nodes) override
Returns the values of shape function at point p.
void checkPoint(const std::vector< double > &p, const std::vector< util::Point > &nodes)
Collection of methods and data related to finite element and mesh.
Collection of methods useful in simulation.
bool isGreater(const double &a, const double &b)
Returns true if a > b.
double det(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
std::vector< std::vector< double > > inv(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
bool isLess(const double &a, const double &b)
Returns true if a < b.
std::vector< double > dot(const std::vector< std::vector< double > > &m, const std::vector< double > &v)
Computes the dot product between matrix and vector.
std::vector< std::vector< double > > transpose(const std::vector< std::vector< double > > &m)
Computes the tranpose 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
Value of derivative of shape functions at quad point p.
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