![]() |
LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
|
Meshes in LehrFEM++ are generally managed through shared pointers. A simple test mesh can be generated using the following code snippet:
The mesh object can be accessed through the pointer mesh_p
(will be used throughout this page). The mesh object provides access to the following information:
Entities implement the lf::mesh::Entity interface and are the building blocks of a mesh. LehrFEM++ provides a number of different types of entities:
A complete list can be found in the inheritance diagram of the lf::mesh::Entity interface class. Entities can be accessed by index or by iterating over all entities of a given co-dimension.
Entities have a number of properties that can be accessed:
It is also possible to access sub-entities of an entity, see lf::mesh::Entity::SubEntities for details.
A slightly more nuanced concept is the relative orientation of sub-entities of the next higher co-dimension. A detailed explanation can be found in the Lecture Document Remark 2.7.2.15.
Mesh data sets are used to store data with entities of the mesh. A fe common use cases are:
In this example, a mesh data set is created that stores boolean values for each entity/edge of the mesh.
To flag all entities on the boundary of the mesh, the following code snippet can be used:
See also Quick Reference - Boundary Conditions for more details on boundary conditions.
The interface is defined in the lf::mesh::MeshDataSet class. More details can be found in the documentation of the lf::mesh::MeshDataSet class.
Mesh functions are wrappers around a functor that can be evaluated on the entire mesh. The interface is defined in lf::mesh::utils::MeshFunction. A more detailed definition can be found in the Lecture Document supplement 2.8.3.32.
The most general representative of a mesh function is lf::mesh::utils::MeshFunctionGlobal. It takes a functor that can be evaluated on the entire mesh. The functor must provide an operator() which takes a point within the entity reference Element and returns a value. Lambda functions are a common way to define such functors.
For efficiency reasons the evaluation points are passed to mesh functions as the columns of a \(d \times n \) - matrix (where \(d\) agrees with the local dimension of the entity and \(n\) is the number of points). This allows for the evaluation of multiple points at once. The following code snippet demonstrates how to define a mesh function that evaluates the function
\[ \alpha(x) = 0.5 \cdot \|x\| \]
on a cell.
There are is also a short-hand for mesh functions that are constant everywhere on the mesh: lf::mesh::utils::MeshFunctionConstant.
MeshFunction objects support binary arithmetic operations +,-, and *, including scalar multiplication, provided that such operations are possible for their underlying types. As well as unary operations such as -, transpose(), and squaredNorm().
A special case of mesh functions are finite element mesh functions. They are used to represent the solution of a finite element problem on a mesh.
The standard ways to create a Mesh object are:
LehrFEM++ provides a number of mesh refinement tools included in the lf::refinement namespace.
Mesh refinement using LehrFEM++ is covered in Lecture Document Subsection 3.1.4 and heavily used in Lecture Document Chapter 3.
Meshes can be built 'manually' using the lf::mesh::MeshFactory class. It follows a builder pattern and allows the user to add entities to the mesh.
We can also use the mesh builder to create a tensor product mesh. LehrFEM++ provides a number of mesh builders for different types of meshes.
The following code snippet demonstrates how to create a 100x100 tensor product mesh of triangles: