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"
11 #include "graphics/spaceTraits.hh"
12 
13 #include "triangle.hh"
14 
15 namespace concepts {
16  // forward declarations
17  class Mesh2;
18  class BoundaryConditions;
19 }
20 
21 namespace 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_;
76  };
77 
78  // ************************************************************** SpaceP1 **
79 
83  class SpaceP1 : public Space {
84  public:
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:
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 
125 namespace 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
A column of a T matrix.
Definition: analytical.hh:18
Scan< Element< Real > > Scanner
Definition: space.hh:47
Triangle & connector() const
Returns the triangle connector (topology)
Definition: cell2D.hh:91
virtual Triangle * newElm_(const concepts::Triangle2d &cell, uint idx[]) const
Definition: space.hh:114
Abstract base class of spaces for DG FEM in 2D on triangles.
Definition: space.hh:30
Triangular element with orthogonal linear shape functions in 2D.
Definition: triangle.hh:77
TriangleP1 Element
Definition: space.hh:85
TriangleP0 Element
Definition: space.hh:107
S(const S &scan)
Definition: space.hh:60
virtual uint nDoF_() const =0
Abstract class for a space.
SpaceP1(concepts::Mesh2 &msh)
Constructor.
Definition: space.hh:89
std::unordered_map< uint, Triangle * > Map
Definition: space.hh:34
const Map & elm_
Definition: space.hh:68
virtual Scanner * scan() const
Definition: space.hh:37
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
A 2D cell: triangle.
Definition: cell2D.hh:31
virtual uint nDoF_() const
Returns number of degrees of freedom per element.
Definition: space.hh:97
Map::const_iterator idx_
Definition: space.hh:67
virtual std::ostream & info(std::ostream &os) const
DG FEM for 2D problems using piecewise linear shape functions.
Definition: bilinearForm.hh:15
Traits for a space.
Definition: spaceTraits.hh:51
virtual void constructor_(concepts::Mesh2 &mesh)
Exception class for assertions.
Definition: exceptions.hh:258
Graphics.
Definition: basis.hh:33
virtual const Triangle & elm(const concepts::Triangle2d *cell) const
Returns the element on triangle cell.
Definition: space.hh:43
const Key & key() const
Returns the key of the connector.
Definition: connector.hh:105
Triangle & operator++(int)
Definition: space.hh:62
Space for linear DG FEM in 2D on triangles.
Definition: space.hh:83
void(* SMap)(const concepts::TColumn< Real > &, concepts::TColumn< Real > &)
Definition: space.hh:32
An abstract class for 2D meshes.
Definition: mesh.hh:103
bool eos() const
Definition: space.hh:61
virtual uint nDoF_() const
Definition: space.hh:118
Map elm_
List of elements.
Definition: space.hh:75
S * clone() const
Definition: space.hh:65
Triangular element with constant shape function in 2D.
Definition: triangle.hh:116
virtual uint nelm() const
Returns the number of elements in the space.
Definition: space.hh:41
Abstract base class for triangular elements in 2D DGFEM.
Definition: triangle.hh:30
Space for piecewise constant DG FEM in 2D on triangles.
Definition: space.hh:105
virtual std::ostream & info(std::ostream &os) const
S(const Map &elm)
Definition: space.hh:59
virtual uint dim() const
Returns the dimension of the space.
Definition: space.hh:39
virtual ~Space()
SpaceP0(concepts::Mesh2 &msh)
Constructor.
Definition: space.hh:111
virtual std::ostream & info(std::ostream &os) const
virtual Triangle * newElm_(const concepts::Triangle2d &cell, uint idx[]) const =0
uint nelm_
Number of elements.
Definition: space.hh:73
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
uint dim_
Number of degrees of freedom.
Definition: space.hh:71
Scanner class for Space.
Definition: space.hh:57
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
virtual Triangle * newElm_(const concepts::Triangle2d &cell, uint idx[]) const
Definition: space.hh:92
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich