Class documentation of Concepts

Loading...
Searching...
No Matches
space.hh
Go to the documentation of this file.
1
6#ifndef linDG2Dspace_hh
7#define linDG2Dspace_hh
8#include "toolbox/hashMap.hh"
9#include "space/space.hh"
12
13#include "triangle.hh"
14
15namespace concepts {
16 // forward declarations
17 class Mesh2;
18 class BoundaryConditions;
19}
20
21namespace linDG2D {
22
23 using concepts::Real;
24
25 // ***************************************************************** Space **
26
30 class Space : public concepts::Space<Real> {
31 public:
32 typedef void (*SMap)(const concepts::TColumn<Real>&,
34 typedef std::unordered_map<uint, Triangle*> Map;
35 Space() : dim_(0), nelm_(0) {}
36 virtual ~Space();
37 virtual Scanner* scan() const { return new S(elm_); }
39 virtual uint dim() const { return dim_; }
41 virtual uint nelm() const { return nelm_; }
43 virtual const Triangle& elm(const concepts::Triangle2d* cell) const {
45 const Map::const_iterator i = elm_.find(cell->connector().key());
46 conceptsAssert(!(i == elm_.end()), concepts::Assertion());
47 return *(i->second);
48 }
49 protected:
50 virtual std::ostream& info(std::ostream& os) const;
51 virtual Triangle* newElm_(const concepts::Triangle2d& cell,
52 uint idx[]) const = 0;
53 virtual uint nDoF_() const = 0;
54 virtual void constructor_(concepts::Mesh2& mesh);
55 private:
57 class S : public Scanner {
58 public:
59 inline S(const Map& elm) : idx_(elm.begin()), elm_(elm) {}
60 inline S(const S& scan) : idx_(scan.idx_), elm_(scan.elm_) {}
61 inline bool eos() const { return idx_ == elm_.end(); }
62 inline Triangle& operator++(int) {
63 return const_cast<Triangle&>(*((*idx_++).second));
64 }
65 inline S* clone() const { return new S(*this); }
66 private:
67 Map::const_iterator idx_;
68 const Map& elm_;
69 };
71 uint dim_;
73 uint nelm_;
75 Map elm_;
76 };
77
78 // ************************************************************** SpaceP1 **
79
83 class SpaceP1 : public Space {
84 public:
85 typedef TriangleP1 Element;
89 SpaceP1(concepts::Mesh2& msh) { constructor_(msh); }
90 protected:
91 virtual std::ostream& info(std::ostream& os) const;
92 virtual Triangle* newElm_(const concepts::Triangle2d& cell,
93 uint idx[]) const {
94 return new TriangleP1(cell, idx);
95 }
97 virtual uint nDoF_() const { return 3; }
98 };
99
100 // ************************************************************** SpaceP0 **
101
105 class SpaceP0 : public Space {
106 public:
107 typedef TriangleP0 Element;
111 SpaceP0(concepts::Mesh2& msh) { constructor_(msh); }
112 protected:
113 virtual std::ostream& info(std::ostream& os) const;
114 virtual Triangle* newElm_(const concepts::Triangle2d& cell,
115 uint idx[]) const {
116 return new TriangleP0(cell, idx);
117 }
118 virtual uint nDoF_() const { return 1; }
119 };
120
121} // namespace linDG2D
122
123// *********************************************** Space Traits for Graphics **
124
125namespace graphics {
126 template<>
127 struct spaceTraits<linDG2D::Space> {
128 static inline uint dim() { return 2; }
129 static inline bool positionConnection() { return false; }
130 static inline bool boundaryElements() { return false; }
131 };
132 template<>
133 struct spaceTraits<linDG2D::SpaceP1> {
134 static inline uint dim() { return 2; }
135 static inline bool positionConnection() { return false; }
136 static inline bool boundaryElements() { return false; }
137 };
138 template<>
139 struct spaceTraits<linDG2D::SpaceP0> {
140 static inline uint dim() { return 2; }
141 static inline bool positionConnection() { return false; }
142 static inline bool boundaryElements() { return false; }
143 };
144} // namespace graphics
145
146#endif // linDG2Dspace_hh
const Key & key() const
Returns the key of the connector.
Definition connector.hh:105
Triangle & connector() const
Returns the triangle connector (topology)
Definition cell2D.hh:91
SpaceP0(concepts::Mesh2 &msh)
Definition space.hh:111
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
SpaceP1(concepts::Mesh2 &msh)
Definition space.hh:89
virtual uint nDoF_() const
Returns number of degrees of freedom per element.
Definition space.hh:97
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual const Triangle & elm(const concepts::Triangle2d *cell) const
Returns the element on triangle cell.
Definition space.hh:43
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint nelm() const
Returns the number of elements in the space.
Definition space.hh:41
virtual Scanner * scan() const
Returns a scanner to iterate over the elements of the space.
Definition space.hh:37
virtual uint dim() const
Returns the dimension of the space.
Definition space.hh:39
#define conceptsAssert(cond, exc)
double Real
Definition typedefs.hh:39