Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
MeshUnstructured_decl.hpp
1#ifndef MESHUNSTRUCTURED_decl_hpp
2#define MESHUNSTRUCTURED_decl_hpp
3
4#include "feddlib/core/Utils/FEDDUtils.hpp"
5#include "Mesh.hpp"
6#include "MeshInterface.hpp"
7#include "MeshFileReader.hpp"
8#include "feddlib/core/FE/EdgeElements.hpp"
9#include "feddlib/core/LinearAlgebra/BlockMatrix.hpp"
10#include "feddlib/core/FE/TriangleElements.hpp"
11#include "feddlib/core/General/ExporterParaView.hpp"
12#include "feddlib/core/LinearAlgebra/MultiVector.hpp"
13
22
27
28
29
30namespace FEDD {
31
32template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
33class MeshUnstructured : public Mesh<SC,LO,GO,NO> {
34
35public:
36 typedef Mesh<SC,LO,GO,NO> Mesh_Type;
37 typedef Teuchos::RCP<MeshUnstructured<SC,LO,GO,NO> > MeshUnstrPtr_Type;
38 typedef Teuchos::RCP<Mesh_Type> MeshPtr_Type;
39
40 typedef std::vector<MeshUnstrPtr_Type> MeshUnstrPtrArray_Type;
41
42 typedef typename Mesh_Type::CommPtr_Type CommPtr_Type;
43 typedef typename Mesh_Type::CommConstPtr_Type CommConstPtr_Type;
44 typedef typename Mesh_Type::Elements_Type Elements_Type;
45 typedef typename Mesh_Type::ElementsPtr_Type ElementsPtr_Type;
46
47 typedef EdgeElements EdgeElements_Type;
48 typedef Teuchos::RCP<EdgeElements_Type> EdgeElementsPtr_Type;
49
50 typedef SurfaceElements SurfaceElements_Type;
51 typedef Teuchos::RCP<SurfaceElements_Type> SurfaceElementsPtr_Type;
52
53 typedef MeshInterface<SC,LO,GO,NO> MeshInterface_Type;
54 typedef Teuchos::RCP<MeshInterface_Type> MeshInterfacePtr_Type;
55
56 typedef Map<LO,GO,NO> Map_Type;
57 typedef typename Map_Type::MapPtr_Type MapPtr_Type;
58 typedef typename Map_Type::MapConstPtr_Type MapConstPtr_Type;
59
60 typedef Teuchos::OrdinalTraits<LO> OTLO;
61
62 typedef MultiVector<SC,LO,GO,NO> MultiVector_Type;
63 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
64 typedef MultiVector<LO,LO,GO,NO> MultiVectorLO_Type;
65 typedef Teuchos::RCP<MultiVectorLO_Type> MultiVectorLOPtr_Type;
66 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorPtrConst_Type;
67
68 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
69 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
70
71 MeshUnstructured();
72
73 MeshUnstructured( CommConstPtr_Type comm, int volumeID=10, std::string meshUnit = "cm", bool convertToCM = false );
74
75 ~MeshUnstructured();
76
81 void buildP2ofP1MeshEdge( MeshUnstrPtr_Type meshP1 );
82
87 void setP2SurfaceElements( MeshUnstrPtr_Type meshP1 );
88
96 void setSurfaceP2( FiniteElement &feP2, const FiniteElement &surfFeP1, const vec2D_int_Type &surfacePermutation, int dim );
97
106 void addSurfaceP2Nodes( FiniteElement &feP2, const FiniteElement &surfFeP1, const vec2D_int_Type &surfacePermutation, int dim );
110 vec_int_Type reorderP2SurfaceIndices( vec_int_Type& additionalP2IDs, vec_int_Type& index, bool track=false);
111
115 void getLocalSurfaceIndices( vec2D_int_Type& surfacePermutation, int surfaceElementOrder );
116
120 void getEdgeCombinations( vec2D_int_Type& edgeCombinations );
121
130 void determinePositionInElementP2( vec_int_Type& positions, vec_GO_Type& elementsGlobalOfEdge, LO p1ID, LO p2ID, MeshUnstrPtr_Type meshP1 );
131
139 int determineFlagP2( FiniteElement& fe, LO p1ID, LO p2ID, vec2D_int_Type& permutation );
140
149 int determineFlagP2( LO p1ID, LO p2ID, LO localEdgeID, vec2D_LO_Type& markedPoint );
150
151 void getTriangles(int vertex1ID, int vertex2ID, vec_int_Type &vertices3ID);
152
153 SurfaceElementsPtr_Type getSurfaceTriangleElements(){return surfaceTriangleElements_;}
154
155 void findSurfaces( const vec_int_Type& elementNodeList, vec_int_Type numbering, vec2D_int_Type& localSurfaceNodeList_vec, vec_int_Type& locSurfaces, bool critical = false );
156
164 void findEdges( const vec_int_Type& elementNodeList, vec_int_Type numbering, vec2D_int_Type& localEdgeNodeList_vec, vec_int_Type& locEdges);
165
170 MeshInterfacePtr_Type getMeshInterface();
171
172 void buildMeshInterfaceParallelAndDistance( MeshUnstrPtr_Type mesh, vec_int_Type flag_vec, vec_dbl_ptr_Type &distancesToInterface );
173
174 void partitionInterface();
175
180 void setEdgeElements(EdgeElementsPtr_Type edgeElements) { edgeElements_ = edgeElements; }
181
186 EdgeElementsPtr_Type getEdgeElements() { return edgeElements_; }
187
192 ElementsPtr_Type getSurfaceEdgeElements() { return surfaceEdgeElements_; }
193
198
203 void readMeshEntity(std::string entityType);
204
208 void setMeshFileName(std::string meshFileName, std::string delimiter);
209
214 int getNumGlobalNodes() { return numNodes_; }
215
220
225
233 void exportMesh(MapConstPtr_Type mapUnique, MapConstPtr_Type mapRep, bool exportEdges=false, bool exportSurface=false, std::string meshName="export.mesh");
234
241 void exportNodeFlags();
242
249 void exportElementFlags();
250
251 /* ###################################################################### */
252
253 MeshInterfacePtr_Type meshInterface_;
254
255 int volumeID_;
256 /* ###################################################################### */
257
258
259 EdgeElementsPtr_Type edgeElements_;
260 ElementsPtr_Type surfaceEdgeElements_;
261 SurfaceElementsPtr_Type surfaceTriangleElements_;
262
263 std::string meshFileName_;
264 std::string delimiter_;
265
266 int numSurfaces_;
267 int numEdges_;
268 int numNodes_;
269 bool convertToCM_; // Whether to convert it into cm Unit
270 std::string meshUnitFinal_; // If converted unit changes
271 std::string meshUnitRead_; // Input mesh unit
272
273private:
274
275 void readSurfaces();
276
277 void readLines();
278
279 void readElements();
280
281 void readNodes();
282
283};
284}
285#endif
Definition EdgeElements.hpp:17
Definition FiniteElement.hpp:17
Definition Map_decl.hpp:30
Definition Matrix_decl.hpp:30
Definition MeshInterface_decl.hpp:19
void setEdgeElements(EdgeElementsPtr_Type edgeElements)
setEdgeElements with external edges
Definition MeshUnstructured_decl.hpp:180
ElementsPtr_Type getSurfaceEdgeElements()
Definition MeshUnstructured_decl.hpp:192
void buildEdgeMap()
Building an edgemap from scratch when edges are already distributed parallel.
Definition MeshUnstructured_def.hpp:1099
void buildP2ofP1MeshEdge(MeshUnstrPtr_Type meshP1)
Function to build a P2 mesh of a P1 mesh.
Definition MeshUnstructured_def.hpp:121
void setSurfaceP2(FiniteElement &feP2, const FiniteElement &surfFeP1, const vec2D_int_Type &surfacePermutation, int dim)
Helper function for setP2SurfaceElements. Adds the correct nodes to the meshP1 subelements....
Definition MeshUnstructured_def.hpp:402
void addSurfaceP2Nodes(FiniteElement &feP2, const FiniteElement &surfFeP1, const vec2D_int_Type &surfacePermutation, int dim)
Helper function for setP2SurfaceElements. Adds the correct nodes to the meshP1 subelements....
Definition MeshUnstructured_def.hpp:330
int determineFlagP2(LO p1ID, LO p2ID, LO localEdgeID, vec2D_LO_Type &markedPoint)
Essentially determine flag of an edge. Thus determine P2 Flag for building P2 mesh....
Definition MeshUnstructured_def.hpp:765
int getNumGlobalNodes()
Get global number of nodes.
Definition MeshUnstructured_decl.hpp:214
void readMeshSize()
Reading mesh size.
Definition MeshUnstructured_def.hpp:1304
void exportMesh(MapConstPtr_Type mapUnique, MapConstPtr_Type mapRep, bool exportEdges=false, bool exportSurface=false, std::string meshName="export.mesh")
Exporting Mesh as .mesh file. For most detailed export we also write surfaces and edges....
Definition MeshUnstructured_def.hpp:1590
int determineFlagP2(FiniteElement &fe, LO p1ID, LO p2ID, vec2D_int_Type &permutation)
Essentially determine flag of an edge. Thus determine P2 Flag for building P2 mesh.
Definition MeshUnstructured_def.hpp:737
void setMeshFileName(std::string meshFileName, std::string delimiter)
Set the .mesh file name.
Definition MeshUnstructured_def.hpp:950
void setP2SurfaceElements(MeshUnstrPtr_Type meshP1)
Adding the correct surface subelement to the new P2 Elements based on the P1 subelements.
Definition MeshUnstructured_def.hpp:283
EdgeElementsPtr_Type getEdgeElements()
Get EdgeElements.
Definition MeshUnstructured_decl.hpp:186
vec_int_Type reorderP2SurfaceIndices(vec_int_Type &additionalP2IDs, vec_int_Type &index, bool track=false)
Depending on the sorting of P1 surface nodes we have to adjust the new ordering of P2 edge midpoints ...
Definition MeshUnstructured_def.hpp:521
void getLocalSurfaceIndices(vec2D_int_Type &surfacePermutation, int surfaceElementOrder)
Get local Surface Indices.
Definition MeshUnstructured_def.hpp:625
void getEdgeCombinations(vec2D_int_Type &edgeCombinations)
Get edge combinations.
Definition MeshUnstructured_def.hpp:670
void determinePositionInElementP2(vec_int_Type &positions, vec_GO_Type &elementsGlobalOfEdge, LO p1ID, LO p2ID, MeshUnstrPtr_Type meshP1)
Determine position of new P2 node in element, as all elements should follow the same structure.
Definition MeshUnstructured_def.hpp:689
void findEdges(const vec_int_Type &elementNodeList, vec_int_Type numbering, vec2D_int_Type &localEdgeNodeList_vec, vec_int_Type &locEdges)
Determine which edges belong to an element.
Definition MeshUnstructured_def.hpp:904
void assignEdgeFlags()
Assigning flags to all edges.
Definition MeshUnstructured_def.hpp:965
void readMeshEntity(std::string entityType)
Reading the .mesh files entities.
Definition MeshUnstructured_def.hpp:1352
MeshInterfacePtr_Type getMeshInterface()
Get mesh interface.
Definition MeshUnstructured_def.hpp:922
Definition MultiVector_decl.hpp:61
Definition TriangleElements.hpp:18
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36