BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Block.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_BLOCK_HPP
13#define BELFEM_CL_BLOCK_HPP
14
15#include "typedefs.hpp"
16#include "cl_Cell.hpp"
17#include "cl_Element.hpp"
18#include "en_DomainType.hpp"
19
20namespace belfem
21{
22 namespace mesh
23 {
24 class GmshReader;
25
26 class Block
27 {
28//------------------------------------------------------------------------------
29 protected:
30//------------------------------------------------------------------------------
31
34
36
38
40
41 string mLabel;
42
44 bool mHasEdges = false ;
45
47 bool mHasFaces = false ;
48
50 bool mIsHidden = false ;
51
54
55 friend GmshReader;
56
57//------------------------------------------------------------------------------
58 public:
59//------------------------------------------------------------------------------
60
61 Block( const id_t aID, const index_t aNumElements );
62
63//------------------------------------------------------------------------------
64
65 ~Block() ;
66
67//------------------------------------------------------------------------------
68
69 inline id_t
70 id() const
71 {
72 return mID;
73 }
74
75 inline index_t
76 index() const
77 {
78 return mIndex;
79 }
80
81 inline void
82 set_index( const index_t aIndex )
83 {
84 mIndex = aIndex;
85 }
86//------------------------------------------------------------------------------
87
88 void
89 insert_element( Element * aElement );
90
91//------------------------------------------------------------------------------
92
93 inline Element *
94 element( const index_t aIndex )
95 {
96 BELFEM_ASSERT( aIndex < mElements.size(),
97 "Invalid Element index %lu in block %lu",
98 ( long unsigned int ) aIndex,
99 ( long unsigned int ) mID );
100
101 return mElements( aIndex );
102 }
103
104//------------------------------------------------------------------------------
105
106 inline Cell< Element * > &
108 {
109 return mElements;
110 }
111
112//------------------------------------------------------------------------------
113
114 inline index_t
116 {
117 return mElements.size();
118 }
119
120//------------------------------------------------------------------------------
121
122 inline string &
124 {
125 return mLabel;
126 }
127
128//------------------------------------------------------------------------------
129
130 inline ElementType
132 {
133 BELFEM_ASSERT( mElements.size() > 0, "Block %u seems to be empty.",
134 ( unsigned int ) mID );
135
136 return mElements( 0 )->type();
137 }
138
139
140//------------------------------------------------------------------------------
141
146 inline bool
147 has_edges() const
148 {
149 return mHasEdges;
150 }
151
152//------------------------------------------------------------------------------
153
158 inline bool
159 has_faces() const
160 {
161 return mHasFaces;
162 }
163
164//------------------------------------------------------------------------------
165
166 inline bool
167 is_hidden() const
168 {
169 return mIsHidden ;
170 }
171
172//------------------------------------------------------------------------------
173
174 void
175 set_edges_flag( const bool aFlag=true );
176
177 void
178 set_faces_flag( const bool aFlag=true );
179
180//------------------------------------------------------------------------------
181
182 void
183 flag_elements( const uint8_t aFlagIndex = 0 );
184
185//------------------------------------------------------------------------------
186
187 void
188 unflag_elements( const uint8_t aFlagIndex = 0 );
189
190//------------------------------------------------------------------------------
191
192 void
193 flag_nodes();
194
195//------------------------------------------------------------------------------
196
197 void
198 unflag_nodes();
199
200//------------------------------------------------------------------------------
201
202 void
204
205//------------------------------------------------------------------------------
206
207 void
208 flag_edges();
209
210//------------------------------------------------------------------------------
211
212 void
213 flag_faces();
214
215//------------------------------------------------------------------------------
216
218 domain_type() const ;
219
220//------------------------------------------------------------------------------
221
222 void
223 set_domain_type( const DomainType aType );
224
225 void
226 set_thickness( const real aThickness );
227
228 real
229 thickness() const ;
230
231 void
232 set_element_counter( const index_t aCounter );
233
234//------------------------------------------------------------------------------
235
236 size_t
237 memory() const ;
238
239//------------------------------------------------------------------------------
240 };
241
242//------------------------------------------------------------------------------
243
244 inline DomainType
246 {
247 return mDomainType ;
248 }
249
250//------------------------------------------------------------------------------
251
252 inline
254 {
255 mDomainType = aType ;
256 }
257
258//------------------------------------------------------------------------------
259
260 inline void
261 Block::set_thickness( const real aThickness )
262 {
263 mThickness = aThickness ;
264 }
265
266//------------------------------------------------------------------------------
267
268 inline real
270 {
271 return mThickness ;
272 }
273
274//------------------------------------------------------------------------------
275
276 inline size_t Block::memory() const
277 {
278 return sizeof( Block )
279 + mElements.size() * sizeof( Element * )
280 + mLabel.capacity() * sizeof( char ) ;
281 }
282
283//------------------------------------------------------------------------------
284
285 inline void Block::set_element_counter( const index_t aCounter )
286 {
287 mElementCounter = aCounter ;
288 }
289
290//------------------------------------------------------------------------------
291
292 }
293}
294#endif //BELFEM_CL_BLOCK_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
size_t size() const
return the size of the Cell
Definition cl_Cell.hpp:181
id_t id() const
Definition cl_Block.hpp:70
bool mHasFaces
flag telling if elements on this block have faces
Definition cl_Block.hpp:47
friend GmshReader
Definition cl_Block.hpp:55
void set_edges_flag(const bool aFlag=true)
Definition cl_Block.cpp:139
bool has_faces() const
function telling if elements in this group have faces ( default : false )
Definition cl_Block.hpp:159
void set_domain_type(const DomainType aType)
Definition cl_Block.hpp:253
DomainType domain_type() const
Definition cl_Block.hpp:245
void flag_nodes()
Definition cl_Block.cpp:78
index_t number_of_elements() const
Definition cl_Block.hpp:115
void set_index(const index_t aIndex)
Definition cl_Block.hpp:82
index_t index() const
Definition cl_Block.hpp:76
string & label()
Definition cl_Block.hpp:123
Block(const id_t aID, const index_t aNumElements)
Definition cl_Block.cpp:21
void set_thickness(const real aThickness)
Definition cl_Block.hpp:261
real mThickness
thickness, only used for thin shells
Definition cl_Block.hpp:53
bool is_hidden() const
Definition cl_Block.hpp:167
bool mHasEdges
flag telling if elements on this block have edges
Definition cl_Block.hpp:44
bool has_edges() const
function telling if elements in this group have edges ( default : false )
Definition cl_Block.hpp:147
void unflag_nodes()
Definition cl_Block.cpp:89
void flag_elements(const uint8_t aFlagIndex=0)
Definition cl_Block.cpp:56
void flag_faces()
Definition cl_Block.cpp:125
Cell< Element * > & elements()
Definition cl_Block.hpp:107
bool mIsHidden
flag telling if block is visualized in VTK tool (not exodus output)
Definition cl_Block.hpp:50
void insert_element(Element *aElement)
Definition cl_Block.cpp:45
index_t mElementCounter
Definition cl_Block.hpp:35
real thickness() const
Definition cl_Block.hpp:269
void flag_edges()
Definition cl_Block.cpp:111
void flag_corner_nodes()
Definition cl_Block.cpp:100
index_t mIndex
Definition cl_Block.hpp:33
id_t mID
Definition cl_Block.hpp:32
DomainType mDomainType
Definition cl_Block.hpp:39
string mLabel
Definition cl_Block.hpp:41
ElementType element_type() const
Definition cl_Block.hpp:131
void set_faces_flag(const bool aFlag=true)
Definition cl_Block.cpp:145
void set_element_counter(const index_t aCounter)
Definition cl_Block.hpp:285
Element * element(const index_t aIndex)
Definition cl_Block.hpp:94
Cell< Element * > mElements
Definition cl_Block.hpp:37
size_t memory() const
Definition cl_Block.hpp:276
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_Mesh_GmshReader.hpp:40
Definition cl_EF_EdgeFunction.hpp:17
void unflag_elements(Cell< Element * > &aElements)
Definition fn_unflag_elements.hpp:24
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int id_t
Definition typedefs.hpp:41
ElementType
Element types.
Definition Mesh_Enums.hpp:27
DomainType domain_type(const string &aString)
Definition en_DomainType.cpp:103
constexpr index_t gNoIndex
Definition typedefs.hpp:57
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
#define BELFEM_QUIET_NAN
Definition typedefs.hpp:87