Class documentation of Concepts

Loading...
Searching...
No Matches
exactEstimator.hh
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"
10
11using concepts::Real;
12
13namespace estimator{
14
15
16
29template<class F = Real>
30class ExactEstimator: public LocalEstimator<F>{
31
32public:
33
42 const concepts::Vector<F>& sol):
43 LocalEstimator<F>(spc, sol){};
44
45
46
63 template<class G, class H>
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
107protected:
108
109 virtual std::ostream& info(std::ostream& os) const{
110 return os << "Exact local error Estimator()";
111 }
112
113
114private:
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
virtual Connector & connector() const =0
Returns the connector.
const Key & key() const
Returns the key of the connector.
Definition connector.hh:105
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
ExactEstimator(const concepts::SpaceOnCells< F > &spc, const concepts::Vector< F > &sol)
void addErrorContr(const concepts::ElementFormula< G > *efrm, const concepts::ElementFormula< H > *afrm, Real s=1.0, const concepts::ElementFormula< F > *w=0)
#define conceptsAssert(cond, exc)
double Real
Definition typedefs.hh:39
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)
Definition integral.hh:214