function.hh

Go to the documentation of this file.
1 
6 #ifndef hpFunction2d_hh
7 #define hpFunction2d_hh
8 
9 #include "toolbox/sequence.hh"
10 #include "geometry/connectorSet.hh"
11 #include "functionBase.hh"
12 #include "edge.hh"
13 #include "traces.hh"
14 
15 #include "neumannTraceElement.hh"
16 #include "neumannTrace.hh"
17 
18 namespace hp2D {
19 
20  // forward declaration
21  class InfiniteQuad;
22 
23  using concepts::Real;
24  using concepts::Real2d;
25 
26  // ***************************************************************** Value **
27 
32  template<typename F = Real, typename G= typename concepts::Realtype<F>::type>
33  class Value : public concepts::ElementFunction<F, G> {
34  public:
35  virtual Value<F,G>* clone() const { return new Value(); }
36 
38  virtual uint n() const { return 1; }
39 
40  virtual void operator() (const concepts::Element<G>& elm,
41  const concepts::Array<F>& coeff,
42  concepts::Array<F>& val, const uint *i) const;
43  virtual void operator() (const concepts::Element<G>& elm,
44  const uint* j,
45  concepts::Array<F>& val, const uint* i) const;
46  virtual void operator() (const concepts::Element<G>& elm,
47  const concepts::Array<F>& coeff,
48  concepts::Array<F>& val, const Real p,
49  const Real t = 0.0) const;
50  virtual void operator() (const concepts::Element<G>& elm,
51  const concepts::Array<F>& coeff,
52  concepts::Array<F>& val, const Real2d& p,
53  const Real t = 0.0) const;
54  virtual void operator() (const concepts::Element<G>& elm,
55  const concepts::Array<F>& coeff,
56  concepts::Array<F>& val,
57  const concepts::Real3d& p,
58  const Real t = 0.0) const;
59 
61  const concepts::Array<F>& coeff,
62  F& val, const uint *i) const;
64  const uint* j, F& val, const uint* i) const;
66  const concepts::Array<F>& coeff, F& val, const Real2d& p,
67  const Real t = 0.0) const;
68  protected:
69  virtual std::ostream& info(std::ostream& os) const;
70  private:
71 
72  bool compute_(const Quad<Real>* elm, const concepts::Array<F>& coeff,
73  F& val, const uint i[2]) const;
74  bool compute_(const InfiniteQuad* elm, const concepts::Array<F>& coeff,
75  F& val, const uint i[2]) const;
76 
77  //template<class H>
78  bool compute_(const Quad<Real>* elm, const uint j[2], F& val, const uint i[2]) const;
79  bool compute_(const InfiniteQuad* elm, const uint j[2], F& val, const uint i[2]) const;
80 
81 
82  bool compute_(const Quad<Real>* elm, const concepts::Array<F>& coeff,
83  F& val, const Real2d& p, const Real t) const;
84 
85  bool compute_(const InfiniteQuad* elm, const concepts::Array<F>& coeff,
86  F& val, const Real2d& p, const Real t) const;
87 
88 
89  bool compute_(const NTElement_BA<Real>* nTelm,const concepts::Array<F>& coeff,
90  F& val, const Real p, const Real t) const;
91 
92  bool compute_(const NeumannTraceElement<Real>* elm, const concepts::Array<F>& coeff,
93  F& val, const Real& p, const Real t) const;
94 
95 
96  void compute_(const concepts::Array<F>& coeff, F& val,
97  const Real* xValues, uint nsx,
98  const Real* yValues, uint nsy) const;
99  };
100 
101  // ****************************************************************** Grad **
102 
107  template<typename F = Real>
108  class Grad : public ElementFunction<2,F> {
109  public:
110  virtual Grad<F>* clone() const { return new Grad(); }
111  protected:
112  virtual std::ostream& info(std::ostream& os) const;
113  private:
114  virtual void compute_(const Quad<Real>& elm,
115  const concepts::Array<F>& coeff,
116  concepts::Array<F>& val,
117  const uint i[2]) const;
118  virtual void compute_(const Quad<Real>& elm, const uint j[2],
119  concepts::Array<F>& val,
120  const uint i[2]) const;
121  virtual void compute_(const Quad<Real>& elm,
122  const concepts::Array<F>& coeff,
123  concepts::Array<F>& val,
124  const Real2d& p, const Real t = 0.0) const;
125  };
126 
127 
128 
129  // ****************************************************************** Laplacian **
130 
136  template<typename F = Real, typename G= typename concepts::Realtype<F>::type>
137  class Laplacian : public concepts::ElementFunction<F, G> {
138  public:
139  virtual Laplacian<F>* clone() const { return new Laplacian(); }
140 
142  virtual uint n() const { return 1; }
143 
144  virtual void operator() (const concepts::Element<G>& elm,
145  const concepts::Array<F>& coeff,
146  concepts::Array<F>& val, const uint *i) const;
147  virtual void operator() (const concepts::Element<G>& elm,
148  const uint* j,
149  concepts::Array<F>& val, const uint* i) const;
150  virtual void operator() (const concepts::Element<G>& elm,
151  const concepts::Array<F>& coeff,
152  concepts::Array<F>& val, const Real p,
153  const Real t = 0.0) const;
154  virtual void operator() (const concepts::Element<G>& elm,
155  const concepts::Array<F>& coeff,
156  concepts::Array<F>& val, const Real2d& p,
157  const Real t = 0.0) const;
158  virtual void operator() (const concepts::Element<G>& elm,
159  const concepts::Array<F>& coeff,
160  concepts::Array<F>& val,
161  const concepts::Real3d& p,
162  const Real t = 0.0) const;
163 
165  const concepts::Array<F>& coeff,
166  F& val, const uint *i) const;
168  const uint* j, F& val, const uint* i) const;
170  const concepts::Array<F>& coeff, F& val, const Real2d& p,
171  const Real t = 0.0) const;
172  protected:
173  virtual std::ostream& info(std::ostream& os) const;
174  private:
175 
176 
177  template<class H>
178  bool compute_(H elm, const concepts::Array<F>& coeff,
179  F& val, const uint i[2]) const;
180 
181  template<class H>
182  bool compute_(H elm, const uint j[2], F& val, const uint i[2]) const;
183 
184  bool compute_(const Quad<Real>* elm, const concepts::Array<F>& coeff,
185  F& val, const Real2d& p, const Real t) const;
186 
187  };
188 
189  // *********************************************************** Partial_xx **
190 
196  template<typename F, typename Q = Quad<Real> >
197  class Partial_xx : public ElementFunction<1,F,Q> {
198  public:
199  virtual Partial_xx<F,Q>* clone() const;
200  protected:
201  virtual std::ostream& info(std::ostream& os) const;
202  private:
203  virtual void compute_(const Q& elm,
204  const concepts::Array<F>& coeff,
205  F& val, const uint i[2]) const;
206  virtual void compute_(const Q& elm, const uint j[3],
207  F& val, const uint i[2]) const;
208  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
209  F& val, const Real2d& p, const Real t = 0.0) const;
210 
211  };
212 
213  // *********************************************************** Partial_yy **
214 
220  template<typename F, typename Q = Quad<Real>>
221  class Partial_yy : public ElementFunction<1,F,Q> {
222  public:
223  virtual Partial_yy<F,Q>* clone() const;
224  protected:
225  virtual std::ostream& info(std::ostream& os) const;
226  private:
227  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
228  F& val, const uint i[2]) const;
229  virtual void compute_(const Q& elm, const uint j[3],
230  F& val, const uint i[2]) const;
231  virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
232  F& val, const Real2d& p, const Real t = 0.0) const;
233  };
234 
235  // **************************************************************** Plcurl **
236 
241  template<typename F = Real>
242  class PlCurl : public ElementFunction<2,F> {
243  public:
244  virtual PlCurl<F>* clone() const { return new PlCurl(); }
245  protected:
246  virtual std::ostream& info(std::ostream& os) const;
247  private:
248  virtual void compute_(const Quad<Real>& elm,
249  const concepts::Array<F>& coeff,
250  concepts::Array<F>& val,
251  const uint i[2]) const;
252  virtual void compute_(const Quad<Real>& elm, const uint j[2],
253  concepts::Array<F>& val,
254  const uint i[2]) const;
255  virtual void compute_(const Quad<Real>& elm,
256  const concepts::Array<F>& coeff,
257  concepts::Array<F>& val,
258  const Real2d& p, const Real t = 0.0) const;
259  };
260 
261  // ***************************************************************** Trace **
262 
269  template<typename F = Real,
270  typename G = typename concepts::Realtype<F>::type>
271  class Trace : public ElementFunction<1,F,hp1D::Element<G> > {
272  public:
274  Trace() : attrib_(concepts::Attribute(0)) {}
277 
280 
281  virtual Trace<F,G>* clone() const {
282  Trace<F,G>* tmp = new Trace();
283  tmp->attrib() = attrib_;
284  return tmp;
285  }
286  protected:
287  virtual std::ostream& info(std::ostream& os) const;
288  private:
290 
291  virtual void compute_(const hp1D::Element<G>& elm,
292  const concepts::Array<F>& coeff,
293  F& val, const uint i[2]) const;
294  virtual void compute_(const hp1D::Element<G>& elm, const uint j[2],
295  F& val, const uint i[2]) const;
296  virtual void compute_(const hp1D::Element<G>& elm,
297  const concepts::Array<F>& coeff,
298  F& val, const Real2d& p, const Real t = 0.0) const;
299  };
300 
301  // ************************************************************ TraceDeriv **
302 
310  template<typename F = Real,
311  typename G = typename concepts::Realtype<F>::type>
312  class TraceDeriv : public ElementFunction<1,F,hp1D::Element<G> > {
313  public:
315  TraceDeriv() : attrib_(concepts::Attribute(0)) {}
318 
321 
322  virtual TraceDeriv<F,G>* clone() const {
323  TraceDeriv<F,G>* tmp = new TraceDeriv();
324  tmp->attrib() = attrib_;
325  return tmp;
326  }
327  protected:
328  virtual std::ostream& info(std::ostream& os) const;
329  private:
331 
332  virtual void compute_(const hp1D::Element<G>& elm,
333  const concepts::Array<F>& coeff,
334  F& val, const uint i[2]) const;
335  virtual void compute_(const hp1D::Element<G>& elm, const uint j[2],
336  F& val, const uint i[2]) const;
337  virtual void compute_(const hp1D::Element<G>& elm,
338  const concepts::Array<F>& coeff,
339  F& val, const Real2d& p, const Real t = 0.0) const;
340  };
341 
342 
343  // ********************************************************** NeumannTrace **
344 
353  template<typename F = Real,
354  typename G = typename concepts::Realtype<F>::type>
355  class NeumannTrace : public ElementFunction<1,F,Quad<G> > {
356  public:
360 
361  virtual NeumannTrace<F,G>* clone() const {
362  return new NeumannTrace();
363  }
364  protected:
365  virtual std::ostream& info(std::ostream& os) const;
366  private:
367 
368  virtual void compute_(const Quad<G>& elm,
369  const concepts::Array<F>& coeff,
370  F& val, const uint i[2]) const;
371  virtual void compute_(const Quad<G>& elm, const uint j[2],
372  F& val, const uint i[2]) const;
373  virtual void compute_(const Quad<G>& elm,
374  const concepts::Array<F>& coeff,
375  F& val, const Real2d& p, const Real t = 0.0) const;
376  };
377 
378  namespace l2 {
379 
380  // *************************************************************** Value **
381 
386  template<typename F = Real, typename G = typename concepts::Realtype<F>::type>
387  class Value : public concepts::ElementFunction<F, G> {
388  public:
389  virtual Value<F,G>* clone() const { return new Value(); }
390 
392  virtual uint n() const { return 1; }
393 
394  virtual void operator() (const concepts::Element<G>& elm,
395  const concepts::Array<F>& coeff,
396  concepts::Array<F>& val, const uint *i) const;
397  virtual void operator() (const concepts::Element<G>& elm,
398  const uint* j,
399  concepts::Array<F>& val, const uint* i) const;
400  virtual void operator() (const concepts::Element<G>& elm,
401  const concepts::Array<F>& coeff,
402  concepts::Array<F>& val, const Real p,
403  const Real t = 0.0) const;
404  virtual void operator() (const concepts::Element<G>& elm,
405  const concepts::Array<F>& coeff,
406  concepts::Array<F>& val, const Real2d& p,
407  const Real t = 0.0) const;
408  virtual void operator() (const concepts::Element<G>& elm,
409  const concepts::Array<F>& coeff,
410  concepts::Array<F>& val,
411  const concepts::Real3d& p,
412  const Real t = 0.0) const;
413 
415  const concepts::Array<F>& coeff,
416  F& val, const uint *i) const;
418  const uint* j, F& val, const uint* i) const;
420  const concepts::Array<F>& coeff, F& val, const Real2d& p,
421  const Real t = 0.0) const;
422  protected:
423  virtual std::ostream& info(std::ostream& os) const;
424  private:
425  bool compute_(const Quad<Real>* elm, const concepts::Array<F>& coeff,
426  F& val, const uint i[2]) const;
427 
428  bool compute_(const Quad<Real>* elm, const uint j[2], F& val, const uint i[2]) const;
429 
430  bool compute_(const Quad<Real>* elm, const concepts::Array<F>& coeff,
431  F& val, const Real2d& p, const Real t) const;
432 
433  void compute_(const concepts::Array<F>& coeff, F& val,
434  const Real* xValues, uint nsx,
435  const Real* yValues, uint nsy) const;
436  };
437 
438 
439  } // namespace l2
440 
441 } // namespace hp2D
442 
443 #endif // hpFunction2d_hh
virtual void compute_(const Quad< G > &elm, const uint j[2], F &val, const uint i[2]) const
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t=0.0) const
The approximated function in a FE space.
Definition: function.hh:33
bool compute_(const Quad< Real > *elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t=0.0) const
virtual void compute_(const hp1D::Element< G > &elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t=0.0) const
virtual std::ostream & info(std::ostream &os) const
An abstract class for a function in a FE space.
bool compute_(const InfiniteQuad *elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
bool compute_(const Quad< Real > *elm, const uint j[2], F &val, const uint i[2]) const
virtual void compute_(const Q &elm, const uint j[3], F &val, const uint i[2]) const
virtual Partial_yy< F, Q > * clone() const
bool compute_(const Quad< Real > *elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t) const
virtual uint n() const
Number of components.
Definition: function.hh:142
virtual std::ostream & info(std::ostream &os) const
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
A 2D FEM element: an infinite quad.
Definition: quad.hh:317
virtual Trace< F, G > * clone() const
Definition: function.hh:281
bool compute_(const Quad< Real > *elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t) const
The Neumann trace of the approximated function in a FE space.
Definition: function.hh:355
Point< Real, 2 > Real2d
Base class for element functions for hp elements in 2D.
Definition: functionBase.hh:38
virtual void compute_(const Q &elm, const uint j[3], F &val, const uint i[2]) const
The Laplacian of the approximated function in a FE space.
Definition: function.hh:137
TraceDeriv(const concepts::Attribute attrib)
Constructor with given attribute.
Definition: function.hh:317
virtual std::ostream & info(std::ostream &os) const
virtual PlCurl< F > * clone() const
Definition: function.hh:244
concepts::Set< concepts::Attribute > attrib_
Definition: function.hh:330
The vectorial 2D curl of the approximated function in a FE space.
Definition: function.hh:242
Element on an edge representing the normal derivatives of neighbouring elements, especially their mea...
virtual NeumannTrace< F, G > * clone() const
Definition: function.hh:361
The approximated function in a FE space.
Definition: function.hh:387
virtual void compute_(const Quad< Real > &elm, const uint j[2], concepts::Array< F > &val, const uint i[2]) const
virtual Grad< F > * clone() const
Definition: function.hh:110
virtual void operator()(const concepts::Element< G > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint *i) const
TraceDeriv()
Constructor.
Definition: function.hh:315
virtual void compute_(const hp1D::Element< G > &elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
virtual void compute_(const hp1D::Element< G > &elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
virtual void compute_(const Quad< G > &elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t=0.0) const
virtual Laplacian< F > * clone() const
Definition: function.hh:139
2D hp-FEM for H1-conforming elements.
void compute_(const concepts::Array< F > &coeff, F &val, const Real *xValues, uint nsx, const Real *yValues, uint nsy) const
bool compute_(H elm, const uint j[2], F &val, const uint i[2]) const
virtual void operator()(const concepts::Element< G > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint *i) const
virtual void operator()(const concepts::Element< G > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint *i) const
virtual std::ostream & info(std::ostream &os) const
virtual std::ostream & info(std::ostream &os) const
virtual void compute_(const Quad< Real > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const Real2d &p, const Real t=0.0) const
virtual std::ostream & info(std::ostream &os) const
virtual std::ostream & info(std::ostream &os) const
virtual TraceDeriv< F, G > * clone() const
Definition: function.hh:322
bool compute_(const NTElement_BA< Real > *nTelm, const concepts::Array< F > &coeff, F &val, const Real p, const Real t) const
An array of objects.
Definition: bilinearForm.hh:23
void compute_(const concepts::Array< F > &coeff, F &val, const Real *xValues, uint nsx, const Real *yValues, uint nsy) const
bool compute_(const Quad< Real > *elm, const uint j[2], F &val, const uint i[2]) const
bool compute_(const InfiniteQuad *elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t) const
virtual void compute_(const Q &elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
Double partial derivative in x direction of the approximated function in a FE space.
Definition: function.hh:197
virtual void compute_(const Quad< Real > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint i[2]) const
concepts::Set< concepts::Attribute > & attrib()
Returns the attributes.
Definition: function.hh:320
virtual void compute_(const Quad< G > &elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
1D generic element.
Definition: element.hh:225
bool compute_(const Quad< Real > *elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
concepts::Set< concepts::Attribute > attrib_
Definition: function.hh:289
bool compute_(H elm, const concepts::Array< F > &coeff, F &val, const uint i[2]) const
virtual void compute_(const hp1D::Element< G > &elm, const uint j[2], F &val, const uint i[2]) const
Trace()
Constructor.
Definition: function.hh:274
Trace(const concepts::Attribute attrib)
Constructor with given attribute.
Definition: function.hh:276
bool compute_(const NeumannTraceElement< Real > *elm, const concepts::Array< F > &coeff, F &val, const Real &p, const Real t) const
virtual Partial_xx< F, Q > * clone() const
Double partial derivative in y direction of the approximated function in a FE space.
Definition: function.hh:221
virtual std::ostream & info(std::ostream &os) const
virtual void compute_(const hp1D::Element< G > &elm, const uint j[2], F &val, const uint i[2]) const
virtual uint n() const
Number of components.
Definition: function.hh:38
virtual void compute_(const Quad< Real > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const Real2d &p, const Real t=0.0) const
virtual std::ostream & info(std::ostream &os) const
virtual Value< F, G > * clone() const
Definition: function.hh:35
virtual std::ostream & info(std::ostream &os) const
bool compute_(const Quad< Real > *elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t) const
NeumannTrace()
Constructor.
Definition: function.hh:359
concepts::Set< concepts::Attribute > & attrib()
Returns the attributes.
Definition: function.hh:279
virtual void compute_(const hp1D::Element< G > &elm, const concepts::Array< F > &coeff, F &val, const Real2d &p, const Real t=0.0) const
The gradient of the approximated function in a FE space.
Definition: function.hh:108
virtual Value< F, G > * clone() const
Definition: function.hh:389
virtual void compute_(const Quad< Real > &elm, const uint j[2], concepts::Array< F > &val, const uint i[2]) const
virtual uint n() const
Number of components.
Definition: function.hh:392
Element on an edge representing the normal derivative of neighbouring elements, especially their mean...
Definition: neumannTrace.hh:40
bool compute_(const InfiniteQuad *elm, const uint j[2], F &val, const uint i[2]) const
The tangential derivative of the Dirichlet trace of the approximated function in a FE space.
Definition: function.hh:312
virtual void compute_(const Quad< Real > &elm, const concepts::Array< F > &coeff, concepts::Array< F > &val, const uint i[2]) const
Attributes for elements of the topology.
Definition: connector.hh:22
The Dirichlet trace of the approximated function in a FE space.
Definition: function.hh:271
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich