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