23 ((-nodes[0].d_x + nodes[1].d_x + nodes[2].d_x - nodes[3].d_x) *
24 (-nodes[0].d_y - nodes[1].d_y + nodes[2].d_y + nodes[3].d_y) -
25 (-nodes[0].d_x - nodes[1].d_x + nodes[2].d_x + nodes[3].d_x) *
26 (-nodes[0].d_y + nodes[1].d_y + nodes[2].d_y - nodes[3].d_y));
31std::vector<fe::QuadData>
38 for (
auto &qd : qds) {
41 qd.d_detJ = getJacobian(qd.d_p, nodes, &(qd.d_J));
47 qd.d_p.d_x = qd.d_shapes[0] * nodes[0].d_x + qd.d_shapes[1] * nodes[1].d_x +
48 qd.d_shapes[2] * nodes[2].d_x + qd.d_shapes[3] * nodes[3].d_x;
49 qd.d_p.d_y = qd.d_shapes[0] * nodes[0].d_y + qd.d_shapes[1] * nodes[1].d_y +
50 qd.d_shapes[2] * nodes[2].d_y + qd.d_shapes[3] * nodes[3].d_y;
53 std::vector<std::vector<double>> ders;
55 for (
size_t i=3; i<4; i++) {
57 auto d1 = (qd.d_derShapes[i][0] * qd.d_J[1][1] - qd.d_derShapes[i][1] *
58 qd.d_J[0][1]) / qd.d_detJ;
60 auto d2 = (-qd.d_derShapes[i][0] * qd.d_J[1][0] + qd.d_derShapes[i][1] *
61 qd.d_J[0][0]) / qd.d_detJ;
63 ders.push_back(std::vector<double>{d1, d2});
65 qd.d_derShapes = ders;
71std::vector<fe::QuadData>
78 for (
auto &qd : qds) {
81 qd.d_w *= getJacobian(qd.d_p, nodes,
nullptr);
84 qd.d_p.d_x = qd.d_shapes[0] * nodes[0].d_x + qd.d_shapes[1] * nodes[1].d_x +
85 qd.d_shapes[2] * nodes[2].d_x + qd.d_shapes[3] * nodes[3].d_x;
86 qd.d_p.d_y = qd.d_shapes[0] * nodes[0].d_y + qd.d_shapes[1] * nodes[1].d_y +
87 qd.d_shapes[2] * nodes[2].d_y + qd.d_shapes[3] * nodes[3].d_y;
99 return std::vector<double>{
100 0.25 * (1. - p.
d_x) * (1. - p.
d_y), 0.25 * (1. + p.
d_x) * (1. - p.
d_y),
101 0.25 * (1. + p.
d_x) * (1. + p.
d_y), 0.25 * (1. - p.
d_x) * (1. + p.
d_y)};
104std::vector<std::vector<double>>
118 std::vector<std::vector<double>> r;
119 r.push_back(std::vector<double>{-0.25 * (1. - p.
d_y), -0.25 * (1. - p.
d_x)});
120 r.push_back(std::vector<double>{0.25 * (1. - p.
d_y), -0.25 * (1. + p.
d_x)});
121 r.push_back(std::vector<double>{0.25 * (1. + p.
d_y), 0.25 * (1. + p.
d_x)});
122 r.push_back(std::vector<double>{-0.25 * (1. + p.
d_y), 0.25 * (1. - p.
d_x)});
128 const std::vector<util::Point> &nodes,
129 std::vector<std::vector<double>> *J) {
131 auto der_shapes = getDerShapes(p);
134 (*J)[0] = std::vector<double>{
135 der_shapes[0][0] * nodes[0].d_x + der_shapes[1][0] * nodes[1].d_x +
136 der_shapes[2][0] * nodes[2].d_x + der_shapes[3][0] * nodes[3].d_x,
137 der_shapes[0][0] * nodes[0].d_y + der_shapes[1][0] * nodes[1].d_y +
138 der_shapes[2][0] * nodes[2].d_y + der_shapes[3][0] * nodes[3].d_y};
139 (*J)[1] = std::vector<double>{
140 der_shapes[0][1] * nodes[0].d_x + der_shapes[1][1] * nodes[1].d_x +
141 der_shapes[2][1] * nodes[2].d_x + der_shapes[3][1] * nodes[3].d_x,
142 der_shapes[0][1] * nodes[0].d_y + der_shapes[1][1] * nodes[1].d_y +
143 der_shapes[2][1] * nodes[2].d_y + der_shapes[3][1] * nodes[3].d_y};
145 return (*J)[0][0] * (*J)[1][1] - (*J)[0][1] * (*J)[1][0];
148 return (der_shapes[0][0] * nodes[0].d_x + der_shapes[1][0] * nodes[1].d_x +
149 der_shapes[2][0] * nodes[2].d_x + der_shapes[3][0] * nodes[3].d_x) *
150 (der_shapes[0][1] * nodes[0].d_y +
151 der_shapes[1][1] * nodes[1].d_y +
152 der_shapes[2][1] * nodes[2].d_y +
153 der_shapes[3][1] * nodes[3].d_y) -
154 (der_shapes[0][0] * nodes[0].d_y + der_shapes[1][0] * nodes[1].d_y +
155 der_shapes[2][0] * nodes[2].d_y + der_shapes[3][0] * nodes[3].d_y) *
156 (der_shapes[0][1] * nodes[0].d_x +
157 der_shapes[1][1] * nodes[1].d_x +
158 der_shapes[2][1] * nodes[2].d_x +
159 der_shapes[3][1] * nodes[3].d_x);
183 if (!d_quads.empty())
187 if (d_quadOrder == 0)
191 std::vector<std::vector<double>> ident_mat;
192 ident_mat.push_back(std::vector<double>{1., 0.});
193 ident_mat.push_back(std::vector<double>{0., 1.});
198 if (d_quadOrder == 1) {
202 std::vector<double> x = std::vector<double>(1, 0.);
203 std::vector<double> w = std::vector<double>(1, 2.);
204 for (
size_t i = 0; i < npts; i++)
205 for (
size_t j = 0; j < npts; j++) {
208 qd.
d_w = w[i] * w[j];
214 d_quads.push_back(qd);
221 if (d_quadOrder == 2) {
225 std::vector<double> x =
226 std::vector<double>{-1. / std::sqrt(3.), 1. / std::sqrt(3.)};
227 std::vector<double> w = std::vector<double>{1., 1.};
228 for (
size_t i = 0; i < npts; i++)
229 for (
size_t j = 0; j < npts; j++) {
232 qd.
d_w = w[i] * w[j];
238 d_quads.push_back(qd);
245 if (d_quadOrder == 3) {
250 std::vector<double> x = std::vector<double>{
251 -std::sqrt(3.) / std::sqrt(5.), 0., std::sqrt(3.) / std::sqrt(5.)};
252 std::vector<double> w = std::vector<double>{5. / 9., 8. / 9., 5. / 9.};
253 for (
size_t i = 0; i < npts; i++)
254 for (
size_t j = 0; j < npts; j++) {
257 qd.
d_w = w[i] * w[j];
263 d_quads.push_back(qd);
270 if (d_quadOrder == 4) {
273 std::vector<double> x =
274 std::vector<double>{-0.3399810435848563, 0.3399810435848563,
275 -0.8611363115940526, 0.8611363115940526};
276 std::vector<double> w =
277 std::vector<double>{0.6521451548625461, 0.6521451548625461,
278 0.3478548451374538, 0.3478548451374538};
279 for (
size_t i = 0; i < npts; i++)
280 for (
size_t j = 0; j < npts; j++) {
283 qd.
d_w = w[i] * w[j];
289 d_quads.push_back(qd);
296 if (d_quadOrder == 5) {
299 std::vector<double> x =
300 std::vector<double>{0., -0.5384693101056831, 0.5384693101056831,
301 -0.9061798459386640, 0.9061798459386640};
302 std::vector<double> w = std::vector<double>{
303 0.5688888888888889, 0.4786286704993665, 0.4786286704993665,
304 0.2369268850561891, 0.2369268850561891};
305 for (
size_t i = 0; i < npts; i++)
306 for (
size_t j = 0; j < npts; j++) {
309 qd.
d_w = w[i] * w[j];
315 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 the Jacobian of map .
std::vector< fe::QuadData > getQuadDatas(const std::vector< util::Point > &nodes) override
Get vector of quadrature data.
void init() override
Compute the quadrature points for quadrangle 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 area of element.
std::vector< fe::QuadData > getQuadPoints(const std::vector< util::Point > &nodes) override
Get vector of quadrature data.
QuadElem(size_t order)
Constructor for quadrangle element.
Collection of methods and data related to finite element and mesh.
Collection of methods useful in simulation.
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_x
the x coordinate