BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Mesh_SourceExpander.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_MESH_SOURCEEXPANDER_HPP
13#define BELFEM_CL_MESH_SOURCEEXPANDER_HPP
14
15#include "assert.hpp"
16#include "cl_Cell.hpp"
17#include "cl_DynamicBitset.hpp"
18#include "cl_Mesh.hpp"
19#include "cl_Vector.hpp"
20namespace belfem
21{
22 namespace mesh
23 {
25 {
26 Mesh * mMesh ;
27
28 DynamicBitset * mNodeBitset = nullptr ;
29 DynamicBitset * mEdgeBitset = nullptr ;
30 DynamicBitset * mFaceBitset = nullptr ;
31 DynamicBitset * mElementBitset = nullptr ;
32 DynamicBitset * mFacetBitset = nullptr ;
33
34 Cell< index_t > mBasisIndices ;
35
36 Cell< Basis * > mSources ;
38
39 Vector< real > mWork ;
40
41 public:
42
43 SourceExpander( Mesh * aMesh );
44
46
47 void
48 run();
49
50 void
51 expand_sources( Basis * aBasis );
52
53 private:
54
56 bitset( const EntityType aEntityType );
57
58 void
59 reset_bitsets();
60
61 void
62 flag_all_sources( const Basis * aBasis );
63
64 void
65 expand_weights( const Basis * aBasis, const real aWeight=1.0 );
66
67
68 };
69
70
71 inline DynamicBitset *
72 SourceExpander::bitset( const EntityType aEntityType )
73 {
74 switch( aEntityType )
75 {
76 case EntityType::NODE :
77 {
78 return mNodeBitset ;
79 }
80 case EntityType::EDGE :
81 {
82 return mEdgeBitset ;
83 }
84 case EntityType::FACE :
85 {
86 return mFaceBitset ;
87 }
89 {
90 return mElementBitset ;
91 }
93 {
94 return mFacetBitset ;
95 }
96 default:
97 {
98 BELFEM_ERROR( false, "Unknown entity type" );
99 return nullptr ;
100 }
101 }
102 }
103
104 inline
105 void SourceExpander::flag_all_sources( const Basis * aBasis )
106 {
107 for ( uint k=0; k<aBasis->number_of_sources() ; ++k )
108 {
109 const Basis * tSource = aBasis->source( k ) ;
110 BELFEM_ASSERT( aBasis != tSource, "Basis and source are the same" );
111 this->bitset( tSource->entity_type() )->set( tSource->index() );
112 this->flag_all_sources( tSource );
113 }
114
115 if ( aBasis->is_hanging() )
116 {
117 this->bitset( aBasis->entity_type() )->reset( aBasis->index() );
118 }
119 }
120
121 inline void
122 SourceExpander::expand_weights( const Basis * aBasis, const real aWeight )
123 {
124 for ( uint k=0; k<aBasis->number_of_sources(); ++k )
125 {
126 const Basis * tSource = aBasis->source( k ) ;
127 if ( tSource->is_hanging() )
128 {
129 this->expand_weights( tSource, aWeight * aBasis->weight( k ) );
130 }
131 else
132 {
133 mWeights( tSource ) += aWeight * aBasis->weight( k ) ;
134 }
135 }
136 }
137
138 }
139}
140#endif // BELFEM_CL_MESH_SOURCEEXPANDER_HPP
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
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_Mesh_Basis.hpp:33
SourceExpander(Mesh *aMesh)
Definition cl_Mesh_SourceExpander.cpp:18
void expand_sources(Basis *aBasis)
Definition cl_Mesh_SourceExpander.cpp:63
Definition cl_EF_EdgeFunction.hpp:17
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
EntityType
Definition Mesh_Enums.hpp:116
@ NODE
Definition Mesh_Enums.hpp:117
@ FACE
Definition Mesh_Enums.hpp:119
@ EDGE
Definition Mesh_Enums.hpp:118
@ FACET
Definition Mesh_Enums.hpp:121
@ ELEMENT
Definition Mesh_Enums.hpp:122
double real
Definition typedefs.hpp:36