Class documentation of Concepts

Loading...
Searching...
No Matches
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
14namespace geometry {
15
16using namespace concepts;
17
18
19// a pair of a Quadkey and a local dof of the corresponding patch node
20struct 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
44struct 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
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
84public:
85
86
87
88 //make sure new PatchTypes, are involved in the methods
89 enum PatchType{
90 INNER,
91 NEUMANN_NEUMANN,
92 DIRICHLET_NEUMANN,
93 NEUMANN_DIRICHLET,
94 DIRICHLET_DIRICHLET,
95 NOT_FEATURED_YET
96 };
97
98 typedef Sequence<quad_loc>::iterator iterator;
99 typedef Sequence<quad_loc>::const_iterator const_iterator;
100
101
107 lEdgeType_(Boundary::FREE);
108 rEdgeType_(Boundary::FREE);
109 }
110
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
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?
219
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
240protected:
241
242 std::ostream& info(std::ostream& os) const;
243
244private:
245 //A sequence of element keys, in general not sorted.
246 Sequence<quad_loc> elmP_;
247
248
249 // ----leftedge----o----rightegde---- , clockwise
250 // for Boundary vertices, representing the left egde type to the boundary Node
251 concepts::Boundary lEdgeType_;
252 // for Boundary vertices, representing the right egde type to the boundary Node
253 concepts::Boundary rEdgeType_;
254};
255
256
257//################################################ EdgePatch #############################
258
266public:
267
268
269
270 typedef Sequence<edge_dof>::iterator iterator;
271 typedef Sequence<edge_dof>::const_iterator const_iterator;
272
277
278 virtual ~EdgePatch(){}
279
285
290
291
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
325protected:
326 //outputoperator
327 std::ostream& info(std::ostream& os) const;
328
329private:
330 //A sequence of keys, general unsorted.
331 Sequence<edge_dof> edgeP_;
332};//class EdgePatch;
333
334
340public:
341
342 typedef HashMap<ElementPatch>::iterator iterator;
343 typedef HashMap<ElementPatch>::const_iterator const_iterator;
344
350
356 for (; iter != velmMap.end(); ++iter)
357 map_[iter->first] = ElementPatch(iter->second);
358 }
359
360 virtual ~VtxToElmSupportMap() {
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
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
410private:
415
416};
421public:
422
423 typedef HashMap<EdgePatch>::iterator iterator;
424 typedef HashMap<EdgePatch>::const_iterator const_iterator;
425
427 }
428 virtual ~VtxToEdgeSupportMap() {
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
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
468protected:
472 std::ostream& info(std::ostream& os) const;
473private:
478};
479
487
488public:
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
506 const concepts::BoundaryConditions& boundaryInfo() const{
507 return bc_;
508 }
509
515 bool appearingSizes(concepts::Set<uint>& set,const enum ElementPatch::PatchType type) const;
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
523 VtxToEdgeSupportMap edgemap_;
524 //map holding the elm-Patch information
525 VtxToElmSupportMap elmmap_;
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
531 HashMap<Set<uint> > EtoQuadmap_;
532
533 //Sets holding all appearing Patchsizes that exist in the given spaceMesh. Set is empty if the kind of Patch does not exist.
534 concepts::Set<uint> innerPatchsizes_;
535 concepts::Set<uint> nnPatchsizes_;
536 concepts::Set<uint> ndPatchsizes_;
537 concepts::Set<uint> dnPatchsizes_;
538 concepts::Set<uint> ddPatchsizes_;
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.
548 void completeEdgePatches_(const HashMap<HashMap<uint> >& rEdge);
549
550};
551
552}//namespace concepts
553#endif
enum boundaryTypes type() const
Returns the type of the boundary condition.
Definition boundary.hh:74
void push_back(uint edgeKey, concepts::Z2 i)
void insert1st(uint edgeKey, concepts::Z2 i)
bool exist(uint edgeNo)
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
enum PatchType patchType() const
bool exist(uint elmKey)
Boundary getBoundaryEdgeType(uint i) const
ElementPatch(const ElementPatch &elmPatch)
Definition patches.hh:114
quad_loc & operator[](uint pos)
Definition patches.hh:225
void push_back(uint elmKey, uint i)
quad_loc operator[](uint pos) const
Definition patches.hh:235
bool type() const
Definition patches.hh:193
EdgePatch & operator[](uint noVtx)
Definition patches.hh:453
const EdgePatch & operator()(uint noVtx) const
Definition patches.hh:463
std::ostream & info(std::ostream &os) const
const ElementPatch & operator()(uint noVtx) const
Definition patches.hh:400
ElementPatch & operator[](uint noVtx)
Definition patches.hh:390
VtxToElmSupportMap(VtxToElmSupportMap &velmMap)
Definition patches.hh:354
std::ostream & info(std::ostream &os) const
bool appearingSizes(concepts::Set< uint > &set, const enum ElementPatch::PatchType type) const
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::string typeOf(const T &t)
Definition output.hh:43
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition patches.hh:65
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition patches.hh:38