exactEstimator.hh

Go to the documentation of this file.
1 #ifndef exactEstimator_hh
2 #define exactEstimator_hh
3 
4 #include "estimator.hh"
5 
6 //TODO: Precise the includes
7 #include "hp2D.hh"
8 #include "formula.hh"
9 #include "basics/exceptions.hh"
10 
11 using concepts::Real;
12 
13 namespace estimator{
14 
15 
16 
29 template<class F = Real>
30 class ExactEstimator: public LocalEstimator<F>{
31 
32 public:
33 
42  const concepts::Vector<F>& sol):
43  LocalEstimator<F>(spc, sol){};
44 
45 
46 
63  template<class G, class H>
65  const concepts::ElementFormula<H>* afrm,
66  Real s = 1.0,
67  const concepts::ElementFormula<F>* w = 0)
68  {
69  //frm must exist, i.e. avoid clone
70  conceptsAssert(efrm && afrm, concepts::Assertion());
71  std::auto_ptr<typename concepts::SpaceOnCells<F>::Scanner > sc(this->spc_.scan());
72  while (!sc->eos()) {
73  concepts::ElementWithCell<F>& elm = (*sc)++;
74  //current key of element
75  uint K = elm.cell().connector().key();
76  //set the error of the solution in the requested norm
77  Real error_K = 0;
78  if (w)
79  error_K += s * concepts::L2product(elm,
80  *w * (*efrm - * afrm) );
81  else
82  error_K += s * concepts::L2product(elm, *efrm - * afrm);
83  //add current error squared
84  this->globError_ += error_K;
85  //here the global error must be increased and later square rooted
86  LocalEstimator<F>::locError_[K] += error_K;
87  }//loop over space elements
88  }
89 
90 
91  //completes error computation
92  void compute(){
93 
94  //take squareroot of local final contribution
95  typename LocalEstimator<F>::iterator err_K = this->begin();
96  for( ; err_K != this->end(); err_K ++)
97  err_K->second = std::sqrt(err_K->second);
98 
99 
100  this->globError_ = std::sqrt(this->globError_);
101  //compute element residuals and errors with jumpresiduals
102  // computeError_();
103  }
104 
105  virtual ExactEstimator<F>* clone() const{return new ExactEstimator<F>(*this);}
106 
107 protected:
108 
109  virtual std::ostream& info(std::ostream& os) const{
110  return os << "Exact local error Estimator()";
111  }
112 
113 
114 private:
115 
116 
117  // //norm construction stuff
122 
123 // virtual void computeError_(){
124 //
125 // std::auto_ptr<typename concepts::SpaceOnCells<F>::Scanner > sc(this->spc_.scan());
126 // while (!sc->eos()) {
127 // concepts::ElementWithCell<F>& elm = (*sc)++;
128 // //current key of element
129 // uint K = elm.cell().connector().key();
130 //
131 // //set the error of the solution in the requested norm
132 // Real error_K = 0;
133 // for(uint n = 0; n < norm_exact_fs_.size(); ++n){
134 // if (norm_ws_[n])
135 // error_K += norm_s_[n] * concepts::L2product(elm,
136 // *(norm_ws_[n]) * (*(norm_exact_fs_[n])
137 // - *(norm_apprx_fs_[n])));
138 // else
139 // error_K += norm_s_[n] * concepts::L2product(elm,
140 // *(norm_exact_fs_[n]) - *(norm_apprx_fs_[n]));
141 // }//for n-th contribution
142 //
143 // //add current error squared
144 // this->globError_ += error_K;
145 // //here the global error must be increased and later square rooted
146 // LocalEstimator<F>::locError_[K] = std::sqrt(error_K);
147 // DEBUGL(COMPUTE_D, "estimated error on K = " << K << " : " << LocalEstimator<F>::locError_[K])
148 // }//loop over space elements
149 // //take square root to obtain global error
150 // this->globError_ = std::sqrt(this->globError_);
151 // }//compute Error
152 
153 
154 };//class exact Error
155 
156 
157 
158 
159 } // namespace estimator
160 
161 #endif // exactEstimator_hh
concepts::Sequence< const concepts::ElementFormula< F > * > norm_apprx_fs_
void addErrorContr(const concepts::ElementFormula< G > *efrm, const concepts::ElementFormula< H > *afrm, Real s=1.0, const concepts::ElementFormula< F > *w=0)
Sets individual norm contributions up to now everything in L2 norm.
ExactEstimator(const concepts::SpaceOnCells< F > &spc, const concepts::Vector< F > &sol)
Constructur of the exact error estimator.
Real L2product(const ElementWithCell< G > &elm, const ElementFormula< F, G > &u, const ElementFormula< Real > *c=0, const Real t=0.0, IntegrationCell::intFormType form=IntegrationCell::ZERO)
Returns the L2 product or with c weighted L2 product of an element formula u over the cell belonging ...
Definition: integral.hh:214
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
Element with cell.
Abstract class representing the explicit residual a posteriori error estimator.
virtual std::ostream & info(std::ostream &os) const
Exception class for assertions.
Definition: exceptions.hh:258
Interface for a formula defined element by element.
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
Abstract class for a space.
Definition: space.hh:81
concepts::Sequence< Real > norm_s_
concepts::Sequence< const concepts::ElementFormula< F > * > norm_exact_fs_
virtual ExactEstimator< F > * clone() const
concepts::Sequence< const concepts::ElementFormula< F > * > norm_ws_
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich