BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_ControlPoint.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_CONTROLPOINT_HPP
13#define BELFEM_CL_CONTROLPOINT_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 class Element ;
25
26 class ControlPoint : public Basis
27 {
28 // coordinates of this control point
29 real mCoords[ 3 ];
30
32 Element **mElements;
33
35 uint mElementCounter = 0 ;
36
38 ControlPoint **mControlPoints;
39
41 uint mControlPointCounter = 0 ;
42
43//------------------------------------------------------------------------------
44 public:
45//------------------------------------------------------------------------------
46
47 ControlPoint( const id_t aID, const real aX=0.0, const real aY=0.0, const real aZ=0.0 ) ;
48
49//------------------------------------------------------------------------------
50
51 ~ControlPoint() override ;
52
53//------------------------------------------------------------------------------
54
56 entity_type() const override;
57
58//------------------------------------------------------------------------------
59
60 real
61 x() const;
62
63//------------------------------------------------------------------------------
64
65 real
66 y() const;
67
68//------------------------------------------------------------------------------
69
70 real
71 z() const;
72
73//------------------------------------------------------------------------------
74
75 real
76 x( const uint aIndex ) const;
77
78//------------------------------------------------------------------------------
79
81 coords() const;
82
83//------------------------------------------------------------------------------
84
85 void
86 set_coords( const real aX, const real aY, const real aZ );
87
88//------------------------------------------------------------------------------
89
90 void
92
93//------------------------------------------------------------------------------
94
95 void
97
98//------------------------------------------------------------------------------
99
100 void
101 reset_element_container() override;
102
103//------------------------------------------------------------------------------
104
105 void
107
108//------------------------------------------------------------------------------
109
110 void
112
113//------------------------------------------------------------------------------
114
115 void
117//------------------------------------------------------------------------------
118
119 void
120 add_element( Element * aElement );
121
122//------------------------------------------------------------------------------
123
124 void
125 add_control_point( ControlPoint * aControlPoint );
126
127//------------------------------------------------------------------------------
128
129 uint
130 number_of_elements() const override;
131
132//------------------------------------------------------------------------------
133
134 uint
136
137//------------------------------------------------------------------------------
138
139 Element *
140 element( const uint aIndex ) override;
141
142//------------------------------------------------------------------------------
143
144 const Element *
145 element( const uint aIndex ) const;
146
147//------------------------------------------------------------------------------
148
150 control_point( const uint aIndex );
151
152//------------------------------------------------------------------------------
153
154 const ControlPoint *
155 control_point( const uint aIndex ) const;
156
157//------------------------------------------------------------------------------
158
159 size_t memory() const;
160
161//------------------------------------------------------------------------------
162 };
163
164//------------------------------------------------------------------------------
165
166 inline EntityType
171
172//------------------------------------------------------------------------------
173
174 inline real
176 {
177 return mCoords[ 0 ];
178 }
179
180//------------------------------------------------------------------------------
181
182 inline real
184 {
185 return mCoords[ 1 ];
186 }
187
188//------------------------------------------------------------------------------
189
190 inline real
192 {
193 return mCoords[ 2 ];
194 }
195
196//------------------------------------------------------------------------------
197
198 inline real
199 ControlPoint::x( const uint aIndex ) const
200 {
201 BELFEM_ASSERT( aIndex < 3, "Invalid index %u for control point %lu.", ( unsigned int ) aIndex, ( long unsigned int ) id() );
202 return mCoords[ aIndex ];
203 }
204
205//------------------------------------------------------------------------------
206
207 inline Vector<real>
209 {
210 return Vector<real>( { mCoords[0], mCoords[1], mCoords[2] } );
211 }
212
213//------------------------------------------------------------------------------
214
215 inline uint
217 {
218 return mElementCounter;
219 }
220
221//------------------------------------------------------------------------------
222
223 inline uint
225 {
226 return mControlPointCounter;
227 }
228
229//------------------------------------------------------------------------------
230
231 inline Element *
233 {
234 BELFEM_ASSERT( aIndex < mElementCounter,
235 "Invalid control point index %u for element %lu. (expect < %u)",
236 ( unsigned int ) aIndex, ( long unsigned int ) id(),
237 ( unsigned int ) mElementCounter );
238 return mElements[ aIndex ];
239 }
240
241//------------------------------------------------------------------------------
242
243 inline const Element *
244 ControlPoint::element( const uint aIndex ) const
245 {
246 BELFEM_ASSERT( aIndex < mElementCounter,
247 "Invalid control point index %u for element %lu. (expect < %u)",
248 ( unsigned int ) aIndex, ( long unsigned int ) id(), ( unsigned int )
249 mElementCounter );
250 return mElements[ aIndex ];
251 }
252
253//------------------------------------------------------------------------------
254
255 inline ControlPoint *
257 {
258 BELFEM_ASSERT( aIndex < mControlPointCounter,
259 "Invalid control point index %u for control point %lu. (expect < %u)",
260 ( unsigned int ) aIndex, ( long unsigned int ) id(),
261 ( unsigned int ) mControlPointCounter );
262 return mControlPoints[ aIndex ];
263 }
264
265//------------------------------------------------------------------------------
266
267 inline const ControlPoint *
268 ControlPoint::control_point( const uint aIndex ) const
269 {
270 BELFEM_ASSERT( aIndex < mControlPointCounter,
271 "Invalid control point index %u for control point %lu. (expect < %u)",
272 ( unsigned int ) aIndex, ( long unsigned int ) id(),
273 ( unsigned int ) mControlPointCounter );
274 return mControlPoints[ aIndex ];
275 }
276
277//------------------------------------------------------------------------------
278
279 inline void
281 {
282 ++mElementCounter;
283 }
284
285//------------------------------------------------------------------------------
286
288 {
289 ++mControlPointCounter;
290 }
291
292//------------------------------------------------------------------------------
293
294 inline void ControlPoint::add_element( Element *aElement )
295 {
296 mElements[ mElementCounter++ ] = aElement;
297 }
298
299//------------------------------------------------------------------------------
300
301 inline void ControlPoint::add_control_point( ControlPoint *aControlPoint )
302 {
303 mControlPoints[ mControlPointCounter++ ] = aControlPoint;
304 }
305
306//------------------------------------------------------------------------------
307
308 inline size_t
310 {
311 return sizeof( ControlPoint )
312 + ( mElementCounter ) * sizeof( Element * )
313 + ( mControlPointCounter ) * sizeof( ControlPoint * );
314 }
315
316//------------------------------------------------------------------------------
317 }
318}
319#endif //BELFEM_CL_CONTROLPOINT_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Column vector.
Definition cl_BZ_Vector.hpp:41
Basis()
Definition cl_Mesh_Basis.cpp:21
Definition cl_ControlPoint.hpp:27
Element * element(const uint aIndex) override
Definition cl_ControlPoint.hpp:232
real y() const
Definition cl_ControlPoint.hpp:183
void allocate_element_container()
Definition cl_ControlPoint.cpp:62
void set_coords(const real aX, const real aY, const real aZ)
Definition cl_ControlPoint.cpp:52
void reset_element_container() override
Definition cl_ControlPoint.cpp:89
uint number_of_elements() const override
Definition cl_ControlPoint.hpp:216
void increment_control_point_counter()
Definition cl_ControlPoint.hpp:287
void allocate_control_point_container()
Definition cl_ControlPoint.cpp:75
ControlPoint * control_point(const uint aIndex)
Definition cl_ControlPoint.hpp:256
size_t memory() const
Definition cl_ControlPoint.hpp:309
real z() const
Definition cl_ControlPoint.hpp:191
Vector< real > coords() const
Definition cl_ControlPoint.hpp:208
real x() const
Definition cl_ControlPoint.hpp:175
ControlPoint(const id_t aID, const real aX=0.0, const real aY=0.0, const real aZ=0.0)
Definition cl_ControlPoint.cpp:21
EntityType entity_type() const override
returns the type of this vertex
Definition cl_ControlPoint.hpp:167
uint number_of_control_points() const
Definition cl_ControlPoint.hpp:224
void add_control_point(ControlPoint *aControlPoint)
Definition cl_ControlPoint.hpp:301
void reset_control_point_container()
Definition cl_ControlPoint.cpp:102
void increment_element_counter()
Definition cl_ControlPoint.hpp:280
void add_element(Element *aElement)
Definition cl_ControlPoint.hpp:294
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_EF_EdgeFunction.hpp:17
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
unsigned int id_t
Definition typedefs.hpp:41
EntityType
Definition Mesh_Enums.hpp:116
@ CONTROLPOINT
Definition Mesh_Enums.hpp:123
double real
Definition typedefs.hpp:36