1#ifndef ErrorEstimation_decl_hpp
2#define ErrorEstimation_decl_hpp
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/core/Mesh/MeshUnstructured.hpp"
17#include "feddlib/amr/ErrorEstimation.hpp"
18#include "feddlib/amr/RefinementFactory.hpp"
19#include "feddlib/amr/AdaptiveMeshRefinement.hpp"
20#include "feddlib/core/LinearAlgebra/BlockMatrix.hpp"
21#include <boost/function.hpp>
34template <
class SC = default_sc,
class LO = default_lo,
class GO = default_go,
class NO = default_no>
35class ErrorEstimation {
38 typedef Teuchos::RCP<MeshUnstructured<SC,LO,GO,NO> > MeshUnstrPtr_Type;
41 typedef Teuchos::RCP<Elements_Type> ElementsPtr_Type;
43 typedef Teuchos::RCP<EdgeElements_Type> EdgeElementsPtr_Type;
45 typedef Teuchos::RCP<SurfaceElements_Type> SurfaceElementsPtr_Type;
51 typedef typename Map_Type::MapPtr_Type MapPtr_Type;
52 typedef typename Map_Type::MapConstPtr_Type MapConstPtr_Type;
55 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
57 typedef Teuchos::RCP<MultiVectorLO_Type> MultiVectorLOPtr_Type;
58 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
59 typedef Teuchos::OrdinalTraits<LO> OTLO;
62 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
65 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
66 typedef Teuchos::RCP<const BlockMultiVector_Type> BlockMultiVectorConstPtr_Type;
70 ErrorEstimation(
int dim, std::string problemType,
bool writeMeshQuality_);
74 MultiVectorPtr_Type
estimateError(MeshUnstrPtr_Type inputMeshP12, MeshUnstrPtr_Type inputMeshP1, BlockMultiVectorConstPtr_Type valuesSolution, RhsFunc_Type rhsFunc, std::string FEType);
80 vec3D_dbl_Type
calcNPhi(std::string phiDerivative,
int dofsSol, std::string FEType);
84 vec2D_dbl_Type
gradPhi(
int dim,
int intFE,vec_dbl_Type &p);
85 vec_dbl_Type
phi(
int dim,
int intFE,vec_dbl_Type &p);
87 MultiVectorPtr_Type
determineCoarseningError(MeshUnstrPtr_Type mesh_k, MeshUnstrPtr_Type mesh_k_m, MultiVectorPtr_Type errorElementMv_k, std::string distribution, std::string markingStrategy,
double theta);
95 void markElements(MultiVectorPtr_Type errorElementMv,
double theta, std::string strategy, MeshUnstrPtr_Type meshUnstr);
97 vec_dbl_Type
determineVolTet(ElementsPtr_Type elements,vec2D_dbl_ptr_Type points);
99 vec_dbl_Type
calcDiamTriangles(ElementsPtr_Type elements,vec2D_dbl_ptr_Type points, vec_dbl_Type& areaTriangles, vec_dbl_Type& rho_T,vec_dbl_Type& C_T);
100 vec_dbl_Type
calcDiamTriangles3D(SurfaceElementsPtr_Type surfaceTriangleElements,vec2D_dbl_ptr_Type points,vec_dbl_Type& areaTriangles, vec_dbl_Type& rho_T,vec_dbl_Type& C_T);
102 vec_dbl_Type
calcDiamTetraeder(ElementsPtr_Type elements,vec2D_dbl_ptr_Type points, vec_dbl_Type volTet);
104 vec_dbl_Type
calcRhoTetraeder(ElementsPtr_Type elements,SurfaceElementsPtr_Type surfaceTriangleElements, vec_dbl_Type volTet, vec_dbl_Type areaTriangles);
106 vec_dbl_Type
determineAreaTriangles(ElementsPtr_Type elements,EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceElements, vec2D_dbl_ptr_Type points);
112 void setErrorEstimate(MultiVectorPtr_Type errorElements) { errorEstimation_ = errorElements;};
114 MultiVectorPtr_Type getErrorEstimate() {
return errorEstimation_ ; };
116 void tagArea(MeshUnstrPtr_Type meshUnstr,vec2D_dbl_Type area);
118 void tagAll(MeshUnstrPtr_Type meshUnstr);
120 void tagFlag( MeshUnstrPtr_Type inputMeshP1,
int flag);
122 std::string refinementRestriction_ =
"none";
123 std::string markingStrategy_ =
"Maximum";
126 bool writeMeshQuality_ =
"false";
127 bool timeTablePrint_ =
"false";
128 int refinement3DDiagonal_ = 0;
131 std::string problemType_;
134 MultiVectorPtr_Type errorEstimation_;
136 MapConstPtr_Type surfaceTriangleMap_;
137 SurfaceElementsPtr_Type surfaceElements_;
142 bool calculatePressure_ =
false;
144 BlockMultiVectorConstPtr_Type valuesSolutionRepVel_;
145 BlockMultiVectorConstPtr_Type valuesSolutionRepPre_;
148 MeshUnstrPtr_Type inputMesh_;
149 MeshUnstrPtr_Type inputMeshP1_;
150 std::string FEType1_;
151 std::string FEType2_;
Definition BlockMultiVector_decl.hpp:25
Definition EdgeElements.hpp:17
Definition Elements.hpp:22
vec_dbl_Type determineAreaTriangles(ElementsPtr_Type elements, EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceElements, vec2D_dbl_ptr_Type points)
Calculating the area of the triangle elements of tetrahedra.
Definition ErrorEstimation_def.hpp:1804
vec2D_dbl_Type getQuadValues(int dim, std::string FEType, std::string Type, vec_dbl_Type &QuadW, FiniteElement surface)
Returns neccesary quadrature Values. Is distinguishes between needing Element or Surface information.
Definition ErrorEstimation_def.hpp:1486
vec_dbl_Type calcDiamTetraeder(ElementsPtr_Type elements, vec2D_dbl_ptr_Type points, vec_dbl_Type volTet)
Calculating the circumdiameter of tetraeder.
Definition ErrorEstimation_def.hpp:1678
double determineDivU(FiniteElement element)
Function that that determines || div(u) ||_T for a Element T.
Definition ErrorEstimation_def.hpp:1227
vec_dbl_Type calculateJump()
Part of the error estimator that calculates the jump part of the estimation. What kind of jump is cal...
Definition ErrorEstimation_def.hpp:663
void tagArea(MeshUnstrPtr_Type meshUnstr, vec2D_dbl_Type area)
Tags only a certain Area for refinement and is independent of any error estimation.
Definition ErrorEstimation_def.hpp:474
vec_dbl_Type phi(int dim, int intFE, vec_dbl_Type &p)
Calcutlating phi depending on quad points p.
Definition ErrorEstimation_def.hpp:2400
void identifyProblem(BlockMultiVectorConstPtr_Type valuesSolution)
Identifying the problem with respect to the degrees of freedom and whether we calculate pressure....
Definition ErrorEstimation_def.hpp:61
vec_dbl_Type calcDiamTriangles3D(SurfaceElementsPtr_Type surfaceTriangleElements, vec2D_dbl_ptr_Type points, vec_dbl_Type &areaTriangles, vec_dbl_Type &rho_T, vec_dbl_Type &C_T)
Calculating the diameter of triangles.
Definition ErrorEstimation_def.hpp:1752
vec2D_dbl_Type gradPhi(int dim, int intFE, vec_dbl_Type &p)
Calcutlating the gradient of phi depending on quad points p.
Definition ErrorEstimation_def.hpp:2269
void buildTriangleMap()
Build Surface Map. Contrary to building the edge map, building the surface map is somewhat simpler as...
Definition ErrorEstimation_def.hpp:2033
void tagAll(MeshUnstrPtr_Type meshUnstr)
Tags only a certain Area for refinement and is independent of any error estimation.
Definition ErrorEstimation_def.hpp:580
vec_dbl_Type calcRhoTetraeder(ElementsPtr_Type elements, SurfaceElementsPtr_Type surfaceTriangleElements, vec_dbl_Type volTet, vec_dbl_Type areaTriangles)
Calcutlating the incircumdiameter of tetrahedra.
Definition ErrorEstimation_def.hpp:1724
void markElements(MultiVectorPtr_Type errorElementMv, double theta, std::string strategy, MeshUnstrPtr_Type meshUnstr)
Function that marks the elements for refinement.
Definition ErrorEstimation_def.hpp:1138
vec3D_dbl_Type calcNPhi(std::string phiDerivative, int dofsSol, std::string FEType)
Function that calculates the jump part for nabla u or p.
Definition ErrorEstimation_def.hpp:783
void updateElementsOfSurfaceLocalAndGlobal(EdgeElementsPtr_Type edgeElements, SurfaceElementsPtr_Type surfaceTriangleElements)
UpdateElementsOfSurfaceLocalAndGlobal is performed here instead of in meshRefinement,...
Definition ErrorEstimation_def.hpp:1951
double determineResElement(FiniteElement element, RhsFunc_Type rhsFunc)
Function that that determines ||\Delta u_h + f ||_(L2(T)), || \Delta u_h + f - \nabla p_h ||_T or || ...
Definition ErrorEstimation_def.hpp:1320
MultiVectorPtr_Type determineCoarseningError(MeshUnstrPtr_Type mesh_k, MeshUnstrPtr_Type mesh_k_m, MultiVectorPtr_Type errorElementMv_k, std::string distribution, std::string markingStrategy, double theta)
DetermineCoarseningError is the essential part of the mesh coarsening process.
Definition ErrorEstimation_def.hpp:1908
vec_dbl_Type calcDiamTriangles(ElementsPtr_Type elements, vec2D_dbl_ptr_Type points, vec_dbl_Type &areaTriangles, vec_dbl_Type &rho_T, vec_dbl_Type &C_T)
Calculating the diameter of triangles.
Definition ErrorEstimation_def.hpp:1849
MultiVectorPtr_Type estimateError(MeshUnstrPtr_Type inputMeshP12, MeshUnstrPtr_Type inputMeshP1, BlockMultiVectorConstPtr_Type valuesSolution, RhsFunc_Type rhsFunc, std::string FEType)
Main Function for a posteriori error estimation.
Definition ErrorEstimation_def.hpp:157
vec_dbl_Type determineVolTet(ElementsPtr_Type elements, vec2D_dbl_ptr_Type points)
function, that determines volume of tetrahedra.
Definition ErrorEstimation_def.hpp:1623
void makeRepeatedSolution(BlockMultiVectorConstPtr_Type valuesSolution)
We split the solution from the BlockMultiVector valuesSolution into one or more seperate blocks,...
Definition ErrorEstimation_def.hpp:99
Definition FiniteElement.hpp:17
Definition Map_decl.hpp:36
Definition Matrix_decl.hpp:32
Definition MultiVector_decl.hpp:36
Definition TriangleElements.hpp:18
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5