Geophysical Inversion and Modeling Library  v1.0.11-38-g7483f4dd
GIMLI::Shape Class Referenceabstract

A Shape defines a geometrical primitive. More...

Inherited by GIMLI::EdgeShape, GIMLI::HexahedronShape, GIMLI::NodeShape, GIMLI::PolygonShape, GIMLI::PyramidShape, GIMLI::QuadrangleShape, GIMLI::TetrahedronShape, GIMLI::TriangleShape, and GIMLI::TriPrismShape.

+ Collaboration diagram for GIMLI::Shape:

Public Member Functions

 Shape ()
virtual ~Shape ()
virtual int rtti () const =0
virtual int dim () const =0
virtual std::string name () const
uint nodeCount () const
void setNode (Index i, Node &n)
const Nodenode (Index i) const
Nodenode (Index i)
const std::vector< Node *> & nodes () const
std::vector< Node *> & nodes ()
virtual std::vector< PolynomialFunction< double > > createShapeFunctions () const
void createJacobian (RMatrix3 &J) const
RMatrix3 createJacobian () const
const RMatrix3invJacobian () const
virtual RVector N (const RVector3 &L) const
virtual void N (const RVector3 &L, RVector &ret) const
virtual void dNdrst (const RVector3 &rst, RMatrix &MdNdrst) const
virtual RMatrix dNdrst (const RVector3 &L) const
virtual void rst2xyz (const RVector3 &rst, RVector3 &xyz) const
virtual RVector3 xyz (const RVector3 &rst) const
virtual void xyz2rst (const RVector3 &xyz, RVector3 &rst) const
virtual RVector3 rst (const RVector3 &xyz) const
virtual RVector3 rst (Index i) const
double drstdxyz (uint rstI, uint xyzJ) const
virtual bool isInside (const RVector3 &xyz, bool verbose=false) const
virtual bool isInside (const RVector3 &xyz, RVector &sf, bool verbose=false) const
virtual bool intersectRay (const RVector3 &start, const RVector3 &dir, RVector3 &pos)
double domainSize () const
RVector3 center () const
virtual RVector3 norm () const
void changed ()
virtual bool enforcePositiveDirection ()

Protected Member Functions

void resizeNodeSize_ (uint n)
virtual double domainSize_ () const

Protected Attributes

double domSize_
bool hasDomSize_
RMatrix3 invJacobian_
std::vector< Node *> nodeVector_

Detailed Description

A Shape defines a geometrical primitive.

A Shape defines a geometrical primitive. And is the geometrical base of a MeshEntity.

Constructor & Destructor Documentation

◆ Shape()

GIMLI::Shape::Shape ( )

Default constructor.

◆ ~Shape()

GIMLI::Shape::~Shape ( )

Default destructor.

Member Function Documentation

◆ center()

RVector3 GIMLI::Shape::center ( ) const

Returns the middle position of this shape

Referenced by GIMLI::MeshEntity::center().

◆ changed()

void GIMLI::Shape::changed ( )

Notify this shape that the inverse Jacobian matrix and the domain size are not longer valid and need recalculation. This method is called if a node has bee transformed.

Referenced by enforcePositiveDirection(), GIMLI::HexahedronShape::enforcePositiveDirection(), and setNode().

◆ createJacobian()

void GIMLI::Shape::createJacobian ( RMatrix3 J) const

Create and return the Jacobian matrix for this shape at the local coordinate $ L[r,s,t]$.
The Jacobian matrix is a 3x3 matrix representing the absolute derivative matrix for this shape regarding the $ \mathcal{N} $ shape functions:

\begin{eqnarray*} J(0,i-1) & = \sum_n^{\mathcal{N}}\frac{dN_n(r,s,t)}{\partial r,s,t}x_n \\ J(1,i-1) & = \sum_n^{\mathcal{N}}\frac{dN_n(r,s,t)}{\partial r,s,t}y_n \\ J(2,i-1) & = \sum_n^{\mathcal{N}}\frac{dN_n(r,s,t)}{\partial r,s,t}z_n \end{eqnarray*}

for i = [1,2,3]

\begin{eqnarray*} & \frac{\partial x}{\partial r}, \frac{\partial x}{\partial s}, \frac{\partial x}{\partial t}\\ J = & \frac{\partial y}{\partial r}, \frac{\partial y}{\partial s}, \frac{\partial y}{\partial t}\\ & \frac{\partial z}{\partial r}, \frac{\partial z}{\partial s}, \frac{\partial z}{\partial t}\\ \end{eqnarray*}

the inverse of the Jacobian results in:

\begin{eqnarray*} & \frac{\partial r}{\partial x}, \frac{\partial r}{\partial y}, \frac{\partial r}{\partial z}\\ J^{-1} = \frac{1}{|J|} & \frac{\partial s}{\partial x}, \frac{\partial s}{\partial y}, \frac{\partial s}{\partial z}\\ & \frac{\partial t}{\partial x}, \frac{\partial t}{\partial y}, \frac{\partial t}{\partial z} \end{eqnarray*}

References dNdrst(), GIMLI::Singleton< ShapeFunctionCache >::instance(), nodeCount(), rtti(), GIMLI::x(), GIMLI::y(), and GIMLI::z().

Referenced by dNdrst(), enforcePositiveDirection(), GIMLI::HexahedronShape::enforcePositiveDirection(), and invJacobian().

◆ dNdrst()

void GIMLI::Shape::dNdrst ( const RVector3 rst,
RMatrix MdNdrst 
) const

Return the derivative matrix of size ( $ 3\times\mathcal{N} $) for the shape functions at the local coordinate. $ L(r,s,t) $. Result is independent of L for linear shape function (TODO Remove on cleanup) $ [[\frac{dN_i(r,s,t)}{\partial r}],[\frac{dN_i(r,s,t)}{\partial s}],[\frac{dN_i(r,s,t)}{\partial t}]^{\mathrm{T}}] $ for $ i = [0,\mathcal{N}$

References createJacobian(), GIMLI::Singleton< ShapeFunctionCache >::instance(), norm(), and rst().

Referenced by createJacobian(), and N().

◆ domainSize()

double GIMLI::Shape::domainSize ( ) const

Get the domain size of this shape, i.e., length, area or volume

References domainSize_().

Referenced by GIMLI::ElectrodeShapeNodesWithBypass::ElectrodeShapeNodesWithBypass(), GIMLI::prepExportSensitivityData(), and GIMLI::MeshEntity::size().

◆ domainSize_()

virtual double GIMLI::Shape::domainSize_ ( ) const

Virtual method to calculate the domain size i.e length, area, volume of the shapes

Reimplemented in GIMLI::TriPrismShape, GIMLI::HexahedronShape, GIMLI::TetrahedronShape, GIMLI::QuadrangleShape, GIMLI::TriangleShape, GIMLI::EdgeShape, and GIMLI::NodeShape.

References GIMLI::str().

Referenced by domainSize().

◆ drstdxyz()

double GIMLI::Shape::drstdxyz ( uint  rstI,
uint  xyzJ 
) const

Return derivative from local coordinates to Cartesian coordinates. These are the elements of the inverse Jacobian matrix.

◆ enforcePositiveDirection()

bool GIMLI::Shape::enforcePositiveDirection ( )

Reverse node sequence order to enforce positive Jacobian determinant. Please use with care! Return True if the order has been changed.

Reimplemented in GIMLI::HexahedronShape.

References changed(), createJacobian(), and GIMLI::det().

◆ intersectRay()

virtual bool GIMLI::Shape::intersectRay ( const RVector3 start,
const RVector3 dir,
RVector3 pos 
  • Return true if the ray intersects the shape. On boundary means inside too. The intersection position is stored in pos.

Reimplemented in GIMLI::QuadrangleShape, GIMLI::TriangleShape, and GIMLI::EdgeShape.

Referenced by GIMLI::Mesh::findCellsAlongRay().

◆ invJacobian()

const RMatrix3 & GIMLI::Shape::invJacobian ( ) const

Return the inverse of the Jacobian Matrix. And create and cache it on demand. The matrix is no more valid if the shape was transformed.

References createJacobian(), GIMLI::Singleton< ShapeFunctionCache >::instance(), and GIMLI::inv().

Referenced by GIMLI::MeshEntity::grad(), and xyz2rst().

◆ isInside() [1/2]

bool GIMLI::Shape::isInside ( const RVector3 xyz,
bool  verbose = false 
) const

Return true if the Cartesian coordinates xyz are inside the shape. On boundary means inside too.

Reimplemented in GIMLI::PolygonShape.

Referenced by GIMLI::Mesh::findNearestNode(), GIMLI::TriangleShape::intersectRay(), and GIMLI::QuadrangleShape::intersectRay().

◆ isInside() [2/2]

bool GIMLI::Shape::isInside ( const RVector3 xyz,
RVector sf,
bool  verbose = false 
) const

Return true if the Cartesian coordinates xyz are inside the shape. On boundary means inside too. sf contains the complete shape function to identify next neighbor.

References GIMLI::Pos< ValueType >::abs(), N(), and rst().

◆ N() [1/2]

RVector GIMLI::Shape::N ( const RVector3 L) const

Return a RVector for the $ n=[0,\mathrm{nodeCount()}] $ shape functions $ N_n(r,s,t)$ at the local coordinate $ L(r,s,t)$.

References nodeCount().

Referenced by isInside(), N(), and rst2xyz().

◆ N() [2/2]

void GIMLI::Shape::N ( const RVector3 L,
RVector ret 
) const

TODO replace this with expressions.
Fill the allocated RVector n of size $ \mathcal{N} $ for the $ n=[0,$ {N} $) $ shape functions $ N_n(r,s,t)$ for the local coordinate $ L(r,s,t)$. For performance reasons the size of L will not be checked. This method needs to be specialized in the corresponding child classes.

References dNdrst(), GIMLI::Singleton< ShapeFunctionCache >::instance(), N(), nodeCount(), and rst().

◆ name()

virtual std::string GIMLI::Shape::name ( ) const

◆ node() [1/2]

const Node & GIMLI::Shape::node ( Index  i) const

Return a read only reference to the i-th Node of this shape.

References nodeCount().

Referenced by GIMLI::EdgeShape::intersectRay(), GIMLI::TriangleShape::intersectRay(), and GIMLI::QuadrangleShape::intersectRay().

◆ node() [2/2]

Node & GIMLI::Shape::node ( Index  i)

Return a reference to the i-th Node of this shape.

References nodeCount().

◆ nodeCount()

◆ nodes() [1/2]

const std::vector< Node * >& GIMLI::Shape::nodes ( ) const

Return a read only reference to all nodes.

Referenced by GIMLI::dcfemDomainAssembleStiffnessMatrix().

◆ nodes() [2/2]

std::vector< Node * >& GIMLI::Shape::nodes ( )

Return a reference to all nodes.

◆ norm()

RVector3 GIMLI::Shape::norm ( ) const

Returns the norm vector if possible otherwise returns non valid Vector3

Reimplemented in GIMLI::PolygonShape, GIMLI::QuadrangleShape, GIMLI::TriangleShape, GIMLI::EdgeShape, and GIMLI::NodeShape.

References rtti().

Referenced by dNdrst(), and GIMLI::Boundary::norm().

◆ rst() [1/2]

◆ rst() [2/2]

RVector3 GIMLI::Shape::rst ( Index  i) const

◆ rst2xyz()

void GIMLI::Shape::rst2xyz ( const RVector3 rst,
RVector3 xyz 
) const

Perform coordinate transformation from the locale coordinates $ (r,s,t)=(r,s,t)=([0..1,0..1,0..1]) $ of this shape to Cartesian coordinates $ (x,y,z) $ regarding to the $ \mathcal{N} $ shape functions N $ N_i $ with $ i=[0,\mathcal{N})$
This is the opposite to xyz2rst().

\begin{eqnarray*} x &=& \sum_i^{\mathcal{N}} N_i(r,s,t)x_i \\ y &=& \sum_i^{\mathcal{N}} N_i(r,s,t)y_i \\ z &=& \sum_i^{\mathcal{N}} N_i(r,s,t)z_i \end{eqnarray*}

This is a generic function and may be overwritten by faster methods for shape simplexes.

References N(), and nodeCount().

Referenced by xyz().

◆ rtti()

◆ setNode()

void GIMLI::Shape::setNode ( Index  i,
Node n 

◆ xyz()

RVector3 GIMLI::Shape::xyz ( const RVector3 rst) const

Return the Cartesian coordinates for the locale coordinates rst. See rst2xyz.

References rst2xyz().

Referenced by GIMLI::calcGCells(), GIMLI::Mesh::createRefined_(), and xyz2rst().

◆ xyz2rst()

void GIMLI::Shape::xyz2rst ( const RVector3 xyz,
RVector3 rst 
) const

Convert Cartesian coordinates into locale coordinates regarding the shape functions. This is the opposite to xyz2rst. This is a generic function and may be overwritten by faster methods for shape simplexes. Solve the nonlinear system of equations by newton method $ \mathrm{d}(x,y,z)= J*\mathrm{d}(r,s,t) $

Reimplemented in GIMLI::TetrahedronShape, and GIMLI::TriangleShape.

References GIMLI::Pos< ValueType >::abs(), invJacobian(), and xyz().

Referenced by rst().