BELFEM 0.9.0
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 //void
253 //flip_node_bitsets();
254
255//-----------------------------------------------------------------------------
256
257 void
258 relink_elements();
259
260//-----------------------------------------------------------------------------
261
262 void
263 relink_element( Element * aElement,
264 Cell< DynamicBitset * > & aBitsets );
265
266//-----------------------------------------------------------------------------
267
268 void
269 collect_duplicates();
270
271//-----------------------------------------------------------------------------
272 };
273
274 inline Cell< Node * > &
276 {
277 return mAbstractNodes;
278 }
279
280//-----------------------------------------------------------------------------
281
282 inline id_t
284 {
285 return mMaxNodeID;
286 }
287
288//-----------------------------------------------------------------------------
289
290 inline id_t
292 {
293 return mMaxSidesetID;
294 }
295
296//-----------------------------------------------------------------------------
297
298
299 inline void
300 CutProcessor::check_edge(
301 Element * aElement,
302 const uint aEdgeIndex,
303 const uint aMinusNodeIndex,
304 const uint aPlusNodeIndex,
305 Cell< DynamicBitset * > & aBitsets )
306 {
307
308
309 if ( ! aElement->edge( aEdgeIndex )->is_flagged() ) return ;
310
311 for ( uint c=0; c<mNumberOfCuts; ++c )
312 {
313 int tValue = mCutData( c )->weight( aElement->edge( aEdgeIndex ) ) ;
314
315 if ( aElement->edge_direction( aEdgeIndex ) == mIs2D ) tValue *= -1 ;
316
317 if ( tValue == 1 )
318 {
319 if ( aElement->node( aPlusNodeIndex )->is_flagged() ) aBitsets( aPlusNodeIndex )->set( c ) ;
320 }
321 else if ( tValue == -1 )
322 {
323 if ( aElement->node( aMinusNodeIndex )->is_flagged() ) aBitsets( aMinusNodeIndex )->set( c ) ;
324 }
325 }
326 }
327
328//-----------------------------------------------------------------------------
329
330 inline void
331 CutProcessor::check_midside(
332 const uint aMinusNodeIndex,
333 const uint aPlusNodeIndex,
334 const uint aMidsideNodeIndex,
335 Cell< DynamicBitset * > & aBitsets )
336 {
337 if ( aBitsets( aPlusNodeIndex )->count() == 0 ) return ;
338 if ( aBitsets( aMinusNodeIndex )->count() == 0 ) return ;
339
340 for ( uint c=0; c<mNumberOfCuts; ++c )
341 {
342 if ( aBitsets( aPlusNodeIndex )->test( c ) and aBitsets( aMinusNodeIndex )->test( c ) )
343 {
344 aBitsets( aMidsideNodeIndex )->set( c );
345 }
346 }
347 }
348
349//-----------------------------------------------------------------------------
350
351
352 }
353}
354#endif //CL_COHOMOLOGYPROCESSOR_HPP
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
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:132
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:275
id_t max_sideset_id()
Definition cl_CutProcessor.hpp:291
id_t max_node_id()
Definition cl_CutProcessor.hpp:283
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:17
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:35