Programming tasks to Scientific Computing I
errorEstimator.h
Go to the documentation of this file.
1 #ifndef EXERCISE_3_ERRORESTIMATOR_H_
2 #define EXERCISE_3_ERRORESTIMATOR_H_
3 
9 #include <typeinfo>
10 #include <cxxabi.h>
11 
12 #include <Eigen/Dense>
13 
17 template<typename ConfiguratorType>
18 class ErrorEstimator
19 {
20 public:
25  // Strangely, lpNorm fails if this is set to
26  // "typename ConfiguratorType::VectorType". Bug?
27  typedef typename Eigen::VectorXd VectorType;
28  typedef typename Eigen::Matrix<RealType, 3, 1> VecType;
29 
36  ErrorEstimator(MeshType &mesh, const ConfiguratorType &config,
37  const VectorType &numericalSolution,
38  RealType gamma = 0.4)
39  : _mesh(mesh),
40  _numericalSolution(config, numericalSolution), _gamma(gamma)
41  {}
42 
44  RealType err = markTriangles();
45  _mesh.refineMarkedTriangles();
46  return err;
47  }
48 
50  RealType markTriangles()
51  {
52  VectorType errEstimates(_mesh.getNumTriangs());
53 
54  computeLocalErrorEstimates(errEstimates);
55 
57 
58  return errEstimates.norm();
59  }
60 
62  void computeLocalErrorEstimates(VectorType &errEstimates) const
63  {
65  }
66 
68  void computeH(VectorType &h) const
69  {
70  for (int t = 0; t < _mesh.getNumTriangs(); ++t) {
71  h[t] = _mesh.getTriang(t).getEdge(_mesh.getLongestEdgeIndex(t)).norm();
72  }
73  }
74 
76  MeshType& getMesh()
77  {
78  return _mesh;
79  }
80 
81 protected:
82 
83  MeshType &_mesh;
85  RealType _gamma;
86 };
87 
88 #endif /* EXERCISE_3_ERRORESTIMATOR_H_ */
Helper class to evaluate a discrete nodal function on a given mesh.
const shellFE::DiscreteFunctionDefaultShellFE< ConfiguratorType > _numericalSolution
const TriangleType & getTriang(const int num) const
Definition: triangMesh.h:87
ErrorEstimator(MeshType &mesh, const ConfiguratorType &config, const VectorType &numericalSolution, RealType gamma=0.4)
Constructor.
Class for local error estimation.
DataTypeContainer::DomVecType DomVecType
DataTypeContainer::RealType RealType
ConfiguratorType::InitType MeshType
RealType markTriangles()
int getNumTriangs() const
Definition: triangMesh.h:46
Eigen::VectorXd VectorType
void computeH(VectorType &h) const
Compute length on longest edge for each element.
RealType markAndRefineTriangles()
ConfiguratorType::DomVecType DomVecType
MeshType & _mesh
DataTypeContainer::TangentVecType TangentVecType
ConfiguratorType::RealType RealType
ConfiguratorType::TangentVecType TangentVecType
MeshType & getMesh()
Returns reference to the mesh that was used for initialization of this object.
Eigen::Matrix< RealType, 3, 1 > VecType
Configurator for Finite Elements.
const TangentVecType & getEdge(int i) const
Access edge i.
void computeLocalErrorEstimates(VectorType &errEstimates) const