functionBase.hh

Go to the documentation of this file.
1 
6 #ifndef hpFunctionBase2d_hh
7 #define hpFunctionBase2d_hh
8 
9 #include "space/function.hh"
10 #include "toolbox/stiffArray.hh"
11 #include "quad.hh"
12 
13 namespace hp2D {
14 
15  using concepts::Real;
16  using concepts::Real2d;
17 
18  // ******************************************************* ElementFunction **
19 
35  template<uint dim, typename F = Real, typename Q = Quad<Real> >
36  class ElementFunction :
37  public concepts::ElementFunction<F, typename Q::type>
38  {
39  public:
41 
43  virtual uint n() const { return dim; }
44 
45  virtual void operator() (const Element& elm,
46  const concepts::Array<F>& coeff,
47  concepts::Array<F>& val, const uint *i) const;
48  virtual void operator() (const Element& elm,
49  const uint* j,
50  concepts::Array<F>& val, const uint* i) const;
51  virtual void operator() (const Element& elm,
52  const concepts::Array<F>& coeff,
53  concepts::Array<F>& val, const Real p,
54  const Real t = 0.0) const;
55  virtual void operator() (const Element& elm,
56  const concepts::Array<F>& coeff,
57  concepts::Array<F>& val, const Real2d& p,
58  const Real t = 0.0) const;
59  virtual void operator() (const Element& elm,
60  const concepts::Array<F>& coeff,
61  concepts::Array<F>& val,
62  const concepts::Real3d& p,
63  const Real t = 0.0) const;
64  private:
65  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
66  concepts::Array<F>& val,
67  const uint i[2]) const = 0;
68 
69  virtual void compute_(const Q& elm, const uint j[3],
70  concepts::Array<F>& val,
71  const uint i[2]) const = 0;
72 
73  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
74  concepts::Array<F>& val,
75  const Real2d& p, const Real t = 0.0) const = 0;
76  };
77 
78  template<uint dim, typename F, typename Q>
80  (const Element& elm, const concepts::Array<F>& coeff,
81  concepts::Array<F>& val, const uint *i) const {
82  // Quadrilaterial
83  const Q* quad = dynamic_cast<const Q*>(&elm);
84  if (quad) return compute_(*quad, coeff, val, i);
85 
86  throw conceptsException(concepts::MissingFeature("element not supported"));
87  }
88 
89  template<uint dim, typename F, typename Q>
91  (const Element& elm, const uint* j,
92  concepts::Array<F>& val, const uint *i) const {
93  // Quadrilaterial
94  const Q* quad = dynamic_cast<const Q*>(&elm);
95  if (quad) return compute_(*quad, j, val, i);
96 
97  throw conceptsException(concepts::MissingFeature("element not supported"));
98  }
99 
100  template<uint dim, typename F, typename Q>
102  (const Element& elm, const concepts::Array<F>& coeff,
103  concepts::Array<F>& val, const Real p, const Real t) const {
104  const Real2d p2(p);
105 
106  // Quadrilaterial
107  const Q* quad = dynamic_cast<const Q*>(&elm);
108  if (quad) return compute_(*quad, coeff, val, p2, t);
109 
110  throw conceptsException(concepts::MissingFeature("element not supported"));
111  }
112 
113  template<uint dim, typename F, typename Q>
115  (const Element& elm, const concepts::Array<F>& coeff,
116  concepts::Array<F>& val, const Real2d& p, const Real t) const {
117  // Quadrilaterial
118  const Q* quad = dynamic_cast<const Q*>(&elm);
119  if (quad) return compute_(*quad, coeff, val, p, t);
120 
121  throw conceptsException(concepts::MissingFeature("element not supported"));
122  }
123 
124  template<uint dim, typename F, typename Q>
126  (const Element& elm, const concepts::Array<F>& coeff,
127  concepts::Array<F>& val, const concepts::Real3d& p, const Real t) const {
128  const Real2d p2(p);
129 
130  // Quadrilaterial
131  const Q* quad = dynamic_cast<const Q*>(&elm);
132  if (quad) return compute_(*quad, coeff, val, p2, t);
133 
134  throw conceptsException(concepts::MissingFeature("element not supported"));
135  }
136 
137  // **************************************************** ElementFunction<1> **
138 
139  template<typename F, typename Q>
140  class ElementFunction<1,F,Q> :
141  public concepts::ElementFunction<F, typename Q::type> {
142  public:
144 
146  virtual uint n() const { return 1; }
147  virtual void operator() (const Element& elm,
148  const concepts::Array<F>& coeff,
149  concepts::Array<F>& val, const uint *i) const;
150  virtual void operator() (const Element& elm,
151  const uint* j,
152  concepts::Array<F>& val, const uint* i) const;
153  virtual void operator() (const Element& elm,
154  const concepts::Array<F>& coeff,
155  concepts::Array<F>& val, const Real p,
156  const Real t = 0.0) const;
157  virtual void operator() (const Element& elm,
158  const concepts::Array<F>& coeff,
159  concepts::Array<F>& val, const Real2d& p,
160  const Real t = 0.0) const;
161  virtual void operator() (const Element& elm,
162  const concepts::Array<F>& coeff,
163  concepts::Array<F>& val,
164  const concepts::Real3d& p,
165  const Real t = 0.0) const;
166 
167  virtual void operator() (const Element& elm,
168  const concepts::Array<F>& coeff,
169  F& val, const uint *i) const;
170  virtual void operator() (const Element& elm,
171  const uint* j,
172  F& val, const uint* i) const;
173  virtual void operator() (const Element& elm,
174  const concepts::Array<F>& coeff,
175  F& val, const Real p,
176  const Real t = 0.0) const;
177  virtual void operator() (const Element& elm,
178  const concepts::Array<F>& coeff,
179  F& val, const Real2d& p,
180  const Real t = 0.0) const;
181  virtual void operator() (const Element& elm,
182  const concepts::Array<F>& coeff,
183  F& val, const concepts::Real3d& p,
184  const Real t = 0.0) const;
185  private:
186  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
187  F& val, const uint i[2]) const = 0;
188  virtual void compute_(const Q& elm, const uint j[3],
189  F& val, const uint i[2]) const = 0;
190  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
191  F& val, const Real2d& p, const Real t) const = 0;
192  };
193 
194  template<typename F, typename Q>
196  (const Element& elm, const concepts::Array<F>& coeff,
197  concepts::Array<F>& val, const uint *i) const {
198  val.resize(1);
199  (*this)(elm, coeff, val[0], i);
200  }
201 
202  template<typename F, typename Q>
204  (const Element& elm, const uint* j,
205  concepts::Array<F>& val, const uint *i) const {
206  val.resize(1);
207  (*this)(elm, j, val[0], i);
208  }
209 
210  template<typename F, typename Q>
212  (const Element& elm, const concepts::Array<F>& coeff,
213  concepts::Array<F>& val, const Real p, const Real t) const {
214  const Real2d p2(p);
215  val.resize(1);
216  (*this)(elm, coeff, val[0], p2, t);
217  }
218 
219  template<typename F, typename Q>
221  (const Element& elm, const concepts::Array<F>& coeff,
222  concepts::Array<F>& val, const Real2d& p, const Real t) const {
223  val.resize(1);
224  (*this)(elm, coeff, val[0], p, t);
225  }
226 
227  template<typename F, typename Q>
229  (const Element& elm, const concepts::Array<F>& coeff,
230  concepts::Array<F>& val, const concepts::Real3d& p, const Real t) const {
231  const Real2d p2(p);
232  val.resize(1);
233  (*this)(elm, coeff, val[0], p2, t);
234  }
235 
236  // *************
237 
238  template<typename F, typename Q>
240  (const Element& elm, const concepts::Array<F>& coeff,
241  F& val, const uint *i) const {
242  // Quadrilaterial
243  const Q* quad = dynamic_cast<const Q*>(&elm);
244  if (quad)
245  return compute_(*quad, coeff, val, i);
246 
247  throw conceptsException(concepts::MissingFeature("element not supported"));
248  }
249 
250  template<typename F, typename Q>
252  (const Element& elm, const uint* j,
253  F& val, const uint *i) const {
254  // Quadrilaterial
255  const Q* quad = dynamic_cast<const Q*>(&elm);
256  if (quad) return compute_(*quad, j, val, i);
257 
258  throw conceptsException(concepts::MissingFeature("element not supported"));
259  }
260 
261  template<typename F, typename Q>
263  (const Element& elm, const concepts::Array<F>& coeff,
264  F& val, const Real p, const Real t) const {
265  const Real2d p2(p);
266  (*this)(elm, coeff, val, p2, t);
267  }
268 
269  template<typename F, typename Q>
271  (const Element& elm, const concepts::Array<F>& coeff,
272  F& val, const Real2d& p, const Real t) const {
273  // Quadrilaterial
274  const Q* quad = dynamic_cast<const Q*>(&elm);
275  if (quad) return compute_(*quad, coeff, val, p, t);
276 
277  throw conceptsException(concepts::MissingFeature("element not supported"));
278  }
279 
280  template<typename F, typename Q>
282  (const Element& elm, const concepts::Array<F>& coeff,
283  F& val, const concepts::Real3d& p, const Real t) const {
284  const Real2d p2(p);
285  (*this)(elm, coeff, val, p2, t);
286  }
287 
288 } // namespace hp2D
289 
290 
291 #endif // hpFunctionBase2d_hh
An abstract class for an element of a space.
Definition: exceptions.hh:15
An abstract class for a function in a FE space.
concepts::Element< typename Q::type > Element
Definition: functionBase.hh:40
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint i[2]) const =0
Point< Real, 2 > Real2d
Base class for element functions for hp elements in 2D.
Definition: functionBase.hh:38
concepts::Element< typename Q::type > Element
virtual void operator()(const Element &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint *i) const
Definition: functionBase.hh:80
virtual uint n() const
Number of components.
2D hp-FEM for H1-conforming elements.
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t) const =0
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const =0
An array of objects.
Definition: bilinearForm.hh:23
Abstract class for a 2D FEM element.
Definition: element.hh:28
virtual uint n() const
Number of components.
Definition: functionBase.hh:43
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const Real2d &p, const Real t=0.0) const =0
Exception class to express a missing feature.
Definition: exceptions.hh:206
virtual void compute_(const Q &elm, const uint j[3], F &val, const uint i[2]) const =0
virtual void compute_(const Q &elm, const uint j[3], concepts::Array< F > &val, const uint i[2]) const =0
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich