BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_CutProcessor.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 CL_COHOMOLOGYPROCESSOR_HPP
13#define CL_COHOMOLOGYPROCESSOR_HPP
14
15#include "typedefs.hpp"
16#include "cl_Cell.hpp"
17#include "cl_Vector.hpp"
18#include "cl_Map.hpp"
19#include "cl_OrderedMap.hpp"
20#include "cl_DynamicBitset.hpp"
21#include "cl_Mesh.hpp"
22#include "cl_Cohomology.hpp"
23#include "cl_CutData.hpp"
24#include "cl_CutSet.hpp"
25
26namespace belfem
27{
28 namespace mesh
29 {
30
38 {
39 Mesh * mMesh ;
40 bool mIs2D ;
41
42 const uint mNumberOfDimensions ;
43 const uint mNumberOfCuts ;
44 const ElementType mElementType ;
45
46 Vector< id_t > mPhiBlocks ;
47 Vector< id_t > mNonPhiBlocks ;
48
50 Cell< Element * > mElements ;
51
53 Cell< Edge * > mCohomologyEdges ;
54
55 Cell< DynamicBitset * > mCohomologyEdgesPlus ;
56 Cell< DynamicBitset * > mCohomologyEdgesMinus ;
57
58 Vector< id_t > mPhiBoundaries ;
59 Vector< id_t > mPhiBoundariesAndPeriodic ;
60
62 Cell< Node * > mNodes ;
63
65 Cell< CutData * > mCutData ;
66
71
73 Cell< string > mPatterns ;
74
76 id_t mMaxElementID ;
77
79 id_t mMaxNodeID ;
80
82 id_t mMaxSidesetID ;
83
85 Cell< Node * > mAbstractNodes ;
86
87 // for more efficient bitset identification
89
90//-----------------------------------------------------------------------------
91 public:
92//-----------------------------------------------------------------------------
93
95 Mesh * aMesh,
96 Cohomology * aCohomology,
97 const Vector< id_t > & aPhiBlocks,
98 const Vector< id_t > & aNonPhiBlocks,
99 const Vector< id_t > & aPhiInterfaces,
100 const Vector< id_t > & aPhiBoundaries,
101 const Vector< id_t > & aPhiPeriodic );
102
104
105
108
109 id_t
110 max_node_id();
111
112 id_t
114
115 void
117
118//-----------------------------------------------------------------------------
119 private:
120//-----------------------------------------------------------------------------
121
122 void
123 create_thin_cut_sidesets();
124
125//-----------------------------------------------------------------------------
126
127 void
128 collect_elements();
129
130//-----------------------------------------------------------------------------
131
132 void
133 collect_edges();
134
135//-----------------------------------------------------------------------------
136
137 void
138 collect_facets();
139
140//-----------------------------------------------------------------------------
141
142 void
143 compute_edge_bitsets();
144
145//-----------------------------------------------------------------------------
146
147 void
148 compute_node_bitsets();
149
150//-----------------------------------------------------------------------------
151
152 void
153 collect_nodes();
154
155//-----------------------------------------------------------------------------
156
157 void
158 determine_cut_sets();
159
160//-----------------------------------------------------------------------------
161
162 index_t
163 pattern_index( const DynamicBitset * aBitset );
164
165//-----------------------------------------------------------------------------
166
167 void
168 create_abstract_nodes();
169
170//-----------------------------------------------------------------------------
171
172 void
173 create_cut_sets();
174
175//-----------------------------------------------------------------------------
176
177 void
178 flip_node_bitsets_tri3(
179 Element * aElement,
180 Cell< DynamicBitset * > & aBitsets );
181
182 void
183 check_edges_tri3(
184 Element * aElement,
185 Cell< DynamicBitset * > & aBitsets );
186
187//-----------------------------------------------------------------------------
188
189 void
190 flip_node_bitsets_tri6(
191 Element * aElement,
192 Cell< DynamicBitset * > & aBitsets );
193
194 void
195 check_edges_tri6(
196 Element * aElement,
197 Cell< DynamicBitset * > & aBitsets );
198
199//-----------------------------------------------------------------------------
200
201 void
202 flip_node_bitsets_tet4(
203 Element * aElement,
204 Cell< DynamicBitset * > & aBitsets );
205
206 void
207 check_edges_tet4(
208 Element * aElement,
209 Cell< DynamicBitset * > & aBitsets );
210
211//-----------------------------------------------------------------------------
212
213 void
214 flip_node_bitsets_tet10(
215 Element * aElement,
216 Cell< DynamicBitset * > & aBitsets );
217
218 void
219 check_edges_tet10(
220 Element * aElement,
221 Cell< DynamicBitset * > & aBitsets );
222
223 void
224 check_node_bitsets( Cell< DynamicBitset * > & aBitsets );
225
226//-----------------------------------------------------------------------------
227
228 void
229 check_edge(
230 Element * aElement,
231 const uint aEdgeIndex,
232 const uint aMinusNodeIndex,
233 const uint aPlusNodeIndex,
234 Cell< DynamicBitset * > & aBitsets );
235
236//-----------------------------------------------------------------------------
237
238 void
239 check_midside(
240 const uint aMinusNodeIndex,
241 const uint aPlusNodeIndex,
242 const uint aMidsideNodeIndex,
243 Cell< DynamicBitset * > & aBitsets );
244
245//-----------------------------------------------------------------------------
246
247 void
248 duplicate_nodes();
249
250//-----------------------------------------------------------------------------
251
252
253//-----------------------------------------------------------------------------
254
255 void
256 relink_elements();
257
258//-----------------------------------------------------------------------------
259
260 void
261 relink_element( Element * aElement,
262 Cell< DynamicBitset * > & aBitsets );
263
264//-----------------------------------------------------------------------------
265
266 void
267 collect_duplicates();
268
269//-----------------------------------------------------------------------------
270 };
271
272 inline Cell< Node * > &
274 {
275 return mAbstractNodes;
276 }
277
278//-----------------------------------------------------------------------------
279
280 inline id_t
282 {
283 return mMaxNodeID;
284 }
285
286//-----------------------------------------------------------------------------
287
288 inline id_t
290 {
291 return mMaxSidesetID;
292 }
293
294//-----------------------------------------------------------------------------
295
296
297 inline void
298 CutProcessor::check_edge(
299 Element * aElement,
300 const uint aEdgeIndex,
301 const uint aMinusNodeIndex,
302 const uint aPlusNodeIndex,
303 Cell< DynamicBitset * > & aBitsets )
304 {
305
306
307 if ( ! aElement->edge( aEdgeIndex )->is_flagged() ) return ;
308
309 for ( uint c=0; c<mNumberOfCuts; ++c )
310 {
311 int tValue = mCutData( c )->weight( aElement->edge( aEdgeIndex ) ) ;
312
313 if ( aElement->edge_direction( aEdgeIndex ) == mIs2D ) tValue *= -1 ;
314
315 if ( tValue == 1 )
316 {
317 if ( aElement->node( aPlusNodeIndex )->is_flagged() ) aBitsets( aPlusNodeIndex )->set( c ) ;
318 }
319 else if ( tValue == -1 )
320 {
321 if ( aElement->node( aMinusNodeIndex )->is_flagged() ) aBitsets( aMinusNodeIndex )->set( c ) ;
322 }
323 }
324 }
325
326//-----------------------------------------------------------------------------
327
328 inline void
329 CutProcessor::check_midside(
330 const uint aMinusNodeIndex,
331 const uint aPlusNodeIndex,
332 const uint aMidsideNodeIndex,
333 Cell< DynamicBitset * > & aBitsets )
334 {
335 if ( aBitsets( aPlusNodeIndex )->count() == 0 ) return ;
336 if ( aBitsets( aMinusNodeIndex )->count() == 0 ) return ;
337
338 for ( uint c=0; c<mNumberOfCuts; ++c )
339 {
340 if ( aBitsets( aPlusNodeIndex )->test( c ) and aBitsets( aMinusNodeIndex )->test( c ) )
341 {
342 aBitsets( aMidsideNodeIndex )->set( c );
343 }
344 }
345 }
346
347//-----------------------------------------------------------------------------
348
349
350 }
351}
352#endif //CL_COHOMOLOGYPROCESSOR_HPP
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
Runtime-sized bitset; one bit per flag, packed into 64-bit words.
Definition cl_DynamicBitset.hpp:33
Hash map (unordered key-value).
Definition cl_Map.hpp:75
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
Sorted map (ordered key-value).
Definition cl_OrderedMap.hpp:32
virtual bool is_flagged(const uint8_t aIndex=0) const
Definition cl_Graph_Vertex.hpp:293
Computes the cohomology groups H^k of a mesh complex.
Definition cl_Cohomology.hpp:37
void save_debug_meshes()
Definition cl_CutProcessor.cpp:130
CutProcessor(Mesh *aMesh, Cohomology *aCohomology, const Vector< id_t > &aPhiBlocks, const Vector< id_t > &aNonPhiBlocks, const Vector< id_t > &aPhiInterfaces, const Vector< id_t > &aPhiBoundaries, const Vector< id_t > &aPhiPeriodic)
Definition cl_CutProcessor.cpp:21
Cell< Node * > & abstract_nodes()
Definition cl_CutProcessor.hpp:273
id_t max_sideset_id()
Definition cl_CutProcessor.hpp:289
id_t max_node_id()
Definition cl_CutProcessor.hpp:281
Lagrange Element baseclass.
Definition cl_Element.hpp:35
virtual bool edge_direction(const uint aEdgeIndex) const
Definition cl_Element.hpp:570
Edge * edge(const uint aIndex) override
Definition cl_Element.hpp:278
Node * node(const uint aIndex) override
Definition cl_Element.hpp:254
const real c
speed of light in m/s ( exact ) http://physics.nist.gov/cgi-bin/cuu/Value?c
Definition constants.hpp:65
Definition cl_EF_EdgeFunction.hpp:24
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
ElementType
Element types.
Definition Mesh_Enums.hpp:27
uint32_t index_t
Definition typedefs.hpp:52
count
Definition test_twist_crosscheck.py:44