v0.14.0
MeshRefinement.hpp
Go to the documentation of this file.
1 /** \file MeshRefinement.hpp
2  * \brief Interface for mesh refinement
3  *
4  * \ingroup mofem_refiner
5  */
6 
7 #ifndef __MESHREFINE_HPP__
8 #define __MESHREFINE_HPP__
9 
10 namespace MoFEM {
11 
12 /** \brief Mesh refinement interface
13 
14  Currently this class is abstraction to Core interface. In future should be
15  outsourced as independent interface.
16 
17  \bug Not working on partitioned meshes
18  \bug Need to be implemented as a stand alone interface not as a part of core
19  structure which should be only basic database
20  \bug If outsourced, class member functions should follow name convention
21  \bug Spelling mistakes will be corrected with names fix to follow name
22  convetion
23 
24  \ingroup mofem_refiner
25  */
27 
28  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
29  UnknownInterface **iface) const;
30 
32  MeshRefinement(const MoFEM::Core &core);
33 
34  virtual ~MeshRefinement() = default;
35 
36  /**
37  * \brief make vertices in the middle of edges in meshset and add them to
38  * refinement levels defined by bit
39  *
40  * Takes entities fromm meshsets and queried recursively (get entities from
41  * meshsets in meshsets, usually have to be used for CUBIT meshset).
42  * If meshset does not contain any edges, get entities in dimension 3 and get
43  * edge adjacencies.
44  *
45  * \param EntityHandle meshset
46  * \param BitRefLevel bitLevel
47  * \param recursive If true, meshsets containing meshsets are queried
48  * recursively. Returns the contents of meshsets, but not the meshsets
49  * themselves if true.
50  */
52  const BitRefLevel &bit,
53  const bool recursive = false,
54  int verb = QUIET,
55  EntityHandle start_v = 0);
56 
57  /**
58  * \brief make vertices in the middle of edges in meshset and add them to
59  * Refinement levels defined by bit
60  *
61  * Takes entities from meshsets and queried recursively (get entities from
62  * meshsets in meshsets, usually have to be used for CUBIT meshset).
63  * If meshset does not contain any edges, get entities in dimension 3 and get
64  * edge adjacencies.
65  *
66  * \param Range consisting edges for refine
67  * \param BitRefLevel bitLevel
68  * \param recursive If true, meshsets containing meshsets are queried
69  * recursively. Returns the contents of meshsets, but not the meshsets
70  * themselves if true.
71  */
73  const BitRefLevel &bit,
74  int verb = QUIET,
75  EntityHandle start_v = 0);
76 
77  /**\brief refine TET in the meshset
78  *
79  * \param EntityHandle meshset
80  * \param BitRefLevel bitLevel
81  * \param verb verbosity level
82  */
84  int verb = QUIET, const bool debug = false);
85 
86  /**\brief refine TET in the meshset
87  *
88  * \param Range of tets to refine
89  * \param BitRefLevel bitLevel
90  * \param BitRefLevel bitLevel
91  * \param verb verbosity level
92  */
93  MoFEMErrorCode refineTets(const Range &tets, const BitRefLevel &bit,
94  int verb = QUIET, const bool debug = false);
95 
96  /**\brief refine TET in the meshset
97  *
98  * \param Range of tets to refine
99  * \param BitRefLevel bitLevel
100  * \param BitRefLevel bitLevel
101  * \param verb verbosity level
102  */
104  const BitRefLevel &bit,
105  int verb = QUIET,
106  const bool debug = false);
107 
108  /**\brief refine TET in the meshset
109  *
110  * \param Range of tets to refine
111  * \param BitRefLevel bitLevel
112  * \param BitRefLevel bitLevel
113  * \param verb verbosity level
114  */
116  const BitRefLevel &bit,
117  int verb = QUIET,
118  const bool debug = false);
119 
120  /**\brief refine PRISM in the meshset
121  *
122  * \param EntityHandle meshset
123  * \param BitRefLevel bitLevel
124  */
126  const BitRefLevel &bit, int verb = QUIET);
127 
128  /**\brief refine meshset, i.e. add child of refined entities to meshset
129  *
130  * \param EntityHandle meshset where to save the child refined entities
131  * \param BitRefLevel bitLevel
132  * \param recursive If true, meshsets containing meshsets are queried
133  * recursively. Returns the contents of meshsets, but not the meshsets
134  * themselves if true.
135  */
137  const BitRefLevel &bit,
138  const bool recursive = false, int verb = QUIET);
139 
140  /**\brief refine triangles in the meshset
141  *
142  * \param EntityHandle meshset
143  * \param BitRefLevel bitLevel
144  * \param verb verbosity level
145  */
146  MoFEMErrorCode refineTris(const EntityHandle meshset, const BitRefLevel &bit,
147  int verb = QUIET, const bool debug = false);
148 
149  /**\brief refine TRI in the meshset
150  *
151  * \param meshset of entities to refine
152  * \param BitRefLevel bit level of created entities
153  * \param verb verbosity level
154  */
155  MoFEMErrorCode refineTris(const Range &tris, const BitRefLevel &bit,
156  int verb = QUIET, const bool debug = false);
157 
158  /**\brief refine TRI in the meshset
159  *
160  * \param Range of entities to refine
161  * \param BitRefLevel bit level of created entities
162  * \param verb verbosity level
163  */
165  const BitRefLevel &bit,
166  int verb = QUIET,
167  const bool debug = false);
168 
169  /**\brief refine TRI in the meshset
170  *
171  * \param Range of entities to refine
172  * \param BitRefLevel bit level of created entities
173  * \param verb verbosity level
174  */
176  const BitRefLevel &bit,
177  int verb = QUIET,
178  const bool debug = false);
179 
180 private:
181  struct SetParent {
182  map<EntityHandle, EntityHandle> parentsToChange;
183  MoFEMErrorCode operator()(const EntityHandle ent, const EntityHandle parent,
184  const RefEntity_multiIndex *ref_ents_ptr,
185  MoFEM::Core &cOre);
186 
187  MoFEMErrorCode operator()(const RefEntity_multiIndex *ref_ents_ptr);
188  };
189 
190 
191  /**
192  * @brief Functions setting edges for refinemnt on enetity level
193  *
194  */
195  using SetEdgeBitsFun = boost::function<
196 
199  &ref_parent_ents_view,
200  EntityHandle tet, BitRefEdges &parent_edges_bit,
201  EntityHandle *edge_new_nodes, int *split_edges
202 
203  )>;
204 
205  /**\brief refine TET in the meshset
206  *
207  * \param Range of tets to refine
208  * \param BitRefLevel bitLevel
209  * \param verb verbosity level
210  */
211  MoFEMErrorCode refineTets(const Range &tets, const BitRefLevel &bit,
212  SetEdgeBitsFun set_edge_bits, int verb,
213  const bool debug);
214 
215  MoFEMErrorCode refineTris(const Range &tris, const BitRefLevel &bit,
216  SetEdgeBitsFun set_edge_bits, int verb,
217  const bool debug);
218 };
219 
220 } // namespace MoFEM
221 
222 #endif // __MESHREFINE_HPP__
223 
224 /**
225  * \defgroup mofem_refiner MeshRefinement
226  * \brief Refine mesh by splitting edges
227  *
228  */
MoFEM::MeshRefinement::SetParent::parentsToChange
map< EntityHandle, EntityHandle > parentsToChange
Definition: MeshRefinement.hpp:182
MoFEM::MeshRefinement::refineTris
MoFEMErrorCode refineTris(const EntityHandle meshset, const BitRefLevel &bit, int verb=QUIET, const bool debug=false)
refine triangles in the meshset
Definition: MeshRefinement.cpp:921
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::MeshRefinement::SetEdgeBitsFun
boost::function< MoFEMErrorCode(moab::Interface &moab, RefEntity_multiIndex_view_by_ordered_parent_entity &ref_parent_ents_view, EntityHandle tet, BitRefEdges &parent_edges_bit, EntityHandle *edge_new_nodes, int *split_edges)> SetEdgeBitsFun
Functions setting edges for refinemnt on enetity level.
Definition: MeshRefinement.hpp:203
EntityHandle
MoFEM::MeshRefinement::addVerticesInTheMiddleOfEdges
MoFEMErrorCode addVerticesInTheMiddleOfEdges(const EntityHandle meshset, const BitRefLevel &bit, const bool recursive=false, int verb=QUIET, EntityHandle start_v=0)
make vertices in the middle of edges in meshset and add them to refinement levels defined by bit
Definition: MeshRefinement.cpp:42
MoFEM::MeshRefinement::SetParent
Definition: MeshRefinement.hpp:181
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::RefEntity_multiIndex_view_by_ordered_parent_entity
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_non_unique< const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, hashed_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< boost::shared_ptr< RefEntity >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >> > > RefEntity_multiIndex_view_by_ordered_parent_entity
Definition: RefEntsMultiIndices.hpp:792
MoFEM::RefEntity_multiIndex
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt > >, ordered_non_unique< tag< Ent_Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, ordered_non_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > > >, ordered_non_unique< tag< Composite_ParentEnt_And_EntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > > > > > RefEntity_multiIndex
Definition: RefEntsMultiIndices.hpp:760
MoFEM::MeshRefinement::cOre
MoFEM::Core & cOre
Definition: MeshRefinement.hpp:31
MoFEM::MeshRefinement::~MeshRefinement
virtual ~MeshRefinement()=default
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
MoFEM::MeshRefinement::refineTets
MoFEMErrorCode refineTets(const EntityHandle meshset, const BitRefLevel &bit, int verb=QUIET, const bool debug=false)
refine TET in the meshset
Definition: MeshRefinement.cpp:197
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::MeshRefinement::MeshRefinement
MeshRefinement(const MoFEM::Core &core)
Definition: MeshRefinement.cpp:39
MoFEM::MeshRefinement::refineTrisHangingNodes
MoFEMErrorCode refineTrisHangingNodes(const EntityHandle meshset, const BitRefLevel &bit, int verb=QUIET, const bool debug=false)
refine TRI in the meshset
Definition: MeshRefinement.cpp:1002
MoFEM::MeshRefinement
Mesh refinement interface.
Definition: MeshRefinement.hpp:26
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
MoFEM::MeshRefinement::SetParent::operator()
MoFEMErrorCode operator()(const EntityHandle ent, const EntityHandle parent, const RefEntity_multiIndex *ref_ents_ptr, MoFEM::Core &cOre)
Definition: MeshRefinement.cpp:209
debug
static const bool debug
Definition: dm_create_subdm.cpp:12
MoFEM::MeshRefinement::refinePrisms
MoFEMErrorCode refinePrisms(const EntityHandle meshset, const BitRefLevel &bit, int verb=QUIET)
refine PRISM in the meshset
Definition: MeshRefinement.cpp:722
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
Range
MoFEM::Types::BitRefEdges
std::bitset< BITREFEDGES_SIZE > BitRefEdges
Definition: Types.hpp:34
MoFEM::MeshRefinement::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: MeshRefinement.cpp:33
MoFEM::MeshRefinement::refineTetsHangingNodes
MoFEMErrorCode refineTetsHangingNodes(const Range &tets, const BitRefLevel &bit, int verb=QUIET, const bool debug=false)
refine TET in the meshset
Definition: MeshRefinement.cpp:276
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
QUIET
@ QUIET
Definition: definitions.h:221
MoFEM::MeshRefinement::refineMeshset
MoFEMErrorCode refineMeshset(const EntityHandle meshset, const BitRefLevel &bit, const bool recursive=false, int verb=QUIET)
refine meshset, i.e. add child of refined entities to meshset
Definition: MeshRefinement.cpp:904