BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Vertex.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_VERTEX_HPP
13#define BELFEM_CL_VERTEX_HPP
14
15#include "typedefs.hpp"
16#include "assert.hpp"
17#include "cl_Mesh_Basis.hpp"
18#include "Mesh_Enums.hpp"
19
20namespace belfem
21{
22 namespace mesh
23 {
24 // forward declarations for nodes and edges
25 class Node ;
26 class Element;
27 class Facet;
28 class Edge ;
29
30 class Vertex : public Basis
31 {
32 protected:
34 Node ** mNodes = nullptr ;
35
37 Edge ** mEdges = nullptr ;
38
40 Face ** mFaces = nullptr ;
41
43 Facet ** mFacets = nullptr ;
44
46 Element ** mElements = nullptr ;
47
49 uint16_t mNodeCounter = 0 ;
50 uint16_t mNodeCapacity = 0 ;
51
53 uint16_t mEdgeCounter = 0 ;
54 uint16_t mEdgeCapacity = 0 ;
55
57 uint16_t mFaceCounter = 0 ;
58 uint16_t mFaceCapacity = 0 ;
59
61 uint16_t mFacetCounter = 0 ;
62 uint16_t mFacetCapacity = 0 ;
63
65 uint16_t mElementCounter = 0 ;
66 uint16_t mElementCapacity = 0 ;
67
68//------------------------------------------------------------------------------
69 public:
70//------------------------------------------------------------------------------
71
72 Vertex();
73
74 ~Vertex() override;
75
76//------------------------------------------------------------------------------
77
82 entity_type() const override ;
83
84//------------------------------------------------------------------------------
85// nodes
86//------------------------------------------------------------------------------
87
88 void
90
91 void
93
94 void
95 allocate_node_container( const uint aCounter=0 );
96
97 void
98 add_node( Node * aNode );
99
100 void
101 insert_node( Node * aNode, const uint aIndex );
102
103 uint
104 number_of_nodes() const override ;
105
106 Node *
107 node( const uint aIndex ) override;
108
109 const Node *
110 node( const uint aIndex ) const override ;
111
112//------------------------------------------------------------------------------
113// edges
114//------------------------------------------------------------------------------
115
116 void
118
119 void
121
122 void
123 allocate_edge_container( const uint aCounter=0 );
124
125 void
126 add_edge( Edge * aEdge );
127
128 void
129 insert_edge( Edge * aEdge, const uint aIndex );
130
131 uint
132 number_of_edges() const override ;
133
134 Edge *
135 edge( const uint aIndex ) override;
136
137 const Edge *
138 edge( const uint aIndex ) const override ;
139
140//------------------------------------------------------------------------------
141// faces
142//------------------------------------------------------------------------------
143
144 void
146
147 void
149
150 void
151 allocate_face_container( const uint aCounter=0 );
152
153 void
154 add_face( Face * aFace );
155
156 uint
157 number_of_faces() const override ;
158
159 Face *
160 face( const uint aIndex ) override;
161
162 const Face *
163 face( const uint aIndex ) const override ;
164
165//------------------------------------------------------------------------------
166// facets
167//------------------------------------------------------------------------------
168
169 void
171
172 void
174
175 void
176 allocate_facet_container( const uint aNumFacets=0 );
177
178 void
179 add_facet( Facet * aFacet );
180
181 virtual uint
182 number_of_facets() const ;
183
184 uint16_t
185 facet_capacity() const ;
186
187 virtual Facet *
188 facet( const uint aIndex );
189
190 virtual const Facet *
191 facet( const uint aIndex ) const ;
192
193//------------------------------------------------------------------------------
194// elements
195//------------------------------------------------------------------------------
196
197 void
198 reset_element_container() override;
199
200 void
202
203 void
204 allocate_element_container( const uint aCounter=0 );
205
206 void
207 add_element( Element * aElement );
208
209 uint
210 number_of_elements() const override ;
211
212 Element *
213 element( const uint aIndex ) override;
214
215 virtual const Element *
216 element( const uint aIndex ) const ;
217
218//------------------------------------------------------------------------------
219
220 virtual void
221 flag_nodes( const uint8_t aIndex = 0 );
222
223 virtual void
224 unflag_nodes( const uint8_t aIndex = 0 );
225
226//------------------------------------------------------------------------------
227 protected:
228//------------------------------------------------------------------------------
229
233 void
235
236//------------------------------------------------------------------------------
237
243 size_t
244 array_memory() const ;
245
246//------------------------------------------------------------------------------
247 };
248
249
250//------------------------------------------------------------------------------
251
252 inline void
254 {
255 BELFEM_ASSERT( mNodeCounter < 65535, "Node counter overflow." );
256 ++mNodeCounter ;
257 }
258
259//------------------------------------------------------------------------------
260
261 inline void
263 {
264 BELFEM_ASSERT( mEdgeCounter < 65535, "Edge counter overflow." );
265 ++mEdgeCounter ;
266 }
267
268//------------------------------------------------------------------------------
269
270 inline void
272 {
273 BELFEM_ASSERT( mFaceCounter < 65535, "Face counter overflow." );
274 ++mFaceCounter ;
275 }
276
277//------------------------------------------------------------------------------
278
279 inline void
281 {
282 BELFEM_ASSERT( mFacetCounter < 65535, "Facet counter overflow." );
283 ++mFacetCounter ;
284 }
285
286//------------------------------------------------------------------------------
287
288 inline void
290 {
291 BELFEM_ASSERT( mElementCounter < 65535, "Element counter overflow." );
293 }
294
295//------------------------------------------------------------------------------
296
297 inline uint
299 {
300 return mNodeCounter ;
301 }
302
303//------------------------------------------------------------------------------
304
305 inline size_t
307 {
308 size_t tMem = this->number_of_vertices() * sizeof( graph::Vertex * );
309
310 tMem += this->number_of_dofs() * sizeof( graph::Vertex * );
311
312 // sources and weights are parallel arrays with the same slot count
313 tMem += this->number_of_sources() * ( sizeof( Basis * ) + sizeof( real ) );
314
315 tMem += mNodeCapacity * sizeof( Node * );
316 tMem += mEdgeCapacity * sizeof( Edge * );
317 tMem += mFaceCapacity * sizeof( Face * );
318 tMem += mFacetCapacity * sizeof( Facet * );
319 tMem += mElementCapacity * sizeof( Element * );
320
321 return tMem ;
322 }
323
324//------------------------------------------------------------------------------
325
326 inline uint
328 {
329 return mEdgeCounter ;
330 }
331
332//------------------------------------------------------------------------------
333
334 inline uint
336 {
337 return mFacetCounter ;
338 }
339
340//------------------------------------------------------------------------------
341
342 inline uint16_t
344 {
345 return mFacetCapacity ;
346 }
347
348//------------------------------------------------------------------------------
349
350 inline uint
352 {
353 return mElementCounter ;
354 }
355
356//------------------------------------------------------------------------------
357
358 inline Node *
359 Vertex::node( const uint aIndex )
360 {
361 BELFEM_ASSERT( aIndex < ( uint ) mNodeCapacity,
362 "Node index %u is out of bounds for element %u, must be < %u.",
363 ( unsigned int ) aIndex,
364 ( unsigned int ) this->id(),
365 ( unsigned int ) mNodeCapacity );
366
367 return mNodes[ aIndex ];
368 }
369
370//------------------------------------------------------------------------------
371
372 inline const Node *
373 Vertex::node( const uint aIndex ) const
374 {
375 BELFEM_ASSERT( aIndex < ( uint ) mNodeCapacity,
376 "Node index %u is out of bounds for element %u, must be < %u.",
377 ( unsigned int ) aIndex,
378 ( unsigned int ) this->id(),
379 ( unsigned int ) mNodeCapacity );
380
381 return mNodes[ aIndex ];
382 }
383
384//------------------------------------------------------------------------------
385
386 inline Edge *
387 Vertex::edge( const uint aIndex )
388 {
389 BELFEM_ASSERT( aIndex < ( uint ) mEdgeCapacity,
390 "Edge index %u is out of bounds for element %u, must be < %u.",
391 ( unsigned int ) aIndex,
392 ( unsigned int ) this->id(),
393 ( unsigned int ) mEdgeCapacity );
394
395 return mEdges[ aIndex ];
396 }
397
398//------------------------------------------------------------------------------
399
400 inline const Edge *
401 Vertex::edge( const uint aIndex ) const
402 {
403 BELFEM_ASSERT( aIndex < ( uint ) mEdgeCapacity,
404 "Edge index %u is out of bounds for element %u, must be < %u.",
405 ( unsigned int ) aIndex,
406 ( unsigned int ) this->id(),
407 ( unsigned int ) mEdgeCapacity );
408
409 return mEdges[ aIndex ];
410 }
411
412//------------------------------------------------------------------------------
413
414 inline uint
416 {
417 return mFaceCounter ;
418 }
419
420 inline Face *
421 Vertex::face( const uint aIndex )
422 {
423 BELFEM_ASSERT( aIndex < ( uint ) mFaceCapacity,
424 "Face index %u is out of bounds for face %u, must be < %u.",
425 ( unsigned int ) aIndex,
426 ( unsigned int ) this->id(),
427 ( unsigned int ) mFaceCapacity );
428
429 return mFaces[ aIndex ];
430 }
431
432 inline const Face *
433 Vertex::face( const uint aIndex ) const
434 {
435 BELFEM_ASSERT( aIndex < ( uint ) mFaceCapacity,
436 "Face index %u is out of bounds for face %u, must be < %u.",
437 ( unsigned int ) aIndex,
438 ( unsigned int ) this->id(),
439 ( unsigned int ) mFaceCapacity );
440
441 return mFaces[ aIndex ];
442 }
443
444//------------------------------------------------------------------------------
445
446 inline Facet *
447 Vertex::facet( const uint aIndex )
448 {
449 BELFEM_ASSERT( aIndex < ( uint ) mFacetCapacity,
450 "Facet index %u is out of bounds for element %u, must be < %u.",
451 ( unsigned int ) aIndex,
452 ( unsigned int ) this->id(),
453 ( unsigned int ) mFacetCapacity );
454
455 return mFacets[ aIndex ];
456 }
457
458//------------------------------------------------------------------------------
459
460 inline const Facet *
461 Vertex::facet( const uint aIndex ) const
462 {
463 BELFEM_ASSERT( aIndex < ( uint ) mFacetCapacity,
464 "Facet index %u is out of bounds for element %u, must be < %u.",
465 ( unsigned int ) aIndex,
466 ( unsigned int ) this->id(),
467 ( unsigned int ) mFacetCapacity );
468
469 return mFacets[ aIndex ];
470 }
471
472//------------------------------------------------------------------------------
473
474 inline Element *
475 Vertex::element( const uint aIndex )
476 {
477 BELFEM_ASSERT( aIndex < ( uint ) mElementCapacity,
478 "Element index %u is out of bounds for element %u, must be < %u.",
479 ( unsigned int ) aIndex,
480 ( unsigned int ) this->id(),
481 ( unsigned int ) mElementCapacity );
482
483 return mElements[ aIndex ];
484 }
485
486//------------------------------------------------------------------------------
487
488 inline const Element *
489 Vertex::element( const uint aIndex ) const
490 {
491 BELFEM_ASSERT( aIndex < ( uint ) mElementCapacity,
492 "Element index %u is out of bounds for element %u, must be < %u.",
493 ( unsigned int ) aIndex,
494 ( unsigned int ) this->id(),
495 ( unsigned int ) mElementCapacity );
496
497 return mElements[ aIndex ];
498 }
499
500//------------------------------------------------------------------------------
501
502 inline EntityType
504 {
505 BELFEM_ERROR( false, "invalid call to abstract class");
506 return EntityType::UNDEFINED ;
507 }
508
509//------------------------------------------------------------------------------
510 }
511}
512#endif //BELFEM_CL_VERTEX_HPP
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Graph node with an adjacency list; the vertex type the graph algorithms operate on.
Definition cl_Graph_Vertex.hpp:32
uint number_of_vertices() const
Definition cl_Graph_Vertex.hpp:323
uint number_of_dofs() const
Definition cl_Mesh_Basis.hpp:341
uint number_of_sources() const
Definition cl_Mesh_Basis.hpp:274
Basis()
Definition cl_Mesh_Basis.cpp:21
Special Edge class for NEDELEC-Type elements.
Definition cl_Edge.hpp:30
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_Face.hpp:29
Definition cl_Facet.hpp:24
Definition cl_Node.hpp:30
Edge * edge()
Definition cl_Segment.hpp:146
Element * element()
expose the element pointer
Definition cl_Segment.hpp:140
Edge ** mEdges
pointer to edges
Definition cl_Vertex.hpp:37
uint number_of_faces() const override
Definition cl_Vertex.hpp:415
uint16_t mNodeCounter
number of nodes connected to this vertex
Definition cl_Vertex.hpp:49
void reset_element_container() override
Definition cl_Vertex.cpp:259
void add_facet(Facet *aFacet)
Definition cl_Vertex.cpp:250
Element * element(const uint aIndex) override
Definition cl_Vertex.hpp:475
uint number_of_nodes() const override
Definition cl_Vertex.hpp:298
virtual uint number_of_facets() const
Definition cl_Vertex.hpp:335
EntityType entity_type() const override
returns the type of this mesh vertex
Definition cl_Vertex.hpp:503
void add_node(Node *aNode)
Definition cl_Vertex.cpp:88
uint16_t mEdgeCounter
number of edges connected to this vertex
Definition cl_Vertex.hpp:53
virtual Facet * facet(const uint aIndex)
Definition cl_Vertex.hpp:447
uint16_t mFaceCapacity
Definition cl_Vertex.hpp:58
void reset_face_container()
Definition cl_Vertex.cpp:173
void increment_edge_counter()
Definition cl_Vertex.hpp:262
uint16_t mElementCounter
number of elements connected to this vertex
Definition cl_Vertex.hpp:65
void increment_node_counter()
Definition cl_Vertex.hpp:253
virtual void unflag_nodes(const uint8_t aIndex=0)
Definition cl_Vertex.cpp:315
void allocate_edge_container(const uint aCounter=0)
Definition cl_Vertex.cpp:127
uint16_t mFacetCapacity
Definition cl_Vertex.hpp:62
uint16_t mFacetCounter
number of facets connected to this vertex
Definition cl_Vertex.hpp:61
uint16_t mFaceCounter
number of faces connected to this vertex
Definition cl_Vertex.hpp:57
uint16_t facet_capacity() const
Definition cl_Vertex.hpp:343
void reset_facet_container()
Definition cl_Vertex.cpp:214
uint16_t mElementCapacity
Definition cl_Vertex.hpp:66
void increment_element_counter()
Definition cl_Vertex.hpp:289
void add_face(Face *aFace)
Definition cl_Vertex.cpp:205
uint16_t mEdgeCapacity
Definition cl_Vertex.hpp:54
void insert_edge(Edge *aEdge, const uint aIndex)
Definition cl_Vertex.cpp:159
Face ** mFaces
pointer to faces
Definition cl_Vertex.hpp:40
void allocate_node_container(const uint aCounter=0)
Definition cl_Vertex.cpp:65
Face * face(const uint aIndex) override
Definition cl_Vertex.hpp:421
void reset_edge_container()
Definition cl_Vertex.cpp:113
void allocate_face_container(const uint aCounter=0)
Definition cl_Vertex.cpp:185
Element ** mElements
pointer to elements
Definition cl_Vertex.hpp:46
uint number_of_elements() const override
Definition cl_Vertex.hpp:351
virtual void flag_nodes(const uint8_t aIndex=0)
Definition cl_Vertex.cpp:304
void reset_node_container()
Definition cl_Vertex.cpp:51
uint number_of_edges() const override
Definition cl_Vertex.hpp:327
void add_edge(Edge *aEdge)
Definition cl_Vertex.cpp:150
void increment_facet_counter()
Definition cl_Vertex.hpp:280
void allocate_element_container(const uint aCounter=0)
Definition cl_Vertex.cpp:273
Node ** mNodes
pointer to nodes
Definition cl_Vertex.hpp:34
void allocate_facet_container(const uint aNumFacets=0)
Definition cl_Vertex.cpp:228
Node * node(const uint aIndex) override
Definition cl_Vertex.hpp:359
Edge * edge(const uint aIndex) override
Definition cl_Vertex.hpp:387
Vertex()
Definition cl_Vertex.cpp:24
void insert_node(Node *aNode, const uint aIndex)
Definition cl_Vertex.cpp:97
uint16_t mNodeCapacity
Definition cl_Vertex.hpp:50
void delete_containers()
must be called by destructor
Definition cl_Vertex.cpp:38
void add_element(Element *aElement)
Definition cl_Vertex.cpp:295
size_t array_memory() const
Definition cl_Vertex.hpp:306
Facet ** mFacets
pointer to facets
Definition cl_Vertex.hpp:43
void increment_face_counter()
Definition cl_Vertex.hpp:271
Definition cl_EF_EdgeFunction.hpp:24
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
EntityType
Definition Mesh_Enums.hpp:116
@ UNDEFINED
Definition Mesh_Enums.hpp:124
double real
Definition typedefs.hpp:36