Class documentation of Concepts

Loading...
Searching...
No Matches
buergDoerfler.hh
1#ifndef buerg_hh
2#define buerg_hh
3
4//#include "estimator.hh"
5#include "meshGraph.hh"
6
7#include "refinement.hh"
8
9//#include "basics/vectorsMatrices.hh"
10
11#include "graphics.hh"
12
14
15
16
17
18namespace estimator{
19
20
21
22//LocalProjection type can specified with this pattern :
23 // H4 : bisection of core cell and anisotrop h refinement of neighbour cells
24 // P1Iso : p_K+1 on core cell and isotrop P_{K'}+1 refinement on neighbours {K'}
25 // P2Iso : p_K+2 on core cell and isotrop P_{K'}+2 refinement on neighbours {K'}
26 enum pattern {NONE, H4, P1ISO, P2ISO, P1ANISO, P2ANISO, H2V, H2H};
27
28
29//class representing a local for a given quad
45
46 public:
47 LocalMesh2(const concepts::MeshGraph2& meshGraph, uint K );
48
50
51 //inline concepts::MutableMesh2& get(){ return mMesh_; }
52 inline uint boundary() const { return bndAttrib_; }
53 //returns the sources, ie. the original pointers of hp2D::Elements used
54 inline const concepts::HashMap<const hp2D::Quad<Real>* >& sources() const {return elms_;}
55 // inline const concepts::HashMap<concepts::Quad*>& connectors() const { return qMap_; }
56 inline uint ncell() const { return cMap_.size(); }
57 inline concepts::Scan2* scan() { return new S(cMap_); }
58 //inline const concepts::Scan2* scan() const { return new S(cMap_); }
59 virtual std::ostream& info(std::ostream& os) const{return os << "LocalMesh[]";}
60 //Scanner of the LocalMesh
61 private:
62
63 class S : public concepts::Scan<concepts::Cell2> {
66 public:
68 cells_(cells), iter_(cells.begin()){}
69 inline S(const S &scan) : iter_(scan.iter_), cells_(scan.cells_) {};
70
71 inline bool eos() const { return iter_ == cells_.end(); }
72 inline concepts::Cell2& operator++(int) { return *((iter_++)->second); }
73
74 inline concepts::Scan2* clone() const { return new S(*this); }
75 };
76
77 //map from vtx key to vertex
82
83 //new unique boundary (marked) attrbute for this local mesh
84 uint bndAttrib_;
85
86 //collection of the original hp2D Elements, here i.e Quads
87 //those collection is needed outside, i.e. for the local projections
89 }; //local Mesh Class
90
91
92//********************************************* Class LOcalProjectionBase *******
93
94template<class F, class H = typename concepts::Realtype<F>::type >
96
97public :
98
100 LocalProjectionBase(enum pattern pat);
101
102protected :
103
104 //pre extraced coefficient due to coarse space element of original space
106
107 //the pattern type which specifies the projection, i.e. the map of PointProjection
108 enum pattern pat_;
109
110 void addH4_(const concepts::HashMap<const hp2D::Quad<H>* >& source,
111 LocalMesh2& locMsh,
112 const concepts::Vector<F>& sol);
113
114 void addP1ISO_(const concepts::HashMap<const hp2D::Quad<H>* >& source,
115 LocalMesh2& locMsh,
116 const concepts::Vector<F>& sol);
117
119
120 public:
121 //Further refinements may possible
122 enum subType {NONE, div4, divH2 , div2V};
123
124 //default for hashmap construct, is never used on real info adding
125 PointProjection(){ i = 5;};
126
127 //i the number of the local quad child
128 //K key of the coarse (original space) element
129 PointProjection(enum subType qs, uint i, const hp2D::Quad<H>* elm);
130
131 PointProjection& operator=(const PointProjection& pP);
132
133 //transforms the point due to quadchild number (i , located from left to right anticlockwise
134 void operator()(concepts::Real2d& p) const;
135
136 //quad child number position
137 uint i;
138 //the subdevision type
139 enum subType sub;
140 uint K;
141 const hp2D::Quad<H>* elm;
142 };
143
144
145 //maps from finer cell key to pointprojection data, i.e quad child number, father quad of original space
146 // which ie. has T matrix, and subdevision info, used for the application operators for integration
147 // this is used to avoid output operator
148 __gnu_cxx::hash_map<uint, PointProjection> data_;
149
150
151};
152
153
154//********************************************* Class LocalProjections_S *******
155
156// Scalar returner point
157
158template<class F, class H = typename concepts::Realtype<F>::type >
160 //concepts::ElementFormula<concepts::Point<F,dim>,H>{ //for vectorvalued
161
162public:
163
164 LocalProjections_S(const enum pattern pat,
165 const concepts::HashMap<const hp2D::Quad<H>* >& source,
166 LocalMesh2& locMsh,
167 const concepts::Vector<F>& sol,
169
171
172 //TODO: This must be done correctly deletion wont work atm ... cannot double delete stuff
173 virtual ~LocalProjections_S();
174
175 virtual F operator() (const concepts::ElementWithCell<H>& elm, const Real p, const Real t = 0.0) const;
176
177 virtual F operator() (const concepts::ElementWithCell<H>& elm, const concepts::Real2d& p,const Real t = 0.0) const;
178
179 virtual F operator() (const concepts::ElementWithCell<H>& elm, const concepts::Real3d& p, const Real t = 0.0) const;
180
182 virtual LocalProjections_S<F,H>* clone() const{ return new LocalProjections_S<F,H>(*this);}
183
184
185
186
187protected:
189 virtual std::ostream& info(std::ostream& os) const;
190
191private:
192 //type of projection, e.g. Value, Grad, Laplacian, ...
193 std::auto_ptr<concepts::ElementFunction<F,H> > f_;
194};
195
196
197
198
199//********************************************* Class LocalProjections_P *******
200// localprojections returning points
201
202//template<uint dim, typename F, typename G>
203template<uint dim, class F, class H = typename concepts::Realtype<F>::type >
204class LocalProjections_P : public LocalProjectionBase<F,H>, public concepts::ElementFormula<concepts::Point<F,dim>, H >{ //concepts::ElementFormula<concepts::Point<F,dim>,H>{ //for vectorvalued
205
206public:
229 LocalProjections_P(const enum pattern pat,
230 const concepts::HashMap<const hp2D::Quad<H>* >& source,
231 LocalMesh2& locMsh, //TODO: Evtl den space nehmen nicht local Mesh, damit sichergestellt wird dass nicht falsches mesh evaluiert wird da kinder dann gar nicht vorhanden
232 //local mesh ist notwendig da sonst die Vater zu kind beziehung flöten geht
233 const concepts::Vector<F>& sol,
235
237
238
239 //TODO: This must be done correctly deletion wont work atm ... cannot double delete stuff
240 virtual ~LocalProjections_P();
241
242
243 virtual concepts::Point<F,dim> operator() (const concepts::ElementWithCell<H>& elm, const Real p, const Real t = 0.0) const;
244
245 virtual concepts::Point<F,dim> operator() (const concepts::ElementWithCell<H>& elm, const concepts::Real2d& p,const Real t = 0.0) const;
246
247 virtual concepts::Point<F,dim> operator() (const concepts::ElementWithCell<H>& elm, const concepts::Real3d& p, const Real t = 0.0) const;
250
251protected:
253 virtual std::ostream& info(std::ostream& os) const;
254
255private:
256 //type of projection, e.g. Value, Grad, Laplacian, ...
257 std::auto_ptr<concepts::ElementFunction<F,H> > f_;
258};
259
260
261
262//********************************************* Class BuerGDoerfler *******
263
270template<class F = Real>
271class BuergDoerfler : public Marking<F>{
272
273public :
274
275 BuergDoerfler(const concepts::SpaceOnCells<Real>& spc, const LocalEstimator<F>& estimator, const concepts::Vector<F>& sol);
276
278 virtual ~BuergDoerfler();
279
280 //MeshGraph2(const concepts::SpaceOnCells<Real>& spc, bool regular = true)
281
282 //FIX ME: rethink template here, for sol this is ok, seems ok
286 void addRhs_f(const concepts::ElementFormula<F>& f, const Real c = 1);
287
288 //TODO: Implement this method to possible generalize burg doerfler
289 //add information for neumann/robin boundary condition
290 void addRhs_g(const concepts::ElementFormula<F>& g, const concepts::Set<uint>& set);
291
292 //TODO: Implement this method to possible generalize burg doerfler
293 //add information to build weak formulation i.e. the billinearforms
294 void addLhs(const concepts::BilinearForm<F>&, const Real c = 1);
295
296 void compute();
297
298
299 //FIXME This is global just for testing ...
300
301 //convergence indicator for h4 pattern, maps from Key to indicator
302 concepts::HashMap<Real> indicator_H4_;
303 //convergence indicator for p1iso pattern, maps from Key to indicator
304 concepts::HashMap<Real> indicator_P1Iso_;
305
306
307
309 concepts::HashMap<Real> sup_P1Iso_;
310
311 //dofs of corresponding refinement pattern spaces :
313 concepts::HashMap<uint> dofs_P1Iso_;
314
315protected:
316 virtual std::ostream& info(std::ostream& os) const;
317
318
319private :
320 //all rhs f data added
322 //and their building coefficients
324 //bool controls if rhs_f data is added
325 bool rhs_f_b_;
326
327
328
329
331 const concepts::Vector<F>& sol_;
332
333
334 concepts::MeshGraph2 meshgraph_;
335 const LocalEstimator<F>& estimator_;
336
337
338 //convergence indicators, maps from cell key to its refinement patterns
339 //corresponding solution of the local problem
340
341// //convergence indicators from h bisection refinement
342// concepts::HashMap<Real> ind_hbisect;
343//
344// //convergence indicators from p increase plus 1
345// concepts::HashMap<Real> ind_p1;
346
347
348 void compute_H4Iso_Ind_K(LocalMesh2& localMesh,
349 uint K,
350 Real n_K,
351 const hp2D::hpFull& globPrebuild,
353
354
355
356 void compute_P1Iso_Ind_K(LocalMesh2& localMesh,
357 uint K,
358 Real n_K,
359 const hp2D::hpFull& globPrebuild,
361
362 void compute_();
363
371 hp2D::hpFull* hbisectPattern_(concepts::Mesh2& msh, uint K,const hp2D::hpFull& globPrebuild);
372
373
374 //p(cell) + 1 pattern on each cell
375 hp2D::hpFull* p1Pattern_(concepts::Mesh2& msh, uint K,const hp2D::hpFull& globPrebuild);
376
377};
378
379
384template<class F = Real>
386
387
388
389
390 struct weightedIndictor : public concepts::OutputOperator{
391
392 weightedIndictor(uint K, Real sup, enum pattern pat);
393
394
395 bool operator<(const weightedIndictor& wI) const;
396
397 bool operator==(const weightedIndictor& wI) const;
398
399 //returns the value
400 Real get() const{ return sup_2;}
401
402 //key of corresponding
403 uint K;
404 //the supremum squared = indicator(pat) * n_K
405 Real sup_2;
406 // Real dof;
407 // Real ind;
408 //pattern type
409 enum pattern type_;
410
411 protected:
412 virtual std::ostream& info(std::ostream& os) const;
413
414 };
415
416 public:
417 //friend class BuerGDoerfler<F>;
418
422 BuergRefinement(Real theta = 0.35);
423
426
427 // builds the refinement strategys for given mark and estimator
428 void buildRefinement(const Marking<F>& mark, const LocalEstimator<F>& estimator);
429
430 virtual std::ostream& info(std::ostream& os) const;
431
432 private:
433 //current cells of given space
434 //concepts::HashMap<const concepts::Cell* > cells_;
435
436 //possible adaptive bulk criteria parameter
437 Real theta_;
438
439
440
441};
442
443
444
445
446
447
448
449
450}
451
452
453
454
455
456#endif // buerg_hh
Two dimensional cell.
Definition cell.hh:89
A scanner for a 2D mesh.
Definition mesh.hh:44
void addRhs_f(const concepts::ElementFormula< F > &f, const Real c=1)
virtual ~BuergDoerfler()
Destructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
BuergRefinement(Real theta=0.35)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual ~BuergRefinement()
Destructor.
uint ncell() const
Returns the number of cells in the mesh.
concepts::Scan2 * scan()
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
LocalProjections_P(const enum pattern pat, const concepts::HashMap< const hp2D::Quad< H > * > &source, LocalMesh2 &locMsh, const concepts::Vector< F > &sol, const concepts::ElementFunction< F, H > &f)
virtual LocalProjections_P< dim, F, H > * clone() const
Virtual copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual LocalProjections_S< F, H > * clone() const
Virtual copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.