GCC Code Coverage Report


Directory: ./
File: FiniteElement/refElement.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 36 43 83.7%
Branches: 9 20 45.0%

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 _REFERENCE_ELEMENT_H
16 #define _REFERENCE_ELEMENT_H
17
18 // System includes
19 #include <unordered_map>
20 #include <vector>
21
22 // External includes
23
24 // Project includes
25 #include "Core/felisce.hpp"
26 #include "Geometry/point.hpp"
27 #include "FiniteElement/basisFunction.hpp"
28 #include "FiniteElement/refShape.hpp"
29 #include "FiniteElement/quadratureRule.hpp"
30
31 namespace felisce
32 {
33 enum DegreeOfFreedomSupport {DOF_NODE_VERTEX,DOF_NODE_EDGE,DOF_NODE_FACE,DOF_NODE_VOLUME,DOF_EDGE,DOF_FACE,DOF_VOLUME};
34 enum DegreeOfFreedomType {DOF_VALUE,DOF_X_DERIVATIVE,DOF_Y_DERIVATIVE,DOF_Z_DERIVATIVE,DOF_NORMAL_DERIVATIVE,
35 DOF_MEAN,DOF_FLUX,DOF_CIRCULATION
36 };
37 /*!
38 \class RefElement
39 \brief The class implementing a reference finite element
40 \authors J-F. Gerbeau
41 */
42 class RefElement {
43 mutable std::unordered_map<DegreeOfFreedomSupport,std::string> m_nameSupportDOF; //! \todo Make it static
44 mutable std::unordered_map<DegreeOfFreedomType,std::string> m_nameTypeDOF; //! \todo Make it static
45 std::string m_name;
46 const RefShape& m_refShape;
47 const BasisFunction& m_basisFunction;
48 // Currently not used const ListOfQuadratureRule& m_listOfQuadratureRule;
49 const DegreeOfFreedomType* m_typeDOF;
50 const DegreeOfFreedomSupport* m_supportDOF;
51 const int* m_idSupportOfDOF; //!< if the dof is on a node, this is the id of the node, if the dof is on an edge, it's the id of the edge, etc.
52 const Point* m_node; //!< the points supporting the nodes. Compulsory order: nodes on vertex, edge, face, volume
53 const int m_numNodeVertex; //!< Number of nodes located on vertices
54 const int m_numNodeEdge;//!< Number of nodes located on edges
55 const int m_numNodeFace;//!< Number of nodes located on faces
56 const int m_numNodeVolume;//!< Number of nodes located on the volume
57 const int m_numNode; //!< m_numNodeVertex + m_numNodeEdge + m_numNodeFace + m_numNodeVolume;
58 const int m_numDOF; //!< = m_basisFunction.size()
59 const int m_numVertex; //!< m_refShape.numVertex()
60 const int m_numEdge; //!< m_refShape.numEdge()
61 const int m_numFace; //!< m_refShape.numFace()
62 const int m_numCoor; //!< m_refShape.numCoor()
63 const RefElement** m_boundaryRefElement; // faces for 3D elements, edges for 2D elements, NULL for 1D elements
64 // Currently not Used const RefElement** m_boundaryBoundaryRefElement; // edges for 3D elements, NULL for 2D and 1D elements
65 std::vector< std::vector<int> > m_idDOFVertex; //!< list of DOFs per vertex
66 std::vector< std::vector<int> > m_idDOFEdge; //!< list of DOFs per edge
67 std::vector< std::vector<int> > m_idDOFFace;//!< list of DOFs per face
68 std::vector<int> m_idDOFVolume; //!< list of DOFs on the volume
69 std::vector<const Point* > m_nodeDOF; //!< m_nodeDOF[idof] = NULL if idof is not a node, otherwise it is a pointer to the Point supporting the node
70 int m_numDOFNode; //!< = m_numDOFNodeVertex + m_numDOFNodeEdge + m_numDOFNodeFace + m_numDOFNodeVolume;
71 int m_numDOFNodeVertex;
72 int m_numDOFNodeEdge;
73 int m_numDOFNodeFace;
74 int m_numDOFNodeVolume;
75 int m_numDOFEdge;
76 int m_numDOFFace;
77 int m_numDOFVolume;
78 //! num of Dof per edge, per face
79 int m_numDOFPerEdge; //= m_numDOFEdge / m_numEdge
80 int m_numDOFPerFace; //= m_numDOFFace / m_numFace
81
82 bool m_edgesCanHaveDifferentNumberOfDof;
83 std::vector<int> m_numDOFPerSingleEdge;//used only if the above is true, which is false by default. Important in the case of PrismsP1xP2
84 public:
85 RefElement(const std::string& name,
86 const RefShape& refShape,
87 const BasisFunction& basisFunction,
88 const ListOfQuadratureRule& listOfQuadratureRule,
89 const DegreeOfFreedomType* typeDOF,
90 const DegreeOfFreedomSupport* supportDOF,
91 const int* idDOF,
92 const Point* node, int numNodeVertex, int numNodeEdge,int numNodeFace,int numNodeVolume,
93 const RefElement** boundaryRefElement,
94 const RefElement** boundaryBoundaryRefElement,
95 bool edgesCanHaveDifferentNumberOfDof = false);
96
97
98
99 void initStaticMember();
100 inline std::string name() const {
101 return m_name;
102 }
103 10410773 inline int numDOF() const {
104 10410773 return m_basisFunction.size();
105 }
106 8891934 inline const BasisFunction& basisFunction() const {
107 8891934 return m_basisFunction;
108 }
109 inline int numVertex() const {
110 return m_refShape.numVertex();
111 }
112 inline int numEdge() const {
113 return m_refShape.numEdge();
114 }
115 inline int numFace() const {
116 return m_refShape.numFace();
117 }
118
119 inline const int & numDOFNode() const {
120 return m_numDOFNode;
121 }
122 inline int & numDOFNode() {
123 return m_numDOFNode;
124 }
125 10237845 inline const int & numDOFNodeVertex() const {
126 10237845 return m_numDOFNodeVertex;
127 }
128 inline int & numDOFNodeVertex() {
129 return m_numDOFNodeVertex;
130 }
131 10233852 inline const int & numDOFNodeEdge() const {
132 10233852 return m_numDOFNodeEdge;
133 }
134 inline int & numDOFNodeEdge() {
135 return m_numDOFNodeEdge;
136 }
137 10233852 inline const int & numDOFNodeFace() const {
138 10233852 return m_numDOFNodeFace;
139 }
140 inline int & numDOFNodeFace() {
141 return m_numDOFNodeFace;
142 }
143 10233852 inline const int & numDOFNodeVolume() const {
144 10233852 return m_numDOFNodeVolume;
145 }
146 inline int & numDOFNodeVolume() {
147 return m_numDOFNodeVolume;
148 }
149 10233013 inline const int & numDOFEdge() const {
150 10233013 return m_numDOFEdge;
151 }
152 inline int & numDOFEdge() {
153 return m_numDOFEdge;
154 }
155 10233013 inline const int & numDOFFace() const {
156 10233013 return m_numDOFFace;
157 }
158 inline int & numDOFFace() {
159 return m_numDOFFace;
160 }
161 10233013 inline const int & numDOFVolume() const {
162 10233013 return m_numDOFVolume;
163 }
164 inline int & numDOFVolume() {
165 return m_numDOFNodeVolume;
166 }
167
168 931324 inline const int & numDOFPerEdge() const {
169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 931324 times.
931324 FEL_ASSERT( !m_edgesCanHaveDifferentNumberOfDof )
170 931324 return m_numDOFPerEdge;
171 }
172 1916328 inline const int & numDOFPerEdge( int i ) const {
173
2/2
✓ Branch 0 taken 53800 times.
✓ Branch 1 taken 1862528 times.
1916328 if (m_edgesCanHaveDifferentNumberOfDof)
174 53800 return m_numDOFPerSingleEdge[i];
175 else
176 1862528 return m_numDOFPerEdge;
177 }
178 10232244 inline const int & numDOFPerFace() const {
179 10232244 return m_numDOFPerFace;
180 }
181
182 3224 inline const int* idSupportOfDOF() const {
183 3224 return m_idSupportOfDOF;
184 }
185 inline const DegreeOfFreedomSupport* supportDOF() const {
186 return m_supportDOF;
187 }
188
189 513544 inline const Point* node() const {
190 513544 return m_node;
191 }
192
193 inline double nodeCoor(int inode,int icoor) const {
194 return m_node[inode].coor(icoor);
195 }
196 56258 inline const RefElement& boundaryRefElement(int i)const {
197
6/8
✓ Branch 0 taken 29038 times.
✓ Branch 1 taken 27220 times.
✓ Branch 2 taken 13510 times.
✓ Branch 3 taken 15528 times.
✓ Branch 4 taken 40730 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 40730 times.
56258 FEL_ASSERT( (i< m_numFace && m_numCoor == 3) || (i< m_numEdge && m_numCoor == 2) ) ;
198 56258 return *(m_boundaryRefElement[i]);
199 }
200 void print(int verbose,std::ostream& c=std::cout) const;
201 inline bool dofIsANode(int i) const {
202 return(m_supportDOF[i] == DOF_NODE_VERTEX || m_supportDOF[i] == DOF_NODE_EDGE
203 || m_supportDOF[i] == DOF_NODE_FACE || m_supportDOF[i] == DOF_NODE_VOLUME);
204 }
205 void check() const;
206
207 941288 bool edgesCanHaveDifferentNumberOfDof() const{
208 941288 return m_edgesCanHaveDifferentNumberOfDof;
209 }
210 };
211
212 // extern const RefElement refElementNULL;
213 extern const RefElement refElementNode;
214 extern const RefElement refElementSegmentP1;
215 extern const RefElement refElementSegmentP1b;
216 extern const RefElement refElementSegmentP2;
217 extern const RefElement refElementSegmentP3H;
218 extern const RefElement refElementTriangleP1;
219 extern const RefElement refElementTriangleP1b;
220 extern const RefElement refElementTriangleP2;
221 extern const RefElement refElementQuadrangleQ1;
222 extern const RefElement refElementQuadrangleP1xP2;
223 extern const RefElement refElementQuadrangleQ1b;
224 extern const RefElement refElementQuadrangleQ2c;
225 extern const RefElement refElementQuadrangleQ2;
226 extern const RefElement refElementTetrahedronP1;
227 extern const RefElement refElementTetrahedronP1b;
228 extern const RefElement refElementTetrahedronP2;
229 extern const RefElement refElementHexahedronQ1;
230 extern const RefElement refElementHexahedronQ1b;
231 extern const RefElement refElementHexahedronQ2;
232 extern const RefElement refElementHexahedronQ2c;
233 extern const RefElement refElementPrismR1;
234 extern const RefElement refElementPrismP1xP2;
235 extern const RefElement refElementPrismR2;
236 extern const RefElement refElementTetrahedronRT0;
237
238 // extern const RefElement listRefElement[2];
239 }
240
241 #endif
242