GCC Code Coverage Report


Directory: ./
File: FiniteElement/geoElement.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 40 47 85.1%
Branches: 12 28 42.9%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: J-F. Gerbeau
13 //
14
15 #ifndef _GEO_ELEMENT_HPP_
16 #define _GEO_ELEMENT_HPP_
17
18 // System includes
19 #include <iostream>
20 #include <unordered_map>
21 #include <string>
22
23 // External includes
24
25 // Project includes
26 #include "Core/felisce.hpp"
27 #include "FiniteElement/basisFunction.hpp"
28 #include "FiniteElement/refShape.hpp"
29 #include "FiniteElement/refElement.hpp"
30 #include "Geometry/geometricMeshRegion.hpp"
31
32 namespace felisce
33 {
34 /*!
35 \class GeoElement
36 \authors J-F. Gerbeau
37
38 \brief Class implementing a geometric element
39
40 A geometric element is defined by
41 - a set of basis functions
42 - a geometric shape
43 - the coordinates of the points
44
45 Let \f$x_{i,icoor}\f$ be the coordinate \c icoor of the point \c. Then the geometric mapping is defined by
46 \f$\Phi(\hat x) = \sum_{i=1}^{n} \hat x_i \phi_i(\hat x) \f$
47
48 Any new geometric element must be declared in geoElement.hpp and defined in definitionGlobalVariables.cpp
49 */
50 class GeoElement
51 {
52 public:
53 ///@name Type Definitions
54 ///@{
55
56 ///@}
57 ///@name Life Cycle
58 ///@{
59
60 GeoElement(const std::string& name,const RefShape& shape,const BasisFunction& basisFunction,const double* pointCoor,const int numEdge,const int numFace,
61 const int* pointOfEdge,const int* pointOfFace,const int* edgeOfFace,const bool* orientationOfEdge,
62 const GeoElement** boundaryGeoElement,const GeoElement** boundaryBoundaryGeoElement,
63 const RefElement& defaultFiniteEle);
64 ~GeoElement();
65
66 ///@}
67 ///@name Operators
68 ///@{
69
70 ///@}
71 ///@name Operations
72 ///@{
73
74 const RefElement* defineFiniteEle(const GeometricMeshRegion::ElementType eltType, const int typeOfFiniteElement, GeometricMeshRegion& mesh) const;
75
76 ///@}
77 ///@name Access
78 ///@{
79
80 inline std::string name() const {
81 return m_name;
82 }
83
84 3608036 inline const RefShape& shape() const {
85 3608036 return m_shape;
86 }
87
88 86232 inline const RefElement& defaultFiniteEle() const {
89 86232 return m_defaultFiniteEle;
90 }
91
92 170393 inline int numCoor() const {
93 170393 return m_numCoor;
94 }
95
96 10641506 inline int numPoint() const {
97 10641506 return m_numPoint;
98 }
99
100 3262031 inline int numEdge() const {
101 3262031 return m_numEdge;
102 }
103
104 3923622 inline int numFace() const {
105 3923622 return m_numFace;
106 }
107
108 18520 inline int numBdEle() const {
109 18520 return m_numBdEle;
110 }
111
112 16587942 inline int pointOfEdge(int localEdge, int ipoint) const {
113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16587942 times.
16587942 FEL_ASSERT(localEdge<m_numEdge);
114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16587942 times.
16587942 FEL_ASSERT(ipoint<m_numPointPerEdge[localEdge]);
115 16587942 return m_ptOfEd[m_indexPointPerEdge[localEdge]+ipoint];
116 }
117
118 9084960 inline int pointOfFace(int localFace, int ipoint) const {
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9084960 times.
9084960 FEL_ASSERT(localFace<m_numFace);
120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9084960 times.
9084960 FEL_ASSERT(ipoint<m_numPointPerFace[localFace]);
121 9084960 return m_ptOfFa[m_indexPointPerFace[localFace]+ipoint];
122 }
123
124 //! point on the boundary element (face in 3d, edge in 2d, point in 1d)
125 36867240 inline int pointOfBdEle(int localBdEle, int ipoint) const {
126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36867240 times.
36867240 FEL_ASSERT(localBdEle<m_numBdEle);
127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36867240 times.
36867240 FEL_ASSERT(ipoint<m_numPointPerBdEle[localBdEle]);
128 36867240 return m_ptOfBdEle[m_indexPointPerBdEle[localBdEle]+ipoint];
129 }
130
131 inline int edgeOfFace(int localFace, int edge, bool& orientation) const {
132 FEL_ASSERT(localFace<m_numFace);
133 FEL_ASSERT(edge<m_numEdgePerFace[localFace]);
134 orientation = m_orientEd[m_indexEdgePerFace[localFace]+edge];
135 return m_edOfFa[m_indexEdgePerFace[localFace]+edge];
136 }
137
138 // inline int numPointPerEdge() const {return m_numPointPerEdge;}
139 3026038 inline int numPointPerFace(int iface) const {
140
2/4
✓ Branch 0 taken 3026038 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3026038 times.
3026038 FEL_ASSERT(iface < m_numFace && iface >= 0);
141 3026038 return m_numPointPerFace[iface];
142 }
143
144 12703550 inline int numPointPerBdEle(int ibdele) const {
145
2/4
✓ Branch 0 taken 12703550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12703550 times.
12703550 FEL_ASSERT(ibdele < m_numBdEle && ibdele >= 0);
146 12703550 return m_numPointPerBdEle[ibdele];
147 }
148
149 // inline int numEdgePerFace() const {return m_numEdgePerFace;}
150 332912 inline double pointCoor(int ipoint,int icoor) const {
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332912 times.
332912 FEL_ASSERT(ipoint < m_numPoint);
152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332912 times.
332912 FEL_ASSERT(icoor < 3);
153 332912 return m_pointCoor[ 3*ipoint + icoor];
154 }
155
156 54011515 inline const BasisFunction& basisFunction() const {
157 54011515 return m_basisFunction;
158 }
159
160 56258 inline const GeoElement& boundaryGeoElement(int i) const {
161 56258 return *(m_boundaryGeoElement[i]);
162 }
163
164 inline const GeoElement& boundaryBoundaryGeoElement(int i) const {
165 return *(m_boundaryBoundaryGeoElement[i]);
166 }
167
168 ///@}
169 ///@name Inquiry
170 ///@{
171
172 ///@}
173 ///@name Input and output
174 ///@{
175
176 void print(int verbose,std::ostream& c=std::cout) const;
177
178 ///@}
179 ///@name Friends
180 ///@{
181
182 ///@}
183
184 protected:
185 ///@name Protected static Member Variables
186 ///@{
187
188 ///@}
189 ///@name Protected member Variables
190 ///@{
191
192 ///@}
193 ///@name Protected Operators
194 ///@{
195
196 ///@}
197 ///@name Protected Operations
198 ///@{
199
200 ///@}
201 ///@name Protected Access
202 ///@{
203
204 ///@}
205 ///@name Protected Inquiry
206 ///@{
207
208 ///@}
209 ///@name Protected LifeCycle
210 ///@{
211
212 ///@}
213
214 private:
215 ///@name Private static Member Variables
216 ///@{
217
218 ///@}
219 ///@name Private member Variables
220 ///@{
221
222 /*! Name of the geometric element */
223 const std::string m_name; //!< Name of the geometric element
224 /*! Shape of the geometric element \see refShape.hpp*/
225 const RefShape& m_shape;
226 /*! For a geometric element, the basis functions are used to compute the application that maps
227 the reference element onto the current element*/
228 const BasisFunction& m_basisFunction; //!< Basis functions
229 const int m_numCoor; // = m_basisFunction.numCoor()
230 const int m_numPoint; // = m_basisFunction.size()
231 const int m_numEdge;
232 const int m_numFace;
233 const int m_numBdEle; // either = m_numFace (3d) or m_numEdge (2d) or 2 (1d)
234 const double* m_pointCoor;
235 const int* m_ptOfEd;
236 const int* m_ptOfFa;
237 const int* m_ptOfBdEle; //either = m_ptOfFa (3d) or m_ptOfEd (2d) or m_ptOfEd (1d) (only {0,1} are used)
238 const int* m_edOfFa;
239 const bool* m_orientEd;
240 const GeoElement** m_boundaryGeoElement;
241 const GeoElement** m_boundaryBoundaryGeoElement;
242 const RefElement& m_defaultFiniteEle;
243 int* m_numPointPerEdge;
244 int* m_indexPointPerEdge;
245 int* m_numPointPerFace;
246 int* m_indexPointPerFace;
247 int* m_numPointPerBdEle; //either = m_numPointPerFace (3d) or m_numPointPerEdge (2d) or {1,1} (1d)
248 int* m_indexPointPerBdEle; //either = m_indexPointPerFace (3d) or m_indexPointPerEdge (2d) or {0,1} (1d)
249 int* m_numEdgePerFace;
250 int* m_indexEdgePerFace;
251
252 ///@}
253 ///@name Private Operators
254 ///@{
255
256 ///@}
257 ///@name Private Operations
258 ///@{
259
260 ///@}
261 ///@name Private Access
262 ///@{
263
264 ///@}
265 ///@name Private Inquiry
266 ///@{
267
268 ///@}
269 ///@name Private LifeCycle
270 ///@{
271
272 ///@}
273 };
274 ///@}
275 ///@name Type Definitions
276 ///@{
277
278 extern const GeoElement geoElementNULL;
279 extern const GeoElement geoElementNode;
280 extern const GeoElement geoElementSegmentP1;
281 extern const GeoElement geoElementSegmentP1b;
282 extern const GeoElement geoElementSegmentP2;
283 extern const GeoElement geoElementTriangleP1;
284 extern const GeoElement geoElementTriangleP1b;
285 extern const GeoElement geoElementTriangleP2;
286 extern const GeoElement geoElementQuadrangleQ1;
287 extern const GeoElement geoElementQuadrangleP1xP2;
288 extern const GeoElement geoElementQuadrangleQ1b;
289 extern const GeoElement geoElementQuadrangleQ2;
290 extern const GeoElement geoElementQuadrangleQ2c;
291 extern const GeoElement geoElementTetrahedronP1;
292 extern const GeoElement geoElementTetrahedronP1b;
293 extern const GeoElement geoElementTetrahedronP2;
294 extern const GeoElement geoElementHexahedronQ1;
295 extern const GeoElement geoElementHexahedronQ1b;
296 extern const GeoElement geoElementHexahedronQ2;
297 extern const GeoElement geoElementHexahedronQ2c;
298 extern const GeoElement geoElementPrismR1;
299 extern const GeoElement geoElementPrismP1xP2;
300 extern const GeoElement geoElementPrismR2;
301
302 ///@}
303 } /* namespace felisce.*/
304 #endif
305