LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
Classes | Concepts | Typedefs | Functions
lf::mesh::utils Namespace Reference

Contains helper functions and classes that all operate on the interface classes defined in lf::mesh. More...

Classes

class  AllCodimMeshDataSet
 Assigns to every entity(all codims) in a mesh a value of type T More...
 
class  CodimMeshDataSet
 A MeshDataSet that attaches data of type T to every entity of a mesh that has a specified codimension. More...
 
class  MeshDataSet
 Interface that specifies how data is stored with an entity. More...
 
struct  MeshFunctionAT
 Archetype for the MeshFunction concept. More...
 
class  MeshFunctionBinary
 A MeshFunction which combines two other mesh functions using a binary operator (advanced use). More...
 
class  MeshFunctionConstant
 A MeshFunction which takes the same constant value on the whole mesh. More...
 
class  MeshFunctionGlobal
 MeshFunction wrapper for a simple function of physical coordinates. More...
 
class  MeshFunctionUnary
 A mesh function representing another mesh function under a pointwise, unary operation. More...
 
class  StructuredMeshBuilder
 
class  TorusMeshBuilder
 Implements a MeshBuilder for a tensor product grid of a torus. More...
 
class  TPQuadMeshBuilder
 Implements a Builder for a tensor product grid (with rectangular cells) More...
 
class  TPTriagMeshBuilder
 Implements a MeshBuilder that generates a triangular structured mesh. More...
 

Concepts

concept  MeshFunction
 A MeshFunction is a function object that can be evaluated at any point on the mesh.
 

Typedefs

template<class R >
using MeshFunctionReturnType
 Determine the type of objects returned by a MeshFunction.
 

Functions

template<class T >
std::shared_ptr< AllCodimMeshDataSet< T > > make_AllCodimMeshDataSet (const std::shared_ptr< const lf::mesh::Mesh > &mesh)
 Create a new AllCodimMeshDataSet and Default initialize the data.
 
template<std::copy_constructible T>
std::shared_ptr< AllCodimMeshDataSet< T > > make_AllCodimMeshDataSet (const std::shared_ptr< const lf::mesh::Mesh > &mesh, T init_value)
 Create a new AllCodimMeshDataSet and initialize the data of every entity with the given value (T must be copyable!)
 
template<class T >
std::shared_ptr< CodimMeshDataSet< T > > make_CodimMeshDataSet (const std::shared_ptr< const lf::mesh::Mesh > &mesh, base::dim_t codim)
 Create a new CodimMeshDataSet that attaches data of type T with every entity with codimension codim. The data is Default initialized
 
template<std::copy_constructible T>
std::shared_ptr< CodimMeshDataSet< T > > make_CodimMeshDataSet (const std::shared_ptr< const Mesh > &mesh, base::dim_t codim, T init)
 Create a new CodimMeshDataSet that attaches data of type T with every entity with codimension codim. The data of every entity is initialized to the given value (T must be copyable!)
 
template<MeshFunction A, MeshFunction B>
auto operator+ (const A &a, const B &b) -> MeshFunctionBinary< internal::OperatorAddition, A, B >
 Add's two mesh functions.
 
template<MeshFunction A, MeshFunction B>
auto operator- (const A &a, const B &b) -> MeshFunctionBinary< internal::OperatorSubtraction, A, B >
 Subtracts two mesh functions.
 
template<MeshFunction A, MeshFunction B>
auto operator* (const A &a, const B &b) -> MeshFunctionBinary< internal::OperatorMultiplication, A, B >
 Multiply two mesh functions with each other.
 
void PrintInfo (std::ostream &o, const lf::mesh::Mesh &mesh, int ctrl)
 
void PrintInfo (std::ostream &stream, const lf::mesh::Entity &e, int output_ctrl)
 
CodimMeshDataSet< lf::base::size_typeCountNumSuperEntities (const std::shared_ptr< const Mesh > &mesh_p, lf::base::dim_t codim_sub, lf::base::dim_t codim_super)
 store number of adjacent super-entities
 
CodimMeshDataSet< bool > flagEntitiesOnBoundary (const std::shared_ptr< const Mesh > &mesh_p, lf::base::dim_t codim)
 flag entities of a specific co-dimension located on the boundary
 
AllCodimMeshDataSet< bool > flagEntitiesOnBoundary (const std::shared_ptr< const Mesh > &mesh_p)
 flag entities of any co-dimension located on the boundary
 

Detailed Description

Contains helper functions and classes that all operate on the interface classes defined in lf::mesh.

Typedef Documentation

◆ MeshFunctionReturnType

template<class R >
using lf::mesh::utils::MeshFunctionReturnType
Initial value:
internal::VectorElement_t<internal::MeshFunctionReturnType_t<R>>

Determine the type of objects returned by a MeshFunction.

Template Parameters
RThe type of the mesh function (as defined in MeshFunction).

Definition at line 202 of file mesh_function_traits.h.

Function Documentation

◆ CountNumSuperEntities()

CodimMeshDataSet< lf::base::size_type > lf::mesh::utils::CountNumSuperEntities ( const std::shared_ptr< const Mesh > & mesh_p,
lf::base::dim_t codim_sub,
lf::base::dim_t codim_super )

store number of adjacent super-entities

Parameters
mesh_preference to underlying mesh
codim_subco-dimension of the queried entities
codim_superrelative co-dimension (with positive sign) of super entities.
Returns
a cardinal-valued CodimMeshDataSet (= an array of cardinals indexed by entities of a particular co-dimension) storing adjacency numbers

For each entity of a given co-dimension, this function counts the number of adjacent super-entities of some smaller co-dimension.

Example

If, for a 2D mesh we want to count the number of cells adjacent to edges, we have to specify codim_sub = 1, codim_super = 1!

If, for a 2D mesh you want to count the number of cells owning a node, specify codim_sub = 2 and codim_super = 2!

Note
codim_super is relative to codim_sub with flipped sign!

Definition at line 18 of file special_entity_sets.cc.

Referenced by flagEntitiesOnBoundary(), and flagEntitiesOnBoundary().

◆ flagEntitiesOnBoundary() [1/2]

AllCodimMeshDataSet< bool > lf::mesh::utils::flagEntitiesOnBoundary ( const std::shared_ptr< const Mesh > & mesh_p)

flag entities of any co-dimension located on the boundary

Parameters
mesh_pshared pointer to the mesh whose boudnary entities should be flagged.
Returns
an AllCodimMeshDataSet<bool> which flags entities of any co-dimension on the boundary.
See also
flagEntitiesOnBoundary(const std::shared_ptr<const Mesh>& mesh_p, lf::base::dim_t codim)

Definition at line 64 of file special_entity_sets.cc.

References CountNumSuperEntities().

◆ flagEntitiesOnBoundary() [2/2]

CodimMeshDataSet< bool > lf::mesh::utils::flagEntitiesOnBoundary ( const std::shared_ptr< const Mesh > & mesh_p,
lf::base::dim_t codim )

flag entities of a specific co-dimension located on the boundary

Parameters
mesh_pshared pointer to the mesh whose boudnary entities should be flagged.
codimco-dimension of entities to be flagged, must be > 0.
Returns
an object of a boolean-valued CodimMeshDataSet (= an array of boolean values index by entities) for the entities of the specified co-dimension

An entity of co-dimension 1 is located on the boundary, if it is adjacent to exactly 1 cell (= entity of co-dimension 0).

The boundary of a mesh is the set of all entities that are either entities of co-dimension 1 located on the boundary or sub-entities of those.

The implementation of this function relies on CountNumSuperEntities().

The following example code shows how to create a flag array for marking the boundary edges of a 2D mesh:

std::shared_ptr<lf::mesh::Mesh> mesh_p{
A MeshDataSet that attaches data of type T to every entity of a mesh that has a specified codimension...
std::shared_ptr< lf::mesh::Mesh > GenerateHybrid2DTestMesh(int selector, double scale)
Generates a simple 2D hybrid test mesh.
CodimMeshDataSet< bool > flagEntitiesOnBoundary(const std::shared_ptr< const Mesh > &mesh_p, lf::base::dim_t codim)
flag entities of a specific co-dimension located on the boundary

Definition at line 40 of file special_entity_sets.cc.

References CountNumSuperEntities().

◆ make_AllCodimMeshDataSet() [1/2]

template<class T >
std::shared_ptr< AllCodimMeshDataSet< T > > lf::mesh::utils::make_AllCodimMeshDataSet ( const std::shared_ptr< const lf::mesh::Mesh > & mesh)

Create a new AllCodimMeshDataSet and Default initialize the data.

Parameters
meshThe mesh that contains the entities.

Definition at line 119 of file all_codim_mesh_data_set.h.

◆ make_AllCodimMeshDataSet() [2/2]

template<std::copy_constructible T>
std::shared_ptr< AllCodimMeshDataSet< T > > lf::mesh::utils::make_AllCodimMeshDataSet ( const std::shared_ptr< const lf::mesh::Mesh > & mesh,
T init_value )

Create a new AllCodimMeshDataSet and initialize the data of every entity with the given value (T must be copyable!)

Parameters
meshThe mesh that contains the entities.
init_valueThe initial value that should be assigned to every entity.

Definition at line 134 of file all_codim_mesh_data_set.h.

◆ make_CodimMeshDataSet() [1/2]

template<class T >
std::shared_ptr< CodimMeshDataSet< T > > lf::mesh::utils::make_CodimMeshDataSet ( const std::shared_ptr< const lf::mesh::Mesh > & mesh,
base::dim_t codim )

Create a new CodimMeshDataSet that attaches data of type T with every entity with codimension codim. The data is Default initialized

Parameters
meshThe mesh that contains the entities.
codimThe codimension of the entities whith which the data is stored.

Definition at line 91 of file codim_mesh_data_set.h.

◆ make_CodimMeshDataSet() [2/2]

template<std::copy_constructible T>
std::shared_ptr< CodimMeshDataSet< T > > lf::mesh::utils::make_CodimMeshDataSet ( const std::shared_ptr< const Mesh > & mesh,
base::dim_t codim,
T init )

Create a new CodimMeshDataSet that attaches data of type T with every entity with codimension codim. The data of every entity is initialized to the given value (T must be copyable!)

Parameters
meshThe mesh that contains the entities.
codimThe codimension of the entities with which the data is stored.
initThe initial value that should be assigned to every entity.

Definition at line 106 of file codim_mesh_data_set.h.

◆ operator*()

template<MeshFunction A, MeshFunction B>
auto operator* ( const A & a,
const B & b ) -> MeshFunctionBinary<internal::OperatorMultiplication, A, B>

Multiply two mesh functions with each other.

Template Parameters
AThe type of the lhs MeshFunction
BThe type of the rhs MeshFunction
Parameters
athe lhs MeshFunction
bthe rhs MeshFunction
Returns
Return a*b, i.e. a new mesh function which represents the pointwise product of a and b.
Note
if A and B are Eigen::Matrix valued, the resulting MeshFunction will also be Matrix/Vector valued and will represent the Matrix product of a and b.
If you want to apply this operator overload to meshfunctions" which do not reside in the lf::uscalfe namespace, it will not be found by Argument Dependent Lookup (ADL). You can get around this by explicitly importing the operator overload: using lf::uscalfe::operator*;

Example

auto mesh_factory = std::make_unique<mesh::hybrid2d::MeshFactory>(2);
auto gmsh_reader = io::GmshReader(std::move(mesh_factory), "mesh.msh");
// a mesh function which takes the value 1 everywhere
auto mf_one = mesh::utils::MeshFunctionConstant(1.);
// a mesh function which represents the radial vector field (x,y)
auto mf_radial = mesh::utils::MeshFunctionGlobal(
[](const Eigen::Vector2d& x) { return x; });
// a matrix valued mesh function ((x,y),(x^2,y^2))
auto mf_matrix =
mesh::utils::MeshFunctionGlobal([](const Eigen::Vector2d& x) {
return (Eigen::Matrix2d() << x[0], x[1], x[0] * x[0], x[1] * x[1])
.finished();
});
// product of two scalar valued mesh functions:
auto p0 = mf_one * mesh::utils::MeshFunctionConstant(3.);
// product of a scalar valued mesh function with a matrix valued one:
auto p1 = mf_one * mf_matrix;
// product of matrix valued with a vector valued mesh function:
auto p2 = mf_matrix * mf_radial; // will be vector valued
// product of a matrix valued mesh function with itself:
auto p3 = mf_matrix * mf_matrix;

Definition at line 722 of file mesh_function_binary.h.

◆ operator+()

template<MeshFunction A, MeshFunction B>
auto operator+ ( const A & a,
const B & b ) -> MeshFunctionBinary<internal::OperatorAddition, A, B>

Add's two mesh functions.

Template Parameters
AType of the lhs MeshFunction
BType of the rhs MeshFunction
Parameters
athe lhs MeshFunction
bthe rhs MeshFunction
Returns
a + b, i.e. a new mesh function which represents the pointwise addition of a and b
Note
the two mesh functions a and b should produce the same type of values, e.g. both should be scalar valued or both matrix/vector/array valued.
If you want to apply this operator overload to meshfunctions" which do not reside in the lf::uscalfe namespace, it will not be found by Argument Dependent Lookup. You can get around this by explictly importing the operator overload: using lf::uscalfe::operator+;

Example

auto mesh_factory = std::make_unique<mesh::hybrid2d::MeshFactory>(2);
auto gmsh_reader = io::GmshReader(std::move(mesh_factory), "mesh.msh");
// a mesh function that takes the value 1 everywhere
auto mf_one = mesh::utils::MeshFunctionConstant(1.);
// a mesh function which represents the function `sin(x)*cos(y)` (x,y are
// global coordinates)
auto mf_trig = mesh::utils::MeshFunctionGlobal(
[](const Eigen::Vector2d& x) { return std::sin(x[0]) * std::cos(x[1]); });
// mesh function `1+sin(x)*cos(y)`
auto mf_one_trig = mf_one + mf_trig;

Definition at line 664 of file mesh_function_binary.h.

◆ operator-()

template<MeshFunction A, MeshFunction B>
auto operator- ( const A & a,
const B & b ) -> MeshFunctionBinary<internal::OperatorSubtraction, A, B>

Subtracts two mesh functions.

Template Parameters
AType of the lhs MeshFunction
BType of the rhs MeshFunction
Parameters
athe lhs MeshFunction
bthe rhs MeshFunction
Returns
a - b, i.e. a new mesh function which represents the pointwise difference of a minus b
Note
the two mesh functions a and b should produce the same type of values, e.g. both should be scalar valued or both matrix/vector valued.
If you want to apply this operator overload to meshfunctions" which do not reside in the lf::uscalfe namespace, it will not be found by Argument Dependent Lookup (ADL). You can get around this by explicitly importing the operator overload: using lf::uscalfe::operator-;

Example

auto mesh_factory = std::make_unique<mesh::hybrid2d::MeshFactory>(2);
auto gmsh_reader = io::GmshReader(std::move(mesh_factory), "mesh.msh");
// a mesh function that takes the value 1 everywhere
auto mf_one = mesh::utils::MeshFunctionConstant(1.);
// a mesh function which represents the function `sin(x)*cos(y)` (x,y are
// global coordinates)
auto mf_trig = mesh::utils::MeshFunctionGlobal(
[](const Eigen::Vector2d& x) { return std::sin(x[0]) * std::cos(x[1]); });
// mesh function `1-sin(x)*cos(y)`
auto mf_one_minus_trig = mf_one - mf_trig;

Definition at line 693 of file mesh_function_binary.h.

◆ PrintInfo() [1/2]

void lf::mesh::utils::PrintInfo ( std::ostream & o,
const lf::mesh::Mesh & mesh,
int ctrl )
related

Definition at line 18 of file print_info.cc.

◆ PrintInfo() [2/2]

void lf::mesh::utils::PrintInfo ( std::ostream & stream,
const lf::mesh::Entity & e,
int output_ctrl )
related

Definition at line 74 of file print_info.cc.