BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_FEM_Element.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_ELEMENT_HPP
13#define BELFEM_CL_FEM_ELEMENT_HPP
14
15#include "cl_Bitset.hpp"
16#include "cl_Element.hpp"
17#include "cl_FEM_Dof.hpp"
19#include "cl_FEM_Group.hpp"
20#include "cl_FEM_Tmatrix.hpp"
21#include "cl_Matrix.hpp"
22#include "cl_Vector.hpp"
24#include "typedefs.hpp"
25
26namespace belfem
27{
28 namespace fem
29 {
30 class Field;
31
32 class DofManager;
33
34 class Block;
35
36 class SideSet;
37
38//------------------------------------------------------------------------------
39
40 class Element
41 {
42 // parent block of this element
43 Group * mParent;
44
45 // pointer to master, if this is a side element
46 Element * mMaster = nullptr;
47
48 // pointer to slave, if this is a side element
49 Element * mSlave = nullptr;
50
51 // Facet in mesh, if this is a side element
52 mesh::Facet * mFacet = nullptr;
53
54 // helper, special purpose for reference
55 Element * mReferenceElement = nullptr;
56
57 // pointer to element on mesh
58 mesh::Element * mElement;
59
60 // contains the dofs that are connected to this element
61 Dof ** mDOFs = nullptr;
62 uint mNumberOfDofs = 0;
63
64 // contains the independent that are connected to this element
65 Dof ** mLocalDofs = nullptr;
66 uint mNumberOfLocalDofs = 0;
67
68 // T-matrix if it exists
69 Tmatrix * mTmatrix = nullptr;
70
71 // pointer to L-Matrix function
72 void
73 ( Element::*mL )( Matrix< real > & aJ, Matrix< real > & aL );
74
75 real * mRotationData = nullptr;
76
77 // edge directions, if this is a Nedelec element
78 Bitset< 12 > mEdgeDirections;
79
80//------------------------------------------------------------------------------
81 public:
82//------------------------------------------------------------------------------
83
84 Element( Block * aParent,
85 DofManager * aDofManager,
86 mesh::Element * aElement );
87
88 // aura element without dofs
89 Element( Block * aParent, mesh::Element * aElement );
90
91//------------------------------------------------------------------------------
92
93 // constructor for test
94 Element( mesh::Element * aElement );
95
96//------------------------------------------------------------------------------
97
101 Element(
102 SideSet * aParent,
103 DofManager * aDofManager,
104 mesh::Facet * aFacet,
105 const SideSetDofLinkMode aSideSetDofLinkMode,
106 Element * aMaster,
107 Element * aSlave );
108
109//------------------------------------------------------------------------------
110
114 Element(
115 SideSet * aParent,
116 DofManager * aDofManager,
117 mesh::Facet * aFacet,
118 Cell< mesh::Facet * > & aLayers,
119 const id_t aMasterBlockID,
120 const id_t aSlaveBlockID );
121
122//------------------------------------------------------------------------------
123
124 virtual ~Element();
125
126//------------------------------------------------------------------------------
127
132 element();
133
134//------------------------------------------------------------------------------
135
139 Dof *
140 dof( const index_t aIndex );
141
142//------------------------------------------------------------------------------
143
147 uint
148 number_of_dofs() const;
149
150//------------------------------------------------------------------------------
151
155 Dof *
156 local_dof( const index_t aIndex );
157
158//------------------------------------------------------------------------------
159
163 uint
164 number_of_local_dofs() const;
165
166//------------------------------------------------------------------------------
167
171 void
172 flag_dofs();
173
174//------------------------------------------------------------------------------
175
179 void
180 unflag_dofs();
181
185 bool
186 has_rotation() const;
187
188//------------------------------------------------------------------------------
189
190 void
191 get_node_coors( Matrix< real > & aNodeCoords );
192
196 void
197 set_rotation_data( const Matrix< real > & aRotationAxes, const Vector< real > & aRotationAngles );
198
199 void
200 get_rotation_data( Matrix< real > & aRotationAxes, Vector< real > & aRotationAngles );
201
202//------------------------------------------------------------------------------
203
207
208//------------------------------------------------------------------------------
209
213 void
214 edge_directions( real * aEdgeDirections ) const;
215
216//------------------------------------------------------------------------------
217
221 void
222 edge_directions( Bitset< 12 > & aEdgeDirections ) const;
223
224//------------------------------------------------------------------------------
225
229 bool
230 edge_direction( const index_t aIndex ) const;
231
232//------------------------------------------------------------------------------
233
237 id_t
238 id() const;
239
240//------------------------------------------------------------------------------
241
245 Element *
246 master();
247
248//------------------------------------------------------------------------------
249
254 Element *
255 slave();
256
257//------------------------------------------------------------------------------
258
260 facet();
261
262//------------------------------------------------------------------------------
263
264 const mesh::Facet *
265 facet() const;
266
267//------------------------------------------------------------------------------
268
269 Element *
270 reference();
271
272//------------------------------------------------------------------------------
273
274 const Element *
275 reference() const;
276
277//------------------------------------------------------------------------------
278
279 void
280 set_facet( mesh::Facet * aFacet );
281
282//------------------------------------------------------------------------------
283
284 void
285 set_reference( Element * aElement );
286
287//------------------------------------------------------------------------------
288
292 const Material *
293 material() const;
294
295//------------------------------------------------------------------------------
296
297 void
299
300//------------------------------------------------------------------------------
301
302 bool
303 has_t_matrix() const;
304
305//------------------------------------------------------------------------------
306
307 const Tmatrix *
308 t_matrix() const ;
309
310//------------------------------------------------------------------------------
311
312 void
313 relink_dofs( Cell< Dof * > & aGlobalDofs,
314 Cell< Dof * > & aLocalDofs,
315 const Matrix< real > & aTmatrix );
316
317//------------------------------------------------------------------------------
318
319 bool
320 has_hanging_dofs() const ;
321
322//------------------------------------------------------------------------------
323
324 Group *
325 parent() ;
326
327//------------------------------------------------------------------------------
328 private:
329//------------------------------------------------------------------------------
330
331 void
332 link_dofs(
333 DofManager * aDofManager,
334 const SideSetDofLinkMode aMode,
335 const id_t aSideSetID,
336 const id_t aMasterBlockID,
337 const id_t aSlaveBlockID );
338
339//------------------------------------------------------------------------------
340
344 void
345 link_dofs( DofManager * aDofManager, const id_t aBlockID );
346
347//------------------------------------------------------------------------------
348
349 void
350 link_dofs_facet_only(
351 DofManager * aDofManager,
352 const Vector< index_t > & aMasterNodeDofTypes,
353 const Vector< index_t > & aSlaveNodeDofTypes,
354 const Vector< index_t > & aMasterEdgeDofTypes,
355 const Vector< index_t > & aSlaveEdgeDofTypes,
356 const Vector< index_t > & aMasterFaceDofTypes,
357 const Vector< index_t > & aSlaveFaceDofTypes,
358 const Vector< index_t > & aLambdaDofTypes );
359
360//------------------------------------------------------------------------------
361
362 void
363 link_dofs_facet_and_master(
364 DofManager * aDofManager,
365 const Vector< index_t > & aMasterNodeDofTypes,
366 const Vector< index_t > & aSlaveNodeDofTypes,
367 const Vector< index_t > & aMasterEdgeDofTypes,
368 const Vector< index_t > & aSlaveEdgeDofTypes,
369 const Vector< index_t > & aMasterFaceDofTypes,
370 const Vector< index_t > & aSlaveFaceDofTypes,
371 const Vector< index_t > & aLambdaDofTypes );
372
373//------------------------------------------------------------------------------
374
375 void
376 link_dofs_facet_and_slave(
377 DofManager * aDofManager,
378 const Vector< index_t > & aMasterNodeDofTypes,
379 const Vector< index_t > & aSlaveNodeDofTypes,
380 const Vector< index_t > & aMasterEdgeDofTypes,
381 const Vector< index_t > & aSlaveEdgeDofTypes,
382 const Vector< index_t > & aMasterFaceDofTypes,
383 const Vector< index_t > & aSlaveFaceDofTypes,
384 const Vector< index_t > & aLambdaDofTypes );
385
386//------------------------------------------------------------------------------
387
388 void
389 link_dofs_master_and_slave(
390 DofManager * aDofManager,
391 const Vector< index_t > & aFacetOnlyNodeDofTypes,
392 const Vector< index_t > & aMasterNodeDofTypes,
393 const Vector< index_t > & aSlaveNodeDofTypes,
394 const Vector< index_t > & aMasterEdgeDofTypes,
395 const Vector< index_t > & aSlaveEdgeDofTypes,
396 const Vector< index_t > & aMasterFaceDofTypes,
397 const Vector< index_t > & aSlaveFaceDofTypes,
398 const Vector< index_t > & aLambdaDofTypes );
399
400//------------------------------------------------------------------------------
401
402 void
403 link_dofs_thin_shell(
404 DofManager * aDofManager,
405 Cell< mesh::Facet * > & aLayers,
406 const SideSetDofLinkMode aMode,
407 const id_t aMasterBlockID,
408 const id_t aSlaveBlockID );
409
410//------------------------------------------------------------------------------
411
412 void
413 link_dofs_thin_shell_master_and_slave(
414 DofManager * aDofManager,
415 Cell< mesh::Facet * > & aLayers,
416 const Vector< index_t > & aFacetNodeDofTypes,
417 const Vector< index_t > & aMasterNodeDofTypes,
418 const Vector< index_t > & aSlaveNodeDofTypes,
419 const Vector< index_t > & aThinShellEdgeDofTypes,
420 const Vector< index_t > & aThinShellFaceDofTypes,
421 const Vector< index_t > & aLambdaDofTypes );
422
423//------------------------------------------------------------------------------
424
425 void
426 link_dofs_thin_shell_facet_only(
427 DofManager * aDofManager,
428 Cell< mesh::Facet * > & aLayers,
429 const Vector< index_t > & aThinShellNodeDofTypes,
430 const Vector< index_t > & aThinShellEdgeDofTypes,
431 const Vector< index_t > & aThinShellFaceDofTypes );
432
433//------------------------------------------------------------------------------
434
435 void
436 grab_edge_directions_for_facet( Element * aReferenceElement );
437
438//------------------------------------------------------------------------------
439
440 void
441 link_node_dofs(
442 DofManager * aDofManager,
443 const Vector< index_t > & aDofTypes,
444 mesh::Element * aReferenceElement,
445 const uint aNumberOfNodesPerElement,
446 index_t & aCount );
447
448//------------------------------------------------------------------------------
449
450 void
451 link_edge_dofs(
452 DofManager * aDofManager,
453 const Vector< index_t > & aDofTypes,
454 mesh::Element * aReferenceElement,
455 const uint aNumberOfEdgesPerElement,
456 index_t & aCount );
457
458//------------------------------------------------------------------------------
459
460 void
461 link_face_dofs(
462 DofManager * aDofManager,
463 const Vector< index_t > & aDofTypes,
464 mesh::Element * aReferenceElement,
465 const uint aNumberOfFacesPerElement,
466 index_t & aCount );
467
468//------------------------------------------------------------------------------
469
470 void
471 link_edge_dofs_thin_shell(
472 DofManager * aDofManager,
473 const Vector< index_t > & aDofTypes,
474 Cell< mesh::Facet * > & aLayers,
475 index_t & aCount );
476
477//------------------------------------------------------------------------------
478
479 void
480 link_face_dofs_thin_shell(
481 DofManager * aDofManager,
482 const Vector< index_t > & aDofTypes,
483 Cell< mesh::Facet * > & aLayers,
484 index_t & aCount );
485
486//------------------------------------------------------------------------------
487
488 void
489 link_lambda_dofs( DofManager * aDofManager,
490 const Vector< index_t > & aDofTypes,
491 index_t & aCount );
492
493//------------------------------------------------------------------------------
494
495 void
496 compute_edge_directions();
497
498//------------------------------------------------------------------------------
499
500 void
501 compute_edge_directions_thinshell();
502
503//------------------------------------------------------------------------------
504
505 /*
506 * special function needed for Surface class
507 */
508 void
509 set_element( mesh::Element * aElement );
510
511//------------------------------------------------------------------------------
512
513 };
514
515//------------------------------------------------------------------------------
516
517 inline Element *
519 {
520 return mMaster;
521 }
522
523//------------------------------------------------------------------------------
524
525 inline Element *
527 {
528 return mSlave;
529 }
530
531//------------------------------------------------------------------------------
532
533 inline mesh::Facet *
535 {
536 return mFacet;
537 }
538
539//------------------------------------------------------------------------------
540
541 inline const mesh::Facet *
543 {
544 return mFacet;
545 }
546
547//------------------------------------------------------------------------------
548
549 inline void
551 {
552 mFacet = aFacet;
553 }
554
555//------------------------------------------------------------------------------
556
557 inline void
559 {
560 mReferenceElement = aElement;
561 }
562
563//------------------------------------------------------------------------------
564
565 inline const Material *
567 {
568 return mParent->material();
569 }
570
571//------------------------------------------------------------------------------
572
573 inline mesh::Element *
575 {
576 return mElement;
577 }
578
579//------------------------------------------------------------------------------
580
581 inline Dof *
582 Element::dof( const index_t aIndex )
583 {
584 return mDOFs[ aIndex ];
585 }
586
587//------------------------------------------------------------------------------
588
589 inline uint
591 {
592 return mNumberOfDofs;
593 }
594
595//------------------------------------------------------------------------------
596
597 inline Dof *
599 {
600 return mNumberOfLocalDofs == 0 ? mDOFs[ aIndex ] : mLocalDofs[ aIndex ];
601 }
602
603//------------------------------------------------------------------------------
604
605 inline uint
607 {
608 return mNumberOfLocalDofs == 0 ? mNumberOfDofs : mNumberOfLocalDofs ;
609 }
610
611//------------------------------------------------------------------------------
612
613 inline bool
615 {
616 return mRotationData != nullptr;
617 }
618
619//------------------------------------------------------------------------------
620
621 inline void
622 Element::edge_directions( real * aEdgeDirections ) const
623 {
624 for ( uint e = 0; e < mElement->number_of_edges(); ++e )
625 {
626 aEdgeDirections[ e ] = mEdgeDirections.test( e ) ? 1.0 : -1.0;
627 }
628 }
629
630//------------------------------------------------------------------------------
631
632
633 inline void
634 Element::edge_directions( Bitset< 12 > & aEdgeDirections ) const
635 {
636 for ( uint e = 0; e < mElement->number_of_edges(); ++e )
637 {
638 if ( mEdgeDirections.test( e ))
639 {
640 aEdgeDirections.set( e );
641 }
642 else
643 {
644 aEdgeDirections.reset( e );
645 }
646 }
647 }
648
649//------------------------------------------------------------------------------
650
651 inline bool
652 Element::edge_direction( const index_t aIndex ) const
653 {
654 return mEdgeDirections.test( aIndex );
655 }
656
657//------------------------------------------------------------------------------
658
659 inline id_t
661 {
662 return mElement->id();
663 }
664
665//------------------------------------------------------------------------------
666
667 inline void
669 {
670 uint tN = aNodeCoords.n_rows();
671 uint tD = aNodeCoords.n_cols();
672
673 for ( uint i = 0; i < tD; ++i )
674 {
675 for ( uint k = 0; k < tN; ++k )
676 {
677 aNodeCoords( k, i ) = mElement->node( k )->x( i );
678 }
679 }
680 }
681
682//------------------------------------------------------------------------------
683
684 inline bool
686 {
687 return mTmatrix != nullptr ;
688 }
689
690//------------------------------------------------------------------------------
691
692 inline const Tmatrix *
694 {
695 return mTmatrix ;
696 }
697
698//------------------------------------------------------------------------------
699
700 inline void
701 Element::set_element( mesh::Element * aElement )
702 {
703 mElement = aElement;
704 }
705
706//------------------------------------------------------------------------------
707
708 inline Group *
710 {
711 return mParent;
712 }
713
714//------------------------------------------------------------------------------
715
716 inline Element *
718 {
719 return mReferenceElement;
720 }
721
722 inline const Element *
724 {
725 return mReferenceElement;
726 }
727
728 }
729}
730#endif //BELFEM_CL_FEM_ELEMENT_HPP
void reset(const index_t aIndex)
set a bit to false
Definition cl_Bitset.hpp:103
void set(const index_t aIndex)
set a bit to true
Definition cl_Bitset.hpp:92
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
Base class for all materials in BELFEM.
Definition cl_Material.hpp:270
size_t n_rows() const
Definition cl_AR_Matrix.hpp:183
size_t n_cols() const
Definition cl_AR_Matrix.hpp:191
Definition cl_FEM_Block.hpp:35
Definition cl_FEM_Dof.hpp:28
Main workhorse: DOF management, assembly coordination and the solver interface.
Definition cl_FEM_DofManager.hpp:52
Definition cl_FEM_Element.hpp:41
void edge_directions(real *aEdgeDirections) const
expose container for edge directions (obsolete)
Definition cl_FEM_Element.hpp:622
Element * slave()
return the slave element, only for sidesets, returns null if there is none
Definition cl_FEM_Element.hpp:526
const Material * material() const
return the material of this element
Definition cl_FEM_Element.hpp:566
void unflag_dofs()
unflag all dofs that are connected to this element
Definition cl_FEM_Element.cpp:1235
void get_node_coors(Matrix< real > &aNodeCoords)
Definition cl_FEM_Element.hpp:668
bool has_hanging_dofs() const
Definition cl_FEM_Element.cpp:1474
void flag_dofs()
flag all dofs that are connected to this element
Definition cl_FEM_Element.cpp:1224
void add_t_matrix(const Matrix< real > &aT)
void set_rotation_data(const Matrix< real > &aRotationAxes, const Vector< real > &aRotationAngles)
set the rotation axes
Definition cl_FEM_Element.cpp:1343
Group * parent()
Definition cl_FEM_Element.hpp:709
Element(Block *aParent, DofManager *aDofManager, mesh::Element *aElement)
Definition cl_FEM_Element.cpp:24
Dof * dof(const index_t aIndex)
expose a specific dof
Definition cl_FEM_Element.hpp:582
void set_facet(mesh::Facet *aFacet)
Definition cl_FEM_Element.hpp:550
void relink_dofs(Cell< Dof * > &aGlobalDofs, Cell< Dof * > &aLocalDofs, const Matrix< real > &aTmatrix)
Definition cl_FEM_Element.cpp:1430
uint number_of_dofs() const
expose the number of dofs
Definition cl_FEM_Element.hpp:590
void set_reference(Element *aElement)
Definition cl_FEM_Element.hpp:558
Dof * local_dof(const index_t aIndex)
expose a specific dof
Definition cl_FEM_Element.hpp:598
uint number_of_local_dofs() const
expose the number of dofs
Definition cl_FEM_Element.hpp:606
bool edge_direction(const index_t aIndex) const
expose container for edge directions
Definition cl_FEM_Element.hpp:652
bool has_rotation() const
tell if this element has rotation properties
Definition cl_FEM_Element.hpp:614
const Tmatrix * t_matrix() const
Definition cl_FEM_Element.hpp:693
Element * reference()
Definition cl_FEM_Element.hpp:717
mesh::Facet * facet()
Definition cl_FEM_Element.hpp:534
bool has_t_matrix() const
Definition cl_FEM_Element.hpp:685
Element * master()
return the master element, only for sidesets
Definition cl_FEM_Element.hpp:518
id_t id() const
return the id of the underlying mesh element
Definition cl_FEM_Element.hpp:660
mesh::Element * element()
expose the underlying element on the mesh
Definition cl_FEM_Element.hpp:574
void get_rotation_data(Matrix< real > &aRotationAxes, Vector< real > &aRotationAngles)
Definition cl_FEM_Element.cpp:1389
Definition cl_FEM_Group.hpp:45
Definition cl_FEM_SideSet.hpp:64
Definition cl_FEM_Tmatrix.hpp:22
Definition cl_Facet.hpp:24
Definition cl_IFB_LINE3.hpp:21
SideSetDofLinkMode
how the dofs of a sideset element are linked to its facet, master and slave elements ( six modes plus...
Definition en_IWG_SideSetDofLinkMode.hpp:25
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
double real
Definition typedefs.hpp:36
Definition Element.py:1