NAME
ElmMatVec - element matrix and vector for FEM programming
INCLUDE
include "ElmMatVec.h"
SYNTAX
class ElmMatVec
{
public:
int elm_no; // element number
int nedof; // no of element degrees of freedom (unknowns)
int neeqs; // no of element equations
Handle(DegFreeFE) dof; // info on boundary conditions and loc2glob mapping
private:
void modify (int i, NUMT v); // called by enforceEssBC
public:
ElmMatVec ();
void attach (DegFreeFE& dof);
void detach () { dof.detach(); }
ElmMatVec (DegFreeFE& dof);
~ElmMatVec ();
bool refill (int elm_no); // redim A and b, compute new loc2glob
void fill (const ElmMatVec& elmat); // fill in A and b values from elmat
DegFreeFE& getDegFreeFE () { return dof(); }
Mat(NUMT) A; // element matrix
Vec(NUMT) b; // element column vector
VecSimple(int) loc2glob_u; // local-global dof mapping for unknowns
VecSimple(int) loc2glob_e; // local-global mapping for equations
Vec(NUMT) b_mod; // optional vec for rhs modification
int getNoDofInElm () const { return nedof; }
void enforceEssBC ();
bool ok () const;
void print (Os os, int help = 1) const;
// default/dummy functions:
COPY_CONSTRUCTOR(ElmMatVec);
ASSIGNMENT_OPERATOR(ElmMatVec);
};
KEYWORDS
element matrix, element vector, finite elements
DESCRIPTION
The class represents the element matrix and vector that are fre
quently used when programming finite element methods. In addi
tion, the class has data for the mapping between local and global
degrees of freedom and data for the boundary conditions.
The contents of the class are used when assembling the element
level contributions in a finite element algorithm. The class also
implements the essential boundary conditions at nodes in the ele
ment. The computation of the data in the class is performed by
the refill function for initialization, then the programmer fills
the element matrix and vector with contents, for example, in a
numerical integration loop over the element. When using class FEM
algorithms, one usually adds the contribution from the current
integration point to the ElmMatVec object in an integrands rou
tine. Alternatively, the programmer can fill the ElmMatVec object
in calcElmMatVec using explicit analytical expressions for the
element contributions.
It is a requirement that the element matrix is a square matrix.
That is, in mixed finite element methods one should compute a
square element matrix containing all contributions to system of
equations from the element. Partitioning into different global
matrices should be carried out elsewhere (LinEqMatrix or
LinEqAdmFE). This restriction is likely to be relaxed in the
future when Diffpack will support mixed finite element methods.
The row number of the element matrix reflects the weighting func
tion number, or more precisely, the discrete equation number,
while the column number reflect the primary unknown number.
NOTE: Some comments in the documentation of this class refer to
mixed finite element methods. Support for such methods is only to
a very limited extent provided by the present version of the
class.
CONSTRUCTORS AND INITIALIZATION
There are two ways of creating a class instance: 1) use the con
structor without arguments and then attach a DegFreeFE object
keeping track of the grid, element and linear system degrees of
freedom, or 2) use the constructor that takes the DegFreeFE
object as argument. Note that for each element, one must take a
refill call in order to initialize the ElmMatVec object for that
particular element. The refill function will size A and b cor
rectly, set these to zero (which is required if they are used
inside a numerical integration loop), and compute the local-
global degrees of freedom mapping (loc2glob array).
One can easily make a VecSimplest(ElmMatVec) object for storing
all the element matrices and vectors in a finite element problem.
However, one should be aware of the efficiency loss of such a
structure since each element matrix and vector must be allocated
separately and will hence be spread out in memory. For high effi
ciency one should store all the element matrices and vectors in
pure arrays that occupy a continuous memory segment. The Diff
pack application ADRnl demonstrates various approaches.
MEMBER FUNCTIONS
The data members A and b represent the element matrix and vector,
respectively.
The loc2glob_e array is used for mapping the local equation num
bers to the global equation numbers, and the loc2glob_u array are
used for mapping the local unknowns to the global unknowns. In
most cases, these two mapping arrays will be identical, but there
are situations when programming mixed finite element methods
where the two arrays differ and the stiffness matrices may be
rectangular (at least the separately assembled blocks in a global
stiffness matrix on block form).
getNoDofInElm - returns the number of degrees of freedom for this
element. The number equals the number of rows in the element
matrix and vector.
enforceEssBC - enforces essential boundary conditions. If the
system of linear equations, corresponding to a ElmMatVec object,
has an unknown which is a correction vector, special care must be
taken. This is the case when e.g. Newton's method are used for
solving systems of nonlinear equations. In each linear problem it
is assumed that the total solution has its boundary conditions
inserted and that the correction vector must have zeroes for all
entries where the value is known. That is, in the modification of
A and b one must set the essential condition to be zero. The
ElmMatVec::enforceEssBC function calls the zeroInterpreta
tionOfEssBC of DegFreeFE for determining whether the user has
indicated to the DegFreeFE object that all non-zero essential
boundary condition values are to be interpreted as if they were
zero. When Newton-Raphson's method is used, it is important that
the programmer calls the fillEssBC2zero function of the DegFreeFE
class object prior to any enforceEssBC.
enforceConstraints - enforce conditions on constrained nodes. The
use of a dynamic grid will cause some nodes to be constrained.
DEVELOPED BY
SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway
AUTHOR
Hans Petter Langtangen, SINTEF/UiO, optimizations by Klas
Samuelsson