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

Implements mesh::MeshFactory interface and can be used to construct a hybrid mesh with dimMesh=2. More...

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

Inheritance diagram for lf::mesh::hybrid2d::MeshFactory:
lf::mesh::MeshFactory

Public Member Functions

 MeshFactory (const MeshFactory &)=delete
 
 MeshFactory (MeshFactory &&)=delete
 
MeshFactoryoperator= (const MeshFactory &)=delete
 
MeshFactoryoperator= (MeshFactory &&)=delete
 
 MeshFactory (dim_t dim_world, bool check_completeness=true)
 Construct a new builder that can be used to construct a new hybrid2d mesh.
 
dim_t DimWorld () const override
 Return the Mesh::DimWorld() of the mesh that will be returned.
 
dim_t DimMesh () const override
 Return the Mesh::DimMesh() of the mesh that will be returned.
 
size_type AddPoint (coord_t coord) override
 Add a point to the mesh.
 
size_type AddPoint (std::unique_ptr< geometry::Geometry > &&geometry) override
 Add a point to the mesh.
 
size_type AddEntity (base::RefEl ref_el, const std::span< const size_type > &nodes, std::unique_ptr< geometry::Geometry > &&geometry) override
 Add an an entity (codim>0) to the mesh.
 
std::shared_ptr< mesh::MeshBuild () override
 Construct a mesh out of the specified nodes and elements.
 
void PrintLists (std::ostream &o=std::cout) const
 output function printing assembled lists of entity information
 
 ~MeshFactory () override=default
 Virtual destructor.
 

Static Public Member Functions

static std::shared_ptr< spdlog::logger > & Logger ()
 logger that is used by the build method to output additional information to the command line.
 

Private Attributes

dim_t dim_world_
 
hybrid2d::Mesh::NodeCoordList nodes_
 
hybrid2d::Mesh::EdgeList edges_
 
hybrid2d::Mesh::CellList elements_
 
bool check_completeness_
 

Additional Inherited Members

- Public Types inherited from lf::mesh::MeshFactory
using size_type = unsigned int
 
using coord_t = Eigen::VectorXd
 Coordinate type of a point.
 
using dim_t = base::dim_t
 
- Protected Member Functions inherited from lf::mesh::MeshFactory
 MeshFactory ()=default
 
 MeshFactory (const MeshFactory &)=default
 
 MeshFactory (MeshFactory &&)=default
 
MeshFactoryoperator= (const MeshFactory &)=default
 
MeshFactoryoperator= (MeshFactory &&)=default
 

Detailed Description

Implements mesh::MeshFactory interface and can be used to construct a hybrid mesh with dimMesh=2.

A planar triangular mesh with affine triangles as cells can be completely specified by giving the list of vertex coordinates, an optional list of edges, and a list of cells (triangles, quadrilaterals). All entities can be supplied with a geometry. If this is missing, the mesh builder tries to infer it from sub-entities or super-entities. If this is not possible, an affine entity is built.

Definition at line 23 of file mesh_factory.h.

Constructor & Destructor Documentation

◆ MeshFactory() [1/3]

lf::mesh::hybrid2d::MeshFactory::MeshFactory ( const MeshFactory & )
delete

◆ MeshFactory() [2/3]

lf::mesh::hybrid2d::MeshFactory::MeshFactory ( MeshFactory && )
delete

◆ MeshFactory() [3/3]

lf::mesh::hybrid2d::MeshFactory::MeshFactory ( dim_t dim_world,
bool check_completeness = true )
inlineexplicit

Construct a new builder that can be used to construct a new hybrid2d mesh.

Parameters
dim_worldThe dimension of the euclidean space in which the mesh is embedded.
check_completenessIf set to true, calling Build() 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.

Definition at line 41 of file mesh_factory.h.

◆ ~MeshFactory()

lf::mesh::hybrid2d::MeshFactory::~MeshFactory ( )
overridevirtualdefault

Virtual destructor.

Reimplemented from lf::mesh::MeshFactory.

Member Function Documentation

◆ AddEntity()

MeshFactory::size_type lf::mesh::hybrid2d::MeshFactory::AddEntity ( base::RefEl ref_el,
const std::span< const size_type > & nodes,
std::unique_ptr< geometry::Geometry > && geometry )
overridevirtual

Add an an entity (codim>0) to the mesh.

Parameters
ref_elThe reference element of the entity.
nodesThe 0-based indices of the nodes that make up this entity (as returned from AddPoint()). This range should contain exactly ref_el.NumNodes().
geometryThe geometric description of the mesh entity. Can be a nullptr (see below).
Returns
The index of the entity that will be created. It is guaranteed that the indices are consecutive (per dimension).

Use this method to add mesh elements (codim=0) and optionally entities with codim>0 if this entity

  • should use a particular geometry object that cannot be deduced from its super-entities, or
  • if you need to know the index of this entity at a later stage, e.g. to assign flags.

If geometry == nullptr

If the geometry object is not specified, the mesh will try to deduce the geometry from super entities (i.e. entities that contain the given entity as a sub-entity). E.g. if you add an entity with ref_el=RefEl::kSegment to a mesh with dimMesh=2 and you don't specify a geometry, then the geometry of the entity will be deduced from any triangle/quadrilateral that contains this entity (using the method geometry::Geometry::SubGeometry()). If the MeshFactory cannot deduce the geometry from a father entity, an error will be raised when Build() is called.

Since the geometry object is taken from a super entity, there is no guarantee that the node order of the created entity and the one passed trough the parameter nodes are the same!

If geometry != nullptr

If you specify a geometry explicitly, the created entity will have exactly this geometry object as a reference. Hence the node ordering of the created entity object agrees with the ordering of nodes.

Note
The node indices passed with the parameter nodes must have been obtained with AddPoint() before calling this method.

Implements lf::mesh::MeshFactory.

Definition at line 45 of file mesh_factory.cc.

References dim_world_, lf::base::RefEl::Dimension(), edges_, elements_, lf::base::RefEl::kSegment(), nodes_, lf::base::RefEl::NumNodes(), and lf::base::RefEl::ToString().

◆ AddPoint() [1/2]

MeshFactory::size_type lf::mesh::hybrid2d::MeshFactory::AddPoint ( coord_t coord)
overridevirtual

Add a point to the mesh.

Parameters
coordThe coordinate of the point (should have DimWorld() rows)
Returns
The 0-based index of the entity that will be created. The first call to this method will return 0, the second call 1, ...

Implements lf::mesh::MeshFactory.

Definition at line 18 of file mesh_factory.cc.

References dim_world_, and nodes_.

◆ AddPoint() [2/2]

MeshFactory::size_type lf::mesh::hybrid2d::MeshFactory::AddPoint ( std::unique_ptr< geometry::Geometry > && geometry)
overridevirtual

Add a point to the mesh.

Parameters
geometryunique pointer to geometry object giving location of point
Returns
The 0-based index of the entity that will be created. The first call to this method will return 0, the second call 1, ...

Implements lf::mesh::MeshFactory.

Definition at line 28 of file mesh_factory.cc.

References dim_world_, lf::base::RefEl::kPoint(), and nodes_.

◆ Build()

std::shared_ptr< mesh::Mesh > lf::mesh::hybrid2d::MeshFactory::Build ( )
overridevirtual

Construct a mesh out of the specified nodes and elements.

Returns
The created mesh.
Note
All data supplied to the MeshFactory will be cleared after a mesh has been built successfully. I.e. the mesh factory can be used to construct another mesh after calling Build().

Implements lf::mesh::MeshFactory.

Definition at line 105 of file mesh_factory.cc.

References check_completeness_, dim_world_, edges_, elements_, Logger(), nodes_, and PrintLists().

◆ DimMesh()

dim_t lf::mesh::hybrid2d::MeshFactory::DimMesh ( ) const
inlineoverridevirtual

Return the Mesh::DimMesh() of the mesh that will be returned.

Implements lf::mesh::MeshFactory.

Definition at line 46 of file mesh_factory.h.

◆ DimWorld()

dim_t lf::mesh::hybrid2d::MeshFactory::DimWorld ( ) const
inlineoverridevirtual

Return the Mesh::DimWorld() of the mesh that will be returned.

Implements lf::mesh::MeshFactory.

Definition at line 44 of file mesh_factory.h.

References dim_world_.

◆ Logger()

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

logger that is used by the build method to output additional information to the command line.

Definition at line 12 of file mesh_factory.cc.

References lf::base::InitLogger().

Referenced by Build().

◆ operator=() [1/2]

MeshFactory & lf::mesh::hybrid2d::MeshFactory::operator= ( const MeshFactory & )
delete

◆ operator=() [2/2]

MeshFactory & lf::mesh::hybrid2d::MeshFactory::operator= ( MeshFactory && )
delete

◆ PrintLists()

void lf::mesh::hybrid2d::MeshFactory::PrintLists ( std::ostream & o = std::cout) const

output function printing assembled lists of entity information

Definition at line 128 of file mesh_factory.cc.

References edges_, elements_, and nodes_.

Referenced by Build().

Member Data Documentation

◆ check_completeness_

bool lf::mesh::hybrid2d::MeshFactory::check_completeness_
private

Definition at line 74 of file mesh_factory.h.

Referenced by Build().

◆ dim_world_

dim_t lf::mesh::hybrid2d::MeshFactory::dim_world_
private

Definition at line 67 of file mesh_factory.h.

Referenced by AddEntity(), AddPoint(), AddPoint(), Build(), and DimWorld().

◆ edges_

hybrid2d::Mesh::EdgeList lf::mesh::hybrid2d::MeshFactory::edges_
private

Definition at line 69 of file mesh_factory.h.

Referenced by AddEntity(), Build(), and PrintLists().

◆ elements_

hybrid2d::Mesh::CellList lf::mesh::hybrid2d::MeshFactory::elements_
private

Definition at line 70 of file mesh_factory.h.

Referenced by AddEntity(), Build(), and PrintLists().

◆ nodes_

hybrid2d::Mesh::NodeCoordList lf::mesh::hybrid2d::MeshFactory::nodes_
private

Definition at line 68 of file mesh_factory.h.

Referenced by AddEntity(), AddPoint(), AddPoint(), Build(), and PrintLists().


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