BELFEM 0.9.0
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 // void
208 // edge_directions( Vector< real > & aEdgeDirections ) const ;
209
210//------------------------------------------------------------------------------
211
215 void
216 edge_directions( real * aEdgeDirections ) const;
217
218//------------------------------------------------------------------------------
219
223 void
224 edge_directions( Bitset< 12 > & aEdgeDirections ) const;
225
226//------------------------------------------------------------------------------
227
231 bool
232 edge_direction( const index_t aIndex ) const;
233
234//------------------------------------------------------------------------------
235
239 id_t
240 id() const;
241
242//------------------------------------------------------------------------------
243
247 Element *
248 master();
249
250//------------------------------------------------------------------------------
251
256 Element *
257 slave();
258
259//------------------------------------------------------------------------------
260
262 facet();
263
264//------------------------------------------------------------------------------
265
266 const mesh::Facet *
267 facet() const;
268
269//------------------------------------------------------------------------------
270
271 Element *
272 reference();
273
274//------------------------------------------------------------------------------
275
276 const Element *
277 reference() const;
278
279//------------------------------------------------------------------------------
280
281 void
282 set_facet( mesh::Facet * aFacet );
283
284//------------------------------------------------------------------------------
285
286 void
287 set_reference( Element * aElement );
288
289//------------------------------------------------------------------------------
290
294 const Material *
295 material() const;
296
297//------------------------------------------------------------------------------
298
299 void
301
302//------------------------------------------------------------------------------
303
304 bool
305 has_t_matrix() const;
306
307//------------------------------------------------------------------------------
308
309 const Tmatrix *
310 t_matrix() const ;
311
312//------------------------------------------------------------------------------
313
314 void
315 relink_dofs( Cell< Dof * > & aGlobalDofs,
316 Cell< Dof * > & aLocalDofs,
317 const Matrix< real > & aTmatrix );
318
319//------------------------------------------------------------------------------
320
321 bool
322 has_hanging_dofs() const ;
323
324//------------------------------------------------------------------------------
325
326 Group *
327 parent() ;
328
329//------------------------------------------------------------------------------
330 private:
331//------------------------------------------------------------------------------
332
333 void
334 link_dofs(
335 DofManager * aDofManager,
336 const SideSetDofLinkMode aMode,
337 const id_t aSideSetID,
338 const id_t aMasterBlockID,
339 const id_t aSlaveBlockID );
340
341//------------------------------------------------------------------------------
342
346 void
347 link_dofs( DofManager * aDofManager, const id_t aBlockID );
348
349//------------------------------------------------------------------------------
350
351 void
352 link_dofs_facet_only(
353 DofManager * aDofManager,
354 const Vector< index_t > & aMasterNodeDofTypes,
355 const Vector< index_t > & aSlaveNodeDofTypes,
356 const Vector< index_t > & aMasterEdgeDofTypes,
357 const Vector< index_t > & aSlaveEdgeDofTypes,
358 const Vector< index_t > & aMasterFaceDofTypes,
359 const Vector< index_t > & aSlaveFaceDofTypes,
360 const Vector< index_t > & aLambdaDofTypes );
361
362//------------------------------------------------------------------------------
363
364 void
365 link_dofs_facet_and_master(
366 DofManager * aDofManager,
367 const Vector< index_t > & aMasterNodeDofTypes,
368 const Vector< index_t > & aSlaveNodeDofTypes,
369 const Vector< index_t > & aMasterEdgeDofTypes,
370 const Vector< index_t > & aSlaveEdgeDofTypes,
371 const Vector< index_t > & aMasterFaceDofTypes,
372 const Vector< index_t > & aSlaveFaceDofTypes,
373 const Vector< index_t > & aLambdaDofTypes );
374
375//------------------------------------------------------------------------------
376
377 void
378 link_dofs_facet_and_slave(
379 DofManager * aDofManager,
380 const Vector< index_t > & aMasterNodeDofTypes,
381 const Vector< index_t > & aSlaveNodeDofTypes,
382 const Vector< index_t > & aMasterEdgeDofTypes,
383 const Vector< index_t > & aSlaveEdgeDofTypes,
384 const Vector< index_t > & aMasterFaceDofTypes,
385 const Vector< index_t > & aSlaveFaceDofTypes,
386 const Vector< index_t > & aLambdaDofTypes );
387
388//------------------------------------------------------------------------------
389
390 void
391 link_dofs_master_and_slave(
392 DofManager * aDofManager,
393 const Vector< index_t > & aFacetOnlyNodeDofTypes,
394 const Vector< index_t > & aMasterNodeDofTypes,
395 const Vector< index_t > & aSlaveNodeDofTypes,
396 const Vector< index_t > & aMasterEdgeDofTypes,
397 const Vector< index_t > & aSlaveEdgeDofTypes,
398 const Vector< index_t > & aMasterFaceDofTypes,
399 const Vector< index_t > & aSlaveFaceDofTypes,
400 const Vector< index_t > & aLambdaDofTypes );
401
402//------------------------------------------------------------------------------
403
404 void
405 link_dofs_thin_shell(
406 DofManager * aDofManager,
407 Cell< mesh::Facet * > & aLayers,
408 const SideSetDofLinkMode aMode,
409 const id_t aMasterBlockID,
410 const id_t aSlaveBlockID );
411
412//------------------------------------------------------------------------------
413
414 void
415 link_dofs_thin_shell_master_and_slave(
416 DofManager * aDofManager,
417 Cell< mesh::Facet * > & aLayers,
418 const Vector< index_t > & aFacetNodeDofTypes,
419 const Vector< index_t > & aMasterNodeDofTypes,
420 const Vector< index_t > & aSlaveNodeDofTypes,
421 const Vector< index_t > & aThinShellEdgeDofTypes,
422 const Vector< index_t > & aThinShellFaceDofTypes,
423 const Vector< index_t > & aLambdaDofTypes );
424
425//------------------------------------------------------------------------------
426
427 void
428 link_dofs_thin_shell_facet_only(
429 DofManager * aDofManager,
430 Cell< mesh::Facet * > & aLayers,
431 const Vector< index_t > & aThinShellNodeDofTypes,
432 const Vector< index_t > & aThinShellEdgeDofTypes,
433 const Vector< index_t > & aThinShellFaceDofTypes );
434
435//------------------------------------------------------------------------------
436
437 void
438 grab_edge_directions_for_facet( Element * aReferenceElement );
439
440//------------------------------------------------------------------------------
441
442 void
443 link_node_dofs(
444 DofManager * aDofManager,
445 const Vector< index_t > & aDofTypes,
446 mesh::Element * aReferenceElement,
447 const uint aNumberOfNodesPerElement,
448 index_t & aCount );
449
450//------------------------------------------------------------------------------
451
452 void
453 link_edge_dofs(
454 DofManager * aDofManager,
455 const Vector< index_t > & aDofTypes,
456 mesh::Element * aReferenceElement,
457 const uint aNumberOfEdgesPerElement,
458 index_t & aCount );
459
460//------------------------------------------------------------------------------
461
462 void
463 link_face_dofs(
464 DofManager * aDofManager,
465 const Vector< index_t > & aDofTypes,
466 mesh::Element * aReferenceElement,
467 const uint aNumberOfFacesPerElement,
468 index_t & aCount );
469
470//------------------------------------------------------------------------------
471
472 void
473 link_edge_dofs_thin_shell(
474 DofManager * aDofManager,
475 const Vector< index_t > & aDofTypes,
476 Cell< mesh::Facet * > & aLayers,
477 index_t & aCount );
478
479//------------------------------------------------------------------------------
480
481 void
482 link_face_dofs_thin_shell(
483 DofManager * aDofManager,
484 const Vector< index_t > & aDofTypes,
485 Cell< mesh::Facet * > & aLayers,
486 index_t & aCount );
487
488//------------------------------------------------------------------------------
489
490 void
491 link_lambda_dofs( DofManager * aDofManager,
492 const Vector< index_t > & aDofTypes,
493 index_t & aCount );
494
495//------------------------------------------------------------------------------
496
497 void
498 compute_edge_directions();
499
500//------------------------------------------------------------------------------
501
502 void
503 compute_edge_directions_thinshell();
504
505//------------------------------------------------------------------------------
506
507 /*
508 * special function needed for Surface class
509 */
510 void
511 set_element( mesh::Element * aElement );
512
513//------------------------------------------------------------------------------
514
515 };
516
517//------------------------------------------------------------------------------
518
519 inline Element *
521 {
522 return mMaster;
523 }
524
525//------------------------------------------------------------------------------
526
527 inline Element *
529 {
530 return mSlave;
531 }
532
533//------------------------------------------------------------------------------
534
535 inline mesh::Facet *
537 {
538 return mFacet;
539 }
540
541//------------------------------------------------------------------------------
542
543 inline const mesh::Facet *
545 {
546 return mFacet;
547 }
548
549//------------------------------------------------------------------------------
550
551 inline void
553 {
554 mFacet = aFacet;
555 }
556
557//------------------------------------------------------------------------------
558
559 inline void
561 {
562 mReferenceElement = aElement;
563 }
564
565//------------------------------------------------------------------------------
566
567 inline const Material *
569 {
570 return mParent->material();
571 }
572
573//------------------------------------------------------------------------------
574
575 inline mesh::Element *
577 {
578 return mElement;
579 }
580
581//------------------------------------------------------------------------------
582
583 inline Dof *
584 Element::dof( const index_t aIndex )
585 {
586 return mDOFs[ aIndex ];
587 }
588
589//------------------------------------------------------------------------------
590
591 inline uint
593 {
594 return mNumberOfDofs;
595 }
596
597//------------------------------------------------------------------------------
598
599 inline Dof *
601 {
602 return mNumberOfLocalDofs == 0 ? mDOFs[ aIndex ] : mLocalDofs[ aIndex ];
603 }
604
605//------------------------------------------------------------------------------
606
607 inline uint
609 {
610 return mNumberOfLocalDofs == 0 ? mNumberOfDofs : mNumberOfLocalDofs ;
611 }
612
613//------------------------------------------------------------------------------
614
615 inline bool
617 {
618 return mRotationData != nullptr;
619 }
620
621//------------------------------------------------------------------------------
622
623 inline void
624 Element::edge_directions( real * aEdgeDirections ) const
625 {
626 for ( uint e = 0; e < mElement->number_of_edges(); ++e )
627 {
628 aEdgeDirections[ e ] = mEdgeDirections.test( e ) ? 1.0 : -1.0;
629 }
630 }
631
632//------------------------------------------------------------------------------
633
634
635 inline void
636 Element::edge_directions( Bitset< 12 > & aEdgeDirections ) const
637 {
638 for ( uint e = 0; e < mElement->number_of_edges(); ++e )
639 {
640 if ( mEdgeDirections.test( e ))
641 {
642 aEdgeDirections.set( e );
643 }
644 else
645 {
646 aEdgeDirections.reset( e );
647 }
648 }
649 }
650
651//------------------------------------------------------------------------------
652
653 inline bool
654 Element::edge_direction( const index_t aIndex ) const
655 {
656 return mEdgeDirections.test( aIndex );
657 }
658
659//------------------------------------------------------------------------------
660
661 inline id_t
663 {
664 return mElement->id();
665 }
666
667//------------------------------------------------------------------------------
668
669 inline void
671 {
672 uint tN = aNodeCoords.n_rows();
673 uint tD = aNodeCoords.n_cols();
674
675 for ( uint i = 0; i < tD; ++i )
676 {
677 for ( uint k = 0; k < tN; ++k )
678 {
679 aNodeCoords( k, i ) = mElement->node( k )->x( i );
680 }
681 }
682 }
683
684//------------------------------------------------------------------------------
685
686 inline bool
688 {
689 return mTmatrix != nullptr ;
690 }
691
692//------------------------------------------------------------------------------
693
694 inline const Tmatrix *
696 {
697 return mTmatrix ;
698 }
699
700//------------------------------------------------------------------------------
701
702 inline void
703 Element::set_element( mesh::Element * aElement )
704 {
705 mElement = aElement;
706 }
707
708//------------------------------------------------------------------------------
709
710 inline Group *
712 {
713 return mParent;
714 }
715
716//------------------------------------------------------------------------------
717
718 inline Element *
720 {
721 return mReferenceElement;
722 }
723
724 inline const Element *
726 {
727 return mReferenceElement;
728 }
729
730 }
731}
732#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
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
Base class for all materials in BELFEM.
Definition cl_Material.hpp:279
size_t n_rows() const
Definition cl_AR_Matrix.hpp:205
size_t n_cols() const
Definition cl_AR_Matrix.hpp:213
Definition cl_FEM_Block.hpp:35
Definition cl_FEM_Dof.hpp:28
this class creates the DOFs based on the passed equation object.
Definition cl_FEM_DofManager.hpp:55
Definition cl_FEM_Element.hpp:41
void edge_directions(real *aEdgeDirections) const
expose container for edge directions (obsolete)
Definition cl_FEM_Element.hpp:624
Element * slave()
return the slave element, only for sidesets, returns null if there is none
Definition cl_FEM_Element.hpp:528
const Material * material() const
return the material of this element
Definition cl_FEM_Element.hpp:568
void unflag_dofs()
unflag all dofs that are connected to this element
Definition cl_FEM_Element.cpp:1326
void get_node_coors(Matrix< real > &aNodeCoords)
Definition cl_FEM_Element.hpp:670
bool has_hanging_dofs() const
Definition cl_FEM_Element.cpp:1593
void flag_dofs()
flag all dofs that are connected to this element
Definition cl_FEM_Element.cpp:1315
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:1441
Group * parent()
Definition cl_FEM_Element.hpp:711
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:584
void set_facet(mesh::Facet *aFacet)
Definition cl_FEM_Element.hpp:552
void relink_dofs(Cell< Dof * > &aGlobalDofs, Cell< Dof * > &aLocalDofs, const Matrix< real > &aTmatrix)
Definition cl_FEM_Element.cpp:1541
uint number_of_dofs() const
expose the number of dofs
Definition cl_FEM_Element.hpp:592
void set_reference(Element *aElement)
Definition cl_FEM_Element.hpp:560
Dof * local_dof(const index_t aIndex)
expose a specific dof
Definition cl_FEM_Element.hpp:600
uint number_of_local_dofs() const
expose the number of dofs
Definition cl_FEM_Element.hpp:608
bool edge_direction(const index_t aIndex) const
expose container for edge directions
Definition cl_FEM_Element.hpp:654
bool has_rotation() const
tell if this element has rotation properties
Definition cl_FEM_Element.hpp:616
const Tmatrix * t_matrix() const
Definition cl_FEM_Element.hpp:695
Element * reference()
Definition cl_FEM_Element.hpp:719
mesh::Facet * facet()
Definition cl_FEM_Element.hpp:536
bool has_t_matrix() const
Definition cl_FEM_Element.hpp:687
Element * master()
return the master element, only for sidesets
Definition cl_FEM_Element.hpp:520
id_t id() const
return the id of the underlying mesh element
Definition cl_FEM_Element.hpp:662
mesh::Element * element()
expose the underlying element on the mesh
Definition cl_FEM_Element.hpp:576
void get_rotation_data(Matrix< real > &aRotationAxes, Vector< real > &aRotationAngles)
Definition cl_FEM_Element.cpp:1494
Definition cl_FEM_Group.hpp:45
Definition cl_FEM_SideSet.hpp:60
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