Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
AdaptiveMeshRefinement_decl.hpp
1#ifndef AdaptiveMeshRefinement_decl_hpp
2#define AdaptiveMeshRefinement_decl_hpp
3
4#include <Tpetra_CrsMatrix.hpp>
5#include <boost/function.hpp>
6
7#include "feddlib/core/Utils/FEDDUtils.hpp"
8#include "feddlib/core/Mesh/Mesh.hpp"
9#include "feddlib/core/Mesh/MeshUnstructured.hpp"
10#include "feddlib/core/Mesh/MeshInterface.hpp"
11#include "feddlib/core/Mesh/MeshFileReader.hpp"
12#include "feddlib/core/FE/EdgeElements.hpp"
13#include "feddlib/core/FE/TriangleElements.hpp"
14#include "feddlib/core/FE/EdgeElements.hpp"
15#include "feddlib/core/FE/Domain.hpp"
16#include "feddlib/core/FEDDCore.hpp"
17#include "feddlib/core/Mesh/MeshStructured.hpp"
18#include "feddlib/core/Mesh/MeshUnstructured.hpp"
19#include "feddlib/core/LinearAlgebra/BlockMatrix.hpp"
20#include "feddlib/core/General/ExporterTxt.hpp"
21
22#include "feddlib/problems/abstract/Problem.hpp"
23
24#include "feddlib/amr/ExporterParaViewAMR.hpp"
25#include "feddlib/amr/ErrorEstimation.hpp"
26#include "feddlib/amr/RefinementFactory.hpp"
27
35
36namespace FEDD {
37
38template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
39class AdaptiveMeshRefinement {
40
41public:
42 typedef Mesh<SC,LO,GO,NO> Mesh_Type;
43 typedef MeshUnstructured<SC,LO,GO,NO> MeshUnstr_Type;
44 typedef Teuchos::RCP<MeshUnstructured<SC,LO,GO,NO> > MeshUnstrPtr_Type;
45
46 typedef std::vector<MeshUnstrPtr_Type> MeshUnstrPtrArray_Type;
47
48 typedef typename Mesh_Type::CommPtr_Type CommPtr_Type;
49 typedef typename Mesh_Type::CommConstPtr_Type CommConstPtr_Type;
50
51 typedef Elements Elements_Type;
52 typedef Teuchos::RCP<Elements_Type> ElementsPtr_Type;
53 typedef SurfaceElements SurfaceElements_Type;
54 typedef Teuchos::RCP<SurfaceElements_Type> SurfaceElementsPtr_Type;
55 typedef EdgeElements EdgeElements_Type;
56 typedef Teuchos::RCP<EdgeElements_Type> EdgeElementsPtr_Type;
57
58 typedef Map<LO,GO,NO> Map_Type;
59 typedef typename Map_Type::MapPtr_Type MapPtr_Type;
60 typedef typename Map_Type::MapConstPtr_Type MapConstPtr_Type;
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 MultiVector<GO,LO,GO,NO> MultiVectorGO_Type;
67 typedef Teuchos::RCP<MultiVectorGO_Type> MultiVectorGOPtr_Type;
68 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
69 typedef Teuchos::OrdinalTraits<LO> OTLO;
70
71 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
72 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
73
74 typedef ExporterParaViewAMR<SC,LO,GO,NO> Exporter_Type;
75 typedef Teuchos::RCP<Exporter_Type> ExporterPtr_Type;
76 typedef Teuchos::RCP<ExporterTxt> ExporterTxtPtr_Type;
77
78 typedef Problem<SC,LO,GO,NO> Problem_Type;
79 typedef Teuchos::RCP<Problem_Type> ProblemPtr_Type;
80
81 typedef Domain<SC,LO,GO,NO> Domain_Type;
82 typedef Teuchos::RCP<Domain_Type> DomainPtr_Type;
83 typedef std::vector<DomainPtr_Type> DomainPtrArray_Type;
84
85 typedef std::vector<MultiVectorPtr_Type> MultiVectorPtrArray_Type;
86
87 typedef BlockMultiVector<SC,LO,GO,NO> BlockMultiVector_Type;
88 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
89 typedef Teuchos::RCP<const BlockMultiVector_Type> BlockMultiVectorConstPtr_Type;
90
91 AdaptiveMeshRefinement();
92
93 AdaptiveMeshRefinement(ParameterListPtr_Type parameterListAll);
94
95 AdaptiveMeshRefinement(std::string problemType, ParameterListPtr_Type parameterListAll);
96
97 AdaptiveMeshRefinement(std::string problemType, ParameterListPtr_Type parameterListAll , Func_Type exactSolFunc );
98 AdaptiveMeshRefinement(std::string problemType, ParameterListPtr_Type parameterListAll , Func_Type exactSolFuncU,Func_Type exactSolFuncP );
99
100 ~AdaptiveMeshRefinement();
101
102 DomainPtr_Type globalAlgorithm(DomainPtr_Type domainP1, DomainPtr_Type domainP12, BlockMultiVectorConstPtr_Type solution,ProblemPtr_Type problem, RhsFunc_Type rhsFunc );
103
104 DomainPtr_Type refineArea(DomainPtr_Type domainP1, vec2D_dbl_Type area, int level);
105
106 DomainPtr_Type refineUniform(DomainPtr_Type domainP1, int level);
107
108 DomainPtr_Type refineFlag(DomainPtr_Type domainP1, int level ,int flag);
109
110 MultiVectorConstPtr_Type calcExactSolution();
111 MultiVectorConstPtr_Type calcExactSolutionP();
112 //void determineCoarsening();
113
114 void identifyProblem(BlockMultiVectorConstPtr_Type valuesSolution);
115
116 void calcErrorNorms(MultiVectorConstPtr_Type exactSolution, MultiVectorConstPtr_Type solutionP12,MultiVectorConstPtr_Type exactSolutionP);
117
118 void initExporter( ParameterListPtr_Type parameterListAll);
119
120 void exportSolution(MeshUnstrPtr_Type mesh, MultiVectorConstPtr_Type exportSolutionMv, MultiVectorConstPtr_Type errorValues, MultiVectorConstPtr_Type exactSolutionMv,MultiVectorConstPtr_Type exportSolutionPMv, MultiVectorConstPtr_Type exactSolutionPMv);
121
122 void exportError(MeshUnstrPtr_Type mesh, MultiVectorConstPtr_Type errorElConst, MultiVectorConstPtr_Type errorElConstH1 , MultiVectorConstPtr_Type difH1Eta ,MultiVectorConstPtr_Type vecDecompositionConst );
123
124 void writeRefinementInfo();
125
126 void buildSurfaceTriangleElements(ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceTriangleElements );
127
128 vec_bool_Type checkInterfaceSurface( EdgeElementsPtr_Type edgeElements,vec_int_Type originFlag, vec_int_Type edgeNumbers, int indexElement);
129
130protected:
131
132
133
134private:
135
136 RhsFunc_Type rhsFunc_;
137 Func_Type exactSolFunc_;
138
139 Func_Type exactSolPFunc_;
140
141 MeshUnstrPtr_Type inputMeshP1_;
142 MeshUnstrPtr_Type inputMeshP12_;
143 MeshUnstrPtr_Type outputMesh_;
144
145 MultiVectorPtrArray_Type errorEstimationMv_;
146
147 MultiVectorPtr_Type errorElementsMv_;
148 MultiVectorPtr_Type errorH1ElementsMv_;
149 MultiVectorPtr_Type difH1EtaElementsMv_;
150
151 MultiVectorConstPtr_Type errorNodesMv_;
152 MultiVectorConstPtr_Type errorNodesPMv_;
153
154 BlockMultiVectorConstPtr_Type solution_;
155
156 CommConstPtr_Type comm_;
157
158 bool exportWithParaview_ = true;
159 bool initExporter_=false;
160
161 ExporterPtr_Type exporterSol_;
162 ExporterPtr_Type exporterSolP_;
163 ExporterPtr_Type exporterError_;
164
165 DomainPtrArray_Type domainsP1_;
166 DomainPtrArray_Type domainsP12_;
167
168 DomainPtr_Type domainP1_;
169 DomainPtr_Type domainP12_;
170
171 ProblemPtr_Type problem_;
172
173 std::string refinementRestriction_ = "keepRegularity";
174 std::string markingStrategy_ = "Maximum";
175
176 double theta_ = 0.5;
177 double tol_= 0.001 ;
178
179 bool meshQualityPrint_ = "false";
180 bool timeTablePrint_ = "false";
181 int refinement3DDiagonal_ = 0; // 0 beeing the shortest interior Diagonal, 1 the second shortest and 2 the longest interior Diagonal
182
183 std::string problemType_;
184 int dim_;
185
186 int currentIter_;
187 int maxIter_ = 5;
188 int maxRank_;
189
190 std::string FEType1_;
191 std::string FEType2_;
192
193 vec_dbl_Type maxErrorEl;
194 vec_dbl_Type maxErrorKn;
195 vec_int_Type numElements;
196 vec_int_Type numElementsProc;
197 vec_dbl_Type relError;
198 vec_dbl_Type eRelError;
199 vec_dbl_Type errorH1;
200 vec_dbl_Type errorL2;
201 vec_dbl_Type errorL2P;
202 vec_int_Type numNodes;
203
204 bool writeRefinementTime_ = true ;
205 bool writeRefinementInfo_ = true ;
206 bool writeMeshQuality_ = true ;
207
208 bool hasProblemType_=true;
209
210 ParameterListPtr_Type parameterListAll_ ;
211
212 int dofs_;
213 int dofsP_;
214
215 bool exactSolInput_ = false ;
216 bool exactSolPInput_ = false ;
217
218 bool calculatePressure_=false;
219
220 int restrictionLayer_=2;
221
222 int coarseningCycle_=0 ;
223 int coarseningM_ = 1;
224 int coarseningN_ = 1;
225
226 std::string refinementMode_ = "Regular";
227
228
229
230};
231}
232#endif
MultiVectorConstPtr_Type calcExactSolution()
Calculating exact solution for velocity if possible with exactSolFunc_.
Definition AdaptiveMeshRefinement_def.hpp:620
DomainPtr_Type globalAlgorithm(DomainPtr_Type domainP1, DomainPtr_Type domainP12, BlockMultiVectorConstPtr_Type solution, ProblemPtr_Type problem, RhsFunc_Type rhsFunc)
Global Algorithm of Mesh Refinement.
Definition AdaptiveMeshRefinement_def.hpp:408
DomainPtr_Type refineUniform(DomainPtr_Type domainP1, int level)
Initializing problem if uniform refinement is requested.
Definition AdaptiveMeshRefinement_def.hpp:286
void writeRefinementInfo()
Writing refinement information at the end of mesh refinement.
Definition AdaptiveMeshRefinement_def.hpp:977
void exportError(MeshUnstrPtr_Type mesh, MultiVectorConstPtr_Type errorElConst, MultiVectorConstPtr_Type errorElConstH1, MultiVectorConstPtr_Type difH1Eta, MultiVectorConstPtr_Type vecDecompositionConst)
ParaViewExporter export of solutions and other error values on current mesh.
Definition AdaptiveMeshRefinement_def.hpp:951
MultiVectorConstPtr_Type calcExactSolutionP()
Calculating exact solution for pressure if possible with exactSolPFunc_.
Definition AdaptiveMeshRefinement_def.hpp:647
void exportSolution(MeshUnstrPtr_Type mesh, MultiVectorConstPtr_Type exportSolutionMv, MultiVectorConstPtr_Type errorValues, MultiVectorConstPtr_Type exactSolutionMv, MultiVectorConstPtr_Type exportSolutionPMv, MultiVectorConstPtr_Type exactSolutionPMv)
ParaViewExporter export of solutions and other error values on current mesh.
Definition AdaptiveMeshRefinement_def.hpp:895
void initExporter(ParameterListPtr_Type parameterListAll)
ParaViewExporter initiation. ParameterListAll contains most settings for ExporterParaView....
Definition AdaptiveMeshRefinement_def.hpp:865
DomainPtr_Type refineArea(DomainPtr_Type domainP1, vec2D_dbl_Type area, int level)
Initializing problem if only a certain area should be refined.
Definition AdaptiveMeshRefinement_def.hpp:240
void identifyProblem(BlockMultiVectorConstPtr_Type valuesSolution)
Identifying the problem with respect to the degrees of freedom and whether we calculate pressure....
Definition AdaptiveMeshRefinement_def.hpp:370
void calcErrorNorms(MultiVectorConstPtr_Type exactSolution, MultiVectorConstPtr_Type solutionP12, MultiVectorConstPtr_Type exactSolutionP)
Calculating error norms. If the exact solution is unknown we use approxmated error norm and error ind...
Definition AdaptiveMeshRefinement_def.hpp:674
Definition BlockMultiVector_decl.hpp:25
Definition Domain_decl.hpp:20
Definition EdgeElements.hpp:17
Definition Elements.hpp:23
Definition ExporterParaViewAMR_decl.hpp:29
Definition Map_decl.hpp:30
Definition Matrix_decl.hpp:30
Definition MeshUnstructured_decl.hpp:33
Definition Mesh_decl.hpp:25
Definition MultiVector_decl.hpp:61
Definition Problem_decl.hpp:42
Definition TriangleElements.hpp:18
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36