LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
lf::mesh::hybrid2d::Mesh Class Reference

Basis 2D mesh type compliant with abstract mesh interface. More...

#include <lf/mesh/hybrid2d/mesh.h>

Inheritance diagram for lf::mesh::hybrid2d::Mesh:
lf::mesh::Mesh

Public Member Functions

unsigned DimMesh () const override
 The dimension of the manifold described by the mesh, or equivalently the maximum dimension of the reference elements present in the mesh.
 
unsigned DimWorld () const override
 The dimension of the Euclidean space in which the mesh is embedded.
 
std::span< const Entity *const > Entities (unsigned codim) const override
 All entities of a given codimension.
 
size_type NumEntities (unsigned codim) const override
 The number of Entities that have the given codimension.
 
size_type NumEntities (lf::base::RefEl ref_el_type) const override
 Tells number of entities of a particular topological/geometric type.
 
size_type Index (const Entity &e) const override
 Acess to the index of a mesh entity of any co-dimension.
 
const mesh::EntityEntityByIndex (dim_t codim, glb_idx_t index) const override
 Method for accessing an entity through its index.
 
bool Contains (const mesh::Entity &e) const override
 Check if the given entity is a part of this mesh.
 
- Public Member Functions inherited from lf::mesh::Mesh
virtual ~Mesh ()=default
 virtual destructor
 

Static Public Member Functions

static std::shared_ptr< spdlog::logger > & Logger ()
 logger, used by methods of Mesh to log additional information.
 

Private Types

using GeometryPtr = std::unique_ptr<geometry::Geometry>
 Data types for passing information about mesh intities.
 
using NodeCoordList = std::vector<GeometryPtr>
 
using EdgeList
 
using CellList
 

Private Member Functions

 Mesh (dim_t dim_world, NodeCoordList nodes, EdgeList edges, CellList cells, bool check_completeness)
 Construction of mesh from information gathered in a MeshFactory.
 

Private Attributes

dim_t dim_world_ {}
 
std::vector< hybrid2d::Pointpoints_
 array of 0-dimensional entity object of co-dimension 2
 
std::vector< hybrid2d::Segmentsegments_
 array of 1-dimensional entity object of co-dimension 1
 
std::vector< hybrid2d::Triangletrias_
 array of triangular cell objects, oo-dimension 0
 
std::vector< hybrid2d::Quadrilateralquads_
 array of quadrilateral cell objects, oo-dimension 0
 
std::array< std::vector< const mesh::Entity * >, 3 > entity_pointers_
 Auxliary array of cell (co-dim ==0 entities) pointers.
 

Friends

class MeshFactory
 

Additional Inherited Members

- Public Types inherited from lf::mesh::Mesh
using size_type = lf::base::size_type
 
using dim_t = lf::base::dim_t
 
- Protected Member Functions inherited from lf::mesh::Mesh
 Mesh ()=default
 
 Mesh (const Mesh &)=default
 
 Mesh (Mesh &&)=default
 
Meshoperator= (const Mesh &)=default
 
Meshoperator= (Mesh &&)=default
 

Detailed Description

Basis 2D mesh type compliant with abstract mesh interface.

Definition at line 35 of file mesh.h.

Member Typedef Documentation

◆ CellList

Initial value:
std::vector<std::pair<std::array<size_type, 4>, GeometryPtr>>
std::unique_ptr< geometry::Geometry > GeometryPtr
Data types for passing information about mesh intities.
Definition mesh.h:70

Definition at line 74 of file mesh.h.

◆ EdgeList

Initial value:
std::vector<std::pair<std::array<size_type, 2>, GeometryPtr>>

Definition at line 72 of file mesh.h.

◆ GeometryPtr

Data types for passing information about mesh intities.

Definition at line 70 of file mesh.h.

◆ NodeCoordList

Definition at line 71 of file mesh.h.

Constructor & Destructor Documentation

◆ Mesh()

lf::mesh::hybrid2d::Mesh::Mesh ( dim_t dim_world,
NodeCoordList nodes,
EdgeList edges,
CellList cells,
bool check_completeness )
private

Construction of mesh from information gathered in a MeshFactory.

Parameters
dim_worldDimension of the ambient space.
nodessequential container of node coordinates
edgessequential container of pairs of (i) vectors of indices of the nodes of an edge (ii) pointers to the geometry object describing an edge
cellssequential container of pairs of (i) vectors of indices of the nodes of a cell (ii) pointers to the geometry object for the cell
check_completenessIf set to true, the constructor will check that the mesh is topologically complete. That means that every entity with codimension codim>0 is a subentity of at least one entity with codimension codim-1. If check_completeness = true and the mesh is not complete, an assert will fail.

Shape guessing

Shape information usually supplied by a unique pointer to a lf::geometry::Geometry object attached to an entity may be missing for some of the entities. In this case the constructor tries to reconstruct the shape from that of other entities.

The main example is missing geometry information for nodes or edges. In this case a call to the lf::geometry::SubGeometry() method of cell entities is used to generate shape information for its lower-dimensional sub-entities. Note that any adjacent cell can be used and no selection rule is given.

Even cells without shape information may be passed. In this case the current implementation builds a cell with straight edges of type lf::geometry::TriaO1 (in the case of a topological triangle) or lf::geometry::QuadO1 (in the case of a quadrilateral) from the node positions. The shape of edges is not taken into account.

An extreme situation is marked by passing node positions as the only geometric information together with topological node-cell incidence relationships. In this case the constructor will build a mesh with straight edges throughout, type lf::geometry::SegmentO1.

Missing entities

Note
not all edges of the mesh have to be passed in the edges argument; missing edges are inserted based on the information about the cells.
the position of node information the nodes array and of cell information in the cells array, respectively, determines the interpretation of the index numbers, that is the n-th node in the container has index n-1.

is stored in the 'edge_global_index' field of the EdgeData structure.

Definition at line 178 of file mesh.cc.

Member Function Documentation

◆ Contains()

bool lf::mesh::hybrid2d::Mesh::Contains ( const mesh::Entity & e) const
overridevirtual

Check if the given entity is a part of this mesh.

Parameters
eThe entity that should be checked.
Returns
true if the entity belongs to the mesh.

Implements lf::mesh::Mesh.

Definition at line 113 of file mesh.cc.

◆ DimMesh()

unsigned lf::mesh::hybrid2d::Mesh::DimMesh ( ) const
inlineoverridevirtual

The dimension of the manifold described by the mesh, or equivalently the maximum dimension of the reference elements present in the mesh.

See the code snippet showing the use of lf::mesh::Mesh

Implements lf::mesh::Mesh.

Definition at line 37 of file mesh.h.

◆ DimWorld()

unsigned lf::mesh::hybrid2d::Mesh::DimWorld ( ) const
inlineoverridevirtual

The dimension of the Euclidean space in which the mesh is embedded.

Implements lf::mesh::Mesh.

Definition at line 38 of file mesh.h.

References dim_world_.

◆ Entities()

std::span< const Entity *const > lf::mesh::hybrid2d::Mesh::Entities ( unsigned codim) const
overridevirtual

All entities of a given codimension.

Parameters
codimThe codimension of the entities that should be returned.
Returns
A span of pointers to entities that enumerate all entities of the given codimension.
See also
Entity

Principal access method for entities distinguished only by their co-dimension. Hence, all cells of a mesh are covered by the range returned when giving co-dimension 0, regardless of their concrete shape.

The typical loop for entity traversal looks like this, where mesh is a variable containing a reference to a Mesh object.

for (const lf::mesh::Entity* entity : mesh.Entities(codim)) {
....
}
Interface class representing a topological entity in a cellular complex
Definition entity.h:42
std::span< const Entity *const > Entities(unsigned codim) const override
All entities of a given codimension.
Definition mesh.cc:20

Inside the loop body the variable entity contains a pointer to an immutable object of type Entity whose co-dimension is codim.

Note
The pointer remains valid for as long as the mesh data structure remains valid.

Demonstration code

int traverseEntities(const lf::mesh::Mesh& mesh, lf::base::dim_t codim) {
// Typical loop for running through all entities of a specific co-dimension
for (const lf::mesh::Entity* entity : mesh.Entities(codim)) {
// Print entity information including its unique index
std::cout << cnt << ": Entity #" << mesh.Index(*entity) << ": " << *entity
<< std::endl;
cnt++;
}
return cnt;
}

Also see Lecture Document Example 2.7.2.6 or the code snippet showing the use of lf::mesh::Mesh

Implements lf::mesh::Mesh.

Definition at line 20 of file mesh.cc.

◆ EntityByIndex()

const Entity * lf::mesh::hybrid2d::Mesh::EntityByIndex ( dim_t codim,
glb_idx_t index ) const
overridevirtual

Method for accessing an entity through its index.

Parameters
codimcodimension of the entity. Remember that indices are supposed to be unique and contiguous for a given co-dimension
indexan integer between 0 and number of entities of the given co-dimension -1. It passes the index.
Returns
pointer to the entity object with the given index.

Based on the bijectition between entities of a given co-dimension and an integer range. The following expression should evaluate to true, if mesh is a reference to a Mesh object, and idx a valid index

((idx < mesh.NumEntities(codim)) &&
mesh.Index(*mesh.EntityByIndex(codim,idx)) == idx)
Note
O(1) access complexity due to table lookup.

Also see the code snippet showing the use of lf::mesh::Mesh

Implements lf::mesh::Mesh.

Definition at line 106 of file mesh.cc.

◆ Index()

Mesh::size_type lf::mesh::hybrid2d::Mesh::Index ( const Entity & e) const
overridevirtual

Acess to the index of a mesh entity of any co-dimension.

Parameters
eEntity whose index is requested
Returns
index ranging from 0 to no. of entities of the same co-dimension-1

It is a strict convention in LehrFEM++ that all entities of the same co-dimension belonging to a mesh are endowed with an integer index. These indices are guaranteed to be contiguous and to range from 0 to Size(codim)-1, cf. Lecture Document Equation 2.7.2.5.

Note
The index of a mesh entity is NOT related to its position in the range returned by the Entities() method.

Also see the code snippet showing the use of lf::mesh::Mesh

The indexing of mesh entities is explained in Lecture Document Subsection 2.7.2.1

Implements lf::mesh::Mesh.

Definition at line 84 of file mesh.cc.

◆ Logger()

static std::shared_ptr< spdlog::logger > & lf::mesh::hybrid2d::Mesh::Logger ( )
inlinestatic

logger, used by methods of Mesh to log additional information.

Definition at line 135 of file mesh.h.

References lf::base::InitLogger().

◆ NumEntities() [1/2]

Mesh::size_type lf::mesh::hybrid2d::Mesh::NumEntities ( lf::base::RefEl ref_el_type) const
overridevirtual

Tells number of entities of a particular topological/geometric type.

Parameters
ref_el_typetopological/geometric type
Returns
number of entities of that type

Implements lf::mesh::Mesh.

Definition at line 62 of file mesh.cc.

◆ NumEntities() [2/2]

Mesh::size_type lf::mesh::hybrid2d::Mesh::NumEntities ( unsigned codim) const
overridevirtual

The number of Entities that have the given codimension.

Parameters
codimThe codimension of the entities that should be counted.
Returns
That number of entities that have the given codimension.

See the code snippet showing the use of lf::mesh::Mesh

Implements lf::mesh::Mesh.

Definition at line 49 of file mesh.cc.

Friends And Related Symbol Documentation

◆ MeshFactory

friend class MeshFactory
friend

Definition at line 131 of file mesh.h.

Member Data Documentation

◆ dim_world_

dim_t lf::mesh::hybrid2d::Mesh::dim_world_ {}
private

Definition at line 51 of file mesh.h.

Referenced by DimWorld().

◆ entity_pointers_

std::array<std::vector<const mesh::Entity*>, 3> lf::mesh::hybrid2d::Mesh::entity_pointers_
private

Auxliary array of cell (co-dim ==0 entities) pointers.

This array serves two purposes. It facilitates the construction of a range covering all the cells. It is also required to retrieving the entity of a specific codimension belonging to an index.

Definition at line 67 of file mesh.h.

◆ points_

std::vector<hybrid2d::Point> lf::mesh::hybrid2d::Mesh::points_
private

array of 0-dimensional entity object of co-dimension 2

Definition at line 53 of file mesh.h.

◆ quads_

std::vector<hybrid2d::Quadrilateral> lf::mesh::hybrid2d::Mesh::quads_
private

array of quadrilateral cell objects, oo-dimension 0

Definition at line 59 of file mesh.h.

◆ segments_

std::vector<hybrid2d::Segment> lf::mesh::hybrid2d::Mesh::segments_
private

array of 1-dimensional entity object of co-dimension 1

Definition at line 55 of file mesh.h.

◆ trias_

std::vector<hybrid2d::Triangle> lf::mesh::hybrid2d::Mesh::trias_
private

array of triangular cell objects, oo-dimension 0

Definition at line 57 of file mesh.h.


The documentation for this class was generated from the following files: