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

Trilinear hexahedron (VTK type 12) on reference cube [-1,1]^3. More...

#include <hexElem.h>

Inheritance diagram for fe::HexElem:
Collaboration diagram for fe::HexElem:

Public Member Functions

 HexElem (size_t order)
 
double elemSize (const std::vector< util::Point > &nodes) override
 Returns the size of element (length in 1-d, area in 2-d, volume in 3-d element)
 
- 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.
 
virtual std::vector< double > getShapes (const util::Point &p, const std::vector< util::Point > &nodes)
 Returns the values of shape function at point p.
 
virtual std::vector< std::vector< double > > getDerShapes (const util::Point &p, const std::vector< util::Point > &nodes)
 Returns the values of derivative of shape function at point p.
 
std::vector< fe::QuadDatagetQuadDatas (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::QuadDatagetQuadPoints (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.
 
double getJacobian (const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
 Computes Jacobian of map from reference element \( T^0 \) to given element \( T \).
 
void init () override
 Compute the quadrature points.
 

Additional Inherited Members

- Protected Member Functions inherited from fe::BaseElem
virtual util::Point mapPointToRefElem (const util::Point &p, const std::vector< util::Point > &nodes)
 Maps point p in a given element to the reference element and returns the mapped point.
 
- 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::QuadDatad_quads
 Quadrature data collection.
 

Detailed Description

Trilinear hexahedron (VTK type 12) on reference cube [-1,1]^3.

Node ordering matches VTK / createUniformMesh: bottom face 0-1-2-3 (ξ,η at ζ=-1), top face 4-5-6-7 (ζ=+1).

Definition at line 24 of file hexElem.h.

Constructor & Destructor Documentation

◆ HexElem()

fe::HexElem::HexElem ( size_t  order)
explicit

Definition at line 27 of file hexElem.cpp.

29 this->init();
30}
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.
Definition hexElem.cpp:83
static const int vtk_type_hexahedron
Integer flag for hexahedron element.

References init().

Here is the call graph for this function:

Member Function Documentation

◆ elemSize()

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

Returns the size of element (length in 1-d, area in 2-d, volume in 3-d element)

Parameters
nodesVertices of element
Returns
size Size of the element

Implements fe::BaseElem.

Definition at line 32 of file hexElem.cpp.

32 {
33 // Reference cube volume is 8; for a parallelepiped V = 8 * det(J(0,0,0)).
34 // General hex: integrate |det J| with the stored reference quadrature.
35 if (d_quads.empty())
36 return 8. * getJacobian(util::Point(0., 0., 0.), nodes, nullptr);
37 double vol = 0.;
38 for (const auto &qd : d_quads)
39 vol += qd.d_w * getJacobian(qd.d_p, nodes, nullptr);
40 return vol;
41}
std::vector< fe::QuadData > d_quads
Quadrature data collection.
Definition baseElem.h:224
double getJacobian(const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J) override
Computes Jacobian of map from reference element to given element .
Definition hexElem.cpp:62
A structure to represent 3d vectors.
Definition point.h:30

◆ getDerShapes()

std::vector< std::vector< double > > fe::HexElem::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 52 of file hexElem.cpp.

52 {
53 std::vector<std::vector<double>> r(8, std::vector<double>(3, 0.));
54 for (size_t i = 0; i < 8; ++i) {
55 r[i][0] = 0.125 * SX[i] * (1. + SY[i] * p.d_y) * (1. + SZ[i] * p.d_z);
56 r[i][1] = 0.125 * SY[i] * (1. + SX[i] * p.d_x) * (1. + SZ[i] * p.d_z);
57 r[i][2] = 0.125 * SZ[i] * (1. + SX[i] * p.d_x) * (1. + SY[i] * p.d_y);
58 }
59 return r;
60}
double d_y
the y coordinate
Definition point.h:36
double d_z
the z coordinate
Definition point.h:39
double d_x
the x coordinate
Definition point.h:33

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

◆ getJacobian()

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

Computes Jacobian of map from reference element \( T^0 \) to given element \( T \).

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

Implements fe::BaseElem.

Definition at line 62 of file hexElem.cpp.

64 {
65 auto der = getDerShapes(p);
66 std::vector<std::vector<double>> Jloc(3, std::vector<double>(3, 0.));
67 for (size_t a = 0; a < 8; ++a) {
68 Jloc[0][0] += der[a][0] * nodes[a].d_x;
69 Jloc[0][1] += der[a][0] * nodes[a].d_y;
70 Jloc[0][2] += der[a][0] * nodes[a].d_z;
71 Jloc[1][0] += der[a][1] * nodes[a].d_x;
72 Jloc[1][1] += der[a][1] * nodes[a].d_y;
73 Jloc[1][2] += der[a][1] * nodes[a].d_z;
74 Jloc[2][0] += der[a][2] * nodes[a].d_x;
75 Jloc[2][1] += der[a][2] * nodes[a].d_y;
76 Jloc[2][2] += der[a][2] * nodes[a].d_z;
77 }
78 if (J != nullptr)
79 *J = Jloc;
80 return util::det(Jloc);
81}
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.
Definition hexElem.cpp:52
double det(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
Definition matrix.cpp:75

References util::det().

Here is the call graph for this function:

◆ getShapes()

std::vector< double > fe::HexElem::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 43 of file hexElem.cpp.

43 {
44 std::vector<double> N(8);
45 for (size_t i = 0; i < 8; ++i)
46 N[i] = 0.125 * (1. + SX[i] * p.d_x) * (1. + SY[i] * p.d_y) *
47 (1. + SZ[i] * p.d_z);
48 return N;
49}

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

◆ init()

void fe::HexElem::init ( )
overrideprivatevirtual

Compute the quadrature points.

This must be implemented by inheriting classes.

Implements fe::BaseElem.

Definition at line 83 of file hexElem.cpp.

83 {
84 if (!d_quads.empty())
85 return;
86
87 if (d_quadOrder == 0) {
88 d_quads.resize(0);
89 return;
90 }
91
92 std::vector<std::vector<double>> ident(3, std::vector<double>(3, 0.));
93 ident[0][0] = ident[1][1] = ident[2][2] = 1.;
94
95 std::vector<double> x;
96 std::vector<double> w;
97 if (d_quadOrder == 1) {
98 x = {0.};
99 w = {2.};
100 } else if (d_quadOrder == 2) {
101 x = {-1. / std::sqrt(3.), 1. / std::sqrt(3.)};
102 w = {1., 1.};
103 } else {
104 // order >= 3: 3-point Gauss on [-1,1]
105 x = {-std::sqrt(3.) / std::sqrt(5.), 0., std::sqrt(3.) / std::sqrt(5.)};
106 w = {5. / 9., 8. / 9., 5. / 9.};
107 }
108
109 const size_t npts = x.size();
110 d_quads.clear();
111 d_quads.reserve(npts * npts * npts);
112 for (size_t i = 0; i < npts; ++i)
113 for (size_t j = 0; j < npts; ++j)
114 for (size_t k = 0; k < npts; ++k) {
115 fe::QuadData qd;
116 qd.d_w = w[i] * w[j] * w[k];
117 qd.d_p = util::Point(x[i], x[j], x[k]);
118 qd.d_shapes = getShapes(qd.d_p);
120 qd.d_J = ident;
121 qd.d_detJ = 1.;
122 d_quads.push_back(qd);
123 }
124}
size_t d_quadOrder
Order of quadrature point integration approximation.
Definition baseElem.h:218
std::vector< double > getShapes(const util::Point &p) override
Returns the values of shape function at point p on reference element.
Definition hexElem.cpp:43
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

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 HexElem().

Here is the caller graph for this function:

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