BELFEM 0.9.4
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_CutFactory.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_CUTFACTORY_HPP
13#define BELFEM_CL_CUTFACTORY_HPP
14
15#include "commtools.hpp"
16#include "typedefs.hpp"
17#include "cl_Mesh.hpp"
19#include "cl_Cohomology.hpp"
20#include "cl_Homology.hpp"
21
22#include "en_CutAlgorithm.hpp"
24#include "cl_Topology.hpp"
26namespace belfem
27{
28 namespace mesh
29 {
30//-----------------------------------------------------------------------------
31
39 {
40 const proc_t mCommRank ;
41 Mesh * mMesh ;
42 id_t mMaxID = 0 ;
43
44 Topology * mTopology ;
45 PeriodicityFactory * mPeriodicFactory = nullptr ;
46 const Vector< id_t > & mThinShellSidesets ;
47
48 Cell< Node * > & mAbstractNodes ;
49 Cell< Node * > & mOrphanedNodes ;
50 Cell< Protoshell * > & mProtoshells ;
51
52 const CutAlgorithm mAlgorithm ;
53 const bool mUseEnrichment ;
54
55 Vector< id_t > mThinShellBoundaryIDs ;
56
57 Cell< SideSet * > mThinShellBoundaries ;
58
59 // owned: each holds the original facets of a thin-shell sideset
60 // between duplicate_and_relink_facets() and the restore, and
61 // deletes them with itself. A restored slot is nullptr
62 Cell< SideSet * > mTemporaryThinShellSidesets ;
63
64 //Cell<Cell< id_t >> mCurrentTerminals ;
65 Cell<Cell< id_t >> mTerminals ;
66 Cell< id_t > mThinShellIndices; //Indices of thin shell terminals in mTerminals ;
67
68 Vector< id_t> mOuterBoundaries ;
69
70 SimplicialComplex * mSimplicialComplex = nullptr ;
71 Cohomology * mCohomology = nullptr ;
72 Homology * mRelativeHomology = nullptr ;
73
74
75 Cell< Node * > mThinShellDuplicates ;
76 Cell< Node * > mThinShellMasterNodes ;
77 Cell< Node * > mThinShellSlaveNodes ;
78
79 Map< id_t, Vector< index_t > * > mIndicesOfOriginalTerminalNodes ;
80
81 //Map< id_t, DynamicBitset * > mNodesOnOriginalTerminalSidesets ;
82
83 // this matrix lists the cuts based on the cohomologies
84 //Vector< id_t > mTriBlocks ;
85 //Vector< id_t > mTetBlocks ;
86 //Vector< id_t > mPyraBlocks ;
87
88 //Map< id_t, Element * > mElementMap ;
89 //Map< id_t, Node * > mNodeMap ;
90
91
92
93 // future user settings
94 bool mSuggestHomologies = true ; // this needs to be turned on for the incidence matrix to work!
95
96 // poisson gives prettier cuts, but is slower
97 bool mUsePoissonInsteadOfRcm = false ;
98
99
100//-----------------------------------------------------------------------------
101 public:
102//-----------------------------------------------------------------------------
103
105 Mesh * aMesh,
106 Topology * aTopology,
107 Cell< Protoshell * > & aProtoshells,
108 const CutAlgorithm aAlgorithm,
109 const bool aUseEnrichment );
110
111//-----------------------------------------------------------------------------
112
113 ~CutFactory();
114
115//-----------------------------------------------------------------------------
116
117 void
118 set_terminals( const Cell<Cell< id_t >> & aTerminals, const Cell<id_t> & aThinShellIndices );
119
120//-----------------------------------------------------------------------------
121
122 void
123 set_periodicity( PeriodicityFactory * aPeriodicFactory );
124
125//-----------------------------------------------------------------------------
126
127 void
128 run();
129
130//-----------------------------------------------------------------------------
131
132 // returns the abstract nodes that represent the dof for the cuts
135
136//-----------------------------------------------------------------------------
137
138 // returns the orphaned nodes if they exist
141
142//-----------------------------------------------------------------------------
143
144 bool
146
147//-----------------------------------------------------------------------------
148
149 void
151
152 void
154
155 void
157
158 void
160
161 void
163
164//-----------------------------------------------------------------------------
165
166 void
168
169 void
171 SideSet * aSideSet,
172 Vector< real > & aWorkA,
173 Vector< real > & aWorkB,
174 Vector< real > & aN );
175
189 void
191
192//-----------------------------------------------------------------------------
193
210 static void
212 Mesh * aMesh,
213 Cell< Protoshell * > & aShells,
214 const index_t aNumMeshCurves );
215
216//-----------------------------------------------------------------------------
217
235 static void
237 Curve * aCurve,
238 const Cell< Node * > & aDuplicates,
239 id_t & aMaxID );
240
241//-----------------------------------------------------------------------------
242
243 void
245
246//-----------------------------------------------------------------------------
247
248 inline Vector< id_t > &
250 {
251 return mThinShellBoundaryIDs ;
252 }
253
254//-----------------------------------------------------------------------------
255
258 {
259 return mTemporaryThinShellSidesets( aID )->facets();
260 }
261
262//-----------------------------------------------------------------------------
263
266 {
267 return mThinShellMasterNodes ;
268 }
269
270//-----------------------------------------------------------------------------
271
274 {
275 return mThinShellSlaveNodes ;
276 }
277
278//-----------------------------------------------------------------------------
279 private:
280//-----------------------------------------------------------------------------
281
282
283 void
284 link_node_duplicates_and_originals();
285
286//-----------------------------------------------------------------------------
287
288 void
289 collect_orphan_nodes();
290
291//-----------------------------------------------------------------------------
292 void
293 collect_nodes_and_elements_on_blocks(
294 const Vector< id_t > & aBlockIDs,
295 Cell< Element * > & aElements,
296 Cell< Node * > & aNodes );
297
298//-----------------------------------------------------------------------------
299
300 void
301 compute_rcm_problem();
302
303//-----------------------------------------------------------------------------
304
305 void
306 compute_cohomologies();
307
308//-----------------------------------------------------------------------------
309
310 void
311 compute_thin_cuts_and_duplicate_interface_nodes();
312
313//-----------------------------------------------------------------------------
314
315 void
316 restore_thin_shell_sidesets();
317
318//-----------------------------------------------------------------------------
319
320 void
321 write_debug_cohomology( Homology * aSuggestedHomology ) ;
322
323//-----------------------------------------------------------------------------
324
325 void
326 create_curves_for_thinshells();
327
328 void
329 create_side_curves_for_thinshells_3d();
330
331 void
332 collect_boundary_sidesets( Vector< id_t > & aIDs );
333
334//-----------------------------------------------------------------------------
335
337 check_element_types() ;
338
339//-----------------------------------------------------------------------------
340
341 // for debugging
342 void
343 save_edges( const uint aIndex );
344
345
346//-----------------------------------------------------------------------------
347
348 SideSet *
349 create_cut_sideset_2d(
350 const uint aIndex,
351 const ElementType aType,
352 Cell< Element * > & aElements,
353 const Vector< int > & aCases );
354
355//-----------------------------------------------------------------------------
356
357 SideSet *
358 create_cut_sideset_3d(
359 const uint aIndex,
360 const ElementType aType,
361 Cell< Element * > & aElements,
362 const Vector< int > & aCases );
363
364//-----------------------------------------------------------------------------
365
366
367 void
368 flag_nodes_and_facets_of_tape_sidesets( Cell< Node * > & aNodes ) ;
369
370//-----------------------------------------------------------------------------
371
372 Facet *
373 create_facet( Element * aElement, Cell< Element * > & aCandidates );
374
375//-----------------------------------------------------------------------------
376
377 bool
378 connect_facet_to_slave( Facet * aFacet );
379
380//-----------------------------------------------------------------------------
381
382 void
383 unflag_symmetry_sidesets();
384
385//-----------------------------------------------------------------------------
386
387 void
388 compute_element_adjacencies();
389
390//-----------------------------------------------------------------------------
391
392 void
393 compute_poisson_problem();
394
395 };
396 }
397}
398#endif //BELFEM_CL_CUTFACTORY_HPP
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
Hash map (unordered key-value).
Definition cl_Map.hpp:75
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
Computes the cohomology groups H^k of a mesh complex.
Definition cl_Cohomology.hpp:37
Definition cl_Curve.hpp:27
void set_periodicity(PeriodicityFactory *aPeriodicFactory)
Definition cl_CutFactory.cpp:103
Cell< Node * > & abstract_nodes()
Definition cl_CutFactory.cpp:2363
void orient_terminal_curves_sub(SideSet *aSideSet, Vector< real > &aWorkA, Vector< real > &aWorkB, Vector< real > &aN)
Definition cl_CutFactory.cpp:1813
void duplicate_and_relink_facets()
Definition cl_CutFactory.cpp:1485
Vector< id_t > & thin_shell_boundaries()
Definition cl_CutFactory.hpp:249
Cell< Node * > & orphaned_nodes()
Definition cl_CutFactory.cpp:2371
static void refuse_closed_side_curve_sharing_nodes(Mesh *aMesh, Cell< Protoshell * > &aShells, const index_t aNumMeshCurves)
Refuses a geometrically closed side curve of any shell in aShells that shares a node with a terminal ...
Definition cl_CutFactory.cpp:2013
Cell< Node * > & thin_shell_master_nodes()
Definition cl_CutFactory.hpp:265
void orient_terminal_curves()
Definition cl_CutFactory.cpp:1757
static void close_terminal_loop(Curve *aCurve, const Cell< Node * > &aDuplicates, id_t &aMaxID)
Closes one terminal curve into a loop.
Definition cl_CutFactory.cpp:1589
CutFactory(Mesh *aMesh, Topology *aTopology, Cell< Protoshell * > &aProtoshells, const CutAlgorithm aAlgorithm, const bool aUseEnrichment)
Definition cl_CutFactory.cpp:42
void duplicate_nodes_on_face_sidesets()
Definition cl_CutFactory.cpp:1181
void relink_non_thinshell_facets()
Definition cl_CutFactory.cpp:1537
void orient_terminal_curves_2D()
Gives every 2-D terminal curve the counter-clockwise sense about +z around its tape.
Definition cl_CutFactory.cpp:1853
void run()
Definition cl_CutFactory.cpp:111
void set_terminals(const Cell< Cell< id_t > > &aTerminals, const Cell< id_t > &aThinShellIndices)
Definition cl_CutFactory.cpp:95
Cell< Facet * > & thin_shell_facets(const id_t aID)
Definition cl_CutFactory.hpp:257
Cell< Node * > & thin_shell_slave_nodes()
Definition cl_CutFactory.hpp:273
void relink_slave_elements_with_duplicate_nodes()
Definition cl_CutFactory.cpp:1406
bool create_thin_shell_cuts()
Definition cl_CutFactory.cpp:1134
void close_terminal_loops()
Definition cl_CutFactory.cpp:1575
void save_curve_debug_meshes()
Definition cl_CutFactory.cpp:2564
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_Facet.hpp:24
Computes the homology groups H_k of a mesh complex.
Definition cl_Homology.hpp:36
Creates a Periodicity object by matching nodes on two periodic boundary planes.
Definition cl_Mesh_PeriodicityFactory.hpp:34
Definition cl_SideSet.hpp:29
Simplicial complex reduction engine underlying the homology and cohomology computation.
Definition cl_SimplicialComplex.hpp:37
Analyzes and classifies mesh topology for finite element simulations.
Definition cl_Topology.hpp:44
Definition cl_EF_EdgeFunction.hpp:24
CutAlgorithm
Definition en_CutAlgorithm.hpp:22
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
int proc_t
Definition commtypes.hpp:29
ElementType
Element types.
Definition Mesh_Enums.hpp:27
uint32_t index_t
Definition typedefs.hpp:52