GCC Code Coverage Report


Directory: ./
File: DegreeOfFreedom/supportDofMesh.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 12 18 66.7%
Branches: 0 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. Foulon and others
13 //
14
15 /*!
16 \file supportDofMesh.hpp
17 \author J. Foulon and others
18 \date 07/10/2010
19 \brief SupportDofMesh class declaration
20 */
21
22 #ifndef SUPPORTDOFMESH_HPP
23 #define SUPPORTDOFMESH_HPP
24
25 // System includes
26 #include <vector>
27 #include <unordered_map>
28
29 // External includes
30
31 // Project includes
32 #include "Core/felisceParam.hpp"
33 #include "DegreeOfFreedom/variable.hpp"
34 #include "FiniteElement/refElement.hpp"
35 #include "FiniteElement/curBaseFiniteElement.hpp"
36 #include "Geometry/geometricMeshRegion.hpp"
37
38 namespace felisce
39 {
40 class GeoElement;
41 /*!
42 \class SupportDofMesh
43 \date 07/10/2010
44 \brief Object SupportDofMesh links the mesh and the finite element used to solve the problem.
45 We build one SupportDofMesh by variable and etablish a link from GeometricMeshRegion to SupportDofMesh.
46 The supports of dof for a variable are stored in CSR format with 2 arrays m_iEle which contains
47 the first index of the supports in the elements, that are stored in array m_iSupportDof.
48 Ex: iel = 5. Support dof in element number iel are stored in m_iSupport from m_iEle[iel] to (m_iEle[iel+1]-1).
49 */
50 class SupportDofMesh {
51 public:
52 //! simplify ElementType enum use.
53 typedef GeometricMeshRegion::ElementType ElementType;
54 //! typedef to simplify use of the std::map<finite element name --> finite element reference>.
55 typedef std::unordered_map<std::string, const RefElement*> StringToReferenceElement;
56 //! Map to link name of the finite element reference to the finite element reference object.
57 static StringToReferenceElement m_eltRefNameToRefEle;
58
59 // Constructors
60 //=============
61 SupportDofMesh( const Variable& variable, const GeometricMeshRegion::Pointer& mesh);
62 SupportDofMesh( const Variable& variable, const GeometricMeshRegion::Pointer& meshLocal, std::vector<felInt>& loc2GlobElemSupport, SupportDofMesh& supportDofMesh);
63
64 // Link geometry and support dof mesh.
65 //====================================
66 //void setSizeOfIdElementSupport(felInt numElement);
67
68 //! \brief get the id of the element from its type and its id with respect to its type
69 void getIdElementSupport(const ElementType& eltType, felInt ielGeom, std::vector<felInt>& vectorSupport) const;
70 void getIdElementSupport(const ElementType& eltType, felInt ielGeom, felInt& ielSupportDof) const;
71
72 void getIdElementSupport(felInt idEle, std::vector<felInt>& vecSupport) const;
73 void getIdElementSupport(felInt idEle, felInt& ielSupportDof) const;
74
75 void printIdElementSupport(std::ostream& outstr = std::cout) const;
76
77 void getIdPointElementSupport(felInt idEle, std::vector<felInt>& vecIdPoint) const;
78
79 /*!
80 * \brief Computes the list of all element supports of element iel.
81 *
82 * \param[in] iel Index of finite element considered.
83 * \param[out] indexes All indexes of support dof related to the \a iel finite element.
84 */
85 void getIndexesElementSupport(int iel, std::vector<int>& indexes) const;
86
87 void fusionSupportDof(const Variable& variable);
88
89 void matchingElemConnectivity(std::size_t labelIN, std::size_t labelOUT, std::set<std::size_t>& listSuppDofIN, std::set<std::size_t>& listSuppDofOUT);
90
91 void getElemConnectivitySingleLabel(std::size_t label, std::set<std::size_t>& listSuppDof);
92
93 void GetPermutationList(std::vector<std::pair<std::size_t, std::size_t> >& listSuppDofMatched);
94
95
96 // Embedded Interface
97 void matchEmbeddedLabelPairs(const Variable& variable);
98
99 // Cracks
100 void matchCrackLabelPairs(const Variable& variable);
101
102 // For both cracks and embedded interface
103 void extractIdElemWithConnectivityFromSides(std::size_t labelSide1, std::size_t labelSide2,
104 std::vector< std::pair<std::size_t, std::set<std::size_t> > >& listSuppElemSide1,
105 std::vector< std::pair<std::size_t, std::set<std::size_t> > >& listSuppElemSide2);
106
107 /*!
108 * \brief Duplicate the support dof intersected by the structure
109 *
110 * This function duplicates the marked support dof. It modify four vectors:
111 * - m_listNode
112 * - m_vectorIdElementSupport
113 * - m_iEle
114 * - m_iSupportDof
115 *
116 * In the variable m_listNode , the duplicated support dof are insert at the end.
117 * In the other vectors, the element on the "left" side (the one where the normal is pointing) is
118 * always the first. The element on the "right"side is the second one.
119 * This function assumes that you are using \f$ P^1 \f$ finite element.
120 */
121 void duplicateSupportElements( std::map<felInt, felInt>& listIntersectedEltIdx,
122 std::map<felInt, std::vector<felInt> >& listIntersectedVerSgn,
123 std::map<felInt, std::map<felInt, felInt> >& mapVerticesIdxToDupl);
124
125
126 //! Print function
127 //================
128 void print(int verbose = 0, std::ostream& outstr = std::cout) const;
129
130 // Access functions
131 //=================
132 271018001 inline int getNumSupportDof(felInt iel) const {
133 271018001 return (static_cast<int>(m_iEle[iel+1] - m_iEle[iel]));
134 }
135
136 inline const std::vector<Point> & listNode() const {
137 return m_listNode;
138 }
139 10095609 inline std::vector<Point> & listNode() {
140 10095609 return m_listNode;
141 }
142
143 inline const std::vector<felInt> & iSupportDof() const {
144 return m_iSupportDof;
145 }
146 1244979060 inline std::vector<felInt> & iSupportDof() {
147 1244979060 return m_iSupportDof;
148 }
149
150 inline const std::vector<felInt> & iEle() const {
151 return m_iEle;
152 }
153 1255181676 inline std::vector<felInt> & iEle() {
154 1255181676 return m_iEle;
155 }
156
157 inline const std::vector<std::vector<felInt> > & vectorIdElementSupport() const {
158 return m_vectorIdElementSupport;
159 }
160
161 inline std::vector<std::vector<felInt> > & vectorIdElementSupport() {
162 return m_vectorIdElementSupport;
163 }
164
165 inline const std::map<felInt, felInt> & mapSuppElemMatched() const {
166 return m_mapSuppElemMatched;
167 }
168
169 inline const std::map<felInt, felInt> & mapSuppDofMatched0() const {
170 return m_mapSuppDofMatched0;
171 }
172
173 inline const std::map<felInt, felInt> & mapSuppDofMatched1() const {
174 return m_mapSuppDofMatched1;
175 }
176
177 inline const std::map<felInt, felInt> & mapSuppElemMatchedCrack() const {
178 return m_mapSuppElemMatchedCrack;
179 }
180
181 inline const std::map<felInt, felInt> & mapSuppDofMatchedCrack0() const {
182 return m_mapSuppDofMatchedCrack0;
183 }
184
185 inline const std::map<felInt, felInt> & mapSuppDofMatchedCrack1() const {
186 return m_mapSuppDofMatchedCrack1;
187 }
188
189 inline const std::vector<felInt> & listPerm() const {
190 return m_listPerm;
191 }
192
193 363915 inline std::vector<felInt> & listPerm() {
194 363915 return m_listPerm;
195 }
196
197 94093586 inline const felInt & numSupportDof() const {
198 94093586 return m_numSupportDof;
199 }
200
201 inline const felInt & getIdFusionDarcy() const {
202 return m_idFusionDarcy;
203 }
204
205 // Set functions
206 // =============
207 void setNumSupportDof(felInt newNum) {
208 m_numSupportDof = newNum;
209 }
210
211 private:
212
213 //! Reference to mesh
214 GeometricMeshRegion::Pointer m_mesh;
215
216 //! Variable associate to these supports of dof
217 Variable m_variable;
218 //! List of support dof coordinate (similar to list of point in the mesh format)
219 std::vector<Point> m_listNode;
220
221 //! total number of support Dof
222 //! if NOT FusionDof m_numSupportDof == listeNode.size()
223 //! if DO FusionDof m_numSupportDof != listeNode.size()
224 felInt m_numSupportDof;
225 felInt m_idFusionDarcy;
226
227 std::vector<felInt> m_listPerm;
228
229 //! Pointer to the supports of dof of elements (CSR format: array1)
230 std::vector <felInt> m_iEle;
231
232 //! Store all supports of dof (element by element) (CSR format: array2).
233 std::vector <felInt> m_iSupportDof;
234
235 //! Link between the id of element in the mesh and the associated support element
236 std::vector <std::vector< felInt > > m_vectorIdElementSupport;
237
238 //! Link support elements from both sides of an embedded interface problem (Side 0, Side 1)
239 std::map<felInt,felInt> m_mapSuppElemMatched;
240 //! Link support dofs from both sides of an embedded interface problem
241 std::map<felInt,felInt> m_mapSuppDofMatched0; // from Side 0 to Side 1
242 std::map<felInt,felInt> m_mapSuppDofMatched1; // form Side 1 to Side 0
243
244 //~ Link support elements and dofs from both sides of a CRACK problem
245 std::map<felInt,felInt> m_mapSuppElemMatchedCrack;
246 //! Link support dofs from both sides of an embedded interface problem
247 std::map<felInt,felInt> m_mapSuppDofMatchedCrack0; // from Side 0 to Side 1
248 std::map<felInt,felInt> m_mapSuppDofMatchedCrack1; // form Side 1 to Side 0
249
250
251 //! mesh points are already copied.
252 bool m_copiedMeshPoint;
253
254 //! edge nodes are allocated
255 felInt m_numDofSupportedByEdge;
256 bool m_resizedEdgeNode;
257
258 //! face nodes are allocated
259 bool m_resizedFaceNode;
260
261 //! volume nodes are allocated
262 bool m_resizedVolumeNode;
263
264 //! embedded interface related maps are created
265 bool m_createdEmbeddedInterfaceMaps;
266
267 //! crack related maps are created
268 bool m_createdCrackInterfaceMaps;
269
270
271 //===============================
272 //! internal functions:
273 //! Initialisation of the std::unordered_map m_eltRefNameToRefEle
274 void m_initMap();
275
276 //! resize: m_iSupportDof and m_iEle
277 void m_resizeSupportVectors();
278
279 //! copy the mesh points into m_listNode
280 void m_copyNodes();
281
282 //! resize lists
283 void m_resizeEdgeNodes();
284 void m_resizeFaceNodes(const RefElement& refElement);
285 void m_resizeVolumeNodes(const RefElement& refElement);
286
287 //! make the link between the nodes of the (reference) finite element, and
288 //! the nodes of the geometric element of the mesh (useful for P1 geoEle and P2 refEle...)
289 void m_linkNodesGeoAndRefEle(const CurBaseFiniteElement& fe, std::vector<int>& feIdLocalDof) const;
290
291 //! build the nodes that live on middle edges or middle faces
292 //! used to use P2/Q2 finite elements on P1/Q1 mesh
293 //! (all edges or faces must have been built in the mesh previously)
294 void m_buildNodesOfEdgeFaceVolumePerBag(const std::vector<ElementType>& theBagElt, felInt* countElement, bool boundary_flag);
295
296 //! return:
297 //! elem : the element.
298 //! elemConnectivity: the ID of the nodes of the element. Ex. P2: [V0, V1, V2, Mid0, Mid1, Mid2]
299 void m_getElementSupportConnectivity(const RefElement& refEle, ElementType eltType, felInt iel, const std::vector<int>& feIdLocalDof,
300 std::vector<felInt>& the_elem, std::vector<felInt>& elemConnectivity) const;
301
302 //! build the arrays in CSR format: m_iEle, m_iSupportDof :
303 void m_buildSupportCSR(const std::vector<ElementType>& theBagElt, felInt& cptElt, felInt* countEltPerType);
304
305 //! to switch from geoEle P1 to refEle P2 for instance
306 const RefElement& m_chooseRefEleFromFEType(const GeoElement& geoEle, const ElementType eltType) const;
307
308 };
309 }
310
311 #endif
312