BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_FEM_Group.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_FEM_GROUP_HPP
13#define BELFEM_CL_FEM_GROUP_HPP
14
15#include "typedefs.hpp"
16#include "constants.hpp"
17#include "cl_Cell.hpp"
18#include "cl_Vector.hpp"
19#include "cl_Matrix.hpp"
20#include "Mesh_Enums.hpp"
21#include "cl_Mesh.hpp"
22#include "meshtools.hpp"
24#include "cl_Material.hpp"
25#include "en_DomainType.hpp"
28#include "cl_FEM_Calculator.hpp"
29
30namespace belfem
31{
32 class Material;
33 enum class MaterialType;
34
35 namespace fem
36 {
37 class DofManagerBase;
38 class Element;
39 class Block ;
40 class BoundaryCondition ;
41
42//------------------------------------------------------------------------------
43
44 class Group
45 {
46//------------------------------------------------------------------------------
47 protected:
48//------------------------------------------------------------------------------
49
50 // pointer to parent
52
53 // pointer to swap object
54 Calculator * mCalc = nullptr ;
55
56 // either block or sideset
58
60
61 const id_t mID;
62
64
65 // flag that tells if elements are destoyed by destructor
66 const bool mOwnElements ;
67
69
70 // detailed domain type, mainly used for Maxwell
72
73 // container for node coordinates
75
76 // must be set by child
78
80
81 //bool mIsIsogeometric = true ;
82
83 //IntegrationData * mIntegrationData = nullptr ;
84
85 // this is meant if the geometry data are different
86 //IntegrationData * mGeometryIntegrationData = nullptr ;
87
88 // shape function for element boundaries
90
91 // Element container
93
95
96 // pointer to material ( owned by kernel )
97 Material * mMaterial = nullptr;
98
99 // pointer to boundary condition, if set
100 const BoundaryCondition * mBoundaryCondition = nullptr ;
101
102 Map< id_t, Element * > mElementMap ; // map to access element by ID
103
104 // empty sidesets and blocks have the id zero.
105 // the fake ID helps to access the underlying objects on the mesh
107
109 bool mHasRHS = true ;
110
113
116
117//------------------------------------------------------------------------------
118 public:
119//------------------------------------------------------------------------------
120
121 Group( DofManagerBase * aParent,
122 const GroupType aGroupType,
123 const ElementType aElementType,
124 const id_t aID,
125 const index_t aNumberOfElements,
126 const bool aOwnElements=true );
127
128//------------------------------------------------------------------------------
129
130 virtual ~Group() = default ;
131
132//------------------------------------------------------------------------------
133
138 type() const ;
139
140//------------------------------------------------------------------------------
141
145 id_t
146 id() const;
147
148//------------------------------------------------------------------------------
149
153 virtual ElementType
154 element_type() const;
155
156//------------------------------------------------------------------------------
157
162 parent();
163
164//------------------------------------------------------------------------------
165
166 /*
167 * return the number of elements of this block
168 */
169 index_t
170 number_of_elements() const;
171
172//------------------------------------------------------------------------------
173
174 /*
175 * return the number of nodes per element
176 */
177 uint
179
180//------------------------------------------------------------------------------
181
182 /*
183 * return the number of edges per element
184 */
185 uint
187
188//------------------------------------------------------------------------------
189
190 /*
191 * return the number of faces per element
192 */
193 uint
195
196//------------------------------------------------------------------------------
197
201 const IntegrationData *
202 integration() const ;
203
204//------------------------------------------------------------------------------
205
206 const IntegrationData *
207 enrichment_data( const uint aFacet ) const ;
208
209//------------------------------------------------------------------------------
210
211 virtual const IntegrationData *
212 thinshell_integration() const ;
213
214//------------------------------------------------------------------------------
215
216 /*
217 * expose element container
218 */
220 elements();
221
224
225//------------------------------------------------------------------------------
226
227 bool
228 element_exists( const id_t aID );
229
230//------------------------------------------------------------------------------
231
235 Calculator *
236 calculator() ;
237
238//------------------------------------------------------------------------------
239
244 node_coords() ;
245
246//------------------------------------------------------------------------------
247
253 field_data( const string & aLabel );
254
255//------------------------------------------------------------------------------
256
257 void
258 set_material( Material * aMaterial );
259
260//------------------------------------------------------------------------------
261
262 void
263 set_material( const string & aLabel );
264
265//------------------------------------------------------------------------------
266
267 Material *
268 material();
269
270//------------------------------------------------------------------------------
271
272 const Material *
273 material() const;
274
275//------------------------------------------------------------------------------
276
277 // needed if you want to access element by id
278 void
280
281//------------------------------------------------------------------------------
282
283 // get an element using its ID instead of index
284 Element *
285 element( const id_t aID );
286
287//------------------------------------------------------------------------------
288// RHS flags
289//------------------------------------------------------------------------------
290
291 // flag telling field if an RHS side exists
292 bool
293 has_rhs() const ;
294
295 // set or unset the rhs flag
296 void
297 set_rhs_flag( const bool aFlag );
298
299//------------------------------------------------------------------------------
300// Helpers
301//------------------------------------------------------------------------------
302
310 const id_t &
311 mesh_id() const ;
312
313 void
314 set_mesh_id( const id_t & aID );
315
316//------------------------------------------------------------------------------
317
321 virtual IntegrationData *
322 master_integration( const uint aSideSetIndex );
323
324 virtual IntegrationData *
325 slave_integration( const uint aSideSetIndex );
326
327 void
329
330//------------------------------------------------------------------------------
331
334
335//------------------------------------------------------------------------------
336
337 void
338 set_domain_type( const DomainType aType );
339
340//------------------------------------------------------------------------------
341
343 domain_type() const ;
344
345//------------------------------------------------------------------------------
346
350 virtual ElementType
351 master_type() const ;
352//------------------------------------------------------------------------------
353
357 virtual ElementType
358 slave_type() const ;
359
360//------------------------------------------------------------------------------
361
366 virtual uint
368
369//------------------------------------------------------------------------------
370
375 virtual uint
377
378//------------------------------------------------------------------------------
379
384 virtual real
385 thin_shell_thickness( const uint aLayerIndex ) const ;
386
387//------------------------------------------------------------------------------
388
393 virtual real
394 thin_shell_thickness() const ;
395
396//------------------------------------------------------------------------------
397
403 bool
404 is_active() const ;
405
406//------------------------------------------------------------------------------
407
412 activation_mode() const ;
413
414//------------------------------------------------------------------------------
415
419 void
421
422//------------------------------------------------------------------------------
423
428 void
429 activate( bool aFlag );
430
431//------------------------------------------------------------------------------
432
433 virtual void
434 initialize_lookup_tables( const uint aOrder );
435
436 bool
438
439//------------------------------------------------------------------------------
440 protected:
441//------------------------------------------------------------------------------
442 void
444
445//------------------------------------------------------------------------------
446 };
447
448//------------------------------------------------------------------------------
449
450 inline DofManagerBase *
452 {
453 return mParent;
454 }
455
456//------------------------------------------------------------------------------
457
458 inline GroupType
460 {
461 return mType ;
462 }
463
464//------------------------------------------------------------------------------
465
466 inline id_t
467 Group::id() const
468 {
469 return mID;
470 }
471
472//------------------------------------------------------------------------------
473
474 inline index_t
476 {
477 return mNumberOfElements;
478 }
479
480//------------------------------------------------------------------------------
481
482 inline uint
487
488//------------------------------------------------------------------------------
489
490 inline uint
495
496//------------------------------------------------------------------------------
497
498 inline uint
503
504//------------------------------------------------------------------------------
505
506 inline Cell< Element * > &
508 {
509 return mElements;
510 }
511
512//------------------------------------------------------------------------------
513
514 inline Cell< Element * > &
516 {
517 return mAuraElements;
518 }
519
520//------------------------------------------------------------------------------
521
522 inline Matrix< real > &
524 {
525 return mNodeCoords ;
526 }
527
528//------------------------------------------------------------------------------
529
530 // get an element using its ID instead of index
531 inline Element *
532 Group::element( const id_t aID )
533 {
534 return mElementMap( aID );
535 }
536
537//------------------------------------------------------------------------------
538
539 inline Material *
541 {
542 return mMaterial;
543 }
544
545//------------------------------------------------------------------------------
546
547 inline const Material *
549 {
550 return mMaterial;
551 }
552
553//------------------------------------------------------------------------------
554
555 // flag telling field if an RHS side exists
556 inline bool
558 {
559 return mHasRHS ;
560 }
561
562//------------------------------------------------------------------------------
563
564 // set or unset the rhs flag
565 inline void
566 Group::set_rhs_flag( const bool aFlag )
567 {
568 mHasRHS = aFlag ;
569 }
570
571//------------------------------------------------------------------------------
572
573 inline const id_t &
575 {
576 return mMeshID ;
577 }
578
579//------------------------------------------------------------------------------
580
581 inline void
583 {
584 mMeshID = aID ;
585 }
586
587//------------------------------------------------------------------------------
588
589
590 inline void
592 {
593 mDomainType = aType ;
594 }
595
596//------------------------------------------------------------------------------
597
598 inline DomainType
600 {
601 return mDomainType ;
602 }
603
604//------------------------------------------------------------------------------
605
606 inline bool
611
612//------------------------------------------------------------------------------
613
616 {
617 return mActivationMode ;
618 }
619
620//------------------------------------------------------------------------------
621
622 inline void
624 {
625 mActivationMode = aMode ;
626 }
627
628//------------------------------------------------------------------------------
629
630 inline void
635
636//------------------------------------------------------------------------------
637
638 inline Calculator *
640 {
641 return mCalc ;
642 }
643
644//------------------------------------------------------------------------------
645
646 inline ElementType
648 {
649 return mElementType;
650 }
651
652//------------------------------------------------------------------------------
653
654 inline const IntegrationData *
656 {
657 return mCalc->integration() ;
658 }
659
660//------------------------------------------------------------------------------
661
662 inline const IntegrationData *
663 Group::enrichment_data( const uint aFacet ) const
664 {
665 return mEnrichmentData( aFacet );
666 }
667
668//------------------------------------------------------------------------------
669
671 {
672 return mEnrichmentData.size() > 0 ;
673 }
674
675//------------------------------------------------------------------------------
676
677 inline bool
679 {
680 return mElementMap.key_exists( aID );
681 }
682
683//------------------------------------------------------------------------------
684 }
685}
686#endif //BELFEM_CL_FEM_GROUP_HPP
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
Hash map (unordered key-value).
Definition cl_Map.hpp:75
Base class for all materials in BELFEM.
Definition cl_Material.hpp:279
Definition cl_FEM_Block.hpp:35
Definition cl_FEM_Calculator.hpp:600
const IntegrationData * integration() const
Definition cl_FEM_Calculator.hpp:2320
abstract interface of the dof manager as seen by the group classes and the IWG; DofManager is its onl...
Definition cl_FEM_DofManagerBase.hpp:44
Definition cl_FEM_Element.hpp:41
bool is_active() const
function telling if values from this group are computed ( default : true ) Returns true for GeometryA...
Definition cl_FEM_Group.hpp:607
const GroupType mType
Definition cl_FEM_Group.hpp:57
const ElementType mElementType
Definition cl_FEM_Group.hpp:59
Matrix< real > mNodeCoords
Definition cl_FEM_Group.hpp:74
DofManagerBase * mParent
Definition cl_FEM_Group.hpp:51
void set_domain_type(const DomainType aType)
Definition cl_FEM_Group.hpp:591
virtual void initialize_lookup_tables(const uint aOrder)
Definition cl_FEM_Group.cpp:234
Vector< real > & field_data(const string &aLabel)
access scal ars from the parent
Definition cl_FEM_Group.cpp:77
virtual const IntegrationData * thinshell_integration() const
Definition cl_FEM_Group.cpp:221
Cell< Element * > & elements()
Definition cl_FEM_Group.hpp:507
void activate(bool aFlag)
set the active flag of the group (backward compatibility) Maps bool to GeometryAndDofs (true) or Inac...
Definition cl_FEM_Group.hpp:631
GroupType type() const
return the type of this group
Definition cl_FEM_Group.hpp:459
const BoundaryCondition * mBoundaryCondition
Definition cl_FEM_Group.hpp:100
Calculator * mCalc
Definition cl_FEM_Group.hpp:54
void delete_pointers()
Definition cl_FEM_Group.cpp:54
bool element_exists(const id_t aID)
Definition cl_FEM_Group.hpp:678
bool has_rhs() const
Definition cl_FEM_Group.hpp:557
virtual ElementType element_type() const
return the element type of this block
Definition cl_FEM_Group.hpp:647
Cell< IntegrationData * > mEnrichmentData
in case for example if bubble functions are used
Definition cl_FEM_Group.hpp:115
const IntegrationData * integration() const
expose the integration data
Definition cl_FEM_Group.hpp:655
uint number_of_faces_per_element() const
Definition cl_FEM_Group.hpp:499
void set_material(Material *aMaterial)
Definition cl_FEM_Group.cpp:85
virtual ElementType master_type() const
returns type of sideset master
Definition cl_FEM_Group.cpp:157
Element * element(const id_t aID)
Definition cl_FEM_Group.hpp:532
Map< id_t, Element * > mElementMap
Definition cl_FEM_Group.hpp:102
bool has_enrichment()
Definition cl_FEM_Group.hpp:670
uint mIntegrationOrder
Definition cl_FEM_Group.hpp:79
virtual IntegrationData * slave_integration(const uint aSideSetIndex)
Definition cl_FEM_Group.cpp:147
Cell< Cell< Matrix< real > > > mBoundaryN
Definition cl_FEM_Group.hpp:89
Group(DofManagerBase *aParent, const GroupType aGroupType, const ElementType aElementType, const id_t aID, const index_t aNumberOfElements, const bool aOwnElements=true)
Definition cl_FEM_Group.cpp:29
virtual ElementType slave_type() const
returns type of sideset slave
Definition cl_FEM_Group.cpp:167
DofManagerBase * parent()
return the field of this block
Definition cl_FEM_Group.hpp:451
Cell< Element * > & aura_elements()
Definition cl_FEM_Group.hpp:515
Calculator * calculator()
expose calculator object
Definition cl_FEM_Group.hpp:639
void create_calculator()
Definition cl_FEM_Group.cpp:122
void set_mesh_id(const id_t &aID)
Definition cl_FEM_Group.hpp:582
virtual IntegrationData * master_integration(const uint aSideSetIndex)
for special purpose integration, sideset only
Definition cl_FEM_Group.cpp:137
GroupActivationMode activation_mode() const
returns the activation mode of this group
Definition cl_FEM_Group.hpp:615
uint mNumberOfNodesPerElement
Definition cl_FEM_Group.hpp:77
void set_activation_mode(const GroupActivationMode aMode)
set the activation mode of the group
Definition cl_FEM_Group.hpp:623
bool mHasRHS
flag telling if block has a right hand side
Definition cl_FEM_Group.hpp:109
const proc_t mCommRank
Definition cl_FEM_Group.hpp:68
const id_t & mesh_id() const
if the sideset or block is empty, ID is zero.
Definition cl_FEM_Group.hpp:574
virtual uint number_of_thin_shell_layers() const
dummy function, throws error unless sideset or shell
Definition cl_FEM_Group.cpp:177
virtual real thin_shell_thickness(const uint aLayerIndex) const
dummy function, throws error unless sideset or shell
Definition cl_FEM_Group.cpp:199
DomainType domain_type() const
Definition cl_FEM_Group.hpp:599
Material * material()
Definition cl_FEM_Group.hpp:540
const id_t mID
Definition cl_FEM_Group.hpp:61
DomainType mDomainType
Definition cl_FEM_Group.hpp:71
virtual ~Group()=default
Matrix< real > & node_coords()
expose container for node coords
Definition cl_FEM_Group.hpp:523
index_t number_of_elements() const
Definition cl_FEM_Group.hpp:475
void create_element_map()
Definition cl_FEM_Group.cpp:101
const IntegrationData * enrichment_data(const uint aFacet) const
Definition cl_FEM_Group.hpp:663
const bool mOwnElements
Definition cl_FEM_Group.hpp:66
const index_t mNumberOfElements
Definition cl_FEM_Group.hpp:63
uint number_of_edges_per_element() const
Definition cl_FEM_Group.hpp:491
id_t id() const
return the id of the group
Definition cl_FEM_Group.hpp:467
virtual uint number_of_ghost_sidesets() const
dummy function, throws error unless sideset or shell
Definition cl_FEM_Group.cpp:186
GroupActivationMode mActivationMode
activation mode determining how this group is used for computation
Definition cl_FEM_Group.hpp:112
Cell< Element * > mAuraElements
Definition cl_FEM_Group.hpp:94
Material * mMaterial
Definition cl_FEM_Group.hpp:97
void set_rhs_flag(const bool aFlag)
Definition cl_FEM_Group.hpp:566
const InterpolationFunction * interpolation_function() const
id_t mMeshID
Definition cl_FEM_Group.hpp:106
Cell< Element * > mElements
Definition cl_FEM_Group.hpp:92
uint number_of_nodes_per_element() const
Definition cl_FEM_Group.hpp:483
Precomputed bundle of integration points, weights and shape-function values.
Definition cl_IF_IntegrationData.hpp:28
the shape function base class
Definition cl_IF_InterpolationFunction.hpp:24
Definition cl_IFB_LINE3.hpp:21
GroupActivationMode
Defines how a fem::Block or fem::SideSet is activated based on its DomainType.
Definition en_FEM_GroupActivationMode.hpp:26
@ Inactive
Definition en_FEM_GroupActivationMode.hpp:29
@ GeometryAndDofs
Definition en_FEM_GroupActivationMode.hpp:27
unsigned int number_of_edges(const enum ElementType aElementType)
Definition meshtools.cpp:140
unsigned int number_of_faces(const enum ElementType aElementType)
Definition meshtools.cpp:750
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
GroupType
Definition Mesh_Enums.hpp:130
uint32_t index_t
Definition typedefs.hpp:52
double real
Definition typedefs.hpp:36
DomainType
Definition en_DomainType.hpp:20
@ Default
Definition en_DomainType.hpp:21
MaterialType
Material classification based on physical behavior.
Definition cl_Material.hpp:107
#define BELFEM_UINT_MAX
Definition typedefs.hpp:80