v0.14.0
Loading...
Searching...
No Matches
NodeMerger.hpp
Go to the documentation of this file.
1/** \file NodeMerger.hpp
2 * \brief NodeMerger interface
3 *
4 * Node merger interface
5 *
6 * \ingroup mofem_node_merger
7 */
8
9#ifndef __NODE_MERGER_HPP__
10#define __NODE_MERGER_HPP__
11
12namespace MoFEM {
13
14/** \brief Merge node by collapsing edge between them
15 *
16 * \ingroup mofem_node_merger
17 */
19
20 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
21 UnknownInterface **iface) const;
22
24
26
27 /**
28 * \brief Return true if successful merge.
29 * @return Error code
30 */
31 inline bool getSuccessMerge() { return successMerge; }
32
33 /**
34 * \brief Set error if no common edge
35 * @param b If true send error if false no error
36 */
37 inline void setErrorIfNoCommonEdge(const bool b = true) {
39 }
40
41 /** \brief merge nodes which sharing edge
42
43 Father is sties, mother is merged.
44
45 \param father node to which mother is merged to.
46 \param mother merged node
47 \param out_tets tetrahedra after merge
48 \param tets_ptr test only tets_ptr from range are changed
49 \param only_if_improve_quality Do merge if that improve quality
50 \param move father by fraction of edge length move=[0,1]
51
52 Move node on the edge, 0 not move, 1 move to mother side, 0.5 will be in the
53 middle.
54
55 */
57 Range &out_tets, Range *tets_ptr = NULL,
58 const bool only_if_improve_quality = false,
59 const double move = 0, const int line_search = 0,
60 Tag th = NULL, const int verb = 0);
61
62 /** \brief merge nodes which sharing edge
63
64 Father is sties, mother is merged.
65
66 \param father node to which mother is merged to.
67 \param mother merged node
68 \param bit level of mesh merged nodes mesh
69 \param test only tets_ptr from range are changed
70 \param only_if_improve_quality Do merge if that improve quality
71 \param move father by fraction of edge length move=[0,1]
72
73 Move node on the edge, 0 not move, 1 move to mother side, 0.5 will be in the
74 middle.
75
76 */
78 BitRefLevel bit, Range *tets_ptr = NULL,
79 const bool only_if_improve_quality = false,
80 const double move = 0, Tag th = NULL);
81
82 /** \brief merge nodes which sharing edge
83
84 Father is sties, mother is merged.
85
86 \param father node to which mother is merged to.
87 \param mother merged node
88 \param tets_from_bit_ref_level only tetrahedrons from bit level are changed
89 \param only_if_improve_quality Do merge if that improve quality
90 \param move father by fraction of edge length move=[0,1]
91
92 Move node on the edge, 0 not move, 1 move to mother side, 0.5 will be in the
93 middle.
94
95 */
98 BitRefLevel tets_from_bit_ref_level,
99 const bool only_if_improve_quality = false,
100 const double move = 0, Tag th = NULL);
101
102 struct ParentChild {
105 ParentChild(const EntityHandle parent, const EntityHandle child)
106 : pArent(parent), cHild(child) {}
107 };
108
109 typedef multi_index_container<
110 ParentChild,
111 indexed_by<ordered_unique<
112 member<ParentChild, EntityHandle, &ParentChild::pArent>>,
113 ordered_non_unique<
114 member<ParentChild, EntityHandle, &ParentChild::cHild>>>>
116
117 /**
118 * \brief Get map of parent cand child
119 * @return
120 */
122
123private:
125 boost::function<double(const double a, const double b)> minQualityFunction;
126
127 bool successMerge; ///< True if marge is success
128 bool errorIfNoCommonEdge; ///< Send error if no common edge
129
130 /**
131 * \brief Calualte quality if nodes merged
132 * @param check_tests tets to check
133 * @param father first node of the edge
134 * @param mother second node of the edge
135 * @param coords_move moved father node
136 * @param min_quality calculated quality
137 * @return error code
138 */
140 minQuality(Range &check_tests, EntityHandle father, EntityHandle mother,
141 double *coords_move, double &min_quality, Tag th = NULL,
142 boost::function<double(double, double)> f =
143 [](double a, double b) -> double { return std::min(a, b); });
144
145 /**
146 * \brief Use bisection method to find point of edge collapse
147 * @param check_tests range of tets to check quality
148 * @param father first node of the edge
149 * @param mother second node of the edge
150 * @param line_search number of iterations
151 * @param coords_move node to move
152 * @return error code
153 */
154 MoFEMErrorCode lineSearch(Range &check_tests, EntityHandle father,
155 EntityHandle mother, int line_search,
156 FTensor::Tensor1<double, 3> &t_move, Tag th = NULL);
157
159
160 struct FaceMap {
163 : e(e), n0(n0), n1(n1) {}
164 };
165
166 typedef multi_index_container<
167 FaceMap, indexed_by<hashed_unique<composite_key<
168 FaceMap, member<FaceMap, EntityHandle, &FaceMap::n0>,
169 member<FaceMap, EntityHandle, &FaceMap::n1>>>>>
171
172};
173
174} // namespace MoFEM
175
176#endif //__NODE_MERGER_HPP__
177
178/**
179 * \defgroup mofem_node_merger NodeMerger
180 * \brief Node merger interface
181 *
182 * \ingroup mofem
183 */
184
185
constexpr double a
auto bit
set bit
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
Core (interface) class.
Definition: Core.hpp:82
FaceMap(const EntityHandle e, const EntityHandle n0, const EntityHandle n1)
Definition: NodeMerger.hpp:162
ParentChild(const EntityHandle parent, const EntityHandle child)
Definition: NodeMerger.hpp:105
Merge node by collapsing edge between them.
Definition: NodeMerger.hpp:18
multi_index_container< ParentChild, indexed_by< ordered_unique< member< ParentChild, EntityHandle, &ParentChild::pArent > >, ordered_non_unique< member< ParentChild, EntityHandle, &ParentChild::cHild > > > > ParentChildMap
Definition: NodeMerger.hpp:115
ParentChildMap parentChildMap
Definition: NodeMerger.hpp:158
MoFEMErrorCode minQuality(Range &check_tests, EntityHandle father, EntityHandle mother, double *coords_move, double &min_quality, Tag th=NULL, boost::function< double(double, double)> f=[](double a, double b) -> double { return std::min(a, b);})
Calualte quality if nodes merged.
Definition: NodeMerger.cpp:339
bool successMerge
True if marge is success.
Definition: NodeMerger.hpp:127
boost::function< double(const double a, const double b)> minQualityFunction
Definition: NodeMerger.hpp:125
bool getSuccessMerge()
Return true if successful merge.
Definition: NodeMerger.hpp:31
MoFEMErrorCode mergeNodes(EntityHandle father, EntityHandle mother, Range &out_tets, Range *tets_ptr=NULL, const bool only_if_improve_quality=false, const double move=0, const int line_search=0, Tag th=NULL, const int verb=0)
merge nodes which sharing edge
Definition: NodeMerger.cpp:37
bool errorIfNoCommonEdge
Send error if no common edge.
Definition: NodeMerger.hpp:128
MoFEMErrorCode getSubInterfaceOptions()
Definition: NodeMerger.cpp:24
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: NodeMerger.cpp:10
multi_index_container< FaceMap, indexed_by< hashed_unique< composite_key< FaceMap, member< FaceMap, EntityHandle, &FaceMap::n0 >, member< FaceMap, EntityHandle, &FaceMap::n1 > > > > > FaceMapIdx
Definition: NodeMerger.hpp:170
void setErrorIfNoCommonEdge(const bool b=true)
Set error if no common edge.
Definition: NodeMerger.hpp:37
MoFEMErrorCode lineSearch(Range &check_tests, EntityHandle father, EntityHandle mother, int line_search, FTensor::Tensor1< double, 3 > &t_move, Tag th=NULL)
Use bisection method to find point of edge collapse.
Definition: NodeMerger.cpp:403
ParentChildMap & getParentChildMap()
Get map of parent cand child.
Definition: NodeMerger.hpp:121
base class for all interface classes