buergDoerfler.hh

Go to the documentation of this file.
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 
18 namespace 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'}
27 
28 
29 //class representing a local for a given quad
44 class LocalMesh2 : public concepts::Mesh2{
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 
94 template<class F, class H = typename concepts::Realtype<F>::type >
96 
97 public :
98 
101 
102 protected :
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
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 
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;
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 
158 template<class F, class H = typename concepts::Realtype<F>::type >
160  //concepts::ElementFormula<concepts::Point<F,dim>,H>{ //for vectorvalued
161 
162 public:
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
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 
187 protected:
189  virtual std::ostream& info(std::ostream& os) const;
190 
191 private:
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>
203 template<uint dim, class F, class H = typename concepts::Realtype<F>::type >
204 class LocalProjections_P : public LocalProjectionBase<F,H>, public concepts::ElementFormula<concepts::Point<F,dim>, H >{ //concepts::ElementFormula<concepts::Point<F,dim>,H>{ //for vectorvalued
205 
206 public:
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
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;
249  virtual LocalProjections_P<dim,F,H>* clone() const{ return new LocalProjections_P<dim,F,H>(*this);}
250 
251 protected:
253  virtual std::ostream& info(std::ostream& os) const;
254 
255 private:
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 
270 template<class F = Real>
271 class BuergDoerfler : public Marking<F>{
272 
273 public :
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
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
303  //convergence indicator for p1iso pattern, maps from Key to indicator
305 
306 
307 
310 
311  //dofs of corresponding refinement pattern spaces :
314 
315 protected:
316  virtual std::ostream& info(std::ostream& os) const;
317 
318 
319 private :
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 
332 
333 
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 
349  uint K,
350  Real n_K,
351  const hp2D::hpFull& globPrebuild,
353 
354 
355 
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 
384 template<class F = Real>
386 
387 
388 
389 
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
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 
425  virtual ~BuergRefinement();
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
438 
439 
440 
441 };
442 
443 
444 
445 
446 
447 
448 
449 
450 }
451 
452 
453 
454 
455 
456 #endif // buerg_hh
const LocalEstimator< F > & estimator_
concepts::HashMap< const hp2D::Quad< Real > * > elms_
hp2D::hpFull * p1Pattern_(concepts::Mesh2 &msh, uint K, const hp2D::hpFull &globPrebuild)
hp2D::hpFull * hbisectPattern_(concepts::Mesh2 &msh, uint K, const hp2D::hpFull &globPrebuild)
An abstract class for a function in a FE space.
virtual LocalProjections_P< dim, F, H > * clone() const
Virtual copy constructor.
S(concepts::HashMap< concepts::Quad2d * > &cells)
BuergDoerfler(const concepts::SpaceOnCells< Real > &spc, const LocalEstimator< F > &estimator, const concepts::Vector< F > &sol)
concepts::HashMap< concepts::Quad * > qMap_
void buildRefinement(const Marking< F > &mark, const LocalEstimator< F > &estimator)
concepts::HashMap< Real > sup_H4_
concepts::HashMap< concepts::Quad2d * >::iterator iter_
void compute_H4Iso_Ind_K(LocalMesh2 &localMesh, uint K, Real n_K, const hp2D::hpFull &globPrebuild, concepts::BoundaryConditions &bc)
concepts::HashMap< concepts::Edge * > eMap_
concepts::HashMap< Real > indicator_P1Iso_
LocalProjections_S(const LocalProjections_S< F, H > &frm)
virtual F operator()(const concepts::ElementWithCell< H > &elm, const Real p, const Real t=0.0) const
void addLhs(const concepts::BilinearForm< F > &, const Real c=1)
A scanner for a 2D mesh.
Definition: mesh.hh:44
virtual ~BuergRefinement()
Destructor.
virtual ~BuergDoerfler()
Destructor.
Helper class for building 2D hp-FEM spaces (space pre builder).
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)
Constructor sources are the original elements that i.e.
LocalMesh2(const concepts::MeshGraph2 &meshGraph, uint K)
PointProjection & operator=(const PointProjection &pP)
concepts::HashMap< uint > dofs_H4_
weightedIndictor(uint K, Real sup, enum pattern pat)
BuergRefinement(Real theta=0.35)
Constructor.
std::auto_ptr< concepts::ElementFunction< F, H > > f_
virtual LocalProjections_S< F, H > * clone() const
Virtual copy constructor.
Element with cell.
LocalProjections_S(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 std::ostream & info(std::ostream &os) const
virtual concepts::Point< F, dim > operator()(const concepts::ElementWithCell< H > &elm, const Real p, const Real t=0.0) const
void addP1ISO_(const concepts::HashMap< const hp2D::Quad< H > * > &source, LocalMesh2 &locMsh, const concepts::Vector< F > &sol)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void addH4_(const concepts::HashMap< const hp2D::Quad< H > * > &source, LocalMesh2 &locMsh, const concepts::Vector< F > &sol)
concepts::Scan2 * scan()
Returns a scanner over the cells of the mesh.
concepts::HashMap< concepts::Vertex * > vMap_
const concepts::HashMap< const hp2D::Quad< Real > * > & sources() const
uint ncell() const
Returns the number of cells in the mesh.
concepts::Sequence< const concepts::ElementFormula< F > * > rhs_f_
Interface for a formula defined element by element.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
bool operator<(const weightedIndictor &wI) const
const concepts::SpaceOnCells< Real > & spc_
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
concepts::Cell2 & operator++(int)
Returns the next element in the scanned set.
concepts::HashMap< Real > sup_P1Iso_
An abstract class for 2D meshes.
Definition: mesh.hh:103
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
Abstract class on Marking.
Definition: marking.hh:15
concepts::HashMap< concepts::Quad2d * > & cells_
__gnu_cxx::hash_map< uint, PointProjection > data_
Two dimensional cell.
Definition: cell.hh:89
concepts::Scan2 * clone() const
concepts::HashMap< uint > dofs_P1Iso_
concepts::HashMap< concepts::Quad2d * > cMap_
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Abstract Class for h refinement only, i.e.
Definition: refinement.hh:59
concepts::MeshGraph2 meshgraph_
concepts::Sequence< Real > c_f_
const concepts::Vector< F > & sol_
void addRhs_f(const concepts::ElementFormula< F > &f, const Real c=1)
This adds the information of the right hand side on the domain.
LocalProjections_P(const LocalProjections_P< dim, F, H > &frm)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
LocalProjectionBase(enum pattern pat)
concepts::HashMap< Real > indicator_H4_
This is a local Neighboorhood Mesh (i.e regular) of a given node (key = K), which content is a space ...
Class representing the hp marking strategy proposed by Buerg in this dissertation.
void addRhs_g(const concepts::ElementFormula< F > &g, const concepts::Set< uint > &set)
concepts::HashMap< concepts::Array< F > > coeffs_
void operator()(concepts::Real2d &p) const
Class providing an output operator.
Actual refinement hp rule that generalizes dörflers bulk marking.
PointProjection(enum subType qs, uint i, const hp2D::Quad< H > *elm)
std::auto_ptr< concepts::ElementFunction< F, H > > f_
void compute_P1Iso_Ind_K(LocalMesh2 &localMesh, uint K, Real n_K, const hp2D::hpFull &globPrebuild, concepts::BoundaryConditions &bc)
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
bool operator==(const weightedIndictor &wI) const
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich