Programming tasks to Scientific Computing I
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ErrorEstimator< ConfiguratorType > Class Template Reference

Class for local error estimation. More...

#include <errorEstimator.h>

Public Types

typedef ConfiguratorType::InitType MeshType
 
typedef ConfiguratorType::RealType RealType
 
typedef Eigen::VectorXd VectorType
 
typedef Eigen::Matrix< RealType, 3, 1 > VecType
 

Public Member Functions

 ErrorEstimator (MeshType &grid, RealType gamma=0.4)
 
RealType markAndRefineTriangles ()
 
RealType markTriangles ()
 

Protected Member Functions

RealType f (const typename ConfiguratorType::Point3DType &x) const
 
void computeLocalErrorEstimates (VectorType &errEstimates) const
 
RealType jumpResidual (int t) const
 
RealType getMidpointValue (int t) const
 

Protected Attributes

MeshType_mesh
 
RealType _gamma
 

Detailed Description

template<typename ConfiguratorType>
class ErrorEstimator< ConfiguratorType >

Class for local error estimation.

Definition at line 20 of file errorEstimator.h.

Member Typedef Documentation

template<typename ConfiguratorType>
typedef ConfiguratorType::InitType ErrorEstimator< ConfiguratorType >::MeshType

Definition at line 23 of file errorEstimator.h.

template<typename ConfiguratorType>
typedef ConfiguratorType::RealType ErrorEstimator< ConfiguratorType >::RealType

Definition at line 24 of file errorEstimator.h.

template<typename ConfiguratorType>
typedef Eigen::VectorXd ErrorEstimator< ConfiguratorType >::VectorType

Definition at line 27 of file errorEstimator.h.

template<typename ConfiguratorType>
typedef Eigen::Matrix<RealType, 3, 1> ErrorEstimator< ConfiguratorType >::VecType

Definition at line 28 of file errorEstimator.h.

Constructor & Destructor Documentation

template<typename ConfiguratorType>
ErrorEstimator< ConfiguratorType >::ErrorEstimator ( MeshType grid,
RealType  gamma = 0.4 
)
inline

Definition at line 30 of file errorEstimator.h.

31  : _mesh(grid), _gamma(gamma)
32  {}
MeshType & _mesh

Member Function Documentation

template<typename ConfiguratorType>
void ErrorEstimator< ConfiguratorType >::computeLocalErrorEstimates ( VectorType errEstimates) const
inlineprotected

Definition at line 69 of file errorEstimator.h.

70  {
71  for (int t = 0; t < _mesh.getNumTriangs(); ++t) {
73  RealType J_t = jumpResidual(t);
74  errEstimates[t] = sqrt(h) * J_t;
75  }
76  }
const TriangleType & getTriang(const int num) const
Definition: triangMesh.h:87
RealType jumpResidual(int t) const
int getNumTriangs() const
Definition: triangMesh.h:46
LocalIndex getLongestEdgeIndex(GlobalIndex triangle) const
Get longest edge index (starting search possibly with a preferred edge)
double RealType
Definition: ex2.cpp:21
MeshType & _mesh
const TangentVecType & getEdge(int i) const
Access edge i.
template<typename ConfiguratorType>
RealType ErrorEstimator< ConfiguratorType >::f ( const typename ConfiguratorType::Point3DType x) const
inlineprotected

Definition at line 55 of file errorEstimator.h.

56  {
57  RealType a = 0.8;
58  RealType b = 0.0;
59  int r = 0;
60 
61  for(int i = 0; i < 4; i++) {
62  r = r || ( (x[1] > b) && (fabs(x[0]) + fabs(x[1]-b) < a) );
63  b += a *= .75;
64  }
65 
66  return 2.0 * static_cast<RealType>(r);
67  }
double RealType
Definition: ex2.cpp:21
template<typename ConfiguratorType>
RealType ErrorEstimator< ConfiguratorType >::getMidpointValue ( int  t) const
inlineprotected

Definition at line 96 of file errorEstimator.h.

96  {
98 
99  RealType res = 0.0;
100  for (int i = 0; i < 3; ++i) {
101  res += f(el.getNode(i));
102  }
103  res /= 3.0;
104 
105  return res;
106  }
RealType f(const typename ConfiguratorType::Point3DType &x) const
const TriangleType & getTriang(const int num) const
Definition: triangMesh.h:87
const Point3DType & getNode(int i) const
Access node i.
double RealType
Definition: ex2.cpp:21
MeshType & _mesh
Triangle which has a tangent space at each node.
template<typename ConfiguratorType>
RealType ErrorEstimator< ConfiguratorType >::jumpResidual ( int  t) const
inlineprotected

Definition at line 78 of file errorEstimator.h.

79  {
80  RealType Jt = 0.0;
81 
82  RealType val = getMidpointValue(t);
83  for (int e = 0; e < 3; ++e) {
84  int neighbour = _mesh.getNeighbour(t, e);
85  // If no neighbour
86  if (neighbour == -1)
87  continue;
88 
89  RealType nVal = getMidpointValue(neighbour);
90  Jt += fabs(val - nVal);
91  }
92 
93  return Jt;
94  }
int getNeighbour(const int elementID, const int acrossLocalEdge) const
Get neighbor on edge.
Definition: triangMesh.h:76
RealType getMidpointValue(int t) const
double RealType
Definition: ex2.cpp:21
MeshType & _mesh
template<typename ConfiguratorType>
RealType ErrorEstimator< ConfiguratorType >::markAndRefineTriangles ( )
inline

Definition at line 34 of file errorEstimator.h.

34  {
35  RealType err = markTriangles();
37  return err;
38  }
void refineMarkedTriangles()
Refines at least all triangles that have been marked.
RealType markTriangles()
double RealType
Definition: ex2.cpp:21
MeshType & _mesh
template<typename ConfiguratorType>
RealType ErrorEstimator< ConfiguratorType >::markTriangles ( )
inline

Definition at line 40 of file errorEstimator.h.

41  {
42  VectorType errEstimates(_mesh.getNumTriangs());
43 
44  computeLocalErrorEstimates(errEstimates);
45  RealType refineAbove = errEstimates.lpNorm<Eigen::Infinity>() * _gamma;
46 
47  for (int t = 0; t < _mesh.getNumTriangs(); ++t)
48  if (errEstimates[t] > refineAbove)
49  _mesh.mark(t);
50 
51  return errEstimates.norm();
52  }
void mark(int element)
Mark element for refinement.
int getNumTriangs() const
Definition: triangMesh.h:46
double RealType
Definition: ex2.cpp:21
ConfiguratorType::VectorType VectorType
Definition: ex2.cpp:26
MeshType & _mesh
void computeLocalErrorEstimates(VectorType &errEstimates) const

Member Data Documentation

template<typename ConfiguratorType>
RealType ErrorEstimator< ConfiguratorType >::_gamma
protected

Definition at line 109 of file errorEstimator.h.

template<typename ConfiguratorType>
MeshType& ErrorEstimator< ConfiguratorType >::_mesh
protected

Definition at line 108 of file errorEstimator.h.


The documentation for this class was generated from the following file: