patches.hh

Go to the documentation of this file.
1 
6 #ifndef patches_hh
7 #define patches_hh
8 
9 #include "space.hh"
10 #include "hp2D.hh"
11 #include "geometry.hh"
12 #include "toolbox.hh"
13 
14 namespace geometry {
15 
16 using namespace concepts;
17 
18 
19 // a pair of a Quadkey and a local dof of the corresponding patch node
20 struct quad_loc: public OutputOperator{
21  uint key;
22  //i is the local dof i = 0,1 , p[0]+1, p[0]+2 of nodal bases on the vtx n of the Patch corresponding to the quad
23  uint i;
24  //concepts::Z4 i;
25 
26  //this can be a uint also
27  quad_loc(uint qkey, uint ldof){
28  key = qkey;
29  i = ldof;
30  }
31 
32  bool operator<(quad_loc const& right) const
33  {
34  return this->key < right.key;
35  }
36 
37  //if Z4 use operator int()
38  virtual std::ostream& info(std::ostream& os) const{
39  return os<< concepts::typeOf(*this) <<"("<<key<<","<<i<<")";
40  }
41 
42 };
43 
44 struct edge_dof: public OutputOperator{
45  uint eKey;
46  //local dof of corresponding node to this edge
48 
49 // edge_dof(){
50 // eKey=0;
51 // i=0;
52 // }
53 
54  edge_dof(uint edgeKey, concepts::Z2 loc){
55  eKey = edgeKey;
56  i = loc;
57  }
58 
59 // edge_dof& operator=(const edge_dof& rval){
60 // eKey = rval.eKey;
61 // i = rval.i;
62 // return *this;
63 // }
64 
65  virtual std::ostream& info(std::ostream& os) const{
66  return os<< concepts::typeOf(*this)<< "("<<eKey<<","<<i.operator int()<<")";
67  }
68 };
69 
70 
71 //################################################ ElementPatch #############################
72 
84 public:
85 
86 
87 
88  //make sure new PatchTypes, are involved in the methods
89  enum PatchType{
95  NOT_FEATURED_YET
96  };
97 
100 
101 
107  lEdgeType_(Boundary::FREE);
108  rEdgeType_(Boundary::FREE);
109  }
110 
114  ElementPatch(const ElementPatch& elmPatch) {
115  for (Sequence<quad_loc>::const_iterator iter = elmPatch.begin(); iter
116  != elmPatch.end(); ++iter)
117  elmP_.push_back(*iter);
118  rEdgeType_ = elmPatch.rEdgeType_;
119  lEdgeType_ = elmPatch.lEdgeType_;
120  }
121 
122  virtual ~ElementPatch() {};
123 
124 
125 
126  bool getPos(uint quadKey, uint& pos) const;
127 
132  enum PatchType patchType() const;
133 
142 
143 
149  //uint <-> Z4
150  void push_back(uint elmKey, uint i);
151 
152  inline iterator begin() {
153  return iterator(elmP_.begin());
154  }
155 
156  inline const_iterator begin() const {
157  return const_iterator(elmP_.begin());
158  }
159 
160  inline iterator end() {
161  return iterator(elmP_.end());
162  }
163 
164  inline const_iterator end() const {
165  return const_iterator(elmP_.end());
166  }
167 
168  /*
169  * Method to add the (unique) key at the first position in the ElementPatch.
170  * If Key is already in the Patch added before it will be set to the first position.
171  * This has an application when sorting the Patch later cause no more Info will be needed.
172  *
173  * @param elmKey Key of the Element.
174  */
175  //Z4 as uint
176  void insert1st(uint elmKey, uint i);
177 
178 
179  /*
180  * @returns Returns the amount of Elements in the Patch.
181  */
182  inline uint size() const {
183  return elmP_.size();
184  }
185 
193  inline bool type() const {
194  return lEdgeType_.type() && rEdgeType_.type();
195  }
196 
197  /*
198  * Method updates the left Edge corresponding to the Vertex that introduces
199  * the Patch elmP_. Make sure you know the orientation of the edge (see e.g.
200  * rho function in topology.hh) to chose right Edge
201  *
202  * n = local number of vtx corresponding to the node
203  */
204  inline void typeUpdateL(concepts::Boundary type) {
205  lEdgeType_ = type;
206  }
207 
208  inline void typeUpdateR(concepts::Boundary type) {
209  rEdgeType_ = type;
210  }
211 
217  //TODO: GO private?
218  bool exist(uint elmKey);
219 
225  inline quad_loc& operator[](uint pos) {
226  assert(pos < elmP_.size());
227  return elmP_[pos];
228  }
229 
235  inline quad_loc operator[](uint pos) const {
236  assert(pos < elmP_.size());
237  return elmP_[pos];
238  }
239 
240 protected:
241 
242  std::ostream& info(std::ostream& os) const;
243 
244 private:
245  //A sequence of element keys, in general not sorted.
247 
248 
249  // ----leftedge----o----rightegde---- , clockwise
250  // for Boundary vertices, representing the left egde type to the boundary Node
252  // for Boundary vertices, representing the right egde type to the boundary Node
254 };
255 
256 
257 //################################################ EdgePatch #############################
258 
265 class EdgePatch: public OutputOperator{
266 public:
267 
268 
269 
272 
277 
278  virtual ~EdgePatch(){}
279 
284  void push_back(uint edgeKey, concepts::Z2 i);
285 
289  bool exist(uint edgeNo);
290 
291 
299  void insert1st(uint edgeKey, concepts::Z2 i);
300 
301 
302  //iterator section
303  inline iterator begin() {
304  return iterator(edgeP_.begin());
305  }
306 
307  inline const_iterator begin() const {
308  return const_iterator(edgeP_.begin());
309  }
310 
311  inline iterator end() {
312  return iterator(edgeP_.end());
313  }
314 
315  inline const_iterator end() const {
316  return const_iterator(edgeP_.end());
317  }
318 
319 
320  inline edge_dof operator[](uint noE) const {
321  assert( noE < edgeP_.size());
322  return edgeP_[noE];
323  }
324 
325 protected:
326  //outputoperator
327  std::ostream& info(std::ostream& os) const;
328 
329 private:
330  //A sequence of keys, general unsorted.
332 };//class EdgePatch;
333 
334 
340 public:
341 
344 
349  }
350 
356  for (; iter != velmMap.end(); ++iter)
357  map_[iter->first] = ElementPatch(iter->second);
358  }
359 
361  }
362 
363  // ##### Iterator section
364 
365  inline iterator begin() {
366  return iterator(map_.begin());
367  }
368 
369  inline const_iterator begin() const {
370  return const_iterator(map_.begin());
371  }
372 
373  inline iterator end() {
374  return iterator(map_.end());
375  }
376 
377  inline const_iterator end() const {
378  return const_iterator(map_.end());
379  }
380 
381  inline size_t size() const{
382  return map_.size();
383  }
384 
390  ElementPatch& operator[](uint noVtx) {
391  return map_[noVtx];
392  }
393 
394 
400  inline const ElementPatch& operator()(uint noVtx) const{
401  assert(map_.find(noVtx)!=map_.end());
402  return map_.find(noVtx)->second;
403  }
404 
408  std::ostream& info(std::ostream& os) const;
409 
410 private:
415 
416 };
421 public:
422 
425 
427  }
429  }
430 
431  //################# Iterator section
432  inline iterator begin() {
433  return iterator(map_.begin());
434  }
435 
436  inline const_iterator begin() const {
437  return const_iterator(map_.begin());
438  }
439 
440  inline iterator end() {
441  return iterator(map_.end());
442  }
443 
444  inline const_iterator end() const {
445  return const_iterator(map_.end());
446  }
447 
453  inline EdgePatch& operator[](uint noVtx) {
454  return map_[noVtx];
455  }
456 
457 
463  inline const EdgePatch& operator()(uint noVtx) const{
464  assert(map_.find(noVtx)!=map_.end());
465  return map_.find(noVtx)->second;
466  }
467 
468 protected:
472  std::ostream& info(std::ostream& os) const;
473 private:
478 };
479 
487 
488 public:
489  template<class F>
491 
492 
493  virtual ~VtxToPatchMaps() {};
494 
495 
496  inline const VtxToEdgeSupportMap& vtxToEdgeSupportMap() const {
497  return edgemap_;
498  }
499 
500 
501  inline const VtxToElmSupportMap& vtxToElmSupportMap() const {
502  return elmmap_;
503  }
504 
505 
507  return bc_;
508  }
509 
516 
517  protected:
518  //output of the elm -and edgemaps
519  std::ostream& info(std::ostream& os) const;
520 
521  private:
522  //map holding the edge-Patch information
524  //map holding the elm-Patch information
526  //reference to the boundary conditions
528 
529  //maps from E to Edgenodes to Quads_loc
530  //map from edge to its underlying quad(s), needed for sorting, and finding neighboured quad
532 
533  //Sets holding all appearing Patchsizes that exist in the given spaceMesh. Set is empty if the kind of Patch does not exist.
539 
540  // Method collect necessary informations to sort patches later, i.e. it fills the EtoQuadmap and the rEdge-mappings.
541  // Furthermore ElmPatches get filled with its belonging Elm-Keys, but unsorted. Then the correct Patchsize is known.
542  void addElementInformation_(const hp2D::Quad<Real>* elmH, HashMap<Set<uint> >& EtoQuadmap, HashMap<HashMap<uint> >& rEdge);
543 
544  // Method sorts the Element-Patches (with rEdge, and EtoElmMap) with overwriting and collect the Patch-sizes.
545  void completeElmPatches_(const HashMap<Set<uint> >& EtoQuadmap,const HashMap<HashMap<uint> >& rEdge);
546 
547  // Method sorts the Edgepatches by overwriting.
549 
550 };
551 
552 }//namespace concepts
553 #endif
Class holding the informations of a regular patch.
Definition: patches.hh:83
const_iterator end() const
Definition: patches.hh:164
HashMap< EdgePatch > map_
HashMap representing the map for being a node key.
Definition: patches.hh:477
VtxToElmSupportMap()
Default Constructor.
Definition: patches.hh:348
bool appearingSizes(concepts::Set< uint > &set, const enum ElementPatch::PatchType type) const
Method returns the appearing sizes of a given PatchType given in the.
quad_loc(uint qkey, uint ldof)
Definition: patches.hh:27
bool exist(uint elmKey)
Checks for existing of a key of an element in the Patch.
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void push_back(uint edgeKey, concepts::Z2 i)
Modified push_back routine that just adds a new edgeKey iff its not already in that EdgePatch.
ElementPatch(const ElementPatch &elmPatch)
Copy Constructor.
Definition: patches.hh:114
EdgePatch & operator[](uint noVtx)
Access operator to a Edgepatch corresponding to input keynumber.
Definition: patches.hh:453
Abstract class for a space.
const VtxToElmSupportMap & vtxToElmSupportMap() const
Definition: patches.hh:501
concepts::Set< uint > ndPatchsizes_
Definition: patches.hh:536
void typeUpdateR(concepts::Boundary type)
Definition: patches.hh:208
void addElementInformation_(const hp2D::Quad< Real > *elmH, HashMap< Set< uint > > &EtoQuadmap, HashMap< HashMap< uint > > &rEdge)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: patches.hh:38
const_iterator begin() const
Definition: patches.hh:307
ElementPatch & operator[](uint noVtx)
Access operator to a Elementpatch corresponding to input keynumber.
Definition: patches.hh:390
concepts::Boundary lEdgeType_
Definition: patches.hh:251
virtual ~EdgePatch()
Definition: patches.hh:278
bool operator<(quad_loc const &right) const
Definition: patches.hh:32
Class holding the Keys of the Edges around a vertex of a regular Patch.
Definition: patches.hh:265
concepts::Set< uint > dnPatchsizes_
Definition: patches.hh:537
HashMap< ElementPatch >::iterator iterator
Definition: patches.hh:342
Sequence< edge_dof >::iterator iterator
Definition: patches.hh:270
virtual ~VtxToPatchMaps()
Definition: patches.hh:493
Class representing the map from Node keys to ElementPatches.
Definition: patches.hh:339
VtxToElmSupportMap elmmap_
Definition: patches.hh:525
concepts::Boundary rEdgeType_
Definition: patches.hh:253
iterator end()
Definition: patches.hh:311
void typeUpdateL(concepts::Boundary type)
Definition: patches.hh:204
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: patches.hh:65
Boundary getBoundaryEdgeType(uint i) const
Method that returns Boundary of the requested BoundaryEdges in the Patch ( i=0,1 ).
HashMap< EdgePatch >::iterator iterator
Definition: patches.hh:423
edge_dof operator[](uint noE) const
Definition: patches.hh:320
Sequence< quad_loc > elmP_
Definition: patches.hh:246
quad_loc & operator[](uint pos)
Access operator.
Definition: patches.hh:225
bool exist(uint edgeNo)
Method checks existence.
Class to describe an element of the boundary.
Definition: boundary.hh:35
concepts::Set< uint > innerPatchsizes_
Definition: patches.hh:534
void completeEdgePatches_(const HashMap< HashMap< uint > > &rEdge)
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
EdgePatch()
Default Constructor, does nothing since this class is builded with its routines.
Definition: patches.hh:276
void insert1st(uint edgeKey, concepts::Z2 i)
Method to add the (unique) key at the first position in the ElementPatch.
std::ostream & info(std::ostream &os) const
Outputoperator.
const_iterator end() const
Definition: patches.hh:377
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
HashMap< ElementPatch >::const_iterator const_iterator
Definition: patches.hh:343
edge_dof(uint edgeKey, concepts::Z2 loc)
Definition: patches.hh:54
std::ostream & info(std::ostream &os) const
Outputoperator.
virtual ~ElementPatch()
Definition: patches.hh:122
quad_loc operator[](uint pos) const
Read Operatpor.
Definition: patches.hh:235
const_iterator begin() const
Definition: patches.hh:436
VtxToEdgeSupportMap edgemap_
Definition: patches.hh:523
void insert1st(uint elmKey, uint i)
concepts::BoundaryConditions & bc_
Definition: patches.hh:527
Sequence< edge_dof > edgeP_
Definition: patches.hh:331
const concepts::BoundaryConditions & boundaryInfo() const
Definition: patches.hh:506
HashMap< Set< uint > > EtoQuadmap_
Definition: patches.hh:531
const_iterator begin() const
Definition: patches.hh:156
bool type() const
Method to tell the kind of the Elementpatch.
Definition: patches.hh:193
const EdgePatch & operator()(uint noVtx) const
Read Operator only.
Definition: patches.hh:463
Sequence< quad_loc >::const_iterator const_iterator
Definition: patches.hh:99
Class representing the map from vertex keys to EdgePatches.
Definition: patches.hh:420
Sequence< edge_dof >::const_iterator const_iterator
Definition: patches.hh:271
uint size() const
Definition: patches.hh:182
concepts::Set< uint > ddPatchsizes_
Definition: patches.hh:538
concepts::Set< uint > nnPatchsizes_
Definition: patches.hh:535
const_iterator end() const
Definition: patches.hh:444
VtxToPatchMaps(const Space< F > &spc, BoundaryConditions &bc)
VtxToElmSupportMap(VtxToElmSupportMap &velmMap)
Copy Constructor.
Definition: patches.hh:354
void push_back(uint elmKey, uint i)
Method to insert a (unique) key of an Element.
Class to build up maps form Vertexkeys to EdgePatches or ElementPatches.
Definition: patches.hh:486
concepts::Z2 i
Definition: patches.hh:47
HashMap< EdgePatch >::const_iterator const_iterator
Definition: patches.hh:424
ElementPatch()
Default Constructor.
Definition: patches.hh:106
Binary group (algebraic): only the values 0 and 1 are represented.
Definition: Zm.hh:16
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
const_iterator begin() const
Definition: patches.hh:369
iterator begin()
Definition: patches.hh:303
Class providing an output operator.
Sequence< quad_loc >::iterator iterator
Definition: patches.hh:98
HashMap< ElementPatch > map_
HashMap representing the map for being a node key.
Definition: patches.hh:414
const ElementPatch & operator()(uint noVtx) const
Read Operator only.
Definition: patches.hh:400
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void completeElmPatches_(const HashMap< Set< uint > > &EtoQuadmap, const HashMap< HashMap< uint > > &rEdge)
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
const VtxToEdgeSupportMap & vtxToEdgeSupportMap() const
Definition: patches.hh:496
const_iterator end() const
Definition: patches.hh:315
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich