Finite elements#
The finiteElements library concerns all the stuff related to the elementary objects of a finite elements discretization, say reference elements that are managed by the base class: RefElement
. This class handles the following data:
an
Interpolation
object carrying some general informations on the finite element such that the finite element type and its conforming space,a
GeomRefElement
object describing the geometric support of the element,a vector of
RefDof
to handle all the degrees of freedom (DOF) attached to the reference element,and additionnal stuff useful for the computation (for instance
ShapeValues
object to store the values of shape functions).
All concrete finite element classes are organized according to their geometry: LagrangeSegment
, LagrangeTriangle
, LagrangeTetrahedron
, … inherit from the RefElement
class through the intermediate classes: RefSegment
, RefTriangle
, RefTetrahedron
, …
GeomRefElement
also provides child classes: GeomRefSegment
, GeomRefTriangle
, GeomRefTetrahedron
, …
A GeomElement
object (geometric element from the mesh) and RefElement
are the main components of
the Element
object, defining a finite element in the physical space. In few words, a Mesh
is a collection of GeomElement
objects and Space
will be a collection of Element
objects.
Important
The Space
is the user class managing the finite elements parameters at its construction. Other classes are internal classes that handle a lot of information and functionnality.
Child classes for segment#
The RefSegment
class has three main child classes :
LagrangeStdSegment
which implements standard Lagrange element at any orderLagrangeGLSegment
which implements Lagrange element based on Gauss-Lobatto points at any orderHermiteStdSegment
which implements standard Hermite element, currently only P3 Hermite
Child classes for triangle#
The RefTriangle
class provides the following types of element:
standard Lagrange element at any order
LagrangeStdTriangle
andLagrangeStdTrianglePk
; the templateLagrangeStdTriangle
class is defined only for low order (up to 6) with better performance andLagrangeStdTrianglePk
class is designed for any order. It uses a general representation of shape functions on xy-monoms basis get from the solving of a linear system. This method is not stable for very high order.HermiteStdTriangle
which implements standard Hermite element, currently only P3 Hermite (not H2 conforming)CrouzeixRaviartStdTriangle
which implements the Crouzeix-Raviart element, currently only P1 (not H1 conforming)RaviartThomasTriangle
which implements the Raviart-Thomas elements (Hdiv conforming): :cpp:class:` RaviartThomasStdTriangleP1` for Raviart-Thomas standard P1 element andRaviartThomasStdTrianglePk
for Raviart-Thomas at any order.NedelecTriangle
which implements the Nedelec elements (Hcurl conforming):NedelecFirstTriangleP1
for Nedelec first family of order 1 element,NedelecFirstTrianglePk
for Nedelec first family of any order andNedelecSecondTrianglePk
for Nedelec second family of any order.MorleyTriangle
andArgyrisTriangle
elements designed for H2-approximation (non H2 conforming and H2 conforming).
Child classes for quadrangle#
Child classes for tetrahedron#
The RefTetrahedron
class provides the following types of element:
LagrangeStdTetrahedron
class is defined only for low order (up to 6) with better performance andLagrangeStdTetrahedronPk
class is designed for any order. It uses a general representation of shape functions on xyz-monoms basis get from the solving of a linear system. This method is not stable for very high order.CrouzeixRaviartTetrahedron
which implements the Crouzeix-Raviart element, currently only P1 (not H1 conforming)NedelecFaceTetrahedron
which implements the Nedelec elements Hdiv conforming:NedelecFaceFirstTetrahedronPk
for Nedelec first family of any order andNedelecFaceSecondTetrahedronPk
for Nedelec second family of any order. The second family is not yet available.NedelecEdgeTetrahedron
which implements the Nedelec elements Hrot conforming:NedelecEdgeFirstTetrahedronPk
for Nedelec first family of any order andNedelecEdgeSecondTetrahedronPk
for Nedelec second family of any order. The second family is not yet available.
Short identifiers of face/edge elements are defined in the following enumerations:
enum FeFaceType
{
_RT_1 = 1, RT_1 = _RT_1, _NF1_1 = _RT_1, NF1_1 = _RT_1,
_RT_2 , RT_2 = _RT_2, _NF1_2 = _RT_2, NF1_2 = _RT_2,
_RT_3 , RT_3 = _RT_3, _NF1_3 = _RT_3, NF1_3 = _RT_3,
_RT_4 , RT_4 = _RT_4, _NF1_4 = _RT_4, NF1_4 = _RT_4,
_RT_5 , RT_5 = _RT_5, _NF1_5 = _RT_5, NF1_5 = _RT_5,
_BDM_1 , BDM_1 = _BDM_1, _NF2_1 = _BDM_1, NF2_1 = _BDM_1,
_BDM_2 , BDM_2 = _BDM_2, _NF2_2 = _BDM_2, NF2_2 = _BDM_2,
_BDM_3 , BDM_3 = _BDM_3, _NF2_3 = _BDM_3, NF2_3 = _BDM_3,
_BDM_4 , BDM_4 = _BDM_4, _NF2_4 = _BDM_4, NF2_4 = _BDM_4,
_BDM_5 , BDM_5 = _BDM_5, _NF2_5 = _BDM_5, NF2_5 = _BDM_5
};
enum FeEdgeType
{
_N1_1 = 1, N1_1 = _N1_1, _NE1_1 = _N1_1, NE1_1 = _N1_1,
_N1_2 , N1_2 = _N1_2, _NE1_2 = _N1_2, NE1_2 = _N1_2,
_N1_3 , N1_3 = _N1_3, _NE1_3 = _N1_3, NE1_3 = _N1_3,
_N1_4 , N1_4 = _N1_4, _NE1_4 = _N1_4, NE1_4 = _N1_4,
_N1_5 , N1_5 = _N1_5, _NE1_5 = _N1_5, NE1_5 = _N1_5,
_N2_1 , N2_1 = _N2_1, _NE2_1 = _N2_1, NE2_1 = _N2_1,
_N2_2 , N2_2 = _N2_2, _NE2_2 = _N2_2, NE2_2 = _N2_2,
_N2_3 , N2_3 = _N2_3, _NE2_3 = _N2_3, NE2_3 = _N2_3,
_N2_4 , N2_4 = _N2_4, _NE2_4 = _N2_4, NE2_4 = _N2_4,
_N2_5 , N2_5 = _N2_5, _NE2_5 = _N2_5, NE2_5 = _N2_5
};
The naming convention is based on the FE periodic table. Note that there is an equivalence between NF1_k and RT_k (Raviart Thomas), NF2_k BDM_k (Brezzi Douglas Marini), N1_k and NE1_k and, N2_k and NE2_k.
Hint
NedelecEdgeTetrahedron
and NedelecFaceTetrahedron
classes use a general process to build shape functions as polynomials related to moment DoFs. To match DoFs on shared edge or shared face, the ascending numbering of vertices is implicitly used even if it is not in fact. This method is particular touchy in case of face DoFs of Nedelec Edge element. Indeed, such DoFs depend on the choice of two tangent vectors, generally two edges of faces of the reference tetrahedron that are mapped to some edges of physical element in a non-trivial way. To ensure a correct matching of such DoFs on a shared face, a rotation has to be applied to shape values to guarantee that they correspond to the same tangent vectors. This is the role of the member function NedelecEdgeFirstTetrahedronPk::rotateDofs
.
Note that if the element vertex numbering and face vertex numbering are ascending, rotateDofs does nothing. This trick is commonly used to overcome this difficulty but as XLiFE++ makes no assumption on geometry, this DoFs rotation is mandatory.
More details on edge/face elements are provided in a specific paper.
Child classes for hexahedron#
Child classes for prism#
Child classes for pyramid#
Examples of elements#
Examples of triangles#
|
|
|
|
|
|
Examples of quadrangles#
|
|
|
|
|
|
Examples of tetrahedra#
|
|
|
|
Examples of hexahedra#
|
|
|
Examples of prisms#
|
|
Examples of pyramids#
|
|
Internal classes#
The Interpolation
class#
The purpose of the Interpolation
class is to store data related to finite element
interpolation. It concerns only general description of an interpolation: type of the finite
element interpolation (Lagrange, Hermite, …), a subtype among standard, Gauss-Lobatto (only
for Lagrange) and first or second family (only for Nedelec), the “order” of the interpolation
for Lagrange family and the space conformity (L2, H1, Hdiv, …). For instance, a Lagrange standard
P1 with H1 conforming is the classic P1 Lagrange interpolation but a Lagrange standard P1 with
L2 conforming means a discontinuous interpolation (like Galerkin discontinuous approximation)
where the vertices of an element are not shared. For the moment, this class is only intended
to support the following choices, that correspond to the _FE_type
, the _FE_subtype
and the _order
keys used in Space
construction:
type |
subtype |
order |
---|---|---|
Lagrange |
standard, Gauss-Lobatto |
any order |
Hermite |
standard |
|
Morley |
standard |
order 2 |
Argyris |
standard |
order 5 |
Crouzet-Raviart |
standard |
order 1 |
Raviart-Thomas |
standard |
any order |
Nedelec |
first or second family |
any order |
Nedelec face |
first or second family |
any order |
Nedelec edge |
first or second family |
any order |
Hint
Nedelec face and Nedelec edge are specific to 3D. Nedelec face corresponds to the 2D Raviart-Thomas family and Nedelec edge corresponds to the 2D Nedelec family.
Hint
The Interpolation
class is intended to support a lot of finite element family, but all are not available. See child classes of RefElement
class to know which families are actually available.
The class Interpolation
has the following attributes:
class Interpolation
{
public:
const FEType type; // interpolation type
const FESubType subtype; // interpolation subtype
const Number numtype; // additional number type (degree for Lagrange)
SobolevType conformSpace; // conforming space
String name; // name of the interpolation type
String subname; // interpolation sub_name
String shortname; // short name (see build)
};
FEType
, FESubType
and SpaceType
are enumerations defined in the
config.hpp file as follows:
enum SobolevType{L2=0,H1,Hdiv,Hcurl,Hrot=Hcurl,H2,Hinf};
enum FEType {Lagrange,Hermite,CrouzeixRaviart,Nedelec,RaviartThomas,NedelecFace, NedelecEdge,_Morley,_Argyris};
enum FESubType {standard=0,gaussLobatto,firstFamily,secondFamily};
The RefDof
class#
The RefDof
class is a class representing a generalized degree of freedom in a reference element.
It is defined by:
A support that can be a point, a side, a side of side or the whole element. When it is a point, we also have its coordinates.
A dimension, that means the number of components of shape functions of the DoF.
Projections data (type and direction) when the DoF is a projection DoF. The projection type is 0 for a general projection, 1 for a \(u.n\) DoF, 2 for a \(u\times n\) DoF.
Derivative data (order and direction) when the DoF is a derivative DoF. The order is 0 when the DoF is defined by an ‘integral’ over its support, or \(n\) for a Hermite DoF derivative of order \(n>0\) or a moment DoF of order \(n>0\).
A shareable property: A DoF is shareable when it is shared between adjacent elements according to space conformity. Such a DoF can be shared or not according to interpolation. For example, every DoFs of a Lagrange H1-confirming element on a side is shared, while DoFs in discontinuous interpolation are not.
class RefDof
{
private:
RefElement* refElt_p; // pointer to refElement related to current refdof (0 if none)
bool sharable_; // DoF is shared according to space conformity
DofLocalization where_; // hierarchic localization of DoF
Number supportNum_; // support localization
Number index_; // rank of the DoF in its localization
Dimen supportDim_; // dimension of the DoF geometric support
Number nodeNum_; // node number when a point DoF
Dimen dim_; // number of components of shape functions of DoF
std::vector<Real> coords_; // coordinates of DoF support if supportDim_=0
Number order_; // order of a derivative DoF or a moment DoF
std::vector<Real> derivativeVector_; // direction vector(s) of a derivative
ProjectionType projectionType_; // type of projection
std::vector<Real> projectionVector_; // direction vector(s) of a projection
DiffOpType diffop_; // DoF differential operator (_id,_dx,_dy, ...)
String name_; // DoF-type name for documentation
}
This class proposes mainly a full constructor and accessors to member data.
Hint
For non-nodal DoFs (supportDim_=0
), virtual coordinates are also defined. They are useful when dealing with essential conditions.
Hint
Up to now, derivative vectors are not used, and the normal vector involved in \(n.\nabla\) DoFs is stored in the projection vector.
Geometric data of a reference element#
The GeomRefElement
class#
The GeomRefElement
object carries geometric data of a reference element: type, dimension, number of vertices, sides and side of sides, measure, and coordinates of vertices. Furthermore, to help to find geometric data on sides, it also carries type, vertex numbers of each side on the first hand, and vertex numbers and relative number to parent side of each side of side on the second hand.
class GeomRefElement
{
protected:
ShapeType shapeType_; //element shape
const Dimen dim_; //element dimension
const Number nbVertices_, nbSides_, nbSideOfSides_; //number of vertices, ...
const Real measure_; //length or area or volume
vector<Real> centroid_; //coordinates of centroid
vector<Real> vertices_; //coordinates of vertices
vector<ShapeType> sideShapeTypes_; //shape type of each side
vector<vector<Number> > sideVertexNumbers_;
vector<vector<Number> > sideOfSideVertexNumbers_;
vector<vector<Number> > sideOfSideNumbers_;
public:
static vector<GeomRefElement*> theGeomRefElements; //vector carrying all GeomReferenceElements
};
It offers:
-
few constructors (the default one, a general one with dimension, measure, centroid, and number of vertices, edges and faces and one more specific for each dimension):
GeomRefElement(); //default constructor GeomRefElement(ShapeType, const Dimen d, const Real m, const Real c, const Number v, const Number e, const Number f); //general GeomRefElement(ShapeType, const Real m = 1.0, const Real c = 0.5); //1D GeomRefElement(ShapeType, const Real m, const Real c, const Number v); //2D GeomRefElement(ShapeType, const Real m, const Real c, const Number v, const Number e); //3D
a private copy constructor and a private assign operator,
-
some public access functions to data:
Dimen dim() const; Number nbSides() const; Number nbSideOfSides() const; Real measure() const; vector<Real>::const_iterator centroid() const; vector<Real>::const_iterator vertices() const; vector<ShapeType> sideShapeTypes() const; const std::vector<std::vector<Number> >& sideVertexNumbers() const; const std::vector<std::vector<Number> >& sideOfSideVertexNumbers() const;
-
some public methods to get data on sides and side of sides:
String shape(const Number sideNum = 0) const; //element (side) shape as a string ShapeType shapeType(const Number sideNum = 0) const; /element (side) shape as a ShapeType bool isSimplex() const; //true if a simplex Number nbVertices(const Number sideNum = 0) const; //number of element (side) vertices Number sideVertex(const Number id, const Number sideNum = 0) const;//number of element (side) std::vector<Real>::const_iterator vertex(const Number vNum) const; //coordinates of n-th vertex Number sideVertexNumber(const Number vNum, const Number sideNum) const; Number sideOfSideVertexNumber(const Number vNum, const Number sideOfSideNum) const; Number sideOfSideNumber(const Number i, const Number sideNum) const; //local number of i-th edge void rotateVertices(const Number newFirst,vector<Number>&) const;// circular permutation vector<Real> sideToElt(Number,vector<Real>::const_iterator) const; virtual Real measure(const Dimen dim, const Number sideNum = 0) const = 0; // projection of a point onto ref element virtual std::vector<Real> projection(const vector<Real>&, Real&) const; // test if a point belongs to current element virtual bool contains(std::vector<Real>& p, Real tol= theTolerance) const;
-
some protected append methods for vertices:
//build vertex 1d/2d/3d coordinates void vertex(vector<Real>::iterator& it, const Real x1); void vertex(vector<Real>::iterator& it, const Real x1, const Real x2); void vertex(vector<Real>::iterator& it, const Real x1, const Real x2, const Real x3);
-
some public error handlers:
void noSuchSideOfSide(const Number) const; void noSuchSide(const Number) const; void noSuchSide(const Number, const Number, const Number = 0, const Number = 0) const; void noSuchFunction(const String& s) const;
-
an external search function in the static run-time list of
GeomRefElement
:GeomRefElement* findGeomRefElement(ShapeType);
Child classes of GeomRefElement
#
The child classes of GeomRefElement
are GeomRefSegment
in 1D, GeomRefTriangle
and GeomRefQuadrangle
in 2D and GeomRefHexahedron
, GeomRefTetrahedron
, GeomRefPrism
and GeomRefPyramid
in 3D.
Except implementation of virtual functions, these child classes provide 2 new member functions used in class constructors:
void sideNumbering(); //local numbers of vertices on sides
void sideOfSideNumbering(); //local numbers of vertices on side of sides
The last one is not defined for GeomRefSegment
.
Reference elements#
The ShapeValues
class#
A ShapeValues
object stores the evaluation of a shape function at a given point. Thus, it carries 2 real vectors of:
class ShapeValues
{
public:
vector<Real> w; //shape functions at a point
vector<vector<Real>> dw; //first derivatives (dx,dy,[dz])
vector<vector<Real>> d2w;//2nd derivatives (dxx,dyy,dxy,[dzz,dxz, dyz])
...
};
It offers:
-
basic constructors:
ShapeValues(); //!< default constructor ShapeValues(const ShapeValues&); //copy constructor ShapeValues& operator=(const ShapeValues&); // assignment operator= ShapeValues(const RefElement&); //constructor with associated RefElement ShapeValues(const RefElement&, const Dimen); //constructor with associated RefElement
-
two public size accessors and empty query:
Dimen dim() const; Number nbDofs() const; bool isEmpty() const;
-
some functions addressing the data:
void resize(const RefElement&, const Dimen); // resize void set(const Real); // set shape functions to const value void assign(const ShapeValues&); // fast assign of shapevalues into current
-
some mapping functions
void extendToVector(Dimen d); //extend scalar shape function to vector void map(const ShapeValues&, const GeomMapData&, bool der1, bool der2); //standard mapping void contravariantPiolaMap(const ShapeValues&, const GeomMapData&, bool der1, bool der2); void covariantPiolaMap(const ShapeValues&, const GeomMapData&, bool der1, bool der2); void Morley2dMap(const ShapeValues&, const GeomMapData&, bool der1, bool der2); void Argyris2dMap(const ShapeValues& rsv, const GeomMapData& gd, bool der1, bool der2); void changeSign(const std::vector<Real>&, Dimen); //change sign of shape functions according to a sign vector
The contravariant and covariant Piola maps are respectively used for Hdiv and Hcurl finite element families. They preserve respectively the normal and tangential traces. If \(J\) denotes the jacobian of the mapping from the reference element to any element, the covariant map is \(J^{-t}\mathbf{\hat{u}}\) and the contravariant map \(J/|J|\mathbf{\hat{u}}\) where \(\mathbf{\hat{u}}\) is a vector field in the reference space. The Morley and Argyris map are specific to these elements, they preserve first and second derivatives involved in such elements.
The RefElement
class#
The RefElement
is the main class of the finiteElement library. First, it has an object of each type previously seen in this chapter, namely Interpolation
, GeomRefElement
, ShapeValues
and RefDof
. Next, It is the mother class of the wide range of true reference elements, identified by shape and interpolation type.
That is why it is a complex class collecting a lot of information and providing many numbering functions such as the number of DoFs, the same number on vertices, on sides, on side of sides, …
To define completely a reference element, we also need data on sides and on side of sides, such as DoF numbers and reference elements. Side and side of side reference elements will be built only when they are needed, equivalent to say only they have meaning. It is the case for H1 finite elements, but not for Hcurl and Hdiv finite elements.
So, the RefElement
attributes are:
class RefElement
{
public:
GeomRefElement* geomRefElem_p; //pointer to geometric reference element
const Interpolation* interpolation_p; //interpolation parameters
vector<RefDof*> refDofs; //local reference Degrees of Freedom
FEMapType mapType; //type of map applied to shape functions of reference element
DofCompatibility DoFCompatibility;//compatibility rule to applied to side DoFs
Dimen dimShapeFunction; //dimension of shape function
bool rotateDof; //if true, apply rotation (given by children) to shape values
Number maxDegree; //maximum degree of shape functions
protected:
String name_; //reference element name (for documentation)
Number nbDofs_; //number of Degrees Of Freedom
Number nbPts_; //number of Points (for local coordinates of points)
Number nbDofsOnVertices_; //nb of sharable DoF on vertices (first DoF)
Number nbDofsInSideOfSides_;//nb of sharable DoF on side of sides (edges)
Number nbDofsInSides_; //nb of sharable DoF on sides (faces or edges)
Number nbInternalDofs_; //nb of non-sharable DoF's
vector<RefElement*> sideRefElems_; //pointers to side reference elements
vector<RefElement*> sideOfSideRefElems_; //pointers to side of side reference elements
public:
vector<vector<Number>> sideDofNumbers_; //DoF numbers for each side
vector<vector<Number>> sideOfSideDofNumbers_; //DoF numbers for each side of side
PolynomialsBasis Wk; //shape functions basis as polynomials
vector<PolynomialsBasis> dWk; //derivatives of shape functions basis as polynomials
bool hasShapeValues; //ref element has shapevalues, generally true
map<Quadrature*,vector<ShapeValues>> qshvs_; //temporary structure to store shape values
map<Quadrature*,vector<ShapeValues>> qshvs_aux;//other temporary structure to store shape values
static vector<RefElement*> theRefElements; //to store run-time RefElement pointers
static const bool isSharable_ = true;
};
The following enumeration collects the types of affine mapping from reference element to any element. It depends on finite element type:
enum FEMapType {_standardMap,_contravariantPiolaMap,_covariantPiolaMap,_MorleyMap,_ArgyrisMap};
It offers:
-
Some constructors, the default one and a constructor by shape type and interpolation:
RefElement(); //default constructor RefElement(ShapeType, const Interpolation* ); //constructor by shape & interpolation
Note that the copy constructor and the assignment operator are private.
-
Some public accessors:
const Interpolation& interpolation() const; String name() const; Number nbPts() const; Number nbDofsOnVertices() const; //nb of DoF supported by vertices Number nbDofsInSides() const; //nb of DoF strictly supported by side Number nbDofsInSideOfSides() const; //nb of DoF strictly supported by side of side bool isSimplex() const ; //true if shape is a simplex Dimen dim() const; //element dimension const RefElement* refElement(Number sideNum = 0) const; //reference element of side const GeomRefElement* geomRefElement(Number sideNum = 0) const; //GeomRefElement of side Number nbDofs(const Number sideNum = 0, const Dimen sideDim = 0) const;//number of DoF by side Number nbInternalDofs(const Number sideNum = 0, const Dimen sideDim = 0) const; ShapeType shapeType() const; //shape of element
-
Some build functions of side and side of side reference elements:
void sideOfSideRefElement(); //reference element constructors on element edges void sideRefElement(); //reference element constructors on element faces
-
Some functions related to shape function computation
void buildPolynomialTree(); //build tree representation of polynomial shape functions Number shapeValueSize() const; virtual void computeShapeFunctions() //compute shape functions virtual void computeShapeValues(vector<Real>::const_iterator it_pt, bool der1 = true, bool der2=false) const = 0; //compute shape functions at point
Shape function of high order element are boring to find. So, XLiFE++ provides tools to get them in a formal way, using
Polynomials
class. The virtual functioncomputeShapeFunctions()
computes them and thebuildPolynomialTree()
function builds a tree representation of the formal representation of shape functions, in order to make faster their computations. -
Some virtual functions to guarantee correct matching of DoFs:
virtual vector<Number> DoFsMap(const Number& i, const Number& j, const Number& k=0) const; virtual Number sideDofsMap(const Number& n, const Number& i, const Number& j, const number_ & k=0) const; virtual Number sideofsideDofsMap(const Number& n, const Number& i, const Number& j=0)const; Number sideOf(Number) const; //side number of a DoF Number sideOfSideOf(Number) const; //return side of side number of a DoF
-
Some general build functions for DoFs:
void LagrangeRefDofs(const int, const int, const int, const Dimen);
As the inheritance diagram is based on shape, these functions specify the interpolation type
-
For output purpose, a
RefElement
may be split in first order elements, either simplices or of same shape, at every order:virtual vector<vector<Number>> splitP1() const; virtual vector<pair<ShapeType,vector<Number>>> splitO1() const;
-
Some external functions to find a reference element in the static list of
RefElement
and create it if not found:RefElement* findRefElement(ShapeType, const Interpolation*); RefElement* selectRefSegment(const Interpolation*); RefElement* selectRefTriangle(const Interpolation*); RefElement* selectRefQuadrangle(const Interpolation*); RefElement* selectRefTetrahedron(const Interpolation*); RefElement* selectRefPrism(const Interpolation*); RefElement* selectRefHexahedron(const Interpolation*); RefElement* selectRefPyramid(const Interpolation*);