PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
fe::TriElem Class Reference

A class for mapping and quadrature related operations for linear triangle element. More...

#include <triElem.h>

Inheritance diagram for fe::TriElem:
Collaboration diagram for fe::TriElem:

Public Member Functions

 TriElem (size_t order)
 Constructor.
 
double elemSize (const std::vector< util::Point > &nodes) override
 Returns the area of 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.
 
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.
 
- Public Member Functions inherited from fe::BaseElem
 BaseElem (size_t order, size_t element_type)
 Constructor.
 
size_t getElemType ()
 Get element type.
 
size_t getQuadOrder ()
 Get order of quadrature approximation.
 
size_t getNumQuadPoints ()
 Get number of quadrature points in the data.
 
std::vector< fe::QuadData > getQuadDatas (const std::vector< util::Point > &nodes)
 Get quadrature data mapped to the physical element (N, dN/dx, x, w, J). Shared isoparametric map; types only fill reference N, dN/dξ, and w.
 
std::vector< fe::QuadData > getQuadPoints (const std::vector< util::Point > &nodes)
 Same as getQuadDatas without transforming dN/dξ to dN/dx.
 

Private Member Functions

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.
 
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.
 
double getJacobian (const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
 Computes the Jacobian of map \( \Phi: T^0 \to T \).
 
void init () override
 Compute the quadrature points for triangle element.
 

Additional Inherited Members

- Protected Attributes inherited from fe::BaseElem
size_t d_quadOrder
 Order of quadrature point integration approximation.
 
size_t d_elemType
 Element type.
 
std::vector< fe::QuadData > d_quads
 Quadrature data collection.
 

Detailed Description

A class for mapping and quadrature related operations for linear triangle element.

The reference triangle element \( T^0 \) is given by vertices \( (0,0), \, (1,0), \, (0,1) \).

  1. The shape functions at point \( (\xi, \eta ) \in T^0 \) are

    \[N^0_1(\xi, \eta) = 1- \xi - \eta, \quad N^0_2(\xi, \eta) = \xi, \quad N^0_3(\xi, \eta) = \eta. \]

  2. For linear triangle element, derivative of shape functions are constant and are as follows

    \[\frac{d N^0_1(\xi, \eta)}{d\xi} = -1, \, \frac{d N^0_1(\xi, \eta) }{d\eta} = -1, \]

    \[\frac{d N^0_2(\xi, \eta)}{d\xi} = 1, \, \frac{d N^0_2(\xi, \eta)}{d\eta} = 0, \]

    \[\frac{d N^0_3(\xi, \eta)}{d\xi} = 0, \, \frac{d N^0_3(\xi, \eta)}{d\eta} = 1. \]

  3. Map \( \Phi: T^0 \to T\) is given by

    \[ x(\xi, \eta) = \sum_{i=1}^3 N^0_i(\xi, \eta) v^i_x, \quad y(\xi, \eta) = \sum_{i=1}^3 N^0_i(\xi, \eta) v^i_y \]

    where \( v^1, v^2, v^3\) are vertices of element \( T \).
  4. The Jacobian of the map \( \Phi: T^0 \to T\) is given by

    \[ J = \left[ { \begin{array}{cc} \frac{dx}{d\xi} &\frac{dy}{d\xi} \\ \frac{dx}{d\eta} & \frac{dy}{d\eta} \\ \end{array} } \right] \]

    and determinant of Jacobian is

    \[ det(J) = \frac{dx}{d\xi} \times \frac{dy}{d\eta} - \frac{dy}{d\xi}\times \frac{dx}{d\eta}. \]

    For linear triangle element, Jacobian (and so \( det(J) \)) is constant. For linear triangle elements,

    \[ \frac{dx}{d\xi} = v^2_x - v^1_x, \quad \frac{dx}{d\eta} = v^3_x - v^1_x, \]

    \[ \frac{dy}{d\xi} = v^2_y - v^1_y, \quad \frac{dy}{d\eta} = v^3_y - v^1_y \]

    and \( det(J) = \frac{area(T)}{area(T^0)} = 2\times area(T) \).
  5. Inverse map \( \Phi^{-1} : T \to T^9 \) for linear triangle element can be derived as follows:

From map \( (\xi, \eta )\in T^0 \to (x,y) \in T \) we have

\[ x = \sum_{i=1}^3 N^0_i(\xi, \eta) v^i_x, \quad y = \sum_{i=1}^3 N^0_i(\xi, \eta) v^i_y. \]

Substituting formula for \( N^0_i \) in above to get

\[ x = (1 - \xi - \eta) v^1_x + \xi v^2_x + \eta v^3_x, \quad y = (1 - \xi - \eta) v^1_y + \xi v^2_y + \eta v^3_y \]

or

\[ x - v^1_x = \xi (v^2_x - v^1_x) + \eta (v^3_x - v^1_x), \quad y - v^1_y = \xi (v^2_y - v^1_y) + \eta (v^3_y - v^1_y). \]

Writing above in matrix form, we have

\[ \left[ {\begin{array}{c} x - v^1_x \\ y - v^1_y \end{array}}\right] = \left[ {\begin{array}{cc} v^2_x - v^1_x & v^3_x - v^1_x \\ v^2_y - v^1_y & v^3_y - v^1_y \end{array}}\right] \, \left[ {\begin{array}{c} \xi \\ \eta \end{array}}\right]. \]

Denoting the matrix as \( B \)

\[ B = \left[ {\begin{array}{cc} v^2_x - v^1_x & v^3_x - v^1_x \\ v^2_y - v^1_y & v^3_y - v^1_y \end{array}}\right] \]

then

\[ C := B^{-1} = \frac{1}{det(B)} \left[ {\begin{array}{cc} v^3_y - v^1_y & -(v^3_x - v^1_x) \\ -(v^2_y - v^1_y) & v^2_x - v^1_x \end{array}}\right]. \]

With \( C \) we have inverse map given by

\[ \xi(x,y) = C_{11} (x - v^1_x) + C_{12} (y - v^1_y), \quad \eta(x,y) = C_{21} (x - v^1_x) + C_{22} (y - v^1_y). \]

Note that matrix \( B \) is a transpose of the Jacobian of map \( \Phi\) and hence \( det(B) = det(J) \).

Definition at line 91 of file triElem.h.

Constructor & Destructor Documentation

◆ TriElem()

fe::TriElem::TriElem ( size_t  order)
explicit

Constructor.

Parameters
orderOrder of quadrature point approximation

Definition at line 18 of file triElem.cpp.

20
21 // compute quad data
22 this->init();
23}
A base class which provides methods to map points to/from reference element and to compute quadrature...
Definition baseElem.h:84
void init() override
Compute the quadrature points for triangle element.
Definition triElem.cpp:129
static const int vtk_type_triangle
Integer flag for triangle element.

References init().

Here is the call graph for this function:

Member Function Documentation

◆ elemSize()

double fe::TriElem::elemSize ( const std::vector< util::Point > &  nodes)
overridevirtual

Returns the area of element.

If triangle \( T \) is given by points \( v^1, v^2, v^3 \) then the area is

\[ area(T) = \frac{(v^2_x - v^1_x) (v^3_y - v^1_y) - (v^3_x - v^1_x) (v^2_y - v^1_y)}{2}, \]

where \( v^i_x, v^i_y \) are the x and y component of point \( v^i \).

Note that area and Jacobian of map \( \Phi: T^0 \to T \) are related as

\[ area(T) = area (T^0) \times det(J). \]

Here, \( area(T^0) = 0.5 \).

Parameters
nodesVertices of element
Returns
vector Vector of shape functions at point p

Implements fe::BaseElem.

Definition at line 25 of file triElem.cpp.

25 {
26 return 0.5 * ((nodes[1].d_x - nodes[0].d_x) * (nodes[2].d_y - nodes[0].d_y) -
27 (nodes[2].d_x - nodes[0].d_x) * (nodes[1].d_y - nodes[0].d_y));
28}

◆ getDerShapes() [1/2]

std::vector< std::vector< double > > fe::TriElem::getDerShapes ( const util::Point &  p)
overrideprivatevirtual

Returns the values of derivative of shape function at point p on reference element.

Parameters
pLocation of point
Returns
vector Vector of derivative of shape functions

Implements fe::BaseElem.

Definition at line 66 of file triElem.cpp.

66 {
67
68 // d N1/d xi = -1, d N1/d eta = -1, d N2/ d xi = 1, d N2/d eta = 0,
69 // d N3/ d xi = 0, d N3/d eta = 1
70 std::vector<std::vector<double>> r;
71 r.push_back(std::vector<double>{-1., -1.});
72 r.push_back(std::vector<double>{1., 0.});
73 r.push_back(std::vector<double>{0., 1.});
74
75 return r;
76}

◆ getDerShapes() [2/2]

std::vector< std::vector< double > > fe::TriElem::getDerShapes ( const util::Point &  p,
const std::vector< util::Point > &  nodes 
)
overridevirtual

Returns the values of derivative of shape function at point p.

Below, we present the derivation of the formula:

We are interested in \( \frac{\partial N_i(x_p, y_p)}{\partial x}\) and \( \frac{\partial N_i(x_p, y_p)}{\partial y}\). By using the map \( \Phi : T^0 \to T\) we have

\[ N^0_i(\xi, \eta) = N_i(x(\xi,\eta), y(\xi, \eta)) \]

and therefore we can write

\[ \frac{\partial N^0_i(\xi, \eta)}{\partial \xi} = \frac{\partial N_i}{\partial x} \frac{\partial x}{\partial \xi} + \frac{\partial N_i}{\partial y} \frac{\partial y}{\partial \xi} \]

and

\[ \frac{\partial N^0_i(\xi, \eta)}{\partial \eta} = \frac{\partial N_i}{\partial x} \frac{\partial x}{\partial \eta} + \frac{\partial N_i}{\partial y} \frac{\partial y}{\partial \eta} \]

which can be written in the matrix form as

\[ \left[ {\begin{array}{c} \frac{\partial N^0_i}{\partial \xi} \\ \frac{\partial N^0_i}{\partial \eta} \end{array}}\right] = \left[ {\begin{array}{cc} \frac{\partial x}{\partial \xi} & \frac{\partial y}{\partial \xi} \\ \frac{\partial x}{\partial \eta} & \frac{\partial y}{\partial \eta} \end{array}}\right] \, \left[ {\begin{array}{c} \frac{\partial N_i}{\partial x} \\ \frac{\partial N_i}{\partial y} \end{array}}\right]. \]

The matrix is the Jacobian matrix \( J \) and follows if vertices of elements are known. Inverse \( J^{-1} \) is given by

\[ J^{-1} = \frac{1}{det(J)} \left[ {\begin{array}{cc} \frac{\partial y}{\partial \eta} & -\frac{\partial y}{\partial \xi} \\ -\frac{\partial x}{\partial \eta} & \frac{\partial x}{\partial \xi} \end{array}}\right]. \]

Using \( J^{-1} \) we have following formula for derivatives of the shape function

\[ \left[ {\begin{array}{c} \frac{\partial N_i}{\partial x} \\ \frac{\partial N_i}{\partial y} \end{array}}\right] = J^{-1} \left[ {\begin{array}{c} \frac{\partial N^0_i}{\partial \xi} \\ \frac{\partial N^0_i}{\partial \eta} \end{array}}\right]. \]

Here, derivatives \( \frac{\partial N^0_i}{ \partial \xi} \) and \( \frac{\partial N^0_i} {\partial \eta } \) correspond to reference element and are easy to compute.

Parameters
pLocation of point
nodesVertices of element
Returns
vector Vector of derivative of shape functions

Reimplemented from fe::BaseElem.

Definition at line 37 of file triElem.cpp.

38 {
39 // get derivatives of shape function in reference triangle
40 auto ders_ref = getDerShapes(mapPointToRefElem(p, nodes));
41
42 // get Jacobian and its determinant
43 std::vector<std::vector<double>> J;
44 auto detJ = getJacobian(p, nodes, &J);
45
46 // to hold derivatives
47 auto ders = ders_ref;
48
49 for (size_t i=0; i<3; i++) {
50 // partial N_i/ partial x
51 ders[i][0] = (ders_ref[i][0] * J[1][1] - ders_ref[i][1] * J[0][1]) / detJ;
52 // partial N_i/ partial y
53 ders[i][1] = (-ders_ref[i][0] * J[1][0] + ders_ref[i][1] * J[0][0]) / detJ;
54 }
55
56 return ders;
57}
double getJacobian(const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
Computes the Jacobian of map .
Definition triElem.cpp:111
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.
Definition triElem.cpp:37
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.
Definition triElem.cpp:79

◆ getJacobian()

double fe::TriElem::getJacobian ( const util::Point &  p,
const std::vector< util::Point > &  nodes,
std::vector< std::vector< double > > *  J 
)
overrideprivatevirtual

Computes the Jacobian of map \( \Phi: T^0 \to T \).

Parameters
pLocation of point in reference element
nodesVertices of element
JMatrix to store the Jacobian (if not nullptr)
Returns
det(J) Determinant of the Jacobain

Implements fe::BaseElem.

Definition at line 111 of file triElem.cpp.

113 {
114
115 if (J != nullptr) {
116 J->resize(2);
117 (*J)[0] = std::vector<double>{nodes[1].d_x - nodes[0].d_x,
118 nodes[1].d_y - nodes[0].d_y};
119 (*J)[1] = std::vector<double>{nodes[2].d_x - nodes[0].d_x,
120 nodes[2].d_y - nodes[0].d_y};
121
122 return (*J)[0][0] * (*J)[1][1] - (*J)[0][1] * (*J)[1][0];
123 }
124
125 return (nodes[1].d_x - nodes[0].d_x) * (nodes[2].d_y - nodes[0].d_y)
126 - (nodes[1].d_y - nodes[0].d_y) * (nodes[2].d_x - nodes[0].d_x);
127}

◆ getShapes() [1/2]

std::vector< double > fe::TriElem::getShapes ( const util::Point &  p)
overrideprivatevirtual

Returns the values of shape function at point p on reference element.

Parameters
pLocation of point
Returns
vector Vector of shape functions at point p

Implements fe::BaseElem.

Definition at line 59 of file triElem.cpp.

59 {
60
61 // N1 = 1 - xi - eta, N2 = xi, N3 = eta
62 return std::vector<double>{1. - p.d_x - p.d_y, p.d_x, p.d_y};
63}
double d_y
the y coordinate
Definition point.h:36
double d_x
the x coordinate
Definition point.h:33

References util::Point::d_x, and util::Point::d_y.

◆ getShapes() [2/2]

std::vector< double > fe::TriElem::getShapes ( const util::Point &  p,
const std::vector< util::Point > &  nodes 
)
overridevirtual

Returns the values of shape function at point p.

We first map the point p in \( T \) to reference triangle \( T^0 \) using fe::TriElem::mapPointToRefElem and then compute shape functions at the mapped point using fe::TriElem::getShapes(const util::Point &).

Parameters
pLocation of point
nodesVertices of element
Returns
vector Vector of shape functions at point p

Reimplemented from fe::BaseElem.

Definition at line 31 of file triElem.cpp.

32 {
33 return getShapes(mapPointToRefElem(p, nodes));
34}
std::vector< double > getShapes(const util::Point &p, const std::vector< util::Point > &nodes) override
Returns the values of shape function at point p.
Definition triElem.cpp:31

◆ init()

void fe::TriElem::init ( )
overrideprivatevirtual

Compute the quadrature points for triangle element.

Implements fe::BaseElem.

Definition at line 129 of file triElem.cpp.

129 {
130
131 //
132 // compute quad data for reference triangle with vertex at
133 // (0,0), (1,0), (0,1)
134 //
135
136 if (!d_quads.empty())
137 return;
138
139 // no point in zeroth order
140 if (d_quadOrder == 0) {
141 d_quads.resize(0);
142 }
143
144 // 2x2 identity matrix
145 std::vector<std::vector<double>> ident_mat;
146 ident_mat.push_back(std::vector<double>{1., 0.});
147 ident_mat.push_back(std::vector<double>{0., 1.});
148
149 //
150 // first order quad points for triangle
151 //
152 if (d_quadOrder == 1) {
153 d_quads.clear();
154 fe::QuadData qd;
155 qd.d_w = 0.5;
156 qd.d_p = util::Point(1. / 3., 1. / 3., 0.);
157 // N1 = 1 - xi - eta, N2 = xi, N3 = eta
158 qd.d_shapes = getShapes(qd.d_p);
159 // d N1/d xi = -1, d N1/d eta = -1, d N2/ d xi = 1, d N2/d eta = 0,
160 // d N3/ d xi = 0, d N3/d eta = 1
162 qd.d_J = ident_mat;
163 qd.d_detJ = 1.;
164 d_quads.push_back(qd);
165 }
166
167 //
168 // second order quad points for triangle
169 //
170 if (d_quadOrder == 2) {
171 d_quads.clear();
172 fe::QuadData qd;
173 // point 1
174 qd.d_w = 1. / 6.;
175 qd.d_p = util::Point(1. / 6., 1. / 6., 0.);
176 qd.d_shapes = getShapes(qd.d_p);
178 qd.d_J = ident_mat;
179 qd.d_detJ = 1.;
180 d_quads.push_back(qd);
181 // point 2
182 qd.d_w = 1. / 6.;
183 qd.d_p = util::Point(2. / 3., 1. / 6., 0.);
184 qd.d_shapes = getShapes(qd.d_p);
186 qd.d_J = ident_mat;
187 qd.d_detJ = 1.;
188 d_quads.push_back(qd);
189 // point 3
190 qd.d_w = 1. / 6.;
191 qd.d_p = util::Point(1. / 6., 2. / 3., 0.);
192 qd.d_shapes = getShapes(qd.d_p);
194 qd.d_J = ident_mat;
195 qd.d_detJ = 1.;
196 d_quads.push_back(qd);
197 }
198
199 //
200 // third order quad points for triangle
201 //
202 if (d_quadOrder == 3) {
203 d_quads.clear();
204 fe::QuadData qd;
205 // point 1
206 qd.d_w = -27. / 96.;
207 qd.d_p = util::Point(1. / 3., 1. / 3., 0.);
208 qd.d_shapes = getShapes(qd.d_p);
210 qd.d_J = ident_mat;
211 qd.d_detJ = 1.;
212 d_quads.push_back(qd);
213 // point 2
214 qd.d_w = 25. / 96.;
215 qd.d_p = util::Point(1. / 5., 3. / 5., 0.);
216 qd.d_shapes = getShapes(qd.d_p);
218 qd.d_J = ident_mat;
219 qd.d_detJ = 1.;
220 d_quads.push_back(qd);
221 // point 3
222 qd.d_w = 25. / 96.;
223 qd.d_p = util::Point(1. / 5., 1. / 5., 0.);
224 qd.d_shapes = getShapes(qd.d_p);
226 qd.d_J = ident_mat;
227 qd.d_detJ = 1.;
228 d_quads.push_back(qd);
229 // point 4
230 qd.d_w = 25. / 96.;
231 qd.d_p = util::Point(3. / 5., 1. / 5., 0.);
232 qd.d_shapes = getShapes(qd.d_p);
234 qd.d_J = ident_mat;
235 qd.d_detJ = 1.;
236 d_quads.push_back(qd);
237 }
238
239 //
240 // fourth order quad points for triangle
241 //
242 if (d_quadOrder == 4) {
243 d_quads.clear();
244 fe::QuadData qd;
245 // point 1
246 qd.d_w = 0.5 * 0.22338158967801;
247 qd.d_p = util::Point(0.44594849091597, 0.44594849091597, 0.);
248 qd.d_shapes = getShapes(qd.d_p);
250 qd.d_J = ident_mat;
251 qd.d_detJ = 1.;
252 d_quads.push_back(qd);
253 // point 2
254 qd.d_w = 0.5 * 0.22338158967801;
255 qd.d_p = util::Point(0.44594849091597, 0.10810301816807, 0.);
256 qd.d_shapes = getShapes(qd.d_p);
258 qd.d_J = ident_mat;
259 qd.d_detJ = 1.;
260 d_quads.push_back(qd);
261 // point 3
262 qd.d_w = 0.5 * 0.22338158967801;
263 qd.d_p = util::Point(0.10810301816807, 0.44594849091597, 0.);
264 qd.d_shapes = getShapes(qd.d_p);
266 qd.d_J = ident_mat;
267 qd.d_detJ = 1.;
268 d_quads.push_back(qd);
269 // point 4
270 qd.d_w = 0.5 * 0.10995174365532;
271 qd.d_p = util::Point(0.09157621350977, 0.09157621350977, 0.);
272 qd.d_shapes = getShapes(qd.d_p);
274 qd.d_J = ident_mat;
275 qd.d_detJ = 1.;
276 d_quads.push_back(qd);
277 // point 5
278 qd.d_w = 0.5 * 0.10995174365532;
279 qd.d_p = util::Point(0.09157621350977, 0.81684757298046, 0.);
280 qd.d_shapes = getShapes(qd.d_p);
282 qd.d_J = ident_mat;
283 qd.d_detJ = 1.;
284 d_quads.push_back(qd);
285 // point 6
286 qd.d_w = 0.5 * 0.10995174365532;
287 qd.d_p = util::Point(0.81684757298046, 0.09157621350977, 0.);
288 qd.d_shapes = getShapes(qd.d_p);
290 qd.d_J = ident_mat;
291 qd.d_detJ = 1.;
292 d_quads.push_back(qd);
293 }
294
295 //
296 // fifth order quad points for triangle
297 //
298 if (d_quadOrder == 5) {
299 d_quads.clear();
300 fe::QuadData qd;
301 // point 1
302 qd.d_w = 0.5 * 0.22500000000000;
303 qd.d_p = util::Point(0.33333333333333, 0.33333333333333, 0.);
304 qd.d_shapes = getShapes(qd.d_p);
306 qd.d_J = ident_mat;
307 qd.d_detJ = 1.;
308 d_quads.push_back(qd);
309 // point 2
310 qd.d_w = 0.5 * 0.13239415278851;
311 qd.d_p = util::Point(0.47014206410511, 0.47014206410511, 0.);
312 qd.d_shapes = getShapes(qd.d_p);
314 qd.d_J = ident_mat;
315 qd.d_detJ = 1.;
316 d_quads.push_back(qd);
317 // point 3
318 qd.d_w = 0.5 * 0.13239415278851;
319 qd.d_p = util::Point(0.47014206410511, 0.05971587178977, 0.);
320 qd.d_shapes = getShapes(qd.d_p);
322 qd.d_J = ident_mat;
323 qd.d_detJ = 1.;
324 d_quads.push_back(qd);
325 // point 4
326 qd.d_w = 0.5 * 0.13239415278851;
327 qd.d_p = util::Point(0.05971587178977, 0.47014206410511, 0.);
328 qd.d_shapes = getShapes(qd.d_p);
330 qd.d_J = ident_mat;
331 qd.d_detJ = 1.;
332 d_quads.push_back(qd);
333 // point 5
334 qd.d_w = 0.5 * 0.12593918054483;
335 qd.d_p = util::Point(0.10128650732346, 0.10128650732346, 0.);
336 qd.d_shapes = getShapes(qd.d_p);
338 qd.d_J = ident_mat;
339 qd.d_detJ = 1.;
340 d_quads.push_back(qd);
341 // point 6
342 qd.d_w = 0.5 * 0.12593918054483;
343 qd.d_p = util::Point(0.10128650732346, 0.79742698535309, 0.);
344 qd.d_shapes = getShapes(qd.d_p);
346 qd.d_J = ident_mat;
347 qd.d_detJ = 1.;
348 d_quads.push_back(qd);
349 // point 7
350 qd.d_w = 0.5 * 0.12593918054483;
351 qd.d_p = util::Point(0.79742698535309, 0.10128650732346, 0.);
352 qd.d_shapes = getShapes(qd.d_p);
354 qd.d_J = ident_mat;
355 qd.d_detJ = 1.;
356 d_quads.push_back(qd);
357 }
358}
std::vector< fe::QuadData > d_quads
Quadrature data collection.
Definition baseElem.h:224
size_t d_quadOrder
Order of quadrature point integration approximation.
Definition baseElem.h:218
A struct to store the quadrature data. List of data are.
Definition quadData.h:23
std::vector< double > d_shapes
Value of shape functions at quad point p.
Definition quadData.h:37
std::vector< std::vector< double > > d_derShapes
Derivatives of shape functions at the quad point.
Definition quadData.h:46
double d_w
Quadrature weight.
Definition quadData.h:26
util::Point d_p
Quadrature point in 1-d, 2-d or 3-d.
Definition quadData.h:29
std::vector< std::vector< double > > d_J
Jacobian of the map from reference element to the element.
Definition quadData.h:54
double d_detJ
Determinant of the Jacobian of the map from reference element to the element.
Definition quadData.h:60
A structure to represent 3d vectors.
Definition point.h:30

References fe::QuadData::d_derShapes, fe::QuadData::d_detJ, fe::QuadData::d_J, fe::QuadData::d_p, fe::QuadData::d_shapes, and fe::QuadData::d_w.

Referenced by TriElem().

Here is the caller graph for this function:

◆ mapPointToRefElem()

util::Point fe::TriElem::mapPointToRefElem ( const util::Point &  p,
const std::vector< util::Point > &  nodes 
)
overrideprivatevirtual

Maps point p in a given element to the reference element.

Let \( v^1, v^2, v^3\) are three vertices of triangle \( T\) and let \(T^0 \) is the reference triangle. Following the introduction to fe::TriElem, the map \( (x,y) \in T \) to \( (\xi, \eta) \in T^0 \) is given by

\[ \xi = C_{11} (x - v^1_x) + C_{12} (y - v^1_y), \quad \eta = C_{21} (x - v^1_x) + C_{22} (y - v^1_y). \]

\( C\) is the inverse of matrix

\[ B = \left[ {\begin{array}{cc} v^2_x - v^1_x & v^3_x - v^1_x \\ v^2_y - v^1_y & v^3_y - v^1_y \end{array}}\right], \]

i.e.

\[ C := B^{-1} = \frac{1}{(v^2_x - v^1_x)(v^3_y - v^1_y) - (v^3_x - v^1_x) (v^2_y - v^1_y)} \left[ {\begin{array}{cc} v^3_y - v^1_y & -(v^3_x - v^1_x) \\ -(v^2_y - v^1_y) & v^2_x - v^1_x \end{array}}\right]. \]

If mapped point \( (\xi, \eta)\) does not satisfy following conditions

  • \[ 0\leq \xi, \eta \]

  • \[ \xi \leq 1 - \eta \quad (or\, equivalently) \quad \eta \leq 1 - \xi \]

    then the point \( (\xi,\eta) \) does not belong to the reference triangle or equivalently point \((x,y) \) does not belong to the triangle \( T \) and the method issues error. Otherwise the method returns point \( (\xi, \eta)\).
Parameters
pLocation of point
nodesVertices of element
Returns
vector Vector of shape functions at point p

Reimplemented from fe::BaseElem.

Definition at line 79 of file triElem.cpp.

80 {
81 auto detB = 2. * elemSize(nodes);
82 auto xi = ((nodes[2].d_y - nodes[0].d_y) * (p.d_x - nodes[0].d_x) -
83 (nodes[2].d_x - nodes[0].d_x) * (p.d_y - nodes[0].d_y)) /
84 detB;
85 auto eta = (-(nodes[1].d_y - nodes[0].d_y) * (p.d_x - nodes[0].d_x) +
86 (nodes[1].d_x - nodes[0].d_x) * (p.d_y - nodes[0].d_y)) /
87 detB;
88
89 if (util::isLess(xi, -1.0E-5) || util::isLess(eta, -1.0E-5) ||
90 util::isGreater(xi, 1. + 1.0E-5 - eta)) {
91 throw std::runtime_error(
93 << "Error: Trying to map point p = (" << p.d_x << ", " << p.d_y
94 << ") in triangle to reference triangle.\n"
95 << "But the point p does not belong to triangle = {("
96 << nodes[0].d_x << ", " << nodes[0].d_y << "), (" << nodes[1].d_x
97 << "," << nodes[1].d_y << "), (" << nodes[2].d_x << ","
98 << nodes[2].d_y << ")}.\n"
99 << "Coordinates in reference triangle are: xi = " << xi
100 << ", eta = " << eta << "\n");
101 }
102
103 if (util::isLess(xi, 0.))
104 xi = 0.;
105 if (util::isLess(eta, 0.))
106 eta = 0.;
107
108 return {xi, eta, 0.};
109}
double elemSize(const std::vector< util::Point > &nodes) override
Returns the area of element.
Definition triElem.cpp:25
Collects a message with stream syntax for use in an exception.
Definition io.h:52
bool isGreater(const double &a, const double &b)
Returns true if a > b.
Definition function.cpp:17
bool isLess(const double &a, const double &b)
Returns true if a < b.
Definition function.cpp:22

References util::Point::d_x, util::Point::d_y, util::isGreater(), and util::isLess().

Here is the call graph for this function:

The documentation for this class was generated from the following files: