BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_MaxwellFactory.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_MAXWELLFACTORY_HPP
13#define CL_MAXWELLFACTORY_HPP
14#include <en_CutAlgorithm.hpp>
15
16#include "typedefs.hpp"
17#include "cl_Map.hpp"
18#include "cl_Mesh.hpp"
19#include "en_DomainType.hpp"
20#include "cl_Vector.hpp"
21#include "cl_FEM_Kernel.hpp"
22#include "cl_IWG_Maxwell.hpp"
24#include "cl_InputFile.hpp"
25#include "cl_FEM_Domain.hpp"
26#include "cl_Topology.hpp"
27#include "cl_Protoshell.hpp"
28
29namespace belfem
30{
31 namespace fem
32 {
40 {
41
42 const proc_t mCommRank ;
43
44 const InputFile * mInputFile ;
45
46 // -- user settings
47
49
50 bool mSaveElementConnectivitiesToBfm = false ;
51 // --- end user settings
52 // deleted by kernel
53 bool mOwnKernelParameters = true ;
54 KernelParameters * mKernelParameters = nullptr ;
55
59 Mesh * mMesh = nullptr ;
60 bool mOwnMesh = true ;
61 string mMeshPath ;
62
63 bool mComputeCohomologies = true ;
64
66
68 bool mUseEnrichment = false ;
69
70 Vector< proc_t > mCommTable ;
71
72 uint mMeshDimension = 0 ;
73 uint mElementOrder = 0 ;
74
75 std::shared_ptr< Kernel > mMagneticKernel ;
76
77 IWG_Maxwell * mMagneticEquation = nullptr ;
78 bool mOwnMagneticEquation = true ;
79
80 DofManager * mMagneticField = nullptr ;
81 mesh::Topology * mTopology = nullptr ;
82
83 Cell< Domain * > mDomains ;
84
85 Cell< mesh::Curve * > mCurves ;
86
87 MaxwellBoundaryConditionFactory * mBoundaryConditionFactory = nullptr ;
88 mesh::PeriodicityFactory * mPeriodicFactory = nullptr ;
89
90 //Terminal information to send to the cut factory
91 Cell< Cell<id_t> > mTerminals;
92 Cell<id_t> mThinShellTerminalIndices ;
93
94 Map< id_t, string > mMaterialBlockAssignment ;
95
96 Vector< index_t > mHangingFacetIndices ;
97 Matrix< real > mHangingFacetTMatrices ;
98
99 Cell< Protoshell * > mProtoshells ;
100
101 Map< string, id_t > mMaterialIDs ;
102 Map<string, Material *> mMaterialMap ;
103
104 // these sidesets are the templates from which we create
105 // the thin shells
107 Map< id_t, mesh::ThinShell * > mThinShellMap ;
108
109 Cell< Cell< index_t > > mThinShellNodeIndices ;
110 Cell< mesh::Node * > mThinShellMasterNodes ;
111 Cell< mesh::Node * > mThinShellSlaveNodes ;
112
113 struct EdgeWorkData
114 {
115 Cell< mesh::Node * > NodesOnThinShell ;
116 Cell< mesh::Node * > NodesOnVolume ;
117
118 Cell< mesh::Edge * > EdgesOnThinShell ;
119 Cell< mesh::Edge * > EdgesOnVolume ;
120 };
121
122 string mLabel ;
123
124//------------------------------------------------------------------------------
125 public:
126//------------------------------------------------------------------------------
127
128 MaxwellFactory( const string & aInputFile );
129
131
132 // owns raw pointers ( the mesh until handover, input file,
133 // factories, topology ); a copy would double-delete them
134 MaxwellFactory( const MaxwellFactory & ) = delete ;
138
139 const string &
140 mesh_path() const ;
141
142//------------------------------------------------------------------------------
143
144 std::shared_ptr< Kernel >
146
147//------------------------------------------------------------------------------
148
149 std::shared_ptr< Controller >
151
152//------------------------------------------------------------------------------
153
154 Cell <PhysicalBoundaryCondition *> &
156
157//------------------------------------------------------------------------------
158
159 Cell <PhysicalBoundaryCondition *>
160 current_BCs() ;
161
162//------------------------------------------------------------------------------
163
164 Mesh *
165 mesh();
166
167//------------------------------------------------------------------------------
168
169 string
170 label() const ;
171
172//------------------------------------------------------------------------------
173
181 static bool
182 mu_is_mu0( const real aMu );
183
184//------------------------------------------------------------------------------
185 private:
186//------------------------------------------------------------------------------
187
188 Mesh *
189 read_mesh();
190
191//------------------------------------------------------------------------------
192
193 void
194 read_domain_types();
195
196//------------------------------------------------------------------------------
197
202 void
203 report_config_difference(
204 const string & aStored,
205 const string & aCurrent );
206
207//------------------------------------------------------------------------------
208
209 void
210 create_curves( const input::Section * aSection );
211
212//------------------------------------------------------------------------------
213
214 void
215 create_periodic( const input::Section * aSection );
216
217//------------------------------------------------------------------------------
218
220 create_equation( const maxwell::Formulation aFormulation );
221
222//------------------------------------------------------------------------------
223
224 void
225 set_block_types_in_magnetic_equation();
226
227//------------------------------------------------------------------------------
239 void
240 fix_facet_masters();
241
242//------------------------------------------------------------------------------
243
250 void
251 align_thin_shell_facets();
252
253//------------------------------------------------------------------------------
254
259 void
260 check_thin_shell_block_sides();
261
262//------------------------------------------------------------------------------
263
267 void
268 read_signed_sidesets(
269 const input::Section * aSection,
270 const string & aKey,
271 Protoshell * aShell );
272
273//------------------------------------------------------------------------------
274
279 void
280 flip_thin_shell_sidesets();
281
282//------------------------------------------------------------------------------
283
284 void
285 create_cuts();
286
287//------------------------------------------------------------------------------
288
289 void
290 create_cuts_sub_master();
291
292//------------------------------------------------------------------------------
293
294 void
295 set_block_and_sideset_names();
296
297//------------------------------------------------------------------------------
298
299 void
300 create_cuts_sub_slave();
301
302//------------------------------------------------------------------------------
303
304 void
305 create_thinshells();
306
307//------------------------------------------------------------------------------
308
309 void
310 create_terminal_list();
311
312//------------------------------------------------------------------------------
313
314 void
315 create_edges_and_faces_on_mesh();
316
317//------------------------------------------------------------------------------
318
319 void
320 create_hanging_edges_and_facets();
321
322//------------------------------------------------------------------------------
323
324 void
325 create_postprocessors();
326
327//------------------------------------------------------------------------------
328
329 void
330 init_fields();
331
332//------------------------------------------------------------------------------
333
334 void
335 configure_solver( const input::Section * aSection, DofManager * aField );
336
337//------------------------------------------------------------------------------
338
339 void
340 create_block_to_material_map();
341
342//------------------------------------------------------------------------------
343
344 void
345 collect_material_labels_from_domains( Vector< id_t > & aBlockIDs, Cell< string > & aMaterialLabels );
346
347//------------------------------------------------------------------------------
348
349 void
350 set_physical_tags_for_elements();
351
352//------------------------------------------------------------------------------
353
354 void
355 synch_material_map();
356
357//------------------------------------------------------------------------------
358
359 void
360 create_materials();
361
362 void
363 assign_materials();
364
365 void
366 delete_unused_materials();
367
368//------------------------------------------------------------------------------
369
370 void
371 read_thin_shell_data();
372
373//------------------------------------------------------------------------------
374
375 void
376 find_autopins( Cell< mesh::Node * > & aPins );
377
378//------------------------------------------------------------------------------
379
386 void
387 impose_autopins();
388
389//------------------------------------------------------------------------------
390
397 mesh::Node *
398 find_fixed_phi_contact(
399 mesh::Node * aPin,
400 Cell< mesh::Node * > & aVisited );
401
402//------------------------------------------------------------------------------
403
407 void
408 push_phi_neighbors(
409 mesh::Node * aNode,
410 Cell< mesh::Node * > & aVisited );
411
412//------------------------------------------------------------------------------
413
414 void
415 hang_thinshell_edges_on_nodes_bottom(
416 EdgeWorkData & aWork,
417 mesh::Facet * aFacets,
418 mesh::Element * aElement );
419
420 void
421 hang_thinshell_edges_on_nodes_top(
422 EdgeWorkData & aWork,
423 mesh::Facet * aFacets,
424 mesh::Element * aElement );
425
426 void
427 hang_thinshell_edges_on_edges_bottom(
428 EdgeWorkData & aWork,
429 mesh::Facet * aFacets,
430 mesh::Element * aElement );
431
432 void
433 hang_thinshell_edges_on_edges_top(
434 EdgeWorkData & aWork,
435 mesh::Facet * aFacets,
436 mesh::Element * aElement );
437
438//------------------------------------------------------------------------------
439 };
440
441 }
442}
443
444#endif //CL_MAXWELLFACTORY_HPP
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
Parser for the input.conf configuration format.
Definition cl_InputFile.hpp:30
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
Thin shell configuration object for electromagnetic simulations.
Definition cl_Protoshell.hpp:41
Main workhorse: DOF management, assembly coordination and the solver interface.
Definition cl_FEM_DofManager.hpp:52
Main electromagnetic integral weak form (h-phi formulation).
Definition cl_IWG_Maxwell.hpp:31
Definition cl_FEM_KernelParameters.hpp:29
Builds the physical boundary conditions of a Maxwell problem.
Definition cl_MaxwellBoundaryConditionFactory.hpp:36
std::shared_ptr< Controller > create_controller()
Definition cl_MaxwellFactory.cpp:1045
static bool mu_is_mu0(const real aMu)
whether a constant permeability counts as mu0 for the thin-shell normal-field recovery beside an h-co...
Definition cl_MaxwellFactory.cpp:1100
std::shared_ptr< Kernel > create_magnetic_kernel()
Definition cl_MaxwellFactory.cpp:669
MaxwellFactory(MaxwellFactory &&)=delete
MaxwellFactory & operator=(const MaxwellFactory &)=delete
const string & mesh_path() const
Definition cl_MaxwellFactory.cpp:254
Cell< PhysicalBoundaryCondition * > & boundary_conditions()
Definition cl_MaxwellFactory.cpp:1069
string label() const
Definition cl_MaxwellFactory.cpp:1092
MaxwellFactory & operator=(MaxwellFactory &&)=delete
MaxwellFactory(const string &aInputFile)
Definition cl_MaxwellFactory.cpp:67
Cell< PhysicalBoundaryCondition * > current_BCs()
Definition cl_MaxwellFactory.cpp:1077
MaxwellFactory(const MaxwellFactory &)=delete
One hierarchical section of a configuration file.
Definition cl_Input_Section.hpp:34
Definition cl_Facet.hpp:24
Creates a Periodicity object by matching nodes on two periodic boundary planes.
Definition cl_Mesh_PeriodicityFactory.hpp:34
Analyzes and classifies mesh topology for finite element simulations.
Definition cl_Topology.hpp:44
Formulation
Definition en_Maxwell_Formulations.hpp:23
@ HPhi
Definition en_Maxwell_Formulations.hpp:24
Definition cl_IFB_LINE3.hpp:21
CutAlgorithm
Definition en_CutAlgorithm.hpp:22
@ PellikkaGeneralized
Definition en_CutAlgorithm.hpp:26
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
ModelDimensionality
Definition en_IWGs.hpp:20
@ UNDEFINED
Definition en_IWGs.hpp:25
int proc_t
Definition commtypes.hpp:29
double real
Definition typedefs.hpp:36
Definition Element.py:1
Definition Node.py:1
Definition __init__.py:1