Class documentation of Concepts

Loading...
Searching...
No Matches
explicitResidual.hh
Go to the documentation of this file.
1
7#ifndef explicitResidual_hh
8#define explicitResidual_hh
9
11
12//TODO: Precise the includes
13#include "hp2D.hh"
15#include "basics/exceptions.hh"
16
17
18namespace concepts{
19
20 template<class F>
22
23 public:
24
25 virtual ~ExplicitResidual(){};
26
27 virtual ExplicitResidual<F>* clone() const = 0;
28
34 frms_.push_back(frm);
35 iNAttrbs_.push_back(nSet);
36 }
37
41 void addHNData(const Set<uint>& nSet){
42 hNAttrbs_ = hNAttrbs_ || nSet;
43 }
44 void addHNData(uint attrb) {
45 hNAttrbs_.insert(attrb);
46 }
47
48
49 protected:
50
51
68 LocalEstimator<F>(spc, sol),res_(res){};
69
70 virtual std::ostream& info(std::ostream& os) const{
71 return os << concepts::typeOf(*this);
72 }
73 //local reference to the residual
75
76 //Neumann formulas
78 //Neumann Attributes inhomogen
79 Sequence<Set<uint> > iNAttrbs_;
80 //Neumann attributes homogen
81 Set<uint> hNAttrbs_;
82
83 private:
84
85 virtual void computeError_(const ElementFormulaContainer<F>& res, HashMap<Real>& jumpResidual) = 0 ;
86 virtual void computeJumpPart_(HashMap<Real>& jumpResidual) const=0;
87 };
88
89
90}
91
92
93
94
95
96namespace hp1D{
97
98 //So far just a abstract class
99 template<class F>
100 class ExplicitResidual1D: concepts::ExplicitResidual<F>{
101
102 public:
103 ExplicitResidual1D(const concepts::SpaceOnCells<F>& spc,
104 const concepts::Vector<F>& sol,
106
107 virtual ~ExplicitResidual1D();
108
109 protected:
110 virtual std::ostream& info(std::ostream& os) const;
111
112 private:
113 virtual void computeError_(const concepts::ElementFormulaContainer<F>& res, concepts::HashMap<Real>& jumpResidual);
114 virtual void computeJumpPart_(concepts::HashMap<Real>& jumpResidual) const;
115 };
116
117}
118
119
120namespace hp2D {
168template<class F>
169class ExplicitResidual2D: public concepts::ExplicitResidual<F> {
170
171public:
172
173 // Flag for the chose of the weight
174 // DIAM : default weight is just the diameter of cell :
175 // w_K = diam(K), w_E = diam(E)
176 // DIAM_HP : residual type variant introduced by melenk and wohlmuth with the help of weighted norms
177 //
178 //
179 // DIAM_P: polynomal degree weighted diameter :
180 // w_K = diam(K)/(1+p_K), w_E = diam(E)/2*(1+p_E)
181
182 // further possible weights :
183 // DIAM_L Diameter devided by eigenvalues lambda_K of the diffusion tensor elementwise.
184 // where the diffussion tensor IK is assumed to be quasi-monoton.
185 // for further details check the Diplomarbeit of Christian Merdon, section 2 and 3.
186 //TODO: RETHINK NAME
187 enum weight {DIAM, DIAM_HP, DIAM_P};
188
206 ExplicitResidual2D(const concepts::SpaceOnCells<F>& spc,
207 const concepts::Vector<F>& sol,
210 bool square = false,
211 enum weight w = DIAM,
212 Real alpha = 0);
213
214
215 virtual ~ExplicitResidual2D(){};
216
217 /*
218 * Starts the actual estimation of error.
219 * You may start this routine after setting the Neumann boundary info data.
220 */
221 void compute();
222
235 class Distance : public concepts::ElementFormula<Real>{
236
237 public:
238 //Constructor
239 Distance(Real alpha=0) : alpha_(alpha){};
240
241 virtual F operator() (const concepts::ElementWithCell<typename concepts::Realtype<F>::type>& elm, const concepts::Real p,const concepts::Real t = 0.0) const{
242 throw concepts::MissingFeature("Operator not implemented.");
243 return 0.0;
244 }
245
246 virtual F operator() (const concepts::ElementWithCell<typename concepts::Realtype<F>::type>& elm, const concepts::Real2d& p,const concepts::Real t = 0.0) const{
247
248 // __________
249 // | : |
250 // |--x p |
251 // | |
252 // |________|
253 //dist = min(x,y,1-x,1-y)
254 concepts::Real dist = std::min(std::min(p[0],p[1]), std::min(1-p[0],1-p[1]));
255 return std::pow(dist, alpha_);
256
257 }
258 virtual F operator() (const concepts::ElementWithCell<typename concepts::Realtype<F>::type>& elm, const concepts::Real3d& p,const concepts::Real t = 0.0) const{
259 //just take p0 and p1 since this class applicates for hp2D::IntegrableQuad
260 concepts::Real dist = std::min(std::min(p[0],p[1]), std::min(1-p[0],1-p[1]));
261 return std::pow(dist, alpha_);
262 }
263
264 virtual Distance* clone() const{return new Distance(*this);}
265
266 virtual ~Distance(){};
267
268 protected:
269 virtual std::ostream& info(std::ostream& os) const{
270 return os<<concepts::typeOf(*this) <<"( alpha = "<<alpha_<<")";
271 }
272
273 private:
274 //representing alpha/2
275 Real alpha_;
276 };
277
278
279
293
294 public:
295 //Constructor
296 EdgeWeight(Real alpha=0) : alpha_(alpha){};
297
298 virtual F operator() (const concepts::ElementWithCell<typename concepts::Realtype<F>::type>& elm, const concepts::Real p,const concepts::Real t = 0.0) const{
299 // ((1-x)*x)^(alpha)
300 return std::pow((1-p)*p, alpha_);
301 }
302
303 //for neumanntracelements
304 virtual F operator() (const concepts::ElementWithCell<typename concepts::Realtype<F>::type>& elm, const concepts::Real2d& p,const concepts::Real t = 0.0) const{
305 //take p[0] since this class applicates on neumanntraceElements which are hp1D::IntegrableElm
306 // ((1-x)*x)^(alpha)
307 return std::pow((1-p[0])*p[0], alpha_);
308
309 }
310 virtual F operator() (const concepts::ElementWithCell<typename concepts::Realtype<F>::type>& elm, const concepts::Real3d& p,const concepts::Real t = 0.0) const{
311 //take p[0] since this class applicates on neumanntraceElements which are hp1D::IntegrableElm
312 // ((1-x)*x)^(alpha)
313 return std::pow((1-p[0])*p[0], alpha_);
314 }
315
316 virtual EdgeWeight* clone() const{return new EdgeWeight(*this);}
317
318 virtual ~EdgeWeight(){};
319
320 protected:
321 virtual std::ostream& info(std::ostream& os) const{
322 return os << concepts::typeOf(*this) << "( alpha = "<<alpha_<<")";
323 }
324
325 private:
326 //representing alpha
327 Real alpha_;
328 };
329
330 virtual const Real operator()() const {return 0.;}
331
332 virtual ExplicitResidual2D<F>* clone() const{return new ExplicitResidual2D<F>(*this);}
333
334 protected:
335 virtual std::ostream& info(std::ostream& os) const {
336 return os << concepts::typeOf(*this);
337 }
338
339 private:
340
341 //flag that marks all elements are squares, then diameter computation is faster.
342 bool square_;
343 //isotropic scalar coefficient function in higest derivative operator
345 //weight type
346 enum weight weight_;
347
348 //weight function exponent
349 Real alpha_;
350
351 //faster data structure for accessing all neumann boundary attributes
352 concepts::Set<uint> allNattrb_;
353
354 virtual void computeError_(const concepts::ElementFormulaContainer<F>& res, concepts::HashMap<Real>& jumpResidual);
355 virtual void computeJumpPart_(concepts::HashMap<Real>& jumpResidual) const;
356
357 };
358
359
360
361
362
363
364
365
366
367
368
369
370} //namespace 2D
371
372
373//namespace hp3D{
374//
375//class ExplicitResidual3D: concepts::ExplicitResidual{
376//public:
377//
378// template<typename F>
379// ExplicitResidual3D(const concepts::SpaceOnCells<F>& spc, const concepts::Vector<F>& sol, const concepts::ElementFormula<F>& res);
380//
381//protected:
382// virtual std::ostream& info(std::ostream& os) const{
383// return os << "Explicit Residual Error Estimator()";
384// }
385//
386//
387//private:
388// virtual void computeError_(const concepts::ElementFormula<F>& res, concepts::HashMap<Real>& jumpResidual);
389// virtual void computeJumpPart_(concepts::HashMap<Real>& jumpResidual) const;
390//};
391//
392//}
393
394#endif // explicitResidual_hh
void addINData(const Set< uint > &nSet, concepts::ElementFormulaContainer< F > frm)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual ExplicitResidual< F > * clone() const =0
Virtual copy constructor.
ExplicitResidual(const SpaceOnCells< F > &spc, const Vector< F > &sol, const ElementFormulaContainer< F > res)
void addHNData(const Set< uint > &nSet)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual Distance * clone() const
Virtual copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual EdgeWeight * clone() const
Virtual copy constructor.
std::string typeOf(const T &t)
Definition output.hh:43
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320