LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
|
A hierarchy of nested 2D hybrid meshes created by refinement. More...
#include <lf/refinement/mesh_hierarchy.h>
Public Member Functions | |
MeshHierarchy (const std::shared_ptr< mesh::Mesh > &base_mesh, std::unique_ptr< mesh::MeshFactory > mesh_factory) | |
Initialize mesh hierarchy with an existing coarsest mesh. | |
MeshHierarchy (const MeshHierarchy &)=delete | |
MeshHierarchy & | operator= (const MeshHierarchy &)=delete |
MeshHierarchy (MeshHierarchy &&)=delete | |
MeshHierarchy & | operator= (MeshHierarchy &&)=delete |
size_type | NumLevels () const |
number of meshes contained in the hierarchy, 1 for a single mesh | |
std::shared_ptr< const mesh::Mesh > | getMesh (size_type level) const |
access the mesh on a particular level | |
std::shared_ptr< mesh::Mesh > | getMesh (size_type level) |
access the mesh on a particular level | |
std::vector< std::shared_ptr< const mesh::Mesh > > | getMeshes () const |
Provides array of shared pointers to meshes contained in the hierarchy. | |
const std::vector< PointChildInfo > & | PointChildInfos (size_type level) const |
Obtain refinement information for all points. | |
const std::vector< EdgeChildInfo > & | EdgeChildInfos (size_type level) const |
Obtain refinement information for all edges. | |
const std::vector< CellChildInfo > & | CellChildInfos (size_type level) const |
Obtain refinement information for all. | |
const std::vector< ParentInfo > & | ParentInfos (size_type level, dim_t codim) const |
Fetch information about parents. | |
const std::vector< sub_idx_t > & | RefinementEdges (size_type level) const |
Access refinement edge indices. | |
void | RefineRegular (RefPat ref_pat=RefPat::rp_regular) |
Perform regular or barycentric uniform refinement of the finest mesh in the hierarchy. | |
template<typename Marker > | |
void | MarkEdges (Marker &&marker) |
Mark the edges of a mesh based on a predicate. | |
void | RefineMarked () |
Conduct local refinement of the mesh splitting all marked edges. | |
void | Coarsen () |
Destroy the mesh on the finest level unless it is the base mesh | |
const lf::geometry::Geometry * | GeometryInParent (size_type level, const lf::mesh::Entity &e) const |
shape of child entity in parent's reference coordinates | |
const lf::mesh::Entity * | ParentEntity (size_type level, const lf::mesh::Entity &e) const |
Retrieve the parent of an entity contained in a mesh of a refinement hierarchy. | |
std::ostream & | PrintInfo (std::ostream &o, unsigned ctrl=0) const |
Output of information about the mesh hierarchy. | |
virtual | ~MeshHierarchy ()=default |
Static Public Member Functions | |
static std::shared_ptr< spdlog::logger > & | Logger () |
Is used by MeshHierarchy to log additional information for debugging purposes. | |
Private Member Functions | |
void | PerformRefinement () |
Create new mesh according to refinement pattern provided for entities. | |
void | initGeometryInParent () |
Initialization of rel_ref_geo fields of ParentInfo structures. | |
Static Private Member Functions | |
static sub_idx_t | LongestEdge (const lf::mesh::Entity &T) |
Finds the index of the longest edge of a triangle. | |
Private Attributes | |
std::vector< std::shared_ptr< mesh::Mesh > > | meshes_ |
the meshes managed by the MeshHierarchy object | |
std::unique_ptr< mesh::MeshFactory > | mesh_factory_ |
The mesh factory to be used to creating a new mesh. | |
std::vector< std::vector< PointChildInfo > > | point_child_infos_ |
information about children of nodes for each level | |
std::vector< std::vector< EdgeChildInfo > > | edge_child_infos_ |
information about children of edges for each level | |
std::vector< std::vector< CellChildInfo > > | cell_child_infos_ |
information about children of cells for each level | |
std::vector< std::array< std::vector< ParentInfo >, 3 > > | parent_infos_ |
information about parent entities on each level | |
std::vector< std::vector< bool > > | edge_marked_ |
Information about marked edges. | |
std::vector< std::vector< sub_idx_t > > | refinement_edges_ |
Information about local refinement edges of triangles. | |
A hierarchy of nested 2D hybrid meshes created by refinement.
This is the fundamental class for managing sequences of meshes that have been created by successive local or global refinement of an initial coarsest mesh. Objects of this class store comprehensive information about the relationship of the meshes in the sequence: parent-child relationships of mesh cells and local refinement patterns.
In the context of studying convergence of finite elemment method objects of type MeshHierarchy can be employed to hold sequencies of uniformly refine meshes, see MeshHierarchy::RefineRegular().
Definition at line 116 of file mesh_hierarchy.h.
lf::refinement::MeshHierarchy::MeshHierarchy | ( | const std::shared_ptr< mesh::Mesh > & | base_mesh, |
std::unique_ptr< mesh::MeshFactory > | mesh_factory ) |
Initialize mesh hierarchy with an existing coarsest mesh.
base_mesh | valid pointer to non-const coarsest mesh |
mesh_factory | factory object creating new meshes during refinement |
ChildInfo
data structures of all entities to indicate absence of children, since no refinement has been done yet.ParentInfo
data structure, since the mesh has not been created by refinement.Definition at line 34 of file mesh_hierarchy.cc.
References cell_child_infos_, edge_child_infos_, edge_marked_, lf::refinement::idx_nil, lf::base::RefEl::kTria(), LongestEdge(), meshes_, parent_infos_, point_child_infos_, and refinement_edges_.
|
delete |
|
delete |
|
virtualdefault |
|
inline |
Obtain refinement information for all.
level | refinement level to be queried |
Definition at line 211 of file mesh_hierarchy.h.
References cell_child_infos_, and NumLevels().
void lf::refinement::MeshHierarchy::Coarsen | ( | ) |
Destroy the mesh on the finest level unless it is the base mesh
|
inline |
Obtain refinement information for all edges.
level | refinement level to be queried |
Definition at line 198 of file mesh_hierarchy.h.
References edge_child_infos_, and NumLevels().
const lf::geometry::Geometry * lf::refinement::MeshHierarchy::GeometryInParent | ( | size_type | level, |
const lf::mesh::Entity & | e ) const |
shape of child entity in parent's reference coordinates
level | level of the fine mesh in the mesh hierarchy |
e | reference to entity object of the fine mesh |
We consider the shape of the reference entity of the parent entity of e as a triangulated domain, if the parent entity has a positive dimension, that is, if it is not a point. The entities of that triangulation correspond to the reference shapes of the child entities on the fine mesh. This method returns the shape of an entity of that triangulation.
Example: The case of a quadrilateral split into four child entities, corresponding to rp_threeedge
as defined in lf::refinement::RefPat, lf::refinement::Hybrid2DRefinementPattern::ChildPolygons(). The following image gives the local child numbers in pink.
The geometries of the child entities are as follows:
\[ \left[\begin{array}{cccc} 1 & 0 & 0 & 1 \\ 1 & 1 & 0.5 & 0.5 \end{array}\right] \]
\[ \left[\begin{array}{ccc} 0 & 0.5 & 0 \\ 0 & 0 & 0.5 \end{array} \right] \]
\[ \left[\begin{array}{ccc} 1 & 0.5 & 1 \\ 0.5 & 0 & 0 \end{array} \right] \]
\[ \left[\begin{array}{ccc} 0.5 & 1 & 0 \\ 0 & 0.5 & 0.5 \end{array} \right] \]
One of the displayed matrices is returned if the entity e
corresponds to that child of a quadrilateral.
Definition at line 1860 of file mesh_hierarchy.cc.
Referenced by lf::refinement::MeshFunctionTransfer< MF >::operator()().
|
inline |
access the mesh on a particular level
level | specifies level of interest, 0 stands for coarsest level |
Definition at line 160 of file mesh_hierarchy.h.
References meshes_.
|
inline |
access the mesh on a particular level
level | specifies level of interest, 0 stands for coarsest level |
Definition at line 151 of file mesh_hierarchy.h.
References meshes_.
Referenced by lf::refinement::MeshFunctionTransfer< MF >::getMesh(), lf::refinement::MeshFunctionTransfer< MF >::MeshFunctionTransfer(), lf::refinement::WriteMatlab(), and lf::refinement::WriteMatlabLevel().
|
inline |
Provides array of shared pointers to meshes contained in the hierarchy.
Definition at line 172 of file mesh_hierarchy.h.
References meshes_.
|
private |
Initialization of rel_ref_geo fields of ParentInfo structures.
This method created geometry::Geometry type objects describing the shape of a child entity in the reference coordinates of its parent.
Definition at line 1605 of file mesh_hierarchy.cc.
Referenced by RefineMarked(), and RefineRegular().
|
static |
Is used by MeshHierarchy to log additional information for debugging purposes.
Definition at line 27 of file mesh_hierarchy.cc.
References lf::base::InitLogger().
Referenced by PerformRefinement().
|
staticprivate |
Finds the index of the longest edge of a triangle.
This method is used for setting refinement edges on coarsest meshes. Called in the constructor of MeshHierarchy.
Definition at line 1839 of file mesh_hierarchy.cc.
Referenced by MeshHierarchy().
void lf::refinement::MeshHierarchy::MarkEdges | ( | Marker && | marker | ) |
Mark the edges of a mesh based on a predicate.
marker | this should be functor of type std::function<bool(const Mesh &,const Entity &)> returning true if the passed edge is to be marked. |
The marker object also takes a reference to a mesh, because marking makes sense only for the finest level. The mesh on the finest level is provided to the marker object by the MeshHierarchy
.
Of course, marking will always affect the finest mesh in hierarchy.
Definition at line 455 of file mesh_hierarchy.h.
References edge_marked_, lf::mesh::Mesh::Entities(), lf::mesh::Mesh::Index(), meshes_, and lf::mesh::Mesh::NumEntities().
|
inline |
number of meshes contained in the hierarchy, 1 for a single mesh
Definition at line 143 of file mesh_hierarchy.h.
References meshes_.
Referenced by CellChildInfos(), EdgeChildInfos(), lf::refinement::MeshFunctionTransfer< MF >::MeshFunctionTransfer(), ParentInfos(), PointChildInfos(), lf::fe::prolongate(), RefinementEdges(), and lf::refinement::WriteMatlab().
|
delete |
|
delete |
const lf::mesh::Entity * lf::refinement::MeshHierarchy::ParentEntity | ( | size_type | level, |
const lf::mesh::Entity & | e ) const |
Retrieve the parent of an entity contained in a mesh of a refinement hierarchy.
level | refinement level > 0 of the fine mesh |
e | pointer to (potential) child entity, must be contained in mesh on the specified level. |
Definition at line 1878 of file mesh_hierarchy.cc.
Referenced by lf::refinement::MeshFunctionTransfer< MF >::operator()().
|
inline |
Fetch information about parents.
level | refinement level of interest |
codim | co-dimension of entities to be queried |
Definition at line 225 of file mesh_hierarchy.h.
References NumLevels(), and parent_infos_.
Referenced by lf::refinement::WriteMatlabLevel().
|
private |
Create new mesh according to refinement pattern provided for entities.
This function expects that the refinement patterns stored in the vectors point_child_infos_
, edge_child_infos_
and cell_child_infos_
have been initialized consistently for the finest mesh. According to this information, refinement is carried out using the object pointed to by mesh_factory_ to created new entities by calling lf::mesh::MeshFactory::Build().
The vectors point_child_infos_
, edge_child_infos_
and cell_child_infos_
will be augmented with information about the indices of the child entities contained in the newly created finest mesh.
This method relies on lf::geometry::Geometry::ChildGeometry() to obtain information about the shape of child entities in the form of lf::geometry::Geometry objects.
The method also initializes the data vectors in _parent_infos_
for the newly created finest mesh.
Definition at line 368 of file mesh_hierarchy.cc.
References lf::refinement::EdgeChildInfo::child_edge_idx, lf::refinement::EdgeChildInfo::child_point_idx, lf::geometry::Geometry::ChildGeometry(), edge_child_infos_, lf::mesh::Mesh::Entities(), lf::mesh::Mesh::Index(), lf::base::RefEl::kPoint(), Logger(), mesh_factory_, meshes_, point_child_infos_, lf::refinement::EdgeChildInfo::ref_pat_, lf::refinement::rp_copy, lf::refinement::rp_nil, and lf::refinement::rp_split.
Referenced by RefineMarked(), and RefineRegular().
|
inline |
Obtain refinement information for all points.
level | refinement level to be queried |
Definition at line 185 of file mesh_hierarchy.h.
References NumLevels(), and point_child_infos_.
std::ostream & lf::refinement::MeshHierarchy::PrintInfo | ( | std::ostream & | o, |
unsigned | ctrl = 0 ) const |
Output of information about the mesh hierarchy.
o | output stream, can be std::cout or similar |
ctrl | controls the level of detail of the generated output. |
The type of output is controlled by the ctrl
static control variable. If its second bit is set, the output function of the mesh class is used.
This is a rudimentary implementation and should be extended.
Definition at line 1896 of file mesh_hierarchy.cc.
void lf::refinement::MeshHierarchy::RefineMarked | ( | ) |
Conduct local refinement of the mesh splitting all marked edges.
This method creates a new mesh by selectively (locally) refining entities of the current finest mesh in the hierarchy. Refinement is controlled by the boolean vector edge_marked_ that indicates, which edges must be refined (= split) in the course of refinement.
REPEAT
UNTIL no extra edges had to be tagged as "to be split"
For details please consult the comments in mesh_hierarchy.cc
This algorithm ends with a set of local refinement patterns for every entity that is compatible with a conforming finite element mesh, that is, hanging nodes are avoided.
Definition at line 116 of file mesh_hierarchy.cc.
References cell_child_infos_, edge_child_infos_, edge_marked_, lf::mesh::Mesh::Entities(), lf::mesh::Mesh::Index(), initGeometryInParent(), lf::base::RefEl::kQuad(), lf::base::RefEl::kSegment(), lf::base::RefEl::kTria(), meshes_, lf::mesh::Mesh::NumEntities(), PerformRefinement(), point_child_infos_, lf::refinement::PointChildInfo::ref_pat, lf::refinement::EdgeChildInfo::ref_pat_, refinement_edges_, lf::refinement::rp_bisect, lf::refinement::rp_copy, lf::refinement::rp_nil, lf::refinement::rp_quadsect, lf::refinement::rp_regular, lf::refinement::rp_split, lf::refinement::rp_threeedge, lf::refinement::rp_trisect, and lf::refinement::rp_trisect_left.
|
inline |
Access refinement edge indices.
level | refinement level of interest |
Definition at line 238 of file mesh_hierarchy.h.
References NumLevels(), and refinement_edges_.
Referenced by lf::refinement::WriteMatlabLevel().
void lf::refinement::MeshHierarchy::RefineRegular | ( | RefPat | ref_pat = RefPat::rp_regular | ) |
Perform regular or barycentric uniform refinement of the finest mesh in the hierarchy.
ref_pat | selector for type of uniform refinement: default is rp_regular, rp_barycentric choses barycentric refinement. |
This method carries out uniform refinement of all cells of a mesh according to the rp_regular
or rp_barycentric
refinement patterns.
A new mesh is added to the bottom of the hierarchy by regularly refining the finest mesh in the hierarchy. Regular refinement means that every node is copied, every edge is split and every cell is subdivided into four or six smaller ones of the same shape.
Internally, this method flags all nodes as to be copied, all edges as to be split and all cells as to be refined according to the passed refinement pattern. Then it calls PerformRefinement().
Definition at line 72 of file mesh_hierarchy.cc.
References cell_child_infos_, edge_child_infos_, lf::mesh::Mesh::Entities(), lf::mesh::Mesh::Index(), initGeometryInParent(), meshes_, lf::mesh::Mesh::NumEntities(), PerformRefinement(), point_child_infos_, lf::refinement::PointChildInfo::ref_pat, lf::refinement::EdgeChildInfo::ref_pat_, lf::refinement::CellChildInfo::ref_pat_, lf::refinement::rp_barycentric, lf::refinement::rp_copy, lf::refinement::rp_regular, and lf::refinement::rp_split.
|
private |
information about children of cells for each level
Definition at line 430 of file mesh_hierarchy.h.
Referenced by CellChildInfos(), MeshHierarchy(), RefineMarked(), and RefineRegular().
|
private |
information about children of edges for each level
Definition at line 428 of file mesh_hierarchy.h.
Referenced by EdgeChildInfos(), MeshHierarchy(), PerformRefinement(), RefineMarked(), and RefineRegular().
|
private |
Information about marked edges.
Definition at line 434 of file mesh_hierarchy.h.
Referenced by MarkEdges(), MeshHierarchy(), and RefineMarked().
|
private |
The mesh factory to be used to creating a new mesh.
Definition at line 424 of file mesh_hierarchy.h.
Referenced by PerformRefinement().
|
private |
the meshes managed by the MeshHierarchy object
Definition at line 422 of file mesh_hierarchy.h.
Referenced by getMesh(), getMesh(), getMeshes(), MarkEdges(), MeshHierarchy(), NumLevels(), PerformRefinement(), RefineMarked(), and RefineRegular().
|
private |
information about parent entities on each level
Definition at line 432 of file mesh_hierarchy.h.
Referenced by MeshHierarchy(), and ParentInfos().
|
private |
information about children of nodes for each level
Definition at line 426 of file mesh_hierarchy.h.
Referenced by MeshHierarchy(), PerformRefinement(), PointChildInfos(), RefineMarked(), and RefineRegular().
|
private |
Information about local refinement edges of triangles.
Definition at line 436 of file mesh_hierarchy.h.
Referenced by MeshHierarchy(), RefineMarked(), and RefinementEdges().