v0.16.3
Loading...
Searching...
No Matches
CGALInterface.hpp
Go to the documentation of this file.
1/** \file CGALInterface.hpp
2 * \brief Local MOAB point-set and CGAL Delaunay mesh transfer.
3 */
4#ifndef MOFEM_CGAL_INTERFACE_HPP
5#define MOFEM_CGAL_INTERFACE_HPP
6
7#include "CGALTools.hpp"
9
10namespace MoFEM {
11
12/** Each managed point set is selected by a nonzero BitRefLevel.
13 * Import constructs a Delaunay triangulation of the selected vertices; it
14 * does not preserve input tetrahedral connectivity, surfaces or meshsets.
15 * Export is additive and never deletes old entities. Use a fresh output level
16 * after changing the CGAL mesh. Mesh distribution is the caller's responsibility.
17 */
19 ~CGALInterface() override = default;
20
21 virtual CGALTools &getTools() = 0;
22
23 /** Local indexed mesh transfer. An empty vertexIds list requests fresh local
24 * IDs and new vertices, even where another mesh has coincident points.
25 * Supplied global vertex IDs are preserved; vertices
26 * and matching simplices already in MOAB are reused. No ancestry is inferred.
27 * CGAL reads only corner connectivity. Matching higher-order MOAB entities
28 * retain their attached nodes; returned closure contains topological nodes.
29 * Exterior faces are oriented with sense +1 relative to the complete output
30 * bit level, including consistent reordering of higher-order edge nodes.
31 * Internal faces retain their connectivity. Newly created entities are linear.
32 * Labels are stored on returned volume/boundary meshsets (zero if absent).
33 * The caller owns these containers. Distributed callers must provide
34 * coordinated global IDs; local allocation does not identify shared copies.
35 */
37 Range &entities, EntityHandle &volume,
38 EntityHandle &surface) = 0;
39 virtual MoFEMErrorCode exportMesh(const Range &cells, TetMeshData &data) = 0;
40
41 /** Remesh selected tetrahedra within the complete source mesh.
42 * Supply protected faces/edges/fixed vertices in source_entities. Adjacent
43 * unselected cells may change to retain conformity. Returns the entire output
44 * closure on a fresh bit; source coordinates and levels are retained.
45 * Transfers registered meshset membership using region/patch/curve labels.
46 * CGAL 6.2 recovers a constrained supporting triangulation for non-convex
47 * domains and cavities. Neighbouring cells may be subdivided for conformity;
48 * communication and solution transfer belong to the caller.
49 * A zero settings.targetEdgeLength performs constraint recovery only,
50 * retaining all source corner coordinates and IDs and allowing Steiner
51 * additions, without isotropic remeshing or a quality-improvement gate.
52 * \code
53 * Range source = cells;
54 * source.merge(crack_faces);
55 * CGALTools::RemeshSettings settings;
56 * settings.targetEdgeLength = .1;
57 * CGALTools::RemeshReport report;
58 * CHKERR bridge->remesh(source, selected_cells, BitRefLevel().set(1),
59 * output, settings, report);
60 * \endcode
61 */
62 virtual MoFEMErrorCode remesh(const Range &source_entities,
63 const Range &selected_cells,
64 BitRefLevel output_bit, Range &entities,
67
68 /** Reconstruct selected tetrahedra and preserve supplied lower-dimensional
69 * source_entities. Cell closure is derived internally. Surface patches retain
70 * topology and vertex IDs; getTools().surfaceFlipAngle controls reconnection
71 * across adjacent facet planes (degrees, 0 is flat). Explicit
72 * edges retain their curve support. Exterior nodes and feature boundaries
73 * are always preserved; a nonzero angle allows piecewise-planar shape changes.
74 * Volume meshset classification must be uniform on selected cells. Unsupported
75 * constraint recovery fails before import, except disconnected reconstructed
76 * surface vertex links: these warn and retain the available patch for inspection.
77 * ConstrainedStrict (CGAL 6.2) instead recovers exact PLC surfaces and removes
78 * outside cells, allowing non-convex domains. Exactly planar simple patches
79 * of equal classification may reconnect; the flip angle is unused. Added
80 * points or patch defects reject the call; no inspection exception or
81 * fallback applies to this method. All corner coordinates and IDs survive.
82 * Records topological ancestry;
83 * call MeshsetsManager to add children to meshsets.
84 * Failure removes newly created entities and leaves output_bit available.
85 * \code
86 * Range selected = cells;
87 * selected.merge(crack_faces);
88 * CHKERR bridge->reconstructDelaunay(selected, BitRefLevel().set(1), output);
89 * \endcode
90 */
91 virtual MoFEMErrorCode
92 reconstructDelaunay(const Range &source_entities, BitRefLevel output_bit,
93 Range &entities,
96
97 /** Crack growth on the managed levels: extension by one face, gap
98 * closure, joins and notch fill. Obtained from getCrackExtension(); the
99 * interface owns it. One rank. See
100 * doc/development/cgal_crack_extension_algorithm.md.
101 */
103 virtual ~CrackExtension() = default;
104
105 /** Front edge and extension direction for extendCrack. */
107 EntityHandle edge = 0;
108 std::array<double, 3> direction{0, 0, 0};
109 };
110
111 /** Extend the crack by one face and publish the result on output_bit.
112 * source_bit selects the current tetrahedra (any other bits allowed) and is
113 * not modified; output_bit must be distinct and unoccupied. Requests are
114 * tried in order; the first front edge with an admissible candidate (see
115 * CGALTools::crackExtensionCandidates) is extended. The patch holds the
116 * settings.ringLimit vertex rings of source cells around the edge. Body
117 * skin, the highest-dimensional members of registered meshsets and the
118 * supplied constraints (faces, curve edges, fixed vertices) are protected;
119 * volume meshsets label cells, so no flip crosses a material interface.
120 * Unchanged entities gain output_bit. Removed entities stay on source_bit
121 * as parents. A moved node becomes a new vertex with a fresh GLOBAL_ID whose
122 * parent is the source vertex, so its whole star is recreated. Created
123 * entities get representative topological parents. closure_faces returns
124 * the faces that closed non-convex front corners in the same step. The
125 * caller adds new_face and closure_faces to the crack meshset and updates
126 * other meshsets from children.
127 * new_face is zero and output_bit stays unused when no request succeeds.
128 * Failure removes created entities and leaves output_bit unused. One rank.
129 */
130 virtual MoFEMErrorCode
131 extendCrack(BitRefLevel source_bit, BitRefLevel output_bit,
132 const Range &crack_faces, const Range &constraints,
133 const std::vector<CrackFrontRequest> &requests,
135 Range &entities, EntityHandle &new_face,
136 CGALTools::CrackExtensionCandidate *applied = nullptr,
138 Range *closure_faces = nullptr) = 0;
139
140 /** Close a gap at a front edge whose closing face is missing, by
141 * CGALTools::crackClosureCandidates, and publish it as extendCrack does.
142 * Same arguments and contract as extendCrack. One rank.
143 */
144 virtual MoFEMErrorCode
145 closeCrackGap(BitRefLevel source_bit, BitRefLevel output_bit,
146 const Range &crack_faces, const Range &constraints,
147 const std::vector<CrackFrontRequest> &requests,
149 Range &entities, EntityHandle &new_face,
150 CGALTools::CrackExtensionCandidate *applied = nullptr,
152 Range *closure_faces = nullptr) = 0;
153
154 /** Join by recovering a face with flips, using
155 * CGALTools::crackJoiningCandidates. Same level, ancestry, rollback and
156 * protection contract as extendCrack; no vertex moves. */
157 virtual MoFEMErrorCode
158 joinCrack(BitRefLevel source_bit, BitRefLevel output_bit,
159 const Range &crack_faces, const Range &constraints,
160 const std::vector<CrackFrontRequest> &requests,
162 Range &entities, EntityHandle &new_face,
163 CGALTools::CrackExtensionCandidate *applied = nullptr,
165 Range *closure_faces = nullptr) = 0;
166
167 /** Faces on bit that join the crack front to the existing crack, by
168 * CGALTools::crackJoinFaces with the protection rules of extendCrack. No
169 * node moves and no topology changes; missing face entities are created
170 * on bit. categories, if given, receives the category of each face in the
171 * order of join_faces' creation. The caller adds join_faces to the crack
172 * meshset. With front_order, return one join at the first eligible listed
173 * edge and optionally its handle in selected_front. gaps_only restricts
174 * selection to faces sharing at least two crack edges. One rank.
175 */
177 BitRefLevel bit, const Range &crack_faces, const Range &constraints,
178 Range &join_faces, std::vector<int> *categories = nullptr,
179 const std::vector<EntityHandle> &front_order = {},
180 EntityHandle *selected_front = nullptr, bool gaps_only = false) = 0;
181
182 /** Faces on bit that close notches of the crack front, by
183 * CGALTools::crackFillFaces with the protection rules of extendCrack.
184 * No topology changes; missing face entities are created on bit. The
185 * caller adds fill_faces to the crack meshset. One rank.
186 */
187 virtual MoFEMErrorCode crackFill(BitRefLevel bit, const Range &crack_faces,
188 const Range &constraints,
189 Range &fill_faces) = 0;
190
191 /** While a scope is alive, the searches (extendCrack, closeCrackGap,
192 * joinCrack, crackJoin and crackFill) reuse the level's cells, the
193 * protection classification and the patches between calls with the same
194 * level, crack faces and constraints. Open a scope only around calls
195 * between which nothing but this interface changes the mesh,
196 * coordinates, meshsets or bit levels; this interface forgets the reused
197 * data whenever it changes the mesh. Scopes nest. CgalCrackGrowth opens
198 * one for the searches of each step. */
211
212 protected:
213 virtual void openSearchCache() = 0; ///< See SearchCacheScope.
214 virtual void closeSearchCache() = 0; ///< See SearchCacheScope.
215 };
216
218
219 /** Retire an inactive level: delete entities whose only level is bit,
220 * clearing parent references to them and removing them from meshsets, then
221 * clear bit from all remaining entities, so it can be reused. Fails if an
222 * entity on another level still uses a retired entity. One rank.
223 */
225
226 /** Replace the managed triangulation with the selected MOAB point set.
227 * Duplicate coordinates are rejected, rather than merging MOAB identities.
228 */
230 BitRefLevel mask = BitRefLevel().set(),
231 int verb = QUIET) = 0;
232
233 /** Export vertices and finite tetrahedra to output_bit. Unchanged vertices
234 * and matching tetrahedra are reused. New or moved vertices get new MOAB
235 * handles. If import selected a linear simplicial source mesh, new vertices
236 * are classified geometrically and MeshRefinement derives/stores ancestry.
237 * Export must then be a subdivision: missing or ambiguous parents are errors.
238 * A source containing only points supplies no higher-dimensional ancestry.
239 * Existing levels and meshsets are retained. Planar sets export vertices only.
240 */
242 BitRefLevel output_bit,
243 int verb = QUIET) = 0;
244
246 return cgalToMoab(bit, bit, verb);
247 }
248
249 /** Borrowed mesh, valid until this level is replaced or cleared.
250 * Include CGALInterfaceTypes.hpp to access its triangulation.
251 */
254 Range &vertices) const = 0;
256};
257
258template <>
260
261} // namespace MoFEM
262
263#endif
CGAL algorithms independent of the MoFEM/MOAB database.
Report & report
const Settings & settings
WorkMesh mesh
std::vector< int > vertices
std::unordered_map< int, NodeConstraint > constraints
std::vector< Cell > cells
MoFEM interface.
SearchCacheScope & operator=(const SearchCacheScope &)=delete
SearchCacheScope(const SearchCacheScope &)=delete
@ QUIET
auto bit
set bit
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
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
CGALInterface * createInterface< CGALInterface >(const MoFEM::Core &core)
virtual MoFEMErrorCode joinCrack(BitRefLevel source_bit, BitRefLevel output_bit, const Range &crack_faces, const Range &constraints, const std::vector< CrackFrontRequest > &requests, const CGALTools::CrackExtensionSettings &settings, Range &entities, EntityHandle &new_face, CGALTools::CrackExtensionCandidate *applied=nullptr, CGALTools::CrackExtensionReport *report=nullptr, Range *closure_faces=nullptr)=0
virtual MoFEMErrorCode closeCrackGap(BitRefLevel source_bit, BitRefLevel output_bit, const Range &crack_faces, const Range &constraints, const std::vector< CrackFrontRequest > &requests, const CGALTools::CrackExtensionSettings &settings, Range &entities, EntityHandle &new_face, CGALTools::CrackExtensionCandidate *applied=nullptr, CGALTools::CrackExtensionReport *report=nullptr, Range *closure_faces=nullptr)=0
virtual void openSearchCache()=0
See SearchCacheScope.
virtual MoFEMErrorCode crackFill(BitRefLevel bit, const Range &crack_faces, const Range &constraints, Range &fill_faces)=0
virtual void closeSearchCache()=0
See SearchCacheScope.
virtual MoFEMErrorCode crackJoin(BitRefLevel bit, const Range &crack_faces, const Range &constraints, Range &join_faces, std::vector< int > *categories=nullptr, const std::vector< EntityHandle > &front_order={}, EntityHandle *selected_front=nullptr, bool gaps_only=false)=0
virtual MoFEMErrorCode extendCrack(BitRefLevel source_bit, BitRefLevel output_bit, const Range &crack_faces, const Range &constraints, const std::vector< CrackFrontRequest > &requests, const CGALTools::CrackExtensionSettings &settings, Range &entities, EntityHandle &new_face, CGALTools::CrackExtensionCandidate *applied=nullptr, CGALTools::CrackExtensionReport *report=nullptr, Range *closure_faces=nullptr)=0
virtual MoFEMErrorCode getMesh(BitRefLevel bit, CGALMesh *&mesh)=0
MoFEMErrorCode cgalToMoab(BitRefLevel bit, int verb=QUIET)
virtual CrackExtension & getCrackExtension()=0
~CGALInterface() override=default
virtual CGALTools & getTools()=0
virtual MoFEMErrorCode clear(BitRefLevel bit)=0
virtual MoFEMErrorCode getLinkedVertices(BitRefLevel bit, Range &vertices) const =0
virtual MoFEMErrorCode remesh(const Range &source_entities, const Range &selected_cells, BitRefLevel output_bit, Range &entities, const CGALTools::RemeshSettings &settings, CGALTools::RemeshReport &report)=0
virtual MoFEMErrorCode importMesh(const TetMeshData &data, BitRefLevel bit, Range &entities, EntityHandle &volume, EntityHandle &surface)=0
virtual MoFEMErrorCode cgalToMoab(BitRefLevel source_bit, BitRefLevel output_bit, int verb=QUIET)=0
virtual MoFEMErrorCode reconstructDelaunay(const Range &source_entities, BitRefLevel output_bit, Range &entities, CGALTools::ReconstructionMethod method=CGALTools::ReconstructionMethod::PointDelaunay)=0
virtual MoFEMErrorCode moabToCgal(BitRefLevel bit, BitRefLevel mask=BitRefLevel().set(), int verb=QUIET)=0
virtual MoFEMErrorCode retireLevel(BitRefLevel bit)=0
virtual MoFEMErrorCode exportMesh(const Range &cells, TetMeshData &data)=0
Core (interface) class.
Definition Core.hpp:83
base class for all interface classes