BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Face.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_FACE_HPP
13#define BELFEM_CL_FACE_HPP
14
15#include "typedefs.hpp"
16#include "assert.hpp"
17#include "cl_Cell.hpp"
18#include "cl_Vertex.hpp"
19
20namespace belfem
21{
22 namespace mesh
23 {
24 class Element ;
25
26//-----------------------------------------------------------------------------
27
28 class Face : public Vertex
29 {
30
31 Element * mMaster = nullptr ;
32 uint mIndexOnMaster ;
33
34 Element * mSlave = nullptr ;
35 uint mIndexOnSlave ;
36
37 // orientation on master is always zero
38 uint mOrientationOnSlave = gNoIndex ;
39
40 Face * mPeriodic = nullptr ;
41
42//-----------------------------------------------------------------------------
43 public:
44//-----------------------------------------------------------------------------
45
46 // 2d constructor
47 Face( Element * aParent );
48
49 // 3d constructor
50 Face( Element * aMaster,
51 const uint aIndexOnMaster,
52 Element * aSlave,
53 const uint aIndexOnSlave,
54 const uint aOrientationOnSlave = gNoIndex );
55
56//-----------------------------------------------------------------------------
57
58 ~Face() override;
59
60//-----------------------------------------------------------------------------
61
62
64 entity_type() const override ;
65
66//-----------------------------------------------------------------------------
67
68 Element *
69 master();
70
71//-----------------------------------------------------------------------------
72
73 Element *
74 slave();
75
76//-----------------------------------------------------------------------------
77
78 uint
79 index_on_master() const ;
80
81//-----------------------------------------------------------------------------
82
83 uint
84 index_on_slave() const ;
85
86//-----------------------------------------------------------------------------
87
88 uint
89 orientation_on_slave() const ;
90
91//-----------------------------------------------------------------------------
92
93 bool
94 edge_direction( const uint aEdgeIndex ) const ;
95
96//-----------------------------------------------------------------------------
97
98 uint
100
101//-----------------------------------------------------------------------------
102
103 void
105
106//-----------------------------------------------------------------------------
107
108 size_t
109 memory() const ;
110
111//-----------------------------------------------------------------------------
112
113 uint
114 number_of_elements() const override ;
115
116//-----------------------------------------------------------------------------
117
118 Element *
119 element(const uint aIndex) override;
120
121//-----------------------------------------------------------------------------
122
123 const Element *
124 element(const uint aIndex) const override;
125
126//------------------------------------------------------------------------------
127
128 void
129 set_master( Element * aElement, const uint aIndex );
130
131 //------------------------------------------------------------------------------
132
133 void
134 set_slave( Element * aElement, const uint aIndex, const uint aOrientation );
135
136 void
137 set_periodic( Face * aPeriodic );
138
139 Face *
140 periodic() ;
141
142 const Face *
143 periodic() const ;
144
145 bool
146 is_periodic() const ;
147
148//-----------------------------------------------------------------------------
149 private:
150//-----------------------------------------------------------------------------
151
152 uint
153 compute_orientation(
154 Element * aMaster,
155 const uint aIndexOnMaster,
156 Element * aSlave,
157 const uint aIndexOnSlave );
158
159//-----------------------------------------------------------------------------
160 };
161//-----------------------------------------------------------------------------
162
163 inline EntityType
165 {
166 return EntityType::FACE ;
167 }
168
169//-----------------------------------------------------------------------------
170
171 inline Element *
173 {
174 return mMaster ;
175 }
176
177//-----------------------------------------------------------------------------
178
179 inline Element *
181 {
182 return mSlave ;
183 }
184
185//-----------------------------------------------------------------------------
186
187 inline uint
189 {
190 return mIndexOnMaster ;
191 }
192
193//-----------------------------------------------------------------------------
194
195 inline uint
197 {
198 return mIndexOnSlave ;
199 }
200
201//-----------------------------------------------------------------------------
202
203 inline uint
205 {
206 return mOrientationOnSlave ;
207 }
208
209//-----------------------------------------------------------------------------
210
211 inline uint
213 {
214 uint aNumElems = 0 ;
215 if ( mMaster != nullptr ) ++ aNumElems ;
216 if ( mSlave != nullptr ) ++ aNumElems ;
217 return aNumElems ;
218 }
219
220//-----------------------------------------------------------------------------
221
222 inline Element *
223 Face::element(const uint aIndex)
224 {
225 if ( aIndex == 0 )
226 {
227 if ( mMaster != nullptr ) return mMaster ;
228 if ( mSlave != nullptr ) return mSlave ;
229 BELFEM_ASSERT( false, "Element index %u out of bounds.", aIndex );
230 return nullptr ;
231 }
232 else
233 {
234 BELFEM_ASSERT( mMaster != nullptr, "Element index %u out of bounds.", aIndex );
235 BELFEM_ASSERT( mSlave != nullptr, "Element index %u out of bounds.", aIndex );
236 return mSlave ;
237 }
238 }
239
240//-----------------------------------------------------------------------------
241
242 inline const Element *
243 Face::element(const uint aIndex) const
244 {
245 if ( aIndex == 0 )
246 {
247 if ( mMaster != nullptr ) return mMaster ;
248 if ( mSlave != nullptr ) return mSlave ;
249 BELFEM_ASSERT( false, "Element index %u out of bounds.", aIndex );
250 return nullptr ;
251 }
252 else
253 {
254 BELFEM_ASSERT( mMaster != nullptr, "Element index %u out of bounds.", aIndex );
255 BELFEM_ASSERT( mSlave != nullptr, "Element index %u out of bounds.", aIndex );
256 return mSlave ;
257 }
258 }
259
260//-----------------------------------------------------------------------------
261
262 inline size_t
264 {
265 return sizeof( Face ) + this->array_memory() ;
266 }
267
268//-----------------------------------------------------------------------------
269
270 inline void
272 {
273 mPeriodic = aPeriodic ;
274 }
275
276 inline Face *
278 {
279 return mPeriodic ;
280 }
281
282 inline const Face *
284 {
285 return mPeriodic ;
286 }
287
288 inline bool
290 {
291 return mPeriodic != nullptr ;
292 }
293
294 }
295}
296
297#endif //BELFEM_CL_FACE_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Lagrange Element baseclass.
Definition cl_Element.hpp:35
Definition cl_Face.hpp:29
bool is_periodic() const
Definition cl_Face.hpp:289
void set_periodic(Face *aPeriodic)
Definition cl_Face.hpp:271
EntityType entity_type() const override
returns the type of this vertex
Definition cl_Face.hpp:164
size_t memory() const
Definition cl_Face.hpp:263
void set_slave(Element *aElement, const uint aIndex, const uint aOrientation)
Definition cl_Face.cpp:215
Element * master()
Definition cl_Face.hpp:172
Element * element(const uint aIndex) override
Definition cl_Face.hpp:223
uint number_of_elements() const override
Definition cl_Face.hpp:212
uint orientation_on_slave() const
Definition cl_Face.hpp:204
Face * periodic()
Definition cl_Face.hpp:277
uint number_of_corner_nodes()
Definition cl_Face.cpp:186
uint index_on_slave() const
Definition cl_Face.hpp:196
bool edge_direction(const uint aEdgeIndex) const
Definition cl_Face.cpp:155
uint index_on_master() const
Definition cl_Face.hpp:188
Face(Element *aParent)
Definition cl_Face.cpp:23
void set_master(Element *aElement, const uint aIndex)
Definition cl_Face.cpp:207
void flag_corner_nodes()
Definition cl_Face.cpp:194
Element * slave()
Definition cl_Face.hpp:180
Vertex()
Definition cl_Vertex.cpp:24
size_t array_memory() const
Definition cl_Vertex.hpp:304
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
@ FACE
Definition Mesh_Enums.hpp:119
constexpr index_t gNoIndex
Definition typedefs.hpp:57