26 return (nodes[1].d_x - nodes[0].d_x);
31 const std::vector<util::Point> &nodes) {
32 return getShapes(mapPointToRefElem(p, nodes));
35std::vector<std::vector<double>>
37 const std::vector<util::Point> &nodes) {
39 auto ders_ref = getDerShapes(mapPointToRefElem(p, nodes));
42 auto detJ = getJacobian(p, nodes,
nullptr);
45 ders_ref[0][0] = ders_ref[0][0] / detJ;
46 ders_ref[1][0] = ders_ref[1][0] / detJ;
55 return std::vector<double>{0.5 * (1. - p.
d_x), 0.5 * (1. + p.
d_x)};
58std::vector<std::vector<double>>
66 std::vector<std::vector<double>> r;
67 r.push_back(std::vector<double>{-0.5});
68 r.push_back(std::vector<double>{0.5});
74 const std::vector<util::Point> &nodes) {
75 auto xi = (2. * p.
d_x - nodes[0].d_x - nodes[1].d_x) /
76 (nodes[0].d_x - nodes[1].d_x);
80 throw std::runtime_error(
82 <<
"Error: Trying to map point p = " << p.
d_x
83 <<
" in given line to reference line.\n"
84 <<
"But the point p does not belong to line = {"
85 << nodes[0].d_x <<
", " << nodes[1].d_x <<
"}.\n");
97 const std::vector<util::Point> &nodes,
98 std::vector<std::vector<double>> *J) {
100 const double Jxi = 0.5 * (nodes[1].d_x - nodes[0].d_x);
104 (*J)[0] = std::vector<double>{Jxi};
120 if (!d_quads.empty())
124 if (d_quadOrder == 0)
128 std::vector<std::vector<double>> ident_mat;
129 ident_mat.push_back(std::vector<double>{1.});
134 if (d_quadOrder == 1) {
144 d_quads.push_back(qd);
150 if (d_quadOrder == 2) {
160 d_quads.push_back(qd);
168 d_quads.push_back(qd);
174 if (d_quadOrder == 3) {
185 d_quads.push_back(qd);
193 d_quads.push_back(qd);
201 d_quads.push_back(qd);
207 if (d_quadOrder == 4) {
210 qd.
d_w = 0.6521451548625461;
216 d_quads.push_back(qd);
218 qd.
d_w = 0.6521451548625461;
224 d_quads.push_back(qd);
226 qd.
d_w = 0.3478548451374538;
232 d_quads.push_back(qd);
234 qd.
d_w = 0.3478548451374538;
240 d_quads.push_back(qd);
246 if (d_quadOrder == 5) {
249 qd.
d_w = 0.5688888888888889;
255 d_quads.push_back(qd);
257 qd.
d_w = 0.4786286704993665;
263 d_quads.push_back(qd);
265 qd.
d_w = 0.4786286704993665;
271 d_quads.push_back(qd);
273 qd.
d_w = 0.2369268850561891;
279 d_quads.push_back(qd);
281 qd.
d_w = 0.2369268850561891;
287 d_quads.push_back(qd);
A base class which provides methods to map points to/from reference element and to compute quadrature...
std::vector< double > getShapes(const util::Point &p, const std::vector< util::Point > &nodes) override
Returns the values of shape function at point p.
LineElem(size_t order)
Constructor for line element.
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.
void init() override
Compute the quadrature points for line element.
double getJacobian(const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
Computes Jacobian of the map .
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.
double elemSize(const std::vector< util::Point > &nodes) override
Returns the length of element.
Collects a message with stream syntax for use in an exception.
Collection of methods useful in simulation.
bool isGreater(const double &a, const double &b)
Returns true if a > b.
bool isLess(const double &a, const double &b)
Returns true if a < b.
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_x
the x coordinate