Class documentation of Concepts

Loading...
Searching...
No Matches
cell2D.hh
Go to the documentation of this file.
1
8#ifndef cell2D_hh
9#define cell2D_hh
10
11#include <iostream>
12
14#include "basics/typedefs.hh"
15#include "basics/level.hh"
16#include "topology.hh"
17#include "cell.hh"
18#include "cell1D.hh"
19#include "elementMaps.hh"
20
21namespace concepts {
22
23
24 // ************************************************************ Triangle2d **
25
31 class Triangle2d : public Cell2 {
32 public:
33
34 /* Type for indices in the hierarchical definition of the cells
35
36 Use a type with a larger range depending on the number of cell
37 refinements.
38 */
39 typedef uint index_type;
40
41 // Maximal number of levels in the cell refinement
42
43 static uint MAX_LEVEL;
44
46 struct Index {
49
54 index_type i_;
55
60 index_type j_;
61
62 Index();
63 Index(uchar l, index_type i, index_type j);
64 std::ostream& info(std::ostream& os) const;
65 };
66
67 friend std::ostream& operator<<(std::ostream& os,
68 const Triangle2d::Index& i);
69
76 virtual ~Triangle2d();
77
83 virtual Triangle2d* child(uint i);
88 virtual const Triangle2d* child(uint i) const;
89
91 inline Triangle& connector() const { return cntr_; }
92
98 ushort level() const { return idx_.l_; }
99
110
111
113 {
114 return chi(coord_local[0], coord_local[1]);
115 }
116
120 Real jacobianDeterminant(const Real x, const Real y) const;
121
133
135 Real area() const;
136
140 MapReal2d jacobianInverse(const Real x, const Real y) const;
141
143 Real3d center() const {return chi(0.66666666666, 0.5);}
145 inline const MappingTriangle2d* map() const {return map_;}
146
149 return new Triangle2d(cntr, map, idx_);}
150
155 static Real2d duffyInv(const Real2d& x);
156 protected:
157 virtual std::ostream& info(std::ostream& os) const;
158 private:
160 Index idx_;
161
163 Triangle& cntr_;
164
166 Triangle2d* lnk_;
167
171 Triangle2d* chld_;
172
174 MappingTriangle2d* map_;
175
178 };
179
180 std::ostream& operator<<(std::ostream& os, const Triangle2d::Index& i);
181
182
183 // **************************************************************** QuadNd **
187 class QuadNd : public Cell2 {
188 public:
189 /* Type for indices in the hierarchical definition of the cells
190
191 Use a type with a larger range depending on the number of cell
192 refinements.
193 */
194 typedef uint index_type;
195
196 // Maximal number of levels in the cell refinement
197
198 static uint MAX_LEVEL;
199
201 struct Index {
204
209 index_type i_;
210
215 index_type j_;
216
217 Index() : level_(0), i_(0), j_(0) {}
218 Index(uchar k, uchar l, index_type i, index_type j) :
219 level_(k), i_(i), j_(j) { level_.l_[1] = l; }
220 std::ostream& info(std::ostream& os) const;
221 };
222
223 QuadNd( Quad &cntr ) : cntr_(cntr) { }
224
225 QuadNd( Quad &cntr, const Index &idx ) : cntr_(cntr), idx_(idx) { }
226
227 friend std::ostream& operator<<(std::ostream& os,
228 const QuadNd::Index& i);
229
231 virtual uint dim() const = 0;
232
234 inline Quad& connector() const {
235 return cntr_;
236 }
237
248 virtual Real gramDeterminantRoot(const Real xi, const Real eta) const = 0;
249
250 virtual Real lineElement(const Real xi, const uint edge) const = 0;
251
257 Level<2> level() const { return idx_.level_; }
258
259 protected:
264
265 };
266
267 // ***************************************************** Quad2dSubdivision **
268
269 class Quad2d;
270
284 public:
287 virtual void createChildren(Quad2d& q) const = 0;
290 virtual void removeChildren(Quad2d& q) const;
293 virtual const QuadSubdivision* topologicalStrategy() const = 0;
294 };
295
296 // ********************************************************* Quad2dSubdiv4 **
297
307 public:
308 virtual void createChildren(Quad2d& q) const;
309 virtual const QuadSubdiv4* topologicalStrategy() const;
310 static const Quad2dSubdiv4* instance();
311 virtual ~Quad2dSubdiv4();
312 protected:
313 virtual std::ostream& info(std::ostream& os) const;
314 private:
315 static std::unique_ptr<Quad2dSubdiv4> instance_;
316 };
317
318 // ******************************************************** Quad2dSubdiv2H **
319
327 public:
328 virtual void createChildren(Quad2d& q) const;
329 virtual const QuadSubdiv2H* topologicalStrategy() const;
330 static const Quad2dSubdiv2H* instance();
331 virtual ~Quad2dSubdiv2H();
332 protected:
333 virtual std::ostream& info(std::ostream& os) const;
334 private:
335 static std::unique_ptr<Quad2dSubdiv2H> instance_;
336 };
337
338 // ******************************************************** Quad2dSubdiv2V **
339
347 public:
348 virtual void createChildren(Quad2d& q) const;
349 virtual const QuadSubdiv2V* topologicalStrategy() const;
350 static const Quad2dSubdiv2V* instance();
351 virtual ~Quad2dSubdiv2V();
352 protected:
353 virtual std::ostream& info(std::ostream& os) const;
354 private:
355 static std::unique_ptr<Quad2dSubdiv2V> instance_;
356 };
357
358 // **************************************************************** Quad2d **
359
378 class Quad2d : public QuadNd {
379 friend class Quad2dSubdivision;
380 friend class Quad2dSubdiv4;
381 friend class Quad2dSubdiv2H;
382 friend class Quad2dSubdiv2V;
383 public:
390 virtual ~Quad2d();
391
392 private:
393 Quad2d(const Quad2d& other);
394 Quad2d& operator=(const Quad2d& other);
395
396 public:
397
403 virtual Quad2d* child(uint i);
408 virtual const Quad2d* child(uint i) const;
409 inline bool hasChildren() const { return chld_ != 0; }
410
419 const Quad2d*
421 const Quad2d* chld = child(i);
422 if (chld == 0) return 0;
423
424 Level<2> l = chld->level();
425 if (idx_.level_.l_[0] == l.l_[0]) xiC = xi;
426 else {
427 xiC = (xi + idx_.i_) * 2.0 - chld->idx_.i_;
428 if (xiC < 0.0 || xiC > 1.0) return 0;
429 }
430 if (idx_.level_.l_[1] == l.l_[1]) etaC = eta;
431 else {
432 etaC = (eta + idx_.j_) * 2.0 - chld->idx_.j_;
433 if (etaC < 0.0 || etaC > 1.0) return 0;
434 }
435 return chld;
436 }
437
446
448 {
449 return chi(coord_local[0], coord_local[1]);
450 }
451
475 MapReal2d jacobian(const Real xi, const Real eta) const;
476
477 MapReal2d jacobian(const concepts::Real2d& p) const;
478
480 MapReal2d jacobianInverse(const Real xi, const Real eta) const {
481 return jacobian(xi, eta).inverse();
482 }
483
487 Real jacobianDeterminant(const Real xi, const Real eta) const {
488 return jacobian(xi, eta).determinant();
489 }
490
491 virtual Real gramDeterminantRoot(const Real xi, const Real eta) const
492 {
493 return jacobianDeterminant(xi, eta);
494 }
495
506 MapReal2d inverseLaplace(const Real xi, const Real eta) const;
507
513 virtual Real lineElement(const Real xi, const uint edge) const;
514
516 Real3d center() const {return chi(0.5, 0.5);}
517
521 inline const MappingQuad2d* map() const {return map_;}
522
534
536 inline Quad2d* clone(Quad& cntr, MappingQuad2d* map) const {
537 return new Quad2d(cntr, map, idx_);}
538
551 virtual void setStrategy(const Quad2dSubdivision* strategy = 0);
552
558 const Quad2dSubdivision* getStrategy() const { return subdivStrategy_; }
559
560 virtual uint dim() const { return 2; }
561 protected:
562 virtual std::ostream& info(std::ostream& os) const;
563
566
570 Quad2d* createChild_(Quad& cntr, const Index& idx, bool flag) const;
571
574 private:
576 Quad2d* lnk_;
577
581 Quad2d* chld_;
582
584 const Quad2dSubdivision* subdivStrategy_;
585
586 // Edges as cells
587 mutable concepts::Array<Edge2d*> edge_;
588
595 virtual Quad2d* createChild_(Quad& cntr, const Index& idx) const;
596 };
597
598 std::ostream& operator<<(std::ostream& os, const Quad2d::Index& i);
599
600 // ******************************************************** InfiniteQuad2d **
601
609 class InfiniteQuad2d : public Cell2 {
610 public:
620
621 virtual Real2d chi(Real xi, Real eta) const = 0;
622
624
625 virtual MapReal2d jacobian(const Real xi, const Real eta) const = 0;
626
628 inline InfiniteQuad& connector() const { return cntr_; }
629 protected:
630 virtual std::ostream& info(std::ostream& os) const;
631 private:
633 Real2d vtx_[2];
635 InfiniteQuad& cntr_;
636 };
637
638 // ******************************************************** InfiniteRect2d **
639
648 public:
655 virtual ~InfiniteRect2d();
656
667 virtual const InfiniteRect2d* child(uint i) const;
668 inline bool hasChildren() const { return chld_ != 0; }
669
677 virtual Real2d chi(Real xi, Real eta) const;
678
680 {
681 return chi(coord_local[0], coord_local[1]);
682 }
683
684 virtual MapReal2d jacobian(const Real xi, const Real eta) const;
685
687 Real3d center() const;
688
691 const Real2d& vtx0, const Real2d& vtx1) const
692 {
693 return new InfiniteRect2d(cntr, vtx0, vtx1);
694 }
695
696 protected:
697 virtual std::ostream& info(std::ostream& os) const;
698 private:
700 UnitNd<2> n_;
701
703 InfiniteRect2d* lnk_;
704
708 InfiniteRect2d* chld_;
709 };
710
711 // ************************************************************ Triangle3d **
712
718 class Triangle3d : public Cell2 {
719 public:
720
721 /* Type for indices in the hierarchical definition of the cells
722
723 Use a type with a larger range depending on the number of cell
724 refinements.
725 */
726 typedef uint index_type;
727
728 // Maximal number of levels in the cell refinement
729
730 static uint MAX_LEVEL;
731
733 struct Index {
736
741 index_type i_;
742
747 index_type j_;
748
749 Index();
750 Index(uchar l, index_type i,index_type j);
751 std::ostream& info(std::ostream& os) const;
752 };
753
754 friend std::ostream& operator<<(std::ostream& os,
755 const Triangle3d::Index& i);
756
763 virtual ~Triangle3d();
764
770 virtual Triangle3d* child(uint i);
775 virtual const Triangle3d* child(uint i) const;
776
778 Triangle& connector() const { return cntr_; }
779
788
790 {
791 return chi(coord_local[0], coord_local[1]);
792 }
793
795 Real3d center() const {return chi(0.66666666666, 0.5);}
796
798 inline const MapTriangle3d* map() const {return map_;}
799
802 return new Triangle3d(cntr, map, idx_);}
803 protected:
804 virtual std::ostream& info(std::ostream& os) const;
805 private:
807 Index idx_;
808
810 Triangle& cntr_;
811
813 Triangle3d* lnk_;
814
818 Triangle3d* chld_;
819
821 MapTriangle3d* map_;
822
825 };
826
827 std::ostream& operator<<(std::ostream& os, const Triangle3d::Index& i);
828
829 // **************************************************************** Quad3d **
830
831 // forward declaration
832 class MappingQuad3d;
833
849 class Quad3d : public QuadNd {
850// friend class Quad3dSubdivision;
851// friend class Quad3dSubdiv4;
852// friend class Quad3dSubdiv2H;
853// friend class Quad3dSubdiv2V;
854
855 public:
865 Quad3d(Quad& cntr, const MappingQuad3d& map, const Z2 dir = 0);
866 virtual ~Quad3d();
867
868 private:
869 Quad3d(Quad& cntr, MappingQuad3d* map, const Index& idx, const Z2 dir = 0);
870 Quad3d(const Quad3d& other);
871 Quad3d& operator=(const Quad3d& other);
872
873 public:
874
880 virtual Quad3d* child(uint i);
885 virtual const Quad3d* child(uint i) const;
886 inline bool hasChildren() const { return chld_ != 0; }
887
896
898 {
899 return chi(coord_local[0], coord_local[1]);
900 }
901
927 Real3d jacobianColumn(uint i, const Real xi, const Real eta) const;
928
932 Real faceElement(const Real xi, const Real eta) const;
933
934 virtual Real gramDeterminantRoot(const Real xi, const Real eta) const
935 {
936 return faceElement(xi, eta);
937 }
938
939 virtual Real lineElement(const Real xi, const uint edge) const;
940
944
946 Real3d center() const {return chi(0.5, 0.5);}
947
951 inline const MappingQuad3d* map() const {return map_;}
952
954 inline Quad3d* clone(Quad& cntr, MappingQuad3d* map) const {
955 return new Quad3d(cntr, map, idx_);}
956
969// virtual void setStrategy(const Quad3dSubdivision* strategy = 0)
970// throw(StrategyChange);
971
977// const Quad3dSubdivision* getStrategy() const { return subdivStrategy_; }
978
979 virtual uint dim() const { return 3; }
980
983 Z2 dir() const { return dir_; }
984
985 protected:
986 virtual std::ostream& info(std::ostream& os) const;
987
990
994 Quad3d* createChild_(Quad& cntr, const Index& idx, bool flag) const;
995
996 private:
998 Quad3d* lnk_;
999
1003 Quad3d* chld_;
1004
1006 Z2 dir_;
1007
1009// const Quad3dSubdivision* subdivStrategy_;
1010
1017 virtual Quad3d* createChild_(Quad& cntr, const Index& idx) const;
1018 };
1019
1020
1021} // namespace concepts
1022
1023#endif // cell2D_hh
Two dimensional cell.
Definition cell.hh:89
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
InfiniteQuad2d(InfiniteQuad &cntr, const Real2d &vtx0, const Real2d &vtx1)
InfiniteQuad & connector() const
Returns the quadrilateral connector (topology)
Definition cell2D.hh:628
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual const InfiniteRect2d * child(uint i) const
virtual Real2d chi(Real xi, Real eta) const
InfiniteRect2d(InfiniteQuad &cntr, const Real2d &vtx0, const Real2d &vtx1)
InfiniteRect2d * clone(InfiniteQuad &cntr, const Real2d &vtx0, const Real2d &vtx1) const
Returns a copy of itself.
Definition cell2D.hh:690
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Real3d elemMap(const Real2d &coord_local) const
Element map from point local coordinates in 2D.
Definition cell2D.hh:679
virtual InfiniteRect2d * child(uint i)
Real3d center() const
Makes no sense. Calling throws an exception.
Mapping< F, DimX, DimY > inverse() const
Returns the inverse of the matrix.
F determinant() const
Returns the determinant of the matrix (only valid for square matrices)
virtual void createChildren(Quad2d &q) const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual const QuadSubdiv2H * topologicalStrategy() const
virtual void createChildren(Quad2d &q) const
virtual const QuadSubdiv2V * topologicalStrategy() const
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.
virtual void createChildren(Quad2d &q) const
virtual const QuadSubdiv4 * topologicalStrategy() const
virtual void removeChildren(Quad2d &q) const
virtual void createChildren(Quad2d &q) const =0
virtual const QuadSubdivision * topologicalStrategy() const =0
virtual const Quad2d * child(uint i) const
virtual Real gramDeterminantRoot(const Real xi, const Real eta) const
Definition cell2D.hh:491
const MappingQuad2d * map() const
Definition cell2D.hh:521
Real2d chi(Real xi, Real eta) const
Quad2d(Quad &cntr, const MappingQuad2d &map)
MapReal2d inverseLaplace(const Real xi, const Real eta) const
const Quad2d * child(uint i, Real xi, Real eta, Real &xiC, Real &etaC) const
Definition cell2D.hh:420
virtual uint dim() const
Definition cell2D.hh:560
MapReal2d jacobianInverse(const Real xi, const Real eta) const
Returns the inverse of the Jacobian for xi, eta .
Definition cell2D.hh:480
Real jacobianDeterminant(const Real xi, const Real eta) const
Definition cell2D.hh:487
Quad2d * createChild_(Quad &cntr, const Index &idx, bool flag) const
MappingQuad2d * map_
Pointer to the element map.
Definition cell2D.hh:565
Real3d elemMap(const Real2d &coord_local) const
Element map from point local coordinates in 2D.
Definition cell2D.hh:447
MapReal2d jacobian(const Real xi, const Real eta) const
Quad2d * clone(Quad &cntr, MappingQuad2d *map) const
Returns a copy of itself.
Definition cell2D.hh:536
Real3d center() const
Returns the center of the cell.
Definition cell2D.hh:516
const Quad2dSubdivision * getStrategy() const
Definition cell2D.hh:558
virtual void setStrategy(const Quad2dSubdivision *strategy=0)
MappingEdge2d * edgeMap(uint edge) const
virtual Real lineElement(const Real xi, const uint edge) const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
Quad2d(Quad &cntr, MappingQuad2d *map, const Index &idx)
Private constructor.
virtual Quad2d * child(uint i)
virtual Real gramDeterminantRoot(const Real xi, const Real eta) const
Definition cell2D.hh:934
Real3d elemMap(const Real2d &coord_local) const
Element map from point local coordinates in 2D.
Definition cell2D.hh:897
const MappingQuad3d * map() const
Definition cell2D.hh:951
Real3d jacobianColumn(uint i, const Real xi, const Real eta) const
virtual uint dim() const
Definition cell2D.hh:979
Quad3d * clone(Quad &cntr, MappingQuad3d *map) const
Returns a copy of itself.
Definition cell2D.hh:954
Quad3d * createChild_(Quad &cntr, const Index &idx, bool flag) const
Quad3d(Quad &cntr, const MappingQuad3d &map, const Z2 dir=0)
MappingQuad3d * map_
Pointer to the element map.
Definition cell2D.hh:989
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
Z2 dir() const
Definition cell2D.hh:983
Real3d n0(Real xi, Real eta) const
virtual const Quad3d * child(uint i) const
Real3d chi(Real xi, Real eta) const
Real faceElement(const Real xi, const Real eta) const
Real3d center() const
Returns the center of the cell.
Definition cell2D.hh:946
virtual Quad3d * child(uint i)
Quad & connector() const
Returns the quadrilateral connector (topology)
Definition cell2D.hh:234
Index idx_
Index of this element.
Definition cell2D.hh:263
virtual Real gramDeterminantRoot(const Real xi, const Real eta) const =0
Quad & cntr_
Reference to the quadrilateral connector (topology)
Definition cell2D.hh:261
Level< 2 > level() const
Definition cell2D.hh:257
virtual uint dim() const =0
ushort level() const
Definition cell2D.hh:98
const MappingTriangle2d * map() const
Returns the element map.
Definition cell2D.hh:145
Real jacobianDeterminant(const Real x, const Real y) const
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
Real3d elemMap(const Real2d &coord_local) const
Element map from point local coordinates in 2D.
Definition cell2D.hh:112
static Real2d duffyInv(const Real2d &x)
Triangle & connector() const
Returns the triangle connector (topology)
Definition cell2D.hh:91
virtual Triangle2d * child(uint i)
Real2d chi(Real xi, Real eta) const
virtual const Triangle2d * child(uint i) const
Triangle2d * clone(Triangle &cntr, MappingTriangle2d *map) const
Returns a copy of itself.
Definition cell2D.hh:148
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
MapReal2d jacobian(Real x, Real y) const
MapReal2d jacobianInverse(const Real x, const Real y) const
Real area() const
Returns the area of the element.
Real3d center() const
Returns the center of the cell.
Definition cell2D.hh:143
Triangle2d(Triangle &cntr, const MappingTriangle2d &map)
Real3d elemMap(const Real2d &coord_local) const
Element map from point local coordinates in 2D.
Definition cell2D.hh:789
const MapTriangle3d * map() const
Returns the element map.
Definition cell2D.hh:798
Triangle3d * clone(Triangle &cntr, MapTriangle3d *map) const
Returns a copy of itself.
Definition cell2D.hh:801
Real3d center() const
Returns the center of the cell.
Definition cell2D.hh:795
Real3d chi(Real xi, Real eta) const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual const Triangle3d * child(uint i) const
Triangle & connector() const
Returns the triangle connector (topology)
Definition cell2D.hh:778
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
Triangle3d(Triangle &cntr, const MapTriangle3d &map)
virtual Triangle3d * child(uint i)
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
unsigned short ushort
Abbreviation for unsigned short.
Definition typedefs.hh:51
unsigned char uchar
Abbreviation for unsigned char.
Definition typedefs.hh:48
short l_[dim]
Level.
Definition level.hh:24
Subclass of QuadNd representing its index.
Definition cell2D.hh:201
Level< 2 > level_
Level of this element.
Definition cell2D.hh:203
Subclass of Triangle2d representing its index.
Definition cell2D.hh:46
uchar l_
Level of this element.
Definition cell2D.hh:48
Subclass of Quad2d representing its index.
Definition cell2D.hh:733
uchar l_
Level of this element.
Definition cell2D.hh:735