22void checkPoint(
const std::vector<double> &p,
const std::vector<util::Point> &nodes) {
48 throw std::runtime_error(
50 <<
"Error: Point p = ("
51 << p[0] <<
", " << p[1] <<
", " << p[2]
52 <<
") does not belong to reference tet element = {("
53 << nodes[0].d_x <<
", " << nodes[0].d_y <<
", " << nodes[0].d_z
55 << nodes[1].d_x <<
"," << nodes[1].d_y <<
", " << nodes[1].d_z
57 << nodes[2].d_x <<
"," << nodes[2].d_y <<
", " << nodes[2].d_z
59 << nodes[3].d_x <<
"," << nodes[3].d_y <<
", " << nodes[3].d_z
61 <<
"Coordinates in reference element are: "
64 <<
", zeta = " << p[2] <<
"\n");
74 throw std::runtime_error(
76 <<
"Error: For linear tet element, we only support upto 3 quad "
77 "order approximation.\n");
87 auto a = nodes[1] - nodes[0];
88 auto b = nodes[2] - nodes[0];
89 auto c = nodes[3] - nodes[0];
90 return (1. / 6.) * a * (b.cross(c));
94 const util::Point &p,
const std::vector<util::Point> &nodes) {
95 return getShapes(mapPointToRefElem(p, nodes));
99 const util::Point &p,
const std::vector<util::Point> &nodes) {
102 auto ders_ref = getDerShapes(mapPointToRefElem(p, nodes));
105 std::vector<std::vector<double>> J;
106 auto detJ = getJacobian(p, nodes, &J);
111 std::vector<std::vector<double>> ders(ders_ref.size(),
112 std::vector<double>(3, 0.));
115 for (
size_t i = 0; i < 4; i++)
132 std::vector<std::vector<double>> r;
133 r.push_back(std::vector<double>{-1., -1., -1.});
134 r.push_back(std::vector<double>{1., 0., 0.});
135 r.push_back(std::vector<double>{0., 1., 0.});
136 r.push_back(std::vector<double>{0., 0., 1.});
143 const util::Point &p,
const std::vector<util::Point> &nodes) {
146 std::vector<std::vector<double>> J(3, std::vector<double>(3, 0.));
147 auto detJ = getJacobian(p, nodes, &J);
157 std::vector<double> vec_p = {p.
d_x - nodes[0].d_x,
158 p.
d_y - nodes[0].d_y,
159 p.
d_z - nodes[0].d_z};
164 checkPoint(p_ref, nodes);
177 const std::vector<util::Point> &nodes,
178 std::vector<std::vector<double>> *J) {
181 (*J)[0] = std::vector<double>{nodes[1].d_x - nodes[0].d_x,
182 nodes[1].d_y - nodes[0].d_y,
183 nodes[1].d_z - nodes[0].d_z};
184 (*J)[1] = std::vector<double>{nodes[2].d_x - nodes[0].d_x,
185 nodes[2].d_y - nodes[0].d_y,
186 nodes[2].d_z - nodes[0].d_z};
187 (*J)[2] = std::vector<double>{nodes[3].d_x - nodes[0].d_x,
188 nodes[3].d_y - nodes[0].d_y,
189 nodes[3].d_z - nodes[0].d_z};
193 std::vector<std::vector<double>> J_local;
195 J_local[0] = std::vector<double>{nodes[1].d_x - nodes[0].d_x,
196 nodes[1].d_y - nodes[0].d_y,
197 nodes[1].d_z - nodes[0].d_z};
198 J_local[1] = std::vector<double>{nodes[2].d_x - nodes[0].d_x,
199 nodes[2].d_y - nodes[0].d_y,
200 nodes[2].d_z - nodes[0].d_z};
201 J_local[2] = std::vector<double>{nodes[3].d_x - nodes[0].d_x,
202 nodes[3].d_y - nodes[0].d_y,
203 nodes[3].d_z - nodes[0].d_z};
215 if (!d_quads.empty())
return;
218 if (d_quadOrder == 0) {
223 std::vector<std::vector<double>> ident_mat;
224 ident_mat.push_back(std::vector<double>{1., 0., 0.});
225 ident_mat.push_back(std::vector<double>{0., 1., 0.});
226 ident_mat.push_back(std::vector<double>{0., 0., 1.});
235 if (d_quadOrder == 1) {
247 d_quads.push_back(qd);
253 if (d_quadOrder == 2) {
258 double a = 0.585410196624969;
259 double b = 0.138196601125011;
267 d_quads.push_back(qd);
275 d_quads.push_back(qd);
283 d_quads.push_back(qd);
291 d_quads.push_back(qd);
297 if (d_quadOrder == 3) {
301 double w1 = -2. / 15.;
315 d_quads.push_back(qd);
323 d_quads.push_back(qd);
331 d_quads.push_back(qd);
339 d_quads.push_back(qd);
347 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.
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.
Collects a message with stream syntax for use in an exception.
void checkPoint(const std::vector< double > &p, const std::vector< util::Point > &nodes)
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
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