CEPS  24.01
Cardiac ElectroPhysiology Simulator
FiniteElements Class Reference

Detailed Description

Holds all finite elements corresponding to each geometrical element.

This class is responsible for building the finite elements using geometrical elements. i.e., for each geometrical element (1D, 2D or 3D) in the geometry, it associates a finite element.

Like for Geometrical Nodes and Cells, there can be owned and halo FE Nodes, but there can be only owned Finite elements

See also
FEBase
ReferenceFE
GeomCell
GeomSimplex

Definition at line 50 of file FiniteElements.hpp.

#include <FiniteElements.hpp>

Inheritance diagram for FiniteElements:
[legend]

Public Member Functions

 FiniteElements ()=delete
 Default Constuctor deleted. More...
 
 FiniteElements (AbstractPdeProblem *problem, CepsUInt order)
 Constructor from an abtract problem and order (see CepsCellType) More...
 
 FiniteElements (const FiniteElements &)=delete
 Copy Constructor deleted. More...
 
 ~FiniteElements () override
 Destructor. More...
 
ReferenceFEgetReferenceElementOfDim (CepsCellType type, CepsUInt dim) const
 Access to reference elements. More...
 
CepsVector< FEBase * > & getFiniteElements ()
 Get vector containing all finite elements of the maximum valid dim. More...
 
CepsVector< FEBase * > & getBoundaryFiniteElements ()
 Get vector containing all finite elements of the maximum valid dim. More...
 
CepsUInt getNumberOfHaloFENodes () const
 Global number of owned nodes. More...
 
CepsUInt getNumberOfOwnedFENodes () const
 Local number of nodes belonging to this process, halo nodes NOT included. More...
 
const CepsVector< FENode * > & getOwnedFENodes ()
 vector of owned nodes More...
 
const CepsVector< FENode * > & getHaloFENodes ()
 vector of halo nodes More...
 
FENodegetFENode (CepsGlobalIndex nID)
 Link to a single node. More...
 
CepsBool isOwnedFENode (CepsGlobalIndex globalID) const
 Tells if node is owned by current CPU. More...
 
CepsBool isHaloFENode (CepsGlobalIndex globalID) const
 Tells if node is halo by current CPU. More...
 
CepsVector< DegreeOfFreedom * > getDofsOnElement (FEBase *elem)
 ALl the dofs defined on an element. More...
 
CepsVector< DegreeOfFreedom * > getDofsOnElementForUnknowns (FEBase *elem, const CepsVector< Unknown * > &us)
 All dofs defined on an element, considering unknowns us. More...
 
CepsIndex getDofSpatialId (const DegreeOfFreedom *dof) const override
 Return the Geom Node Id for a node (not the FENode index returned by dof->getGeomId()) More...
 
DMatPtr getMassMatrix () const
 Pointer on mass matrix. More...
 
DMatPtr getStiffnessMatrix () const
 Pointer on stiffness matrix. More...
 
CepsReal dotProduct (DHVecPtr u, DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={}) final
 returns $u.Mv$ where $M$ is the mass matrix $\int\phi_i\phi_j$ More...
 
CepsReal stiffProduct (DHVecPtr u, DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={})
 returns $u.Kv$ where $K$ is the stiffness matrix $\int\nabla\phi_i.\nabla\phi_j$ More...
 
CepsReal h1Norm (DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={}) override
 sqrt(stiffproduct(v,v)) More...
 
void extractValuesForUnknown (const CepsUnknownIndex &uId, DVecPtr vec, CepsVector< CepsIndex > &indices, CepsVector< CepsReal > &values, CepsBool sendToMaster=false, CepsBool returnGeomIndices=false) override
 Slicing method that extracts the data corresponding to a specific unknown. More...
 
- Public Member Functions inherited from AbstractDiscretization
 AbstractDiscretization ()=delete
 Deleted default constructor. More...
 
 AbstractDiscretization (const AbstractDiscretization &that)=delete
 Deleted Copy constructor (objects are too big, and not really useful) More...
 
AbstractDiscretizationoperator= (const AbstractDiscretization &)=delete
 Deleted assignment operator. More...
 
 ~AbstractDiscretization () override
 Destructor. More...
 
AbstractPdeProblemgetProblem () const
 Return link to pde problem. More...
 
DistributedFactorygetDofsFactory () const
 Get the stored DistributedFactory. More...
 
DistributedInfos< DegreeOfFreedom * > * getDistributedDofs () const
 Get the stored Degree Of Freedom repartition. More...
 
const DegreeOfFreedomTreegetDegreeOfFreedomTree () const
 The sorted degrees of freedom. More...
 
const CepsMap< CepsUnknownIndex, CepsVector< DegreeOfFreedom * > > & getDegreesOfFreedomForUnknown ()
 Dofs sorted by unknown. More...
 
const CepsVector< DegreeOfFreedom * > & getDegreesOfFreedomForUnknown (CepsUnknownIndex uId)
 Dofs for given unknown. More...
 
const CepsVector< DegreeOfFreedom * > & getDegreesOfFreedomForUnknown (Unknown *u)
 Dofs sorted by unknown. More...
 
GeometrygetGeometry () const
 Get the stored Geometry. More...
 
virtual void registerSpatialUnkown (Unknown *u)
 Changes the location of unknown u to be adapted to the discrectization for example CepsLocationFlag::Point for finite elements, Cell for finite volumes. More...
 
DVecPtr newDofVector () const
 Get a new vector from the factory. More...
 
DHVecPtr newDofHaloVector () const
 Get a new vector from the factory, with halo data. More...
 
DMatPtr newDofMatrix () const
 Get a new matrix from the factory. More...
 
DegreeOfFreedomgetDof (CepsGlobalIndex globalDofId)
 Get the dof with given globalID, nullptr if not found. More...
 
const DegreeOfFreedomgetDof (CepsGlobalIndex globalDofId) const
 Get the dof with given globalID, nullptr if not found. More...
 
CepsBool isDofSpatial (CepsGlobalIndex globalDofId) const
 Check if the Unknow is a spatial one (typically CepsLocationFlag != ZeroD) More...
 
CepsVector< DegreeOfFreedom * > getOwnedDofs () const
 Get the degrees of freedom owned by process. More...
 
CepsVector< DegreeOfFreedom * > getHaloDofs () const
 Get the degrees of freedom owned by other processes. More...
 
void evaluateFunctionOnDofs (ceps::Function< CepsReal(CepsStandardArgs)> *func, DHVecPtr v, CepsReal t=0.) const
 Fills vector v with values of function func at owned and halo dofs and time t. More...
 
void findClosestDof (const CepsReal3D &x, Unknown *u, CepsDofGlobalIndex &dofId, CepsProcId &owner)
 Set dofId to that if the closest to position x, also sets owner. More...
 
CepsReal getZeroDValue (Unknown *u, DHVecPtr sol)
 Get the value of a 0D unknown into a solution vector. More...
 
CepsReal l1Norm (DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={})
 L1-norm of a given vector. More...
 
CepsReal l2Norm (DHVecPtr v, CepsBool boundary=false, const CepsSet< CepsAttribute > &attrs={}, const CepsVector< Unknown * > &unknowns={})
 L2-norm of a given vector. Computation of dotproduct depends on the discretization. More...
 
- Public Member Functions inherited from CepsObject
 CepsObject ()=default
 default constructor More...
 
 CepsObject (const CepsObject &)=default
 Copy constructor. More...
 
virtual ~CepsObject ()=default
 Destructor. More...
 
CepsObjectoperator= (const CepsObject &)=default
 Assignment operator. More...
 
CepsObjecttoBaseObject ()
 Returns a pointer to CepsObject class. More...
 
const CepsObjecttoBaseObject () const
 Returns a pointer to CepsObject class, const version. More...
 
ProfilergetProfiler () const
 Access to profiler. More...
 

Protected Member Functions

void initializeRefElements ()
 Configure reference elements. More...
 
void buildElements ()
 main routine of FiniteElements called in the constructor More...
 
void buildElements (Mesh *mesh, CepsBool onBoundary)
 main routine of FiniteElements called in the constructor More...
 
void checkNeighborsBeforeAssign (FEBase *fElem, FEBase *nElem, CepsUInt nID, CepsBool boundary, CepsBool &foundSameDof)
 Checks if a FE node already exists in a neighbor element. More...
 
void createNewNode (FEBase *el, CepsUInt indexDof, CepsBool isBoundary, Mesh *mesh)
 Allocate new node that it is not a geometrical node. More...
 
void computeNeighbors ()
 Compute Neighbors. More...
 
CepsHash3 getNodeHash (const FENode *n) const
 Get the hash value from the coordinates of the node. More...
 
void buildDofsTree () override
 Builds the degrees of freedom tree from the PDE data, uses previously build elements and nodes. buildElements and computeNeighbors must be called beforehand. More...
 
void setSpatialUnknownsDofsInteractions () override
 Build dofs neighboring list for spatial unknowns. Different in FE (same element dofs) and VF, FD dofs on neighbor geom elements. More...
 
- Protected Member Functions inherited from AbstractDiscretization
 AbstractDiscretization (AbstractPdeProblem *problem)
 Constructor to build an object from PDE problem. More...
 
void buildDofs ()
 Builds the degrees of freedom data structures from the PDE data. More...
 
void buildDofsDistributedInfo ()
 Builds the degrees of freedom distribution from the dofs tree. More...
 
void createDofsForZeroDUnknowns ()
 Adds one dof for each zeroD unknown, must be called after all other dofs are distributed. More...
 
virtual void setZeroDUnknownsDofsInteractions ()
 Updates neighboring lists with interaction with 0D unknowns. More...
 
void setupDofsFactory ()
 Prepare the factory that will generate vectors of dofs. More...
 
void extractValuesForUnknownInternal (const CepsUnknownIndex &uId, DVecPtr vec, CepsVector< CepsIndex > &indices, CepsVector< CepsReal > &values, CepsBool sendToMaster, CepsBool returnGeomIndices, std::function< CepsBool(DegreeOfFreedom *)> &selector)
 Slicing method that extracts the data corresponding to a specific unknown. More...
 

Protected Attributes

CepsUInt m_order
 Order used to build elements. More...
 
CepsMap< CepsCellType, CepsArray4< ReferenceFE * > > m_refElems
 Reference elements (point, segment, tri, tetra) More...
 
DistributedInfos< FENode *, CepsHash3 > * m_nodes
 Holds nodes. More...
 
DistributedInfos< FEBase * > * m_volElems
 Holds 1D-3D finite elements. More...
 
DistributedInfos< FEBase * > * m_bdrElems
 Holds 1D-3D finite boundary elements. More...
 
CepsUInt m_maxValidDim
 Get the maximum valid dimension. More...
 
DMatPtr m_mass
 Mass matrix, computed at instantiation. More...
 
DMatPtr m_stiff
 Stiffness matrix, computed at instantiation. More...
 
- Protected Attributes inherited from AbstractDiscretization
AbstractPdeProblemm_problem
 [not owned] Pointer on the pde problem More...
 
Geometrym_geometry
 [not owned] Pointer on the geometry More...
 
DistributedInfos< DegreeOfFreedom * > * m_distributedDofs
 [owned] Pointer on the dofs structure More...
 
DegreeOfFreedomTree m_dofsTree
 [owned] Pointer on the distributed degree of freedom tree More...
 
DistributedFactorym_dofsFactory
 [owned] The factory that builds vectors and matrices More...
 
CepsBool m_dofsBuilt
 Tells if the class has setup all the dofs. More...
 
CepsMap< CepsUnknownIndex, CepsVector< DegreeOfFreedom * > > m_dofsForUnknown
 Reverse mapping of dofs, with unknown index as key. More...
 
CepsLocationFlag m_spatialUnknownsLocation
 Where unknowns are located. Must be set in child classes. More...
 
CepsVector< CepsMap< CepsDofGlobalIndex, CepsSet< CepsDofGlobalIndex > > > m_extraAdjacencyToSend
 A map to correct the missing adjacency that can occur in rare occasions in 3D. More...
 
CepsMap< CepsDofGlobalIndex, CepsSet< CepsDofGlobalIndex > > m_extraAdjacencyToRecv
 A map to correct the missing adjacency that can occur in rare occasions in 3D. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from CepsObject
static Profiler m_profiler
 The same profiler for each big object. More...
 

Constructor & Destructor Documentation

◆ FiniteElements() [1/3]

FiniteElements::FiniteElements ( )
delete

Default Constuctor deleted.

◆ FiniteElements() [2/3]

FiniteElements::FiniteElements ( AbstractPdeProblem problem,
CepsUInt  order 
)

Constructor from an abtract problem and order (see CepsCellType)

Definition at line 42 of file FiniteElements.cpp.

◆ FiniteElements() [3/3]

FiniteElements::FiniteElements ( const FiniteElements )
delete

Copy Constructor deleted.

◆ ~FiniteElements()

FiniteElements::~FiniteElements ( )
override

Destructor.

Definition at line 109 of file FiniteElements.cpp.

Member Function Documentation

◆ buildDofsTree()

void FiniteElements::buildDofsTree ( )
overrideprotectedvirtual

Builds the degrees of freedom tree from the PDE data, uses previously build elements and nodes. buildElements and computeNeighbors must be called beforehand.

Implements AbstractDiscretization.

Definition at line 570 of file FiniteElements.cpp.

◆ buildElements() [1/2]

void FiniteElements::buildElements ( )
protected

main routine of FiniteElements called in the constructor

For a given dimension, we go across all the geometrical elements of that dim

  • we allocate a corresponding finite element (currently FEP1 or FEP2)
  • if needed we add new FE nodes verifying that

FE node does not belong yet to another finite element

FE node is halo or not for that proc

  • we communicate among processors to replace value of haloNodes

Definition at line 351 of file FiniteElements.cpp.

◆ buildElements() [2/2]

void FiniteElements::buildElements ( Mesh mesh,
CepsBool  onBoundary 
)
protected

main routine of FiniteElements called in the constructor

For a given dimension, we go across all the geometrical elements of that dim

  • we allocate a corresponding finite element (currently FEP1 or FEP2)
  • if needed we add new FE nodes verifying that

FE node does not belong yet to another finite element

FE node is halo or not for that proc

  • we communicate among processors to replace value of haloNodes

Definition at line 380 of file FiniteElements.cpp.

◆ checkNeighborsBeforeAssign()

void FiniteElements::checkNeighborsBeforeAssign ( FEBase fElem,
FEBase nElem,
CepsUInt  nID,
CepsBool  boundary,
CepsBool foundSameDof 
)
protected

Checks if a FE node already exists in a neighbor element.

Parameters
[in,out]fElemcurrent finite element from which we explore the neighbors
[in]nElemthe neighbor finite element in which we check the presence of nodes
[in]nIDindex of the node to check in fElem
[in]boundaryindicate if fElem is on the boundary
[out]foundSameDofset to true if node nID in fElem exists in nElem

Definition at line 437 of file FiniteElements.cpp.

◆ computeNeighbors()

void FiniteElements::computeNeighbors ( )
protected

Compute Neighbors.

Definition at line 529 of file FiniteElements.cpp.

◆ createNewNode()

void FiniteElements::createNewNode ( FEBase el,
CepsUInt  indexDof,
CepsBool  isBoundary,
Mesh mesh 
)
protected

Allocate new node that it is not a geometrical node.

Parameters
[in,out]elpointer on finite element
[in]indexDofindex of new dof in el
[in]isBoundarydifferent initialization for boundary elements
[in]meshpointer on the current mesh

Definition at line 472 of file FiniteElements.cpp.

◆ dotProduct()

CepsReal FiniteElements::dotProduct ( DHVecPtr  u,
DHVecPtr  v,
CepsBool  boundary = false,
const CepsSet< CepsAttribute > &  attrs = {},
const CepsVector< Unknown * > &  unknowns = {} 
)
finalvirtual

returns $u.Mv$ where $M$ is the mass matrix $\int\phi_i\phi_j$

Implements AbstractDiscretization.

Definition at line 252 of file FiniteElements.cpp.

◆ extractValuesForUnknown()

void FiniteElements::extractValuesForUnknown ( const CepsUnknownIndex uId,
DVecPtr  vec,
CepsVector< CepsIndex > &  indices,
CepsVector< CepsReal > &  values,
CepsBool  sendToMaster = false,
CepsBool  returnGeomIndices = false 
)
overridevirtual

Slicing method that extracts the data corresponding to a specific unknown.

Parameters
[in]uIdunknown identifier
[in]vecdistributed vector from which to extract
[out]indicesglobal row indices of the extracted dofs
[out]valuesextracted values
[in]sendToMasterdata will be shared with master CPU (e.g. for output)
[in]returnGeomIndicesfill indices with geomIndices instead of dofIndices (outputs) /!\ Only dofs defined on geom points will be parsed !

Implements AbstractDiscretization.

Definition at line 747 of file FiniteElements.cpp.

◆ getBoundaryFiniteElements()

CepsVector< FEBase * > & FiniteElements::getBoundaryFiniteElements ( )

Get vector containing all finite elements of the maximum valid dim.

Definition at line 130 of file FiniteElements.cpp.

◆ getDofsOnElement()

CepsVector< DegreeOfFreedom * > FiniteElements::getDofsOnElement ( FEBase elem)

ALl the dofs defined on an element.

Definition at line 184 of file FiniteElements.cpp.

◆ getDofsOnElementForUnknowns()

CepsVector< DegreeOfFreedom * > FiniteElements::getDofsOnElementForUnknowns ( FEBase elem,
const CepsVector< Unknown * > &  us 
)

All dofs defined on an element, considering unknowns us.

Parameters
eleman element
usvector of unknowns
Returns

Definition at line 196 of file FiniteElements.cpp.

◆ getDofSpatialId()

CepsIndex FiniteElements::getDofSpatialId ( const DegreeOfFreedom dof) const
overridevirtual

Return the Geom Node Id for a node (not the FENode index returned by dof->getGeomId())

Implements AbstractDiscretization.

Definition at line 221 of file FiniteElements.cpp.

◆ getFENode()

FENode * FiniteElements::getFENode ( CepsGlobalIndex  nID)

Link to a single node.

Definition at line 160 of file FiniteElements.cpp.

◆ getFiniteElements()

CepsVector< FEBase * > & FiniteElements::getFiniteElements ( )

Get vector containing all finite elements of the maximum valid dim.

Definition at line 124 of file FiniteElements.cpp.

◆ getHaloFENodes()

const CepsVector< FENode * > & FiniteElements::getHaloFENodes ( )

vector of halo nodes

Definition at line 154 of file FiniteElements.cpp.

◆ getMassMatrix()

DMatPtr FiniteElements::getMassMatrix ( ) const

Pointer on mass matrix.

Definition at line 237 of file FiniteElements.cpp.

◆ getNodeHash()

CepsHash3 FiniteElements::getNodeHash ( const FENode n) const
protected

Get the hash value from the coordinates of the node.

Definition at line 564 of file FiniteElements.cpp.

◆ getNumberOfHaloFENodes()

CepsUInt FiniteElements::getNumberOfHaloFENodes ( ) const

Global number of owned nodes.

Definition at line 136 of file FiniteElements.cpp.

◆ getNumberOfOwnedFENodes()

CepsUInt FiniteElements::getNumberOfOwnedFENodes ( ) const

Local number of nodes belonging to this process, halo nodes NOT included.

Definition at line 142 of file FiniteElements.cpp.

◆ getOwnedFENodes()

const CepsVector< FENode * > & FiniteElements::getOwnedFENodes ( )

vector of owned nodes

Definition at line 148 of file FiniteElements.cpp.

◆ getReferenceElementOfDim()

ReferenceFE * FiniteElements::getReferenceElementOfDim ( CepsCellType  type,
CepsUInt  dim 
) const

Access to reference elements.

Definition at line 345 of file FiniteElements.cpp.

◆ getStiffnessMatrix()

DMatPtr FiniteElements::getStiffnessMatrix ( ) const

Pointer on stiffness matrix.

Definition at line 243 of file FiniteElements.cpp.

◆ h1Norm()

CepsReal FiniteElements::h1Norm ( DHVecPtr  v,
CepsBool  boundary = false,
const CepsSet< CepsAttribute > &  attrs = {},
const CepsVector< Unknown * > &  unknowns = {} 
)
overridevirtual

sqrt(stiffproduct(v,v))

Implements AbstractDiscretization.

Definition at line 317 of file FiniteElements.cpp.

◆ initializeRefElements()

void FiniteElements::initializeRefElements ( )
protected

Configure reference elements.

Definition at line 333 of file FiniteElements.cpp.

◆ isHaloFENode()

CepsBool FiniteElements::isHaloFENode ( CepsGlobalIndex  globalID) const

Tells if node is halo by current CPU.

Definition at line 178 of file FiniteElements.cpp.

◆ isOwnedFENode()

CepsBool FiniteElements::isOwnedFENode ( CepsGlobalIndex  globalID) const

Tells if node is owned by current CPU.

Definition at line 172 of file FiniteElements.cpp.

◆ setSpatialUnknownsDofsInteractions()

void FiniteElements::setSpatialUnknownsDofsInteractions ( )
overrideprotectedvirtual

Build dofs neighboring list for spatial unknowns. Different in FE (same element dofs) and VF, FD dofs on neighbor geom elements.

Implements AbstractDiscretization.

Definition at line 619 of file FiniteElements.cpp.

◆ stiffProduct()

CepsReal FiniteElements::stiffProduct ( DHVecPtr  u,
DHVecPtr  v,
CepsBool  boundary = false,
const CepsSet< CepsAttribute > &  attrs = {},
const CepsVector< Unknown * > &  unknowns = {} 
)

returns $u.Kv$ where $K$ is the stiffness matrix $\int\nabla\phi_i.\nabla\phi_j$

Definition at line 287 of file FiniteElements.cpp.

Field Documentation

◆ m_bdrElems

DistributedInfos<FEBase*>* FiniteElements::m_bdrElems
protected

Holds 1D-3D finite boundary elements.

Definition at line 264 of file FiniteElements.hpp.

◆ m_mass

DMatPtr FiniteElements::m_mass
protected

Mass matrix, computed at instantiation.

Definition at line 268 of file FiniteElements.hpp.

◆ m_maxValidDim

CepsUInt FiniteElements::m_maxValidDim
protected

Get the maximum valid dimension.

Definition at line 266 of file FiniteElements.hpp.

◆ m_nodes

DistributedInfos<FENode*,CepsHash3>* FiniteElements::m_nodes
protected

Holds nodes.

Definition at line 260 of file FiniteElements.hpp.

◆ m_order

CepsUInt FiniteElements::m_order
protected

Order used to build elements.

Definition at line 256 of file FiniteElements.hpp.

◆ m_refElems

CepsMap<CepsCellType,CepsArray4<ReferenceFE*> > FiniteElements::m_refElems
protected

Reference elements (point, segment, tri, tetra)

Definition at line 258 of file FiniteElements.hpp.

◆ m_stiff

DMatPtr FiniteElements::m_stiff
protected

Stiffness matrix, computed at instantiation.

Definition at line 270 of file FiniteElements.hpp.

◆ m_volElems

DistributedInfos<FEBase*>* FiniteElements::m_volElems
protected

Holds 1D-3D finite elements.

Definition at line 262 of file FiniteElements.hpp.


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