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

A base class which provides methods to map points to/from reference element and to compute quadrature data. More...

#include <baseElem.h>

Inheritance diagram for fe::BaseElem:
Collaboration diagram for fe::BaseElem:

Public Member Functions

 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 double elemSize (const std::vector< util::Point > &nodes)=0
 Returns the size of element (length in 1-d, area in 2-d, volume in 3-d element)
 
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::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.
 

Protected Member Functions

virtual std::vector< double > getShapes (const util::Point &p)=0
 Returns the values of shape function at point p on reference element.
 
virtual std::vector< std::vector< double > > getDerShapes (const util::Point &p)=0
 Returns the values of derivative of shape function at point p on reference element.
 
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.
 
virtual double getJacobian (const util::Point &p, const std::vector< util::Point > &nodes, std::vector< std::vector< double > > *J)=0
 Computes Jacobian of map from reference element \( T^0 \) to given element \( T \).
 
virtual void init ()=0
 Compute the quadrature points.
 

Protected Attributes

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 base class which provides methods to map points to/from reference element and to compute quadrature data.

For any type of element, such as fe::LineElem, fe::TriElem, fe::QuadElem, we have following important points

  1. A simple element with predefined vertices is considered as a reference element \( T^0 \). E.g., reference element in fe::TriElem is a triangle with vertices at \((0,0), (1,0), (0,1) \).
  2. Points in reference element \( T^0 \) are described by \( (\xi, \eta, \zeta)\) (in 3-d), \( (\xi, \eta) \) (in 2-d), and \( \xi\) (in 1-d). Points in any other element \( T \) are described by \( (x,y,z)\) (in 3-d), \( (x,y) \) (in 2-d), and \( x\) (in 1-d). Here, we restrict discussion to 3-d element. For 2-d, one should ignore coordinate \(\zeta \) and \( z\), and for 1-d, one should ignore \( \eta, \zeta \) and \( y,z\).
  3. Associated to vertices of the element \( T^0 \) we have shape functions \( N^0_1, N^0_2, ..., N^0_n \), where \( n \) is the number of vertices in the element. Shape functions \( N^0_i \) are functions of point \( (\xi, \eta, \zeta) \in T^0 \). For each type of element, \( n \) is fixed.
  4. For any element \( T \), shape functions are denoted as \( N_1, N_2, ..., N_n \) and are functions of point \( (x,y,z) \in T \).
  5. Element \( T \) is described by vertices \( v^1, v^2, ..., v^n \).
  6. A map \(\Phi : T^0 \to T \) , where \( T \) is a given element formed by vertices \( v^1, v^2, ..., v^n \), is defined as follows:

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

    where \( v^i_x, v^i_y, v^i_z \) are the x, y, and z component of point \( v^i\).
  7. Jacobian of map \( \Phi : T^0 \to T \) is given by

    \[ J = \left[ { \begin{array}{ccc} \frac{dx}{d\xi} &\frac{dy}{d\xi} & \frac{dz}{d\xi} \\ \frac{dx}{d\eta} & \frac{dy}{d\eta} & \frac{dz}{d\eta} \\ \frac{dx}{d\zeta} & \frac{dy}{d\zeta} & \frac{dz}{d\zeta} \\ \end{array} } \right]. \]

    For 2-d element it is

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

    For 1-d element it is

    \[ J = \frac{dx}{d\xi}. \]

    Determinant of the Jacobian is an important quantity and is used to compute the quadrature points, and inverse map \( \Phi^{-1} : T \to T^0 \).
See also
fe::LineElem, fe::TriElem, fe::QuadElem

Definition at line 84 of file baseElem.h.

Constructor & Destructor Documentation

◆ BaseElem()

fe::BaseElem::BaseElem ( size_t  order,
size_t  element_type 
)

Constructor.

Parameters
orderOrder of quadrature point approximation
element_typeType of element

Definition at line 18 of file baseElem.cpp.

19 : d_quadOrder(order), d_elemType(element_type){};
size_t d_elemType
Element type.
Definition baseElem.h:221
size_t d_quadOrder
Order of quadrature point integration approximation.
Definition baseElem.h:218

Member Function Documentation

◆ elemSize()

virtual double fe::BaseElem::elemSize ( const std::vector< util::Point > &  nodes)
pure virtual

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

Implemented in fe::HexElem, fe::LineElem, fe::QuadElem, fe::TetElem, and fe::TriElem.

◆ getDerShapes() [1/2]

virtual std::vector< std::vector< double > > fe::BaseElem::getDerShapes ( const util::Point &  p)
protectedpure virtual

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

Implemented in fe::HexElem, fe::LineElem, fe::QuadElem, fe::TetElem, and fe::TriElem.

◆ getDerShapes() [2/2]

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

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

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

Reimplemented in fe::LineElem, fe::TetElem, and fe::TriElem.

Definition at line 33 of file baseElem.cpp.

34 {
35 throw std::runtime_error(
37 << "Error: For element type = " << d_elemType << " the map from "
38 << "element to reference element is not available.\n"
39 << "Therefore, derivatives of shape function at any "
40 "arbitrary point in the element can not be computed.\n");
41}
Collects a message with stream syntax for use in an exception.
Definition io.h:52

◆ getElemType()

size_t fe::BaseElem::getElemType ( )
inline

Get element type.

Returns
type Type of element

Definition at line 99 of file baseElem.h.

99{ return d_elemType; }

References d_elemType.

◆ getJacobian()

virtual double fe::BaseElem::getJacobian ( const util::Point &  p,
const std::vector< util::Point > &  nodes,
std::vector< std::vector< double > > *  J 
)
protectedpure virtual

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

Implemented in fe::HexElem, fe::LineElem, fe::QuadElem, fe::TetElem, and fe::TriElem.

◆ getNumQuadPoints()

size_t fe::BaseElem::getNumQuadPoints ( )
inline

Get number of quadrature points in the data.

Returns
N Number of quadrature points

Definition at line 111 of file baseElem.h.

111{ return d_quads.size(); }
std::vector< fe::QuadData > d_quads
Quadrature data collection.
Definition baseElem.h:224

References d_quads.

◆ getQuadDatas()

std::vector< fe::QuadData > fe::BaseElem::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.

Definition at line 61 of file baseElem.cpp.

61 {
62 auto qds = d_quads;
63 mapToPhysical(qds, nodes, true);
64 return qds;
65}
void mapToPhysical(std::vector< QuadData > &qds, const std::vector< util::Point > &nodes, bool derivatives)
Definition map.cpp:14

References fe::mapToPhysical().

Referenced by test::testPatchQuad(), test::testPatchTet(), test::testPatchTri(), and test::testPatchTriDistorted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getQuadOrder()

size_t fe::BaseElem::getQuadOrder ( )
inline

Get order of quadrature approximation.

Returns
order Order of approximation

Definition at line 105 of file baseElem.h.

105{ return d_quadOrder; }

References d_quadOrder.

◆ getQuadPoints()

std::vector< fe::QuadData > fe::BaseElem::getQuadPoints ( const std::vector< util::Point > &  nodes)

Same as getQuadDatas without transforming dN/dξ to dN/dx.

Definition at line 68 of file baseElem.cpp.

68 {
69 auto qds = d_quads;
70 mapToPhysical(qds, nodes, false);
71 return qds;
72}

References fe::mapToPhysical().

Here is the call graph for this function:

◆ getShapes() [1/2]

virtual std::vector< double > fe::BaseElem::getShapes ( const util::Point &  p)
protectedpure virtual

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

Implemented in fe::HexElem, fe::LineElem, fe::QuadElem, fe::TetElem, and fe::TriElem.

◆ getShapes() [2/2]

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

Returns the values of shape function at point p.

The point p is assumed to be inside an element \( T\) given by nodes. The idea is to first map point p to the point \( p^0\) in reference element \( T^0 \) and then compute shape functions at \( p^0 \).

The map from any element \( T \) to reference element is \( T^0 \) gets complex for elements like fe::QuadElem. For elements fe:LineElem and fe::TriElem, this follows in closed form. Therefore, this method is only implemented for fe::TriElem and fe::LineElem.

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

Reimplemented in fe::LineElem, fe::TetElem, and fe::TriElem.

Definition at line 22 of file baseElem.cpp.

23 {
24 throw std::runtime_error(
26 << "Error: For element type = " << d_elemType << " the map from "
27 << "element to reference element is not available.\n"
28 << "Therefore, shape function evaluation at any arbitrary point "
29 "in the element is not possible.\n");
30}

◆ init()

void fe::BaseElem::init ( )
protectedpure virtual

Compute the quadrature points.

This must be implemented by inheriting classes.

Implemented in fe::HexElem, fe::LineElem, fe::QuadElem, fe::TetElem, and fe::TriElem.

Definition at line 52 of file baseElem.cpp.

52 {
53
54 throw std::runtime_error(
56 << "Error: init() of BaseElem must be implemented in inheriting "
57 "class.\n");
58}

◆ mapPointToRefElem()

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

Maps point p in a given element to the reference element and returns the mapped point.

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

Reimplemented in fe::LineElem, fe::TetElem, and fe::TriElem.

Definition at line 44 of file baseElem.cpp.

45 {
46 throw std::runtime_error(
48 << "Error: For element type = " << d_elemType << " the map from "
49 << "element to reference element is not available.\n");
50}

Field Documentation

◆ d_elemType

size_t fe::BaseElem::d_elemType
protected

Element type.

Definition at line 221 of file baseElem.h.

Referenced by getElemType().

◆ d_quadOrder

size_t fe::BaseElem::d_quadOrder
protected

Order of quadrature point integration approximation.

Definition at line 218 of file baseElem.h.

Referenced by getQuadOrder(), and fe::TetElem::TetElem().

◆ d_quads

std::vector<fe::QuadData> fe::BaseElem::d_quads
protected

Quadrature data collection.

Definition at line 224 of file baseElem.h.

Referenced by getNumQuadPoints().


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