BELFEM 0.9.3
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 ;
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 Cell< SideSet * > mCuts ;
59
60 // owned: each holds the original facets of a thin-shell sideset
61 // between duplicate_and_relink_facets() and the restore, and
62 // deletes them with itself. A restored slot is nullptr
63 Cell< SideSet * > mTemporaryThinShellSidesets ;
64
65 //Cell<Cell< id_t >> mCurrentTerminals ;
66 Cell<Cell< id_t >> mTerminals ;
67 Cell< id_t > mThinShellIndices; //Indices of thin shell terminals in mTerminals ;
68
69 Vector< id_t> mOuterBoundaries ;
70
71 SimplicialComplex * mSimplicialComplex = nullptr ;
72 Cohomology * mCohomology = nullptr ;
73 Homology * mRelativeHomology = nullptr ;
74
75
76 Cell< Node * > mThinShellDuplicates ;
77 Cell< Node * > mThinShellMasterNodes ;
78 Cell< Node * > mThinShellSlaveNodes ;
79
80 Map< id_t, Vector< index_t > * > mIndicesOfOriginalTerminalNodes ;
81
82 //Map< id_t, DynamicBitset * > mNodesOnOriginalTerminalSidesets ;
83
84 // this matrix lists the cuts based on the cohomologies
85 //Vector< id_t > mTriBlocks ;
86 //Vector< id_t > mTetBlocks ;
87 //Vector< id_t > mPyraBlocks ;
88
89 //Map< id_t, Element * > mElementMap ;
90 //Map< id_t, Node * > mNodeMap ;
91
92
93
94 // future user settings
95 bool mSuggestHomologies = true ; // this needs to be turned on for the incidence matrix to work!
96
97 // poisson gives prettier cuts, but is slower
98 bool mUsePoissonInsteadOfRcm = false ;
99
100
101//-----------------------------------------------------------------------------
102 public:
103//-----------------------------------------------------------------------------
104
106 Mesh * aMesh,
107 Topology * aTopology,
108 Cell< Protoshell * > & aProtoshells,
109 const CutAlgorithm aAlgorithm,
110 const bool aUseEnrichment );
111
112//-----------------------------------------------------------------------------
113
114 ~CutFactory();
115
116//-----------------------------------------------------------------------------
117
118 void
119 set_terminals( const Cell<Cell< id_t >> & aTerminals, const Cell<id_t> & aThinShellIndices );
120
121//-----------------------------------------------------------------------------
122
123 void
124 set_periodicity( PeriodicityFactory * aPeriodicFactory );
125
126//-----------------------------------------------------------------------------
127
128 void
129 run();
130
131//-----------------------------------------------------------------------------
132
133 // returns the abstract nodes that represent the dof for the cuts
136
137//-----------------------------------------------------------------------------
138
139 // returns the orphaned nodes if they exist
142
143//-----------------------------------------------------------------------------
144
146 cuts();
147
148//-----------------------------------------------------------------------------
149
150 bool
152
153//-----------------------------------------------------------------------------
154
155 void
157
158 void
160
161 void
163
164 void
166
167 void
169
170//-----------------------------------------------------------------------------
171
172 void
174
175 void
177 SideSet * aSideSet,
178 Vector< real > & aWorkA,
179 Vector< real > & aWorkB,
180 Vector< real > & aN );
181
195 void
197
198//-----------------------------------------------------------------------------
199
216 static void
218 Mesh * aMesh,
219 Cell< Protoshell * > & aShells,
220 const index_t aNumMeshCurves );
221
222//-----------------------------------------------------------------------------
223
241 static void
243 Curve * aCurve,
244 const Cell< Node * > & aDuplicates,
245 id_t & aMaxID );
246
247//-----------------------------------------------------------------------------
248
249 void
251
252//-----------------------------------------------------------------------------
253
254 inline Vector< id_t > &
256 {
257 return mThinShellBoundaryIDs ;
258 }
259
260//-----------------------------------------------------------------------------
261
264 {
265 return mTemporaryThinShellSidesets( aID )->facets();
266 }
267
268//-----------------------------------------------------------------------------
269
272 {
273 return mThinShellMasterNodes ;
274 }
275
276//-----------------------------------------------------------------------------
277
280 {
281 return mThinShellSlaveNodes ;
282 }
283
284//-----------------------------------------------------------------------------
285 private:
286//-----------------------------------------------------------------------------
287
288
289 void
290 link_node_duplicates_and_originals();
291
292//-----------------------------------------------------------------------------
293
294 void
295 collect_orphan_nodes();
296
297//-----------------------------------------------------------------------------
298 void
299 collect_nodes_and_elements_on_blocks(
300 const Vector< id_t > & aBlockIDs,
301 Cell< Element * > & aElements,
302 Cell< Node * > & aNodes );
303
304//-----------------------------------------------------------------------------
305
306 void
307 compute_rcm_problem();
308
309//-----------------------------------------------------------------------------
310
311 void
312 compute_cohomologies();
313
314//-----------------------------------------------------------------------------
315
316 void
317 compute_thin_cuts_and_duplicate_interface_nodes();
318
319//-----------------------------------------------------------------------------
320
321 void
322 restore_thin_shell_sidesets();
323
324//-----------------------------------------------------------------------------
325
326 void
327 write_debug_cohomology( Homology * aSuggestedHomology ) ;
328
329//-----------------------------------------------------------------------------
330
331 void
332 create_curves_for_thinshells();
333
334 void
335 create_side_curves_for_thinshells_3d();
336
337 void
338 collect_boundary_sidesets( Vector< id_t > & aIDs );
339
340//-----------------------------------------------------------------------------
341
343 check_element_types() ;
344
345//-----------------------------------------------------------------------------
346
347 // for debugging
348 void
349 save_edges( const uint aIndex );
350
351
352//-----------------------------------------------------------------------------
353
354 SideSet *
355 create_cut_sideset_2d(
356 const uint aIndex,
357 const ElementType aType,
358 Cell< Element * > & aElements,
359 const Vector< int > & aCases );
360
361//-----------------------------------------------------------------------------
362
363 SideSet *
364 create_cut_sideset_3d(
365 const uint aIndex,
366 const ElementType aType,
367 Cell< Element * > & aElements,
368 const Vector< int > & aCases );
369
370//-----------------------------------------------------------------------------
371
372
373 void
374 flag_nodes_and_facets_of_tape_sidesets( Cell< Node * > & aNodes ) ;
375
376//-----------------------------------------------------------------------------
377
378 Facet *
379 create_facet( Element * aElement, Cell< Element * > & aCandidates );
380
381//-----------------------------------------------------------------------------
382
383 bool
384 connect_facet_to_slave( Facet * aFacet );
385
386//-----------------------------------------------------------------------------
387
388 void
389 unflag_symmetry_sidesets();
390
391//-----------------------------------------------------------------------------
392
393 void
394 compute_element_adjacencies();
395
396//-----------------------------------------------------------------------------
397
398 void
399 compute_poisson_problem();
400
401 };
402 }
403}
404#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:255
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:271
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< SideSet * > & cuts()
Definition cl_CutFactory.cpp:2379
Cell< Facet * > & thin_shell_facets(const id_t aID)
Definition cl_CutFactory.hpp:263
Cell< Node * > & thin_shell_slave_nodes()
Definition cl_CutFactory.hpp:279
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:2572
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