LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Functions
Cell-Oriented Assembly of R.h.s. Galerkin

Detailed Description

Functions assembleVectorLocally() for setting entries of the vector representing the finite element Galerkin discretization of a linear functional.

Vectors

The functions differ in their arguments, but all are templated with the following types:

Also refer to Lecture Document Example 2.7.4.27 and Lecture Document Example 2.7.4.35.

Functions

template<typename VECTOR , class ENTITY_VECTOR_PROVIDER >
void lf::assemble::AssembleVectorLocally (dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)
 entity-local assembly of (right-hand-side) vectors from element vectors More...
 
template<typename VECTOR , class ENTITY_VECTOR_PROVIDER >
VECTOR lf::assemble::AssembleVectorLocally (dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider)
 entity-local assembly of (right-hand-side) vectors from element vectors More...
 

Function Documentation

◆ AssembleVectorLocally() [1/2]

template<typename VECTOR , class ENTITY_VECTOR_PROVIDER >
VECTOR lf::assemble::AssembleVectorLocally ( dim_t  codim,
const DofHandler dof_handler,
ENTITY_VECTOR_PROVIDER &  entity_vector_provider 
)

entity-local assembly of (right-hand-side) vectors from element vectors

Template Parameters
VECTORa generic vector type with component access through []
ENTITY_VECTOR_PROVIDERtype for objects computing entity-local vectors, models concept EntityVectorProvider
Returns
assembled vector as an object of a type specified by the VECTOR template argument
See also
AssembleVectorLocally(const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)

Additional type requirements for VECTOR template argument

VECTOR must supply a setZero method for initialization with zero. All matrix types of Eigen have such a method see Eigen documentation

Definition at line 347 of file assembler.h.

References lf::assemble::DofHandler::NumDofs().

◆ AssembleVectorLocally() [2/2]

template<typename VECTOR , class ENTITY_VECTOR_PROVIDER >
void lf::assemble::AssembleVectorLocally ( dim_t  codim,
const DofHandler dof_handler,
ENTITY_VECTOR_PROVIDER &  entity_vector_provider,
VECTOR &  resultvector 
)

entity-local assembly of (right-hand-side) vectors from element vectors

Template Parameters
VECTORa generic vector type with component access through []
ENTITY_VECTOR_PROVIDERtype for objects computing entity-local vectors, models concept EntityVectorProvider
Parameters
codimco-dimension of entities over which assembly should be carried out
dof_handlerobject providing local-to-global dof index mapping, see DofHandler
entity_vector_providerlocal entity_vector_provider object (passed as non-const!)
resultvectorgeneric vector for returning the assembled vector

Type requirements for template arguments

  • VECTOR must provide a size() method telling its length and read/write access through the [] operator.
Note
Contributions of element vectors are added to the entries of the resultvector argument. This means that resultvector has to be initialized before calling this function!

Example Usage

// initialize a 2d mesh somehow
std::shared_ptr<mesh::Mesh> mesh;
// define a EntityVectorProvider which returns the volume for every mesh cell
struct VolumeEntityVectorProvider {
bool isActive(const lf::mesh::Entity& e) const { return e.Codim() == 0; }
Eigen::VectorXd Eval(const lf::mesh::Entity& e) const {
return Eigen::VectorXd::Constant(1, geometry::Volume(*e.Geometry()));
}
} entity_vector_provider;
// define a dof handler which assigns a dof to every mesh cell
assemble::UniformFEDofHandler dofh(
mesh, {{base::RefEl::kTria(), 1}, {base::RefEl::kQuad(), 1}});
// initialize the output vector:
Eigen::VectorXd x(dofh.NumDofs());
// assemble the global vector over entities with codim=0:
AssembleVectorLocally(0, dofh, entity_vector_provider, x);
// now x[dofh.GlobalDofIndices(e)[0]] will contain the volume of mesh cell e
static constexpr RefEl kTria()
Returns the reference triangle.
Definition: ref_el.h:158
static constexpr RefEl kQuad()
Returns the reference quadrilateral.
Definition: ref_el.h:166
Interface class representing a topological entity in a cellular complex
Definition: entity.h:39
virtual unsigned Codim() const =0
The codimension of this entity w.r.t. the Mesh.dimMesh() of the owning mesh manager.
virtual const geometry::Geometry * Geometry() const =0
Describes the geometry of this entity.
void AssembleVectorLocally(dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)
entity-local assembly of (right-hand-side) vectors from element vectors
Definition: assembler.h:297
double Volume(const Geometry &geo)
Compute the (approximate) volume (area) of a shape.

Definition at line 297 of file assembler.h.

References lf::assemble::DofHandler::GlobalDofIndices(), lf::assemble::DofHandler::Mesh(), and lf::assemble::DofHandler::NumLocalDofs().

Referenced by projects::ipdg_stokes::assemble::buildSystemMatrixInOutFlow(), projects::ipdg_stokes::assemble::buildSystemMatrixNoFlow(), projects::hldo_sphere::operators::DiracOperator::Compute(), projects::hldo_sphere::operators::WhitneyOneHodgeLaplace< SCALAR >::Compute(), projects::hldo_sphere::operators::WhitneyTwoHodgeLaplace< SCALAR >::Compute(), and projects::hldo_sphere::operators::WhitneyZeroHodgeLaplace< SCALAR >::Compute().