LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Classes | Typedefs | Functions | Variables
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...
 
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...
 

Typedefs

template<class R >
using MeshFunctionReturnType = internal::VectorElement_t< internal::MeshFunctionReturnType_t< R > >
 Determine the type of objects returned by a MeshFunction. More...
 

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. More...
 
template<class T , class = typename std::enable_if< std::is_copy_constructible<T>::value>::type>
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!) More...
 
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 More...
 
template<class T , class = typename std::enable_if< std::is_copy_constructible<T>::value>::type>
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!) More...
 
template<class A , class B , class = std::enable_if_t<isMeshFunction<A> && isMeshFunction<B>>>
auto operator+ (const A &a, const B &b)
 Add's two mesh functions. More...
 
template<class A , class B , class = std::enable_if_t<isMeshFunction<A> && isMeshFunction<B>>>
auto operator- (const A &a, const B &b)
 Subtracts two mesh functions. More...
 
template<class A , class B , class = std::enable_if_t<isMeshFunction<A> && isMeshFunction<B>>>
auto operator* (const A &a, const B &b)
 Multiply two mesh functions with each other. More...
 
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 More...
 
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 More...
 
AllCodimMeshDataSet< bool > flagEntitiesOnBoundary (const std::shared_ptr< const Mesh > &mesh_p)
 flag entities of any co-dimension located on the boundary More...
 

Variables

template<class T , class R = void>
constexpr bool isMeshFunction
 Determine whether a given type fulfills the concept MeshFunction. More...
 

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 = typedef 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 80 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.

References lf::mesh::Entity::SubEntities().

Referenced by 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(), and lf::mesh::Entity::SubEntities().

◆ 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.
Definition: test_meshes.cc:14
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(), and lf::mesh::Entity::SubEntities().

Referenced by FisherKPP::assembleGalerkinMatrices(), projects::ipdg_stokes::assemble::buildSystemMatrixInOutFlow(), projects::ipdg_stokes::assemble::buildSystemMatrixNoFlow(), projects::ipdg_stokes::post_processing::DGnorm(), projects::dpg::flagEntitiesOnInflowBoundary(), projects::dpg::flagEntitiesOnOutflowBoundary(), projects::dpg::test::TestConververgencePrimalDPGAdaptedNormConvectionDiffusionDirichletBVP(), and projects::dpg::test::TestConververgencePrimalDPGConvectionDiffusionDirichletBVP().

◆ 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 118 of file all_codim_mesh_data_set.h.

◆ make_AllCodimMeshDataSet() [2/2]

template<class T , class = typename std::enable_if< std::is_copy_constructible<T>::value>::type>
std::shared_ptr< AllCodimMeshDataSet< T > > lf::mesh::utils::make_AllCodimMeshDataSet ( const std::shared_ptr< const lf::mesh::Mesh > &  mesh,
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 92 of file codim_mesh_data_set.h.

◆ make_CodimMeshDataSet() [2/2]

template<class T , class = typename std::enable_if< std::is_copy_constructible<T>::value>::type>
std::shared_ptr< CodimMeshDataSet< T > > lf::mesh::utils::make_CodimMeshDataSet ( const std::shared_ptr< const Mesh > &  mesh,
base::dim_t  codim,
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 108 of file codim_mesh_data_set.h.

◆ operator*()

template<class A , class B , class = std::enable_if_t<isMeshFunction<A> && isMeshFunction<B>>>
auto operator* ( const A &  a,
const B &  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
// a mesh function which represents the radial vector field (x,y)
[](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;
Reads a Gmsh *.msh file into a mesh::MeshFactory and provides a link between mesh::Entity objects and...
Definition: gmsh_reader.h:70
A MeshFunction which takes the same constant value on the whole mesh.
MeshFunction wrapper for a simple function of physical coordinates.

Definition at line 729 of file mesh_function_binary.h.

◆ operator+()

template<class A , class B , class = std::enable_if_t<isMeshFunction<A> && isMeshFunction<B>>>
auto operator+ ( const A &  a,
const B &  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
// a mesh function which represents the function `sin(x)*cos(y)` (x,y are
// global coordinates)
[](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 671 of file mesh_function_binary.h.

◆ operator-()

template<class A , class B , class = std::enable_if_t<isMeshFunction<A> && isMeshFunction<B>>>
auto operator- ( const A &  a,
const B &  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
// a mesh function which represents the function `sin(x)*cos(y)` (x,y are
// global coordinates)
[](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 700 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 17 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.

Variable Documentation

◆ isMeshFunction

template<class T , class R = void>
constexpr bool lf::mesh::utils::isMeshFunction
inlineconstexpr
Initial value:
=
!std::is_reference_v<T> && std::is_copy_constructible_v<T> &&
std::is_move_constructible_v<T> &&
internal::IsMeshFunctionCallable<T, R>(0)

Determine whether a given type fulfills the concept MeshFunction.

Template Parameters
TThe type to check
RIf specified, check additionally, that the MeshFunction returns objects of type R

Definition at line 70 of file mesh_function_traits.h.