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.Castelneau & J.Foulon & V.Martin |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef GEOMETRICMESHREGION_HPP |
16 |
|
|
#define GEOMETRICMESHREGION_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
|
20 |
|
|
// External includes |
21 |
|
|
|
22 |
|
|
// Project includes |
23 |
|
|
#include "Core/felisce.hpp" |
24 |
|
|
#include "Geometry/listEdges.hpp" |
25 |
|
|
#include "Geometry/listFaces.hpp" |
26 |
|
|
|
27 |
|
|
namespace felisce |
28 |
|
|
{ |
29 |
|
|
///@name felisce Globals |
30 |
|
|
///@{ |
31 |
|
|
|
32 |
|
|
///@} |
33 |
|
|
///@name Type Definitions |
34 |
|
|
///@{ |
35 |
|
|
|
36 |
|
|
///@} |
37 |
|
|
///@name Enum's |
38 |
|
|
///@{ |
39 |
|
|
|
40 |
|
|
///@} |
41 |
|
|
///@name Functions |
42 |
|
|
///@{ |
43 |
|
|
|
44 |
|
|
///@} |
45 |
|
|
///@name felisce Classes |
46 |
|
|
///@{ |
47 |
|
|
class GeoElement; |
48 |
|
|
class GeometricMeshRegion |
49 |
|
|
{ |
50 |
|
|
public: |
51 |
|
|
///@name Enum Definitions |
52 |
|
|
///@{ |
53 |
|
|
|
54 |
|
|
/***************************************** |
55 |
|
|
/ |
56 |
|
|
/ This part contains the number of types of element, |
57 |
|
|
/ number of vertices per element, and maps from |
58 |
|
|
/ name felisce to keyword (medit, ensight, geometric element, ...) |
59 |
|
|
/ used in felisce |
60 |
|
|
/ |
61 |
|
|
/ Mapping between an int and the type of element |
62 |
|
|
/ DO NOT USE THE INT as new types of element could be added! |
63 |
|
|
/ <0,Nod> |
64 |
|
|
/ <1,Seg2> <2,Seg3b> <3,Seg3> |
65 |
|
|
/ <4,Tria3> <5,Tria4> <6,Tria6> |
66 |
|
|
/ <7,Quad4> <8,Quad5> <9,Quad8> <10,Quad8> <11,Quad9> |
67 |
|
|
/ <12,Tetra4> <13,Tetra5> <14,Tetra10> |
68 |
|
|
/ <15,Pyram5> <16,Pyram13> |
69 |
|
|
/ <17,Prism6> <18,Prism15> |
70 |
|
|
/ <19,Hexa8> <20,Hexa9> <21,Hexa20> <22,Hexa26> <23,Hexa27> |
71 |
|
|
/ |
72 |
|
|
/ Note: a Pyram is a pentahedron whose faces are 4 triangles and 1 quadrangle. |
73 |
|
|
/ a Prism is a pentahedron whose faces are 2 triangles and 3 quadrangles. |
74 |
|
|
/ |
75 |
|
|
/ Note: To add a new element: |
76 |
|
|
/ 1/ add the element type in ElementType enum. |
77 |
|
|
/ 2/ set its number of points in m_numPointsPerElt, at the right place! |
78 |
|
|
/ 3/ fill in the dictionnary eltFelNameToEnum,... |
79 |
|
|
/ 4/ fill the corresponding std::unordered_map in the ensight classe (m_eltFelNameToEns6Pair) |
80 |
|
|
/ |
81 |
|
|
*****************************************/ |
82 |
|
|
enum ElementType: std::size_t { |
83 |
|
|
Nod, |
84 |
|
|
Seg2, Seg3b, Seg3, |
85 |
|
|
Tria3, Tria4, Tria6, |
86 |
|
|
Quad4, Quad5, Quad6, Quad8, Quad9, |
87 |
|
|
Tetra4, Tetra5, Tetra10, |
88 |
|
|
Pyram5, Pyram13, |
89 |
|
|
Prism6, Prism9, Prism15, |
90 |
|
|
Hexa8, Hexa9, Hexa20, Hexa26, Hexa27, |
91 |
|
|
ELEMENT_TYPE_COUNTER |
92 |
|
|
}; |
93 |
|
|
|
94 |
|
|
enum class InitialNormalTangentProvided { |
95 |
|
|
NONE, |
96 |
|
|
NORMAL, |
97 |
|
|
TANGENT_1, |
98 |
|
|
TANGENT_2 |
99 |
|
|
}; |
100 |
|
|
|
101 |
|
|
enum DomainDimensionType { |
102 |
|
|
GeoMeshUndefined = -1, |
103 |
|
|
GeoMesh0D = 0, |
104 |
|
|
GeoMesh1D = 1, |
105 |
|
|
GeoMesh2D = 2, |
106 |
|
|
GeoMesh3D = 3 |
107 |
|
|
}; |
108 |
|
|
|
109 |
|
|
//Manage Input/Output Format Type |
110 |
|
|
enum FormatType { |
111 |
|
|
FormatUndefined = -1, |
112 |
|
|
FormatMedit = 0, |
113 |
|
|
FormatEnsight6 = 1 |
114 |
|
|
}; |
115 |
|
|
|
116 |
|
|
///@} |
117 |
|
|
///@name Type Definitions |
118 |
|
|
///@{ |
119 |
|
|
|
120 |
|
|
/// Pointer definition of GeometricMeshRegion |
121 |
|
|
FELISCE_CLASS_POINTER_DEFINITION(GeometricMeshRegion); |
122 |
|
|
|
123 |
|
|
typedef std::pair<std::string , const GeoElement* > FelNameGeoElePair_type; |
124 |
|
|
typedef std::vector<FelNameGeoElePair_type > EnumToFelNameGeoEle_type; |
125 |
|
|
typedef std::unordered_map<std::string, ElementType > StringToElementType_type; |
126 |
|
|
typedef std::unordered_map<ElementType, ElementType > ElementTypeLinearToDifferentElementType_type; |
127 |
|
|
typedef std::map<int, std::set<ElementType> > IntRefToElementType_type; |
128 |
|
|
typedef std::unordered_map<std::string, std::set<int> > NameLabelToListLabel_type; |
129 |
|
|
|
130 |
|
|
typedef std::map<int, std::pair<felInt,felInt> > IntRefToBegEndIndex_type; |
131 |
|
|
|
132 |
|
|
typedef std::pair<ElementType, felInt> seedElement; |
133 |
|
|
|
134 |
|
|
///@} |
135 |
|
|
///@name Public static Member Variables |
136 |
|
|
///@{ |
137 |
|
|
|
138 |
|
|
static constexpr double NWTOLL = 1e-7; |
139 |
|
|
static constexpr std::size_t NMAX = 200; |
140 |
|
|
|
141 |
|
|
// Number of type |
142 |
|
|
static constexpr int m_numTypesOfElement = static_cast<int>(ELEMENT_TYPE_COUNTER); |
143 |
|
|
|
144 |
|
|
// Number of points per element |
145 |
|
|
static const int m_numPointsPerElt[]; |
146 |
|
|
// Number of vertices per element |
147 |
|
|
static const int m_numVerticesPerElt[]; |
148 |
|
|
// Number of edges per element |
149 |
|
|
static const int m_numEdgesPerElt[]; |
150 |
|
|
// Number of faces per element |
151 |
|
|
static const int m_numFacesPerElt[]; |
152 |
|
|
|
153 |
|
|
// static members (constant in pratice) |
154 |
|
|
static EnumToFelNameGeoEle_type eltEnumToFelNameGeoEle; |
155 |
|
|
static StringToElementType_type eltFelNameToEnum; |
156 |
|
|
static ElementTypeLinearToDifferentElementType_type eltLinearToEltQuad; |
157 |
|
|
static ElementTypeLinearToDifferentElementType_type eltLinearToEltBubble; |
158 |
|
|
static std::vector<ElementType> bagElementType0D; |
159 |
|
|
static std::vector<ElementType> bagElementType1D; |
160 |
|
|
static std::vector<ElementType> bagElementType2D; |
161 |
|
|
static std::vector<ElementType> bagElementType3D; |
162 |
|
|
static std::vector<ElementType> bagElementTypeLinear; |
163 |
|
|
|
164 |
|
|
// static (truly not constant) |
165 |
|
|
static NameLabelToListLabel_type descriptionLineEnsightToListLabel; |
166 |
|
|
|
167 |
|
|
///@} |
168 |
|
|
///@name Public member Variables |
169 |
|
|
///@{ |
170 |
|
|
|
171 |
|
|
/// map used to reorder elements per references |
172 |
|
|
/// To a (int) element reference, it associates a pair: |
173 |
|
|
/// 1/ the starting index to the elements having this reference |
174 |
|
|
/// 2/ the number of elements having this reference. |
175 |
|
|
IntRefToBegEndIndex_type intRefToBegEndMaps[ m_numTypesOfElement ]; |
176 |
|
|
|
177 |
|
|
///@} |
178 |
|
|
///@name Life Cycle |
179 |
|
|
///@{ |
180 |
|
|
|
181 |
|
|
/// Constructors |
182 |
|
|
GeometricMeshRegion(); |
183 |
|
|
|
184 |
|
|
/// Copy constructors |
185 |
|
|
GeometricMeshRegion(const GeometricMeshRegion& ) = delete; |
186 |
|
|
|
187 |
|
|
/// Move constructor |
188 |
|
|
GeometricMeshRegion(GeometricMeshRegion&& ) = delete; |
189 |
|
|
|
190 |
|
|
/// Destructor |
191 |
|
|
~GeometricMeshRegion(); |
192 |
|
|
|
193 |
|
|
///@} |
194 |
|
|
///@name Operators |
195 |
|
|
///@{ |
196 |
|
|
|
197 |
|
|
/// Copy assignment |
198 |
|
|
GeometricMeshRegion& operator=(const GeometricMeshRegion& ) = delete; |
199 |
|
|
|
200 |
|
|
/// Move assignment |
201 |
|
|
GeometricMeshRegion& operator=(GeometricMeshRegion&& ) = delete; |
202 |
|
|
|
203 |
|
|
///@} |
204 |
|
|
///@name Operations |
205 |
|
|
///@{ |
206 |
|
|
|
207 |
|
|
/** |
208 |
|
|
* @brief set the dimension |
209 |
|
|
*/ |
210 |
|
|
void setDomainDim(); |
211 |
|
|
|
212 |
|
|
/// Allocate the list of elements of a given type |
213 |
|
|
void allocateElements(const ElementType& eltType); |
214 |
|
|
|
215 |
|
|
/// Delete the list of elements |
216 |
|
|
void deleteElements(); |
217 |
|
|
|
218 |
|
|
/// Reorder the list of elements "eltType" |
219 |
|
|
void reorderListElePerRef(const std::map<int,std::vector<felInt>>& RefToElements, const ElementType eltType); |
220 |
|
|
|
221 |
|
|
/** |
222 |
|
|
* @brief set the bag m_bagElementTypeDomain |
223 |
|
|
*/ |
224 |
|
|
void setBagElementTypeDomain(); |
225 |
|
|
void setBagElementTypeDomainBoundary(); |
226 |
|
|
|
227 |
|
|
/** |
228 |
|
|
* @brief Create the local mesh from the global mesh |
229 |
|
|
* @param[in] meshGlobal The global mesh |
230 |
|
|
* @param[in] eltPartition The partitioning of element. |
231 |
|
|
* @param[in] rank The rank of the process. |
232 |
|
|
* @param[out] loc2globElem Local to global mapping of the elements. |
233 |
|
|
*/ |
234 |
|
|
void setLocalMesh(GeometricMeshRegion& meshGlobal, const std::vector<int>& eltPart, const int rank, std::vector<felInt>& loc2globElem); |
235 |
|
|
|
236 |
|
|
/// Build the list of edges |
237 |
|
|
void buildEdges(); |
238 |
|
|
|
239 |
|
|
/// Build the list of faces |
240 |
|
|
void buildFaces(); |
241 |
|
|
|
242 |
|
|
/// Mesh movement |
243 |
|
|
void moveMesh(const std::vector<double>& disp, const felReal& coef); |
244 |
|
|
|
245 |
|
|
/// Creation of Normal and Tangent at each node |
246 |
|
|
void computeNormalTangent(const InitialNormalTangentProvided initialNormalTangentProvided = InitialNormalTangentProvided::NONE); |
247 |
|
|
|
248 |
|
|
/// Allocate normals and tangents |
249 |
|
|
void allocateListNormalsAndTangents(const InitialNormalTangentProvided initialNormalTangentProvided = InitialNormalTangentProvided::NONE); |
250 |
|
|
|
251 |
|
|
/// Compute the Normal for each element |
252 |
|
|
void computeElementNormal(std::vector<std::vector<Point> >& listElementNormals) const; |
253 |
|
|
|
254 |
|
|
///@} |
255 |
|
|
///@name Access |
256 |
|
|
///@{ |
257 |
|
|
|
258 |
|
|
/// Number coordinates |
259 |
|
17 |
inline const int& numCoor() const { return m_numCoor; } |
260 |
|
34860 |
inline int& numCoor() { return m_numCoor; } |
261 |
|
|
|
262 |
|
|
/// Spatial dimension |
263 |
|
|
inline const int& spatialDim() const { return m_numCoor; } |
264 |
|
1055 |
inline int& spatialDim() { return m_numCoor; } |
265 |
|
|
|
266 |
|
|
/// Domain dimension |
267 |
|
1698795 |
inline const DomainDimensionType& domainDim() const { return m_domainDim; } |
268 |
|
205085 |
inline DomainDimensionType& domainDim() { return m_domainDim; } |
269 |
|
|
|
270 |
|
|
/// Mesh format |
271 |
|
|
inline const FormatType& flagFormatMesh() const { return m_flagFormatMesh; } |
272 |
|
2557 |
inline FormatType& flagFormatMesh() { return m_flagFormatMesh; } |
273 |
|
|
|
274 |
|
|
/// Return true/false wheter the mesh has been moved |
275 |
|
|
inline const bool& moved() const { return m_moved; } |
276 |
|
114 |
inline bool& moved() { return m_moved; } |
277 |
|
|
|
278 |
|
|
/// Number of mesh points |
279 |
|
15465861 |
inline felInt numPoints() const { return m_listPoints.size(); } |
280 |
|
|
|
281 |
|
|
/// Number of elements per element type |
282 |
|
5556222 |
inline const felInt& numElements( const ElementType & eltType ) const { return m_numElements[eltType]; } |
283 |
|
1510862 |
inline felInt& numElements( const ElementType & eltType ) { return m_numElements[eltType]; } |
284 |
|
|
|
285 |
|
|
/// List of mesh points |
286 |
|
17 |
inline const std::vector<Point>& listPoints() const { return m_listPoints; } |
287 |
|
109302882 |
inline std::vector<Point>& listPoints() { return m_listPoints; } |
288 |
|
|
|
289 |
|
|
/// List of mesh points in reference position |
290 |
|
|
inline const std::vector<Point>& listReferencePoints() const { return m_listReferencePoints; } |
291 |
|
✗ |
inline std::vector<Point>& listReferencePoints() { return m_listReferencePoints; } |
292 |
|
|
|
293 |
|
|
/// Get i-th point in mesh |
294 |
|
11100 |
inline const Point& listPoint(const felInt & ivert) const { return m_listPoints[ivert]; } |
295 |
|
20447677 |
inline Point& listPoint(const felInt & ivert) { return m_listPoints[ivert]; } |
296 |
|
|
|
297 |
|
|
/// Get list of elements per element type |
298 |
|
21388 |
inline felInt* listElements( const ElementType& eltType) const { return m_listElements[ eltType ]; } |
299 |
|
10389 |
inline felInt* listElements( const ElementType& eltType) { return m_listElements[ eltType ]; } |
300 |
|
|
|
301 |
|
|
/// Get m_intRefToEnum |
302 |
|
|
inline const IntRefToElementType_type& intRefToEnum() const { return m_intRefToEnum; } |
303 |
|
1341 |
inline IntRefToElementType_type& intRefToEnum() { return m_intRefToEnum; } |
304 |
|
|
|
305 |
|
|
/// Get bag element |
306 |
|
52371 |
inline const std::vector<ElementType>& bagElementTypeDomain() const { return m_bagElementTypeDomain; } |
307 |
|
12657 |
inline const std::vector<ElementType>& bagElementTypeDomainBoundary() const { return m_bagElementTypeDomainBoundary; } |
308 |
|
|
|
309 |
|
|
/// |
310 |
|
|
inline const bool& createNormalTangent() const { return m_createNormalTangent; } |
311 |
|
676550 |
inline bool& createNormalTangent() { return m_createNormalTangent; } |
312 |
|
|
|
313 |
|
|
/// List of normals on mesh points |
314 |
|
|
inline const std::vector<Point>& listNormals() const { return m_listNormals; } |
315 |
|
796541 |
inline std::vector<Point>& listNormals() { return m_listNormals; } |
316 |
|
|
|
317 |
|
|
/// Normal on i-th point |
318 |
|
|
inline const Point& listNormal(const felInt& ivert) const { return m_listNormals[ivert]; } |
319 |
|
16387 |
inline Point& listNormal(const felInt& ivert) { return m_listNormals[ivert]; } |
320 |
|
|
|
321 |
|
|
/// List of tangent on mesh points |
322 |
|
|
inline const std::vector<std::vector<Point>>& listTangents() const { return m_listTangents; } |
323 |
|
|
inline std::vector<std::vector<Point>>& listTangents() { return m_listTangents; } |
324 |
|
|
|
325 |
|
|
/// Tangents on i-th point |
326 |
|
|
inline const std::vector<Point>& listTangents(const felInt dim) const { return m_listTangents[dim]; } |
327 |
|
1536396 |
inline std::vector<Point>& listTangents(const felInt dim) { return m_listTangents[dim]; } |
328 |
|
|
|
329 |
|
|
/// Dim-th tangent on i-th point |
330 |
|
|
inline const Point& listTangent(const felInt dim, const felInt ivert) const { return m_listTangents[dim][ivert]; } |
331 |
|
33 |
inline Point& listTangent(const felInt dim, const felInt ivert) { return m_listTangents[dim][ivert]; } |
332 |
|
|
|
333 |
|
|
/// List of element normals |
334 |
|
|
inline const std::vector<std::vector<Point>>& listElementNormals() const { return m_listEltNormals; } |
335 |
|
22 |
inline std::vector<std::vector<Point>>& listElementNormals() { return m_listEltNormals; } |
336 |
|
|
|
337 |
|
|
/// Normal of i-th element |
338 |
|
|
inline const Point& listElementNormal(const ElementType eltType, const felInt& iel) const { return m_listEltNormals[eltType][iel]; } |
339 |
|
8944 |
inline Point& listElementNormal(const ElementType eltType, const felInt& iel) { return m_listEltNormals[eltType][iel]; } |
340 |
|
|
|
341 |
|
|
/// List of element normals in reference configuration |
342 |
|
|
inline const std::vector<std::vector<Point>>& listElementNormalsInit() const { return m_listEltNormalsInit; } |
343 |
|
2 |
inline std::vector<std::vector<Point>>& listElementNormalsInit() { return m_listEltNormalsInit; } |
344 |
|
|
|
345 |
|
|
/// Normal of i-th element in reference configuration |
346 |
|
|
inline const Point& listElementNormalInit(const ElementType eltType, const felInt& iel) const { return m_listEltNormalsInit[eltType][iel]; } |
347 |
|
8944 |
inline Point& listElementNormalInit(const ElementType eltType, const felInt& iel) { return m_listEltNormalsInit[eltType][iel]; } |
348 |
|
|
|
349 |
|
|
/// Status edges |
350 |
|
|
inline const bool& statusEdges() const { return m_builtEdges; } |
351 |
|
768 |
inline bool& statusEdges() { return m_builtEdges; } |
352 |
|
|
|
353 |
|
|
/// List of edges |
354 |
|
|
inline const ListEdges& listEdges() const { return m_listEdges; } |
355 |
|
242270 |
inline ListEdges& listEdges() { return m_listEdges; } |
356 |
|
|
|
357 |
|
|
/// Status faces |
358 |
|
|
inline const bool& statusFaces() const { return m_builtFaces; } |
359 |
|
6226 |
inline bool& statusFaces() { return m_builtFaces; } |
360 |
|
|
|
361 |
|
|
/// List of faces |
362 |
|
|
inline const ListFaces& listFaces() const { return m_listFaces; } |
363 |
|
|
inline ListFaces& listFaces() { return m_listFaces; } |
364 |
|
|
|
365 |
|
|
/// Number of edges or faces |
366 |
|
66 |
inline felInt numEdges() const { return m_listEdges.numEdges(); } |
367 |
|
✗ |
inline felInt numFaces() const { return m_listFaces.numFaces(); } |
368 |
|
|
|
369 |
|
|
/// Get number points per element type |
370 |
|
10232335 |
inline int numPtsPerElement(const ElementType& ityp) const { return m_numPointsPerElt[ityp]; } |
371 |
|
|
|
372 |
|
|
/** |
373 |
|
|
* @brief Get multiple elements |
374 |
|
|
* @details Retrieve all elements in m_listElements that are indexed by "indexList" and insert |
375 |
|
|
them into "array", starting from the position "startPosArray" in the array. |
376 |
|
|
Ex.: if trias={4 3 0 4 0 1 5 4 1 5 1 2 7 6 3 7 3 4 ...} and indexList={1,3,4} |
377 |
|
|
then array = {..., 4 0 1 5 1 2 7 6 3} ("4": at startPosArray in array). |
378 |
|
|
Beware: the arrays must be allocated before calling getElements. |
379 |
|
|
* @param[in] eltType The type of the elements to retrieve |
380 |
|
|
* @param[in] indexList The list of id of the elements to retrieve |
381 |
|
|
* @param[in] numIndexList The number of element to retrieve |
382 |
|
|
* @param[out] array Array with the retrieved elements |
383 |
|
|
* @param[in] sizeArray The size of array |
384 |
|
|
* @param[in] startPosArray The position from where to insert the elements |
385 |
|
|
*/ |
386 |
|
|
// TODO |
387 |
|
|
void getElements(const ElementType& eltType, const felInt* indexList, felInt numIndexList, |
388 |
|
|
felInt* array, int sizeArray, felInt startPosInArray = 0) const; |
389 |
|
|
|
390 |
|
|
/** |
391 |
|
|
* @brief Fill m_listElements with multiple elements |
392 |
|
|
* @param[in] eltType The type of the elements to insert |
393 |
|
|
* @param[in] indexList The list of id of the elements to insert |
394 |
|
|
* @param[in] numIndexList The number of element to insert |
395 |
|
|
* @param[in] array The array containing the elements to insert |
396 |
|
|
* @param[in] sizeArray the size of array |
397 |
|
|
*/ |
398 |
|
|
// TODO |
399 |
|
|
void setElements(const ElementType& eltType, const felInt* indexList, felInt numIndexList, |
400 |
|
|
const felInt* array, int sizeArray); |
401 |
|
|
|
402 |
|
|
/** |
403 |
|
|
* @brief Get one element in m_listElements. |
404 |
|
|
* @details One can increment the point ID: flagIncrement usage: felisce format (start from 0) -> {medit or ensight...} (start from 1) |
405 |
|
|
* @param[in] eltType The type of the element to get |
406 |
|
|
* @param[in] index The id of the element |
407 |
|
|
* @param[out] array The array to fill with the element |
408 |
|
|
* @param[in] startindex The index where to start in m_listElements |
409 |
|
|
* @param[in] flagIncrement A flag to tell if we start from 0 or 1 |
410 |
|
|
*/ |
411 |
|
|
void getOneElement(const ElementType& eltType, const felInt index, std::vector<felInt>& array, |
412 |
|
|
const felInt startindex = 0, const bool flagIncrement = false) const; |
413 |
|
|
|
414 |
|
|
void getOneElement(const ElementType& eltType, const felInt index, std::vector<felInt>& array, |
415 |
|
|
std::vector<Point*>& rPoints, const felInt startindex = 0, const bool flagIncrement = false) const; |
416 |
|
|
|
417 |
|
|
void getOneElement(const felInt idElem, std::vector<felInt>& array, const bool flagIncrement = false) const; |
418 |
|
|
|
419 |
|
|
/** |
420 |
|
|
* @brief Set one element in m_listElements |
421 |
|
|
* @details flagDecrement usage: {medit or ensight...} (start from 1) -> felisce format (start from 0) |
422 |
|
|
* @param[in] eltType The type of element to std::set |
423 |
|
|
* @param[in] index The id of the element to std::set in m_listElements |
424 |
|
|
* @param[in] array The array containing the element to std::set |
425 |
|
|
* @param[in] flagDecrement A flag to tell if we start from 0 or 1 |
426 |
|
|
*/ |
427 |
|
|
void setOneElement(const ElementType& eltType, const felInt index, |
428 |
|
|
const std::vector<felInt>& array, const bool flagDecrement = false); |
429 |
|
|
|
430 |
|
|
/// Return the number of found elements, put in array all vertices of the elements having the given ref |
431 |
|
|
int getElementsPerRef(const ElementType& eltType, const int ref, std::vector<felInt>& array) const; |
432 |
|
|
|
433 |
|
|
/// Get the indices of the elements of type eltType for the given reference |
434 |
|
|
void getElementsIDPerRef(const ElementType& eltType, const int ref, felInt* out_startindex, felInt* out_numRefEle) const; |
435 |
|
|
|
436 |
|
|
/// Get the element type and its id with respect to the element type of an element |
437 |
|
|
void getTypeElemFromIdElem(const felInt idElem, ElementType& eltType, felInt& idByType) const; |
438 |
|
|
|
439 |
|
|
/// Get the element global id by type and its id with respect to the element type |
440 |
|
|
void getIdElemFromTypeElemAndIdByType(const ElementType eltType, const felInt iElByType, felInt& position) const; |
441 |
|
|
|
442 |
|
|
/// Search a volumic element from the points ID of the face (in 3D). |
443 |
|
|
/// Return the id of the neighboring volume, and the coordinates of its points. |
444 |
|
|
void getElementFromBdElem(const std::vector<felInt>& facePts, std::vector<felInt>& elemIdPointVol, |
445 |
|
|
std::vector< Point* >& elemPointVol, int& idLocFace, felInt& idElemVol); |
446 |
|
|
|
447 |
|
|
/// Search the adjacent element (by eltType and index) sharing one edge/face |
448 |
|
|
bool getAdjElement(ElementType& eltType, felInt& index, int localIndexOfEdgeOrFace) const; |
449 |
|
|
|
450 |
|
|
/// Search the adjacent element (by global element id) sharing one edge/face |
451 |
|
|
std::pair<bool, ElementType> getAdjElement(felInt& idElem, int localIndexOfEdgeOrFace) const; |
452 |
|
|
|
453 |
|
|
/// Set normal in a node |
454 |
|
|
void setListNormal(int iNode, Point vecNormal); |
455 |
|
|
|
456 |
|
|
/// Set tangent in a node |
457 |
|
|
void setListTangent(int idim, int iNode, Point vecTangent); |
458 |
|
|
|
459 |
|
|
///@} |
460 |
|
|
///@name Inquiry |
461 |
|
|
///@{ |
462 |
|
|
|
463 |
|
|
/// Get number of elements per Bag |
464 |
|
|
felInt getNumElementByBag(const std::vector<ElementType>& them_bagElem) const; |
465 |
|
|
|
466 |
|
|
/// Get number of element per spatial dimesion |
467 |
|
1397 |
inline felInt getNumElement1D() const { return getNumElementByBag(bagElementType1D); }; |
468 |
|
133 |
inline felInt getNumElement2D() const { return getNumElementByBag(bagElementType2D); }; |
469 |
|
4 |
inline felInt getNumElement3D() const { return getNumElementByBag(bagElementType3D); }; |
470 |
|
|
|
471 |
|
|
/// Get number of elements |
472 |
|
1913 |
inline felInt getNumDomainElement() const { return getNumElementByBag( m_bagElementTypeDomain ); }; |
473 |
|
333 |
inline felInt getNumBoundaryElement() const { return getNumElementByBag( m_bagElementTypeDomainBoundary ); }; |
474 |
|
548 |
inline felInt getNumElement() const { return getNumElementByBag( m_bagElementTypeDomain ) + getNumElementByBag( m_bagElementTypeDomainBoundary ); }; |
475 |
|
|
|
476 |
|
|
void getAllEdgeOfElement(const ElementType eltType, const felInt iel, std::vector<felInt>& array) const; |
477 |
|
|
void getAllEdgeOfElement(const felInt iel, std::vector<felInt>& array) const; |
478 |
|
|
|
479 |
|
|
void getAllFaceOfElement(const ElementType eltType, const felInt iel, std::vector<felInt>& array) const; |
480 |
|
|
void getAllFaceOfElement(const felInt iel, std::vector<felInt>& array) const; |
481 |
|
|
|
482 |
|
|
void getEdge(const std::vector<felInt>& edgePts, Edge& resultEdge) const; |
483 |
|
|
void getFace(const std::vector<felInt>& facePts, Face& resultFace) const; |
484 |
|
|
|
485 |
|
|
///@} |
486 |
|
|
///@name Input and output |
487 |
|
|
///@{ |
488 |
|
|
|
489 |
|
|
/** |
490 |
|
|
* @brief Print information on the mesh |
491 |
|
|
* @details Print info for elements in domain and boundary bag. Print info for elements' ref. |
492 |
|
|
* @param[in] verbose level of verbose |
493 |
|
|
* @param[in] outstr stream to where the informations are printed |
494 |
|
|
*/ |
495 |
|
|
void print(int verbose = 0, std::ostream& outstr = std::cout) const; |
496 |
|
|
|
497 |
|
|
/// print info for vertices |
498 |
|
|
void printVertices(std::ostream& outstr = std::cout) const; |
499 |
|
|
|
500 |
|
|
/** |
501 |
|
|
* @brief Print info for elements in a bag |
502 |
|
|
* @param[in] bagElem The element bag of elements |
503 |
|
|
* @param[in] verbose level of verbose |
504 |
|
|
* @param[in] outstr stream where to print the infos |
505 |
|
|
* @param[in] incrementPointID To tell if indexes start from 0 or 1 |
506 |
|
|
*/ |
507 |
|
|
void printElements(const std::vector<ElementType>& bagElem, const int verbose = 0, |
508 |
|
|
std::ostream& outstr = std::cout, const bool incrementPointID = false) const; |
509 |
|
|
|
510 |
|
|
/** |
511 |
|
|
* @brief Print info for elements' ref. |
512 |
|
|
* @param bagElem The elements bag |
513 |
|
|
* @param verbose level of verbose |
514 |
|
|
* @param outstr stream where to print |
515 |
|
|
*/ |
516 |
|
|
void printRefToBegEnd(const std::vector<ElementType>& bagElem, const int verbose = 0, std::ostream& outstr = std::cout) const; |
517 |
|
|
|
518 |
|
|
///@} |
519 |
|
|
///@name Friends |
520 |
|
|
///@{ |
521 |
|
|
|
522 |
|
|
///@} |
523 |
|
|
|
524 |
|
|
void extractVerticesFromBoundary(const std::vector<int>& label, std::set<felInt>& list); |
525 |
|
|
|
526 |
|
|
// TODO |
527 |
|
|
bool findLocalCoord(ElementType& ityp, felInt& iel, const Point& point, Point& pointLoc); |
528 |
|
|
bool isPointInTetra(const felInt iel, const Point& p, std::array<double, 4>& bary, const double tol); |
529 |
|
|
bool isPointInTri(const felInt iel, const Point& p, std::array<double, 3>& bary, const double tol); |
530 |
|
|
bool isPointInSeg(const felInt iel, const Point& p, std::array<double, 2>& bary, const double tol); |
531 |
|
|
|
532 |
|
|
typedef std::vector<std::tuple<ElementType, felInt, felInt>> BallMap; |
533 |
|
|
|
534 |
|
|
void getVertexBall(const felInt idxVer, const ElementType eltTyp, const felInt eltGrm, BallMap& ball) const; |
535 |
|
|
void getEdgeShell(const std::vector<felInt>& idxVer, ElementType eltTyp, const felInt eltGrm, BallMap& shell) const; |
536 |
|
|
bool isVertexOfElt(const felInt idxVer, ElementType eltTyp, const felInt eltIdx, felInt &verPos) const; |
537 |
|
|
bool isEdgeOfElt(const std::vector<felInt>& idxVer, const ElementType eltTyp, const felInt eltIdx, felInt &verPos) const; |
538 |
|
|
void getElementPatch(const ElementType typGrm, const felInt eltGrm, std::vector<seedElement>& elementsInPatch) const; |
539 |
|
|
// std::size_t computeConnectedComponents(std::unordered_map<ElementType,std::vector<std::size_t>>& mapCco) const; |
540 |
|
|
|
541 |
|
|
static const std::vector< std::vector< std::vector<unsigned short int> > > m_eltTypMapVerToFac; |
542 |
|
|
static const std::vector< std::vector< std::vector<unsigned short int> > > m_eltTypMapFacToVer; |
543 |
|
|
static const std::vector< std::vector< std::vector<unsigned short int> > > m_eltTypMapEdgToVer; |
544 |
|
|
static const std::vector< std::vector< std::vector<unsigned short int> > > m_eltTypMapEdgToFac; |
545 |
|
|
|
546 |
|
|
protected: |
547 |
|
|
///@name Protected static Member Variables |
548 |
|
|
///@{ |
549 |
|
|
|
550 |
|
|
///@} |
551 |
|
|
///@name Protected member Variables |
552 |
|
|
///@{ |
553 |
|
|
|
554 |
|
|
///@} |
555 |
|
|
///@name Protected Operators |
556 |
|
|
///@{ |
557 |
|
|
|
558 |
|
|
///@} |
559 |
|
|
///@name Protected Operations |
560 |
|
|
///@{ |
561 |
|
|
|
562 |
|
|
///@} |
563 |
|
|
///@name Protected Access |
564 |
|
|
///@{ |
565 |
|
|
|
566 |
|
|
///@} |
567 |
|
|
///@name Protected Inquiry |
568 |
|
|
///@{ |
569 |
|
|
|
570 |
|
|
///@} |
571 |
|
|
///@name Protected LifeCycle |
572 |
|
|
///@{ |
573 |
|
|
|
574 |
|
|
///@} |
575 |
|
|
private: |
576 |
|
|
///@name Private static Member Variables |
577 |
|
|
///@{ |
578 |
|
|
|
579 |
|
|
///@} |
580 |
|
|
///@name Private member Variables |
581 |
|
|
///@{ |
582 |
|
|
|
583 |
|
|
/// Spatial dimension (1, 2, 3) |
584 |
|
|
int m_numCoor = 0; |
585 |
|
|
|
586 |
|
|
/// Domain Dimension (e.g. =2 in 3D for a 2-manifold or surface) |
587 |
|
|
DomainDimensionType m_domainDim = GeoMeshUndefined; |
588 |
|
|
|
589 |
|
|
/// O: if Medit; 1 if Ensight6 |
590 |
|
|
FormatType m_flagFormatMesh = FormatUndefined; |
591 |
|
|
|
592 |
|
|
/// Array of Points (coordinates) |
593 |
|
|
bool m_moved = false; |
594 |
|
|
std::vector<Point> m_listPoints; |
595 |
|
|
std::vector<Point> m_listReferencePoints; |
596 |
|
|
|
597 |
|
|
/// For each type of element the number of elements in the mesh |
598 |
|
|
felInt m_numElements[ m_numTypesOfElement ]; |
599 |
|
|
|
600 |
|
|
/// For each type of element we point to the (1d) array of points of the elements (if present in the mesh) |
601 |
|
|
felInt* m_listElements[ m_numTypesOfElement ]; |
602 |
|
|
|
603 |
|
|
/// Reference to element type std::unordered_map |
604 |
|
|
IntRefToElementType_type m_intRefToEnum; |
605 |
|
|
|
606 |
|
|
/// List of domain element types in the mesh |
607 |
|
|
std::vector<ElementType> m_bagElementTypeDomain; |
608 |
|
|
|
609 |
|
|
/// List of boundary element types in mesh |
610 |
|
|
std::vector<ElementType> m_bagElementTypeDomainBoundary; |
611 |
|
|
|
612 |
|
|
/// List of points normals and tangents |
613 |
|
|
bool m_createNormalTangent = false; |
614 |
|
|
int m_choiceDirectionTangent; |
615 |
|
|
std::vector<Point> m_listNormals; |
616 |
|
|
std::vector<std::vector<Point>> m_listTangents; |
617 |
|
|
|
618 |
|
|
/// List of element normals |
619 |
|
|
std::vector<std::vector<Point> > m_listEltNormals; |
620 |
|
|
std::vector<std::vector<Point> > m_listEltNormalsInit; |
621 |
|
|
|
622 |
|
|
/// List of mesh edges |
623 |
|
|
ListEdges m_listEdges; |
624 |
|
|
|
625 |
|
|
/// true if edges already built |
626 |
|
|
bool m_builtEdges = false; |
627 |
|
|
|
628 |
|
|
/// List of mesh faces |
629 |
|
|
ListFaces m_listFaces; |
630 |
|
|
|
631 |
|
|
/// true if faces already built |
632 |
|
|
bool m_builtFaces = false; |
633 |
|
|
|
634 |
|
|
///@} |
635 |
|
|
///@name Private Operators |
636 |
|
|
///@{ |
637 |
|
|
|
638 |
|
|
///@} |
639 |
|
|
///@name Private Operations |
640 |
|
|
///@{ |
641 |
|
|
|
642 |
|
|
/** |
643 |
|
|
* @brief Allocate m_listElements. |
644 |
|
|
* @details From a bag of elements, one allocates the list of elements of the current mesh, keeping only the elements that have the given rank. |
645 |
|
|
* @param[in] theElementBag The bag containing the element type |
646 |
|
|
* @param[in] meshGlobal The global mesh |
647 |
|
|
* @param[in] eltPartition The partition of the elements |
648 |
|
|
* @param[in] rank The rank of the process |
649 |
|
|
* @param[in,out] countEltTot To count the elements. |
650 |
|
|
*/ |
651 |
|
|
void m_allocateListElementsByRef(const std::vector<ElementType>& theElementBag, GeometricMeshRegion& meshGlobal, |
652 |
|
|
const std::vector<int>& eltPart, const int rank, felInt& numEltTot); |
653 |
|
|
|
654 |
|
|
/** |
655 |
|
|
* @brief Fill m_listElements and update intRefToBegEndMaps |
656 |
|
|
* @details From a bag of elements, one fills in the list of elements of the current mesh, keeping only the elements that have the given rank. (Do this only after having allocated m_listElements.) |
657 |
|
|
* @param[in] theElementBag The bag containing the element types to fill |
658 |
|
|
* @param[in] meshGlobal The global mesh |
659 |
|
|
* @param[in] eltPartition The partition of the elements |
660 |
|
|
* @param[in] rank The rank of the process |
661 |
|
|
* @param[out] loc2globElem The local to global mapping for the elements. |
662 |
|
|
* @param[in,out] countEltTot To count the elements |
663 |
|
|
*/ |
664 |
|
|
void m_fillListElementsByRef(const std::vector<ElementType>& theElementBag, GeometricMeshRegion& meshGlobal, |
665 |
|
|
const std::vector<int>& eltPart, const int rank, std::vector<felInt>& loc2globElem, felInt& numEltTot); |
666 |
|
|
|
667 |
|
|
/// helpers for edges and faces |
668 |
|
|
void m_buildEdgesPerBag(const std::vector<ElementType>& theBagElt, int theDim); |
669 |
|
|
void m_buildFacesPerBag(const std::vector<ElementType>& theBagElt, int theDim); |
670 |
|
|
|
671 |
|
|
///@} |
672 |
|
|
///@name Private Access |
673 |
|
|
///@{ |
674 |
|
|
|
675 |
|
|
///@} |
676 |
|
|
///@name Private Inquiry |
677 |
|
|
///@{ |
678 |
|
|
|
679 |
|
|
///@} |
680 |
|
|
///@name Private LifeCycle |
681 |
|
|
///@{ |
682 |
|
|
|
683 |
|
|
///@} |
684 |
|
|
}; |
685 |
|
|
///@} |
686 |
|
|
///@name Type Definitions |
687 |
|
|
///@{ |
688 |
|
|
|
689 |
|
|
///@} |
690 |
|
|
} /* namespace felisce.*/ |
691 |
|
|
|
692 |
|
|
#endif /* GEOMETRICMESHREGION_HPP defined */ |
693 |
|
|
|