BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_InterfaceProcessor.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_INTERFACEPROCESSOR_HPP
13#define CL_INTERFACEPROCESSOR_HPP
14
15#include "typedefs.hpp"
16#include "cl_Map.hpp"
17#include "cl_Cell.hpp"
18#include "cl_Vector.hpp"
19#include "cl_Mesh.hpp"
20#include "cl_DynamicBitset.hpp"
21#include "cl_Topology.hpp"
22
23namespace belfem
24{
25 namespace mesh
26 {
27 // how an interface set ties its duplicates to their originals
29 {
30 TieWeight1, // default (ferro-air, conductor-air, conductor-ferro): duplicate hangs on its original with weight 1 (viz split only)
31 Decouple // coil-touching: duplicate carries no sources, excluded from the solve
32 };
33
35 {
36 Mesh * mMesh ;
37
38 DynamicBitset * mBitset ;
39
40 Cell< Element * > mElements ;
41 Map< id_t, Node * > mOriginals ;
42
43 Map< id_t, Node * > mDuplicates ;
44 uint mNumberOfSideSets = 0 ;
45
47
48 // domain type of the master block of the first sideset's first facet
49 DomainType mMasterType = DomainType::UNDEFINED ;
50
51//-----------------------------------------------------------------------------
52 Cell< SideSet * > mSideSets ;
53//-----------------------------------------------------------------------------
54 public:
55//-----------------------------------------------------------------------------
56
57 InterfaceSet( Mesh * aMesh, const string aBitsetHex );
58
60
61 void
63
64 void
66
67 void
68 add_sideset( SideSet * aSideSet );
69
71 treatment() const ;
72
74 master_type() const ;
75
76 // a tie-weight set with conductor masters shares its copies
77 bool
78 shares_duplicates() const ;
79
80 void
82
88 void
89 duplicate_nodes( id_t & aMaxNodeID, Map< id_t, Node * > & aSharedDuplicates );
90
91 void
93
95 number_of_nodes() const ;
96
102 void
103 add_duplicates( index_t & aCount, Cell< Node * > & aDuplicates, Map< id_t, Node * > & aOriginalMap );
104
107
109 original_map();
110
111 };
112
114 {
115 Mesh * mMesh ;
116 Topology * mTopology ;
117
118 Cell< Node * > & mAbstractNodes ;
119
120 const uint mNumOriginalSidesets ;
121 id_t mMaxNodeID ;
122
123 DynamicBitset mIsAirBlock ;
124 DynamicBitset mIsFerroBlock ;
125
126 Map< id_t, index_t > mBlockIndices ;
128
129 // link sidesetr IDs to set
131
132 // one conductor-side copy per node, shared by every tie-weight
133 // set with conductor masters and keyed by the id of the node it
134 // duplicates; the mesh owns the copies
135 //
136 // Copy numbering: copies are allocated set by set, in the sets'
137 // order ( the sorted hex strings of the block-index bitsets, a
138 // fixed function of the mesh's block order ), and within a set
139 // in ascending id of the original; a shared copy is allocated by
140 // the first set that reaches the original. They are appended to
141 // the mesh in ascending copy id, which is the allocation order.
142 // Both follow from the block order, the set order and the
143 // original ids alone, never from the iteration order of a Map
144 Map< id_t, Node * > mSharedDuplicates ;
145
146//-----------------------------------------------------------------------------
147 public:
148//-----------------------------------------------------------------------------
149
151 Mesh * aMesh,
152 Topology * aTopology,
153 Cell< Node * > & aAbstractNodes,
154 const uint aNumOriginalSideSets,
155 const id_t aMaxNodeID );
156
158
159//-----------------------------------------------------------------------------
160 private:
161//-----------------------------------------------------------------------------
162
163 void
164 create_interface_sets();
165
166 // whether the interface at aFacet is one this processor
167 // duplicates: a slave exists, the two sides are not both air,
168 // and one side is air or ferro
169 bool
170 duplicates_at( Facet * aFacet ) const ;
171
172 // every sideset with a facet this processor duplicates at must
173 // have masters of one domain type on all its facets that have a
174 // slave; runs before any sideset is admitted and before any copy
175 // is allocated
176 void
177 refuse_mixed_master_types() const ;
178
179 void
180 connect_sidesets_to_interface_sets();
181
182 void
183 populate_interface_sets();
184
185 void
186 duplicate_nodes();
187
188 void
189 pair_cross_set_periodic_duplicates();
190
191 void
192 relink_elements();
193
194 void
195 add_duplicate_nodes_to_mesh();
196
197 void
198 unify_duplicates( Cell< Node * > & aDuplicates );
199
200 bool
201 pair_within( InterfaceSet * aSet, InterfaceSet * aOther ) const ;
202
203 // aSet holds a copy of aNode but no admitted set holds a copy of
204 // its periodic partner aPartner; aOtherType and aOtherTreatment
205 // are the excluded sets that hold one, or nullptr. Always refuses
206 void
207 refuse_unpaired_periodic_copy( InterfaceSet * aSet,
208 Node * aNode,
209 Node * aPartner,
210 InterfaceSet * aOtherType,
211 InterfaceSet * aOtherTreatment ) const ;
212
213 };
214
215 inline InterfaceTreatment
217 {
218 return mTreatment ;
219 }
220
221 inline DomainType
223 {
224 return mMasterType ;
225 }
226
227 inline bool
229 {
230 return mTreatment == InterfaceTreatment::TieWeight1 && mMasterType == DomainType::Conductor ;
231 }
232
233 inline Map< id_t, Node * > &
235 {
236 return mDuplicates ;
237 }
238
239 inline Map< id_t, Node * > &
241 {
242 return mOriginals ;
243 }
244
245 }
246}
247#endif //CL_INTERFACEPROCESSOR_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
Definition cl_Facet.hpp:24
InterfaceProcessor(Mesh *aMesh, Topology *aTopology, Cell< Node * > &aAbstractNodes, const uint aNumOriginalSideSets, const id_t aMaxNodeID)
Definition cl_InterfaceProcessor.cpp:327
Definition cl_InterfaceProcessor.hpp:35
void collect_nodes_and_elements()
Definition cl_InterfaceProcessor.cpp:106
index_t number_of_nodes() const
Definition cl_InterfaceProcessor.cpp:304
void allocate_sideset_container()
Definition cl_InterfaceProcessor.cpp:93
Map< id_t, Node * > & original_map()
Definition cl_InterfaceProcessor.hpp:240
void increment_sideset_counter()
Definition cl_InterfaceProcessor.cpp:87
void duplicate_nodes(id_t &aMaxNodeID, Map< id_t, Node * > &aSharedDuplicates)
takes the copy of each collected node from aSharedDuplicates, keyed by the node's own id,...
Definition cl_InterfaceProcessor.cpp:201
Map< id_t, Node * > & duplicate_map()
Definition cl_InterfaceProcessor.hpp:234
bool shares_duplicates() const
Definition cl_InterfaceProcessor.hpp:228
void add_duplicates(index_t &aCount, Cell< Node * > &aDuplicates, Map< id_t, Node * > &aOriginalMap)
a set with private copies appends them to aDuplicates; a tie-weight set registers the original of eac...
Definition cl_InterfaceProcessor.cpp:310
InterfaceSet(Mesh *aMesh, const string aBitsetHex)
Definition cl_InterfaceProcessor.cpp:64
DomainType master_type() const
Definition cl_InterfaceProcessor.hpp:222
void relink_elements()
Definition cl_InterfaceProcessor.cpp:277
InterfaceTreatment treatment() const
Definition cl_InterfaceProcessor.hpp:216
void add_sideset(SideSet *aSideSet)
Definition cl_InterfaceProcessor.cpp:100
Definition cl_Node.hpp:30
Definition cl_SideSet.hpp:29
Analyzes and classifies mesh topology for finite element simulations.
Definition cl_Topology.hpp:44
Definition cl_EF_EdgeFunction.hpp:24
InterfaceTreatment
Definition cl_InterfaceProcessor.hpp:29
@ TieWeight1
Definition cl_InterfaceProcessor.hpp:30
@ Decouple
Definition cl_InterfaceProcessor.hpp:31
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
uint32_t index_t
Definition typedefs.hpp:52
DomainType
Definition en_DomainType.hpp:20
@ UNDEFINED
Definition en_DomainType.hpp:80
@ Conductor
Definition en_DomainType.hpp:31