Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
RefinementFactory_decl.hpp
1#ifndef RefinementFactory_decl_hpp
2#define RefinementFactory_decl_hpp
3
4#include "feddlib/core/Utils/FEDDUtils.hpp"
5#include "feddlib/core/Mesh/Mesh.hpp"
6#include "feddlib/core/Mesh/MeshUnstructured.hpp"
7#include "feddlib/core/Mesh/MeshInterface.hpp"
8#include "feddlib/core/Mesh/MeshFileReader.hpp"
9#include "feddlib/core/FE/EdgeElements.hpp"
10#include "feddlib/core/FE/TriangleElements.hpp"
11#include "feddlib/core/FE/EdgeElements.hpp"
12#include <Tpetra_CrsMatrix.hpp>
13#include "feddlib/core/FEDDCore.hpp"
14#include "feddlib/core/General/DefaultTypeDefs.hpp"
15#include "feddlib/core/Mesh/MeshStructured.hpp"
16#include "feddlib/amr/RefinementFactory.hpp"
17#include "feddlib/core/LinearAlgebra/BlockMatrix.hpp"
18#include <boost/function.hpp>
19
28
29namespace FEDD {
30
31template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
32class RefinementFactory : public MeshUnstructured<SC,LO,GO,NO> {
33
34public:
35 typedef Mesh<SC,LO,GO,NO> Mesh_Type;
36 typedef MeshUnstructured<SC,LO,GO,NO> MeshUnstr_Type;
37 typedef Teuchos::RCP<MeshUnstructured<SC,LO,GO,NO> > MeshUnstrPtr_Type;
38
39 typedef std::vector<MeshUnstrPtr_Type> MeshUnstrPtrArray_Type;
40
41 /*typedef MeshUnstructuredRefinement<SC,LO,GO,NO> MeshUnstrRef_Type;
42 typedef Teuchos::RCP<MeshUnstrRef_Type> MeshUnstrRefPtr_Type;
43 typedef std::vector<MeshUnstrRefPtr_Type> MeshUnstrRefPtrArray_Type; // Array of meshUnstr for meshRefinement*/
44
45 typedef typename Mesh_Type::CommPtr_Type CommPtr_Type;
46 typedef typename Mesh_Type::CommConstPtr_Type CommConstPtr_Type;
47
48
49 typedef Elements Elements_Type;
50 typedef Teuchos::RCP<Elements_Type> ElementsPtr_Type;
51 typedef SurfaceElements SurfaceElements_Type;
52 typedef Teuchos::RCP<SurfaceElements_Type> SurfaceElementsPtr_Type;
53 typedef EdgeElements EdgeElements_Type;
54 typedef Teuchos::RCP<EdgeElements_Type> EdgeElementsPtr_Type;
55
56 typedef MeshInterface<SC,LO,GO,NO> MeshInterface_Type;
57 typedef Teuchos::RCP<MeshInterface_Type> MeshInterfacePtr_Type;
58
59 typedef Map<LO,GO,NO> Map_Type;
60 typedef typename Map_Type::MapPtr_Type MapPtr_Type;
61 typedef typename Map_Type::MapConstPtr_Type MapConstPtr_Type;
62
63 typedef MultiVector<SC,LO,GO,NO> MultiVector_Type;
64 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
65 typedef MultiVector<LO,LO,GO,NO> MultiVectorLO_Type;
66 typedef Teuchos::RCP<MultiVectorLO_Type> MultiVectorLOPtr_Type;
67 typedef MultiVector<GO,LO,GO,NO> MultiVectorGO_Type;
68 typedef Teuchos::RCP<MultiVectorGO_Type> MultiVectorGOPtr_Type;
69 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorPtrConst_Type;
70 typedef Teuchos::OrdinalTraits<LO> OTLO;
71
72 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
73 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
74
75 RefinementFactory();
76
77 RefinementFactory( CommConstPtr_Type comm, int volumeID=10 );
78
79 RefinementFactory( CommConstPtr_Type comm, int volumeID, ParameterListPtr_Type parameterListAll);
80
81 ~RefinementFactory();
82
83
84 void refineMesh( MeshUnstrPtr_Type meshP1, int iteration, MeshUnstrPtr_Type outputMesh, std::string refinementMode); // MeshRefinement
85
86 void refineRegular(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i, SurfaceElementsPtr_Type surfaceTriangleElements); // aka red refinement
87
88 void refineGreen( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i); // green refinement
89
90 void refineBlue( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i); // blue refinement
91
92 void refineRed( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i); // red refinement
93
94 void refineType1( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements);
95 void refineType2( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements);
96 void refineType3( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements);
97 void refineType4( EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements);
98
99
100 void addMidpoint(EdgeElementsPtr_Type edgeElements, int i); // Adding midpoint on edge
101
102 int determineLongestEdge( EdgeElementsPtr_Type edgeElements, vec_int_Type edgeVec, vec2D_dbl_ptr_Type points); // Determines longest edge in triangle
103
104 void buildEdgeMap(MapConstPtr_Type mapGlobalProc,MapConstPtr_Type mapProc);
105 void buildNodeMap(EdgeElementsPtr_Type edgeElements, MapConstPtr_Type mapGlobalProc, MapConstPtr_Type mapProc, int newPoints, int newPointsRepeated);
106
107
108 void updateElementsOfEdgesLocalAndGlobal(int maxRank, MapConstPtr_Type edgeMap);
109
110 void updateElementsOfSurfaceLocalAndGlobal(EdgeElementsPtr_Type edgeElements);
111
112 vec_bool_Type checkInterfaceSurface( EdgeElementsPtr_Type edgeElements,vec_int_Type originFlag, vec_int_Type edgeNumbers, int indexElement);
113
114 void refinementRestrictions(MeshUnstrPtr_Type meshP1, ElementsPtr_Type elements ,EdgeElementsPtr_Type edgeElements,SurfaceElementsPtr_Type surfaceTriangleElements, int& newPoints, int& newPointsCommon, vec_GO_Type& globalInterfaceIDsTagged, MapConstPtr_Type mapInterfaceEdges, int& newElements); // check if Element that is tagged to be refined green has previously been refined green
115
116 void refineMeshRegIreg(ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, int& newElements, MapConstPtr_Type edgeMap, SurfaceElementsPtr_Type surfaceTriangleElements);
117
118 void buildSurfaceTriangleElements(ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceTriangleElements, MapConstPtr_Type edgeMap, MapConstPtr_Type elementMap );
119
120 void setErrorEstimate(vec_dbl_Type errorElements) { errorEstimation_ = errorElements;};
121
122 vec_dbl_Type getErrorEstimate() { return errorEstimation_ ; };
123
124 void bisectEdges(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements, std::string mode = "default");
125
126 void bisectElement3(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElementp);
127
128 std::string refinementRestriction_ = "none";
129
130 bool writeRefinementTime_ = "true";
131
132 int refinement3DDiagonal_ = 0; // 0 beeing the shortest interior Diagonal, 1 the second shortest and 2 the longest interior Diagonal
133
134 int currentIter_ = 0;
135
136 std::string refinementMode_ = "Regular";
137
138protected:
139 vec_GO_Type globalInterfaceIDs_;
140 vec_dbl_Type errorEstimation_; // error estimated according to A-posteriori Error Estimator. Sorted according to loca Element IDs
141
142 vec_dbl_Type areaTriangles_;
143 vec_dbl_Type volTetraeders_;
144 vec_dbl_Type h_T_diam_E_; // Diameter of 2D Triangular Elements
145 vec_dbl_Type h_T_min_; // Diameter in the 3D Tetraeder Sense
146
147 MapConstPtr_Type surfaceTriangleMap_;
148
149
150
151private:
152
153
154
155
156
157};
158}
159#endif
Definition EdgeElements.hpp:17
Definition Elements.hpp:22
Definition Map_decl.hpp:36
Definition Matrix_decl.hpp:32
Definition MeshInterface_decl.hpp:19
void buildEdgeMap()
Definition MeshUnstructured_def.hpp:1099
Definition Mesh_decl.hpp:25
Definition MultiVector_decl.hpp:36
void buildSurfaceTriangleElements(ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceTriangleElements, MapConstPtr_Type edgeMap, MapConstPtr_Type elementMap)
Building surface triangle elements, as they are not originally part of the mesh information provided ...
Definition RefinementFactory_def.hpp:825
void bisectElement3(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElementp)
2D refinement by bisection of tagged Elements with three tagged Edges.
Definition RefinementFactory_def.hpp:5520
void refineType3(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements)
3D Type(3) refinement as defined in "Tetrahedral Grid Refinement" by J. Bey 'Algorithm Regular Refine...
Definition RefinementFactory_def.hpp:2975
void refineGreen(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i)
2D green refinement: refining the element according to green scheme - connecting node on refined edge...
Definition RefinementFactory_def.hpp:2179
void refineRegular(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i, SurfaceElementsPtr_Type surfaceTriangleElements)
2D and 3D regular refinement. Chosen by error estimator or otherwise elements are refined regular by ...
Definition RefinementFactory_def.hpp:4199
void updateElementsOfEdgesLocalAndGlobal(int maxRank, MapConstPtr_Type edgeMap)
Updating ElementsOfEdgesLocal and ElementsOfEdgesGlobal.
Definition RefinementFactory_def.hpp:1637
void refineMeshRegIreg(ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, int &newElements, MapConstPtr_Type edgeMap, SurfaceElementsPtr_Type surfaceTriangleElements)
Refinement performed according to the set of rules determined by Bey or Verfürth.
Definition RefinementFactory_def.hpp:1497
int determineLongestEdge(EdgeElementsPtr_Type edgeElements, vec_int_Type edgeVec, vec2D_dbl_ptr_Type points)
Eetermine longest edge in triangle.
Definition RefinementFactory_def.hpp:1895
void bisectEdges(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements, std::string mode="default")
2D and 3D that bisects the edges of tagged Elements. Chosen by error estimator or otherwise elements ...
Definition RefinementFactory_def.hpp:5466
void refineType2(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements)
3D Type(2) refinement as defined in "Tetrahedral Grid Refinement" by J. Bey 'Algorithm Regular Refine...
Definition RefinementFactory_def.hpp:3407
void refinementRestrictions(MeshUnstrPtr_Type meshP1, ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceTriangleElements, int &newPoints, int &newPointsCommon, vec_GO_Type &globalInterfaceIDsTagged, MapConstPtr_Type mapInterfaceEdges, int &newElements)
Refinement Restrictions.
Definition RefinementFactory_def.hpp:1177
vec_bool_Type checkInterfaceSurface(EdgeElementsPtr_Type edgeElements, vec_int_Type originFlag, vec_int_Type edgeNumbers, int indexElement)
Checking if surfaces are part of the interface. Done by checking if all edges of a triangle are part ...
Definition RefinementFactory_def.hpp:539
void refineType1(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements)
3D Type(1) refinement as defined in "Tetrahedral Grid Refinement" by J. Bey 'Algorithm Regular Refine...
Definition RefinementFactory_def.hpp:3760
void buildNodeMap(EdgeElementsPtr_Type edgeElements, MapConstPtr_Type mapGlobalProc, MapConstPtr_Type mapProc, int newPoints, int newPointsRepeated)
Building nodemap after refinement.
Definition RefinementFactory_def.hpp:608
void refineRed(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i)
2D red refinement: refining the element red by connecting all tagged edges midpoints....
Definition RefinementFactory_def.hpp:2369
void refineType4(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int indexElement, SurfaceElementsPtr_Type surfaceTriangleElements)
3D Type(4) refinement as defined in "Tetrahedral Grid Refinement" by J. Bey 'Algorithm Regular Refine...
Definition RefinementFactory_def.hpp:2538
void refineMesh(MeshUnstrPtr_Type meshP1, int iteration, MeshUnstrPtr_Type outputMesh, std::string refinementMode)
Main function of RefinementFactory, performs one complete mesh refinement, according to red-green ref...
Definition RefinementFactory_def.hpp:100
void refineBlue(EdgeElementsPtr_Type edgeElements, ElementsPtr_Type elements, int i)
2D blue refinement: refining element according to blue refinement scheme - connecting nodes of shorte...
Definition RefinementFactory_def.hpp:1953
void addMidpoint(EdgeElementsPtr_Type edgeElements, int i)
Adding a Midpoint on an edge.
Definition RefinementFactory_def.hpp:1852
Definition TriangleElements.hpp:18
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5