Class documentation of Concepts

Loading...
Searching...
No Matches
function.hh
Go to the documentation of this file.
1
6#ifndef spcFunction_hh
7#define spcFunction_hh
8
9#include <cstring>
12#include "toolbox/array.hh"
13#include "element.hh"
14
15namespace concepts {
16
17 // ****************************************************** ElementFunction **
18
24 class ElementFunction : public virtual OutputOperator {
25 public:
27 virtual uint n() const = 0;
34 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
35 Array<F>& val, const uint *i) const = 0;
43 virtual void operator() (const Element<G>& elm, const uint* j,
44 Array<F>& val, const uint* i) const = 0;
46
54 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
55 Array<F>& val, const Real p,
56 const Real t = 0.0) const = 0;
57 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
58 Array<F>& val, const Real2d& p,
59 const Real t = 0.0) const = 0;
60 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
61 Array<F>& val, const Real3d& p,
62 const Real t = 0.0) const = 0;
64
65 virtual ElementFunction<F,G>* clone() const = 0;
66 protected:
67 virtual std::ostream& info(std::ostream& os) const {
68 return os << concepts::typeOf(*this)<<"()";
69 }
70 };
71
72 // *************************************************************** Squared **
73
78 class Squared : public ElementFunction<F, G> {
79 public:
82 virtual ~Squared() {}
83 virtual uint n() const { return fun_.n(); }
84
85 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
86 Array<F>& val, const uint *i) const;
87 virtual void operator() (const Element<G>& elm, const uint* j,
88 Array<F>& val, const uint* i) const;
89 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
90 Array<F>& val, const Real p,
91 const Real t = 0.0) const;
92 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
93 Array<F>& val, const Real2d& p,
94 const Real t = 0.0) const;
95 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
96 Array<F>& val, const Real3d& p,
97 const Real t = 0.0) const;
98
99 virtual Squared<F,G>* clone() const { return new Squared(fun_); }
100 protected:
101 virtual std::ostream& info(std::ostream& os) const;
102 private:
106 template<class H>
107 void square_(Array<H>& val) const {
108 conceptsAssert(val.size() <= n(), Assertion());
109 for(uint j=0; j < n(); ++j)
110 val[j] = val[j]*val[j];
111 }
112 };
113
114 // ********************************************************** AbsoluteComp **
115
125 class AbsoluteComp : public ElementFunction<F, G> {
126 public:
129 virtual ~AbsoluteComp() {}
130 virtual uint n() const { return fun_.n(); }
131
132 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
133 Array<F>& val, const uint *i) const;
134 virtual void operator() (const Element<G>& elm, const uint* j,
135 Array<F>& val, const uint* i) const;
136 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
137 Array<F>& val, const Real p,
138 const Real t = 0.0) const;
139 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
140 Array<F>& val, const Real2d& p,
141 const Real t = 0.0) const;
142 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
143 Array<F>& val, const Real3d& p,
144 const Real t = 0.0) const;
145 virtual AbsoluteComp<F,G>* clone() const { return new AbsoluteComp(fun_); }
146 protected:
147 virtual std::ostream& info(std::ostream& os) const;
148 private:
152 void absolute_(Array<F>& val) const;
153 };
154
155 // ************************************************************** Absolute **
156
166 class Absolute : public ElementFunction<F, G> {
167 public:
170 virtual ~Absolute() {}
171 virtual uint n() const { return 1; }
172
173 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
174 Array<F>& val, const uint *i) const;
175 virtual void operator() (const Element<G>& elm, const uint* j,
176 Array<F>& val, const uint* i) const;
177 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
178 Array<F>& val, const Real p,
179 const Real t = 0.0) const;
180 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
181 Array<F>& val, const Real2d& p,
182 const Real t = 0.0) const;
183 virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
184 Array<F>& val, const Real3d& p,
185 const Real t = 0.0) const;
186 virtual Absolute<F,G>* clone() const { return new Absolute(fun_); }
187 protected:
188 virtual std::ostream& info(std::ostream& os) const;
189 private:
193 F absolute_(const Array<F>& val) const;
194 };
195
196} // namespace concepts
197
198#endif // spcFunction_hh
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void operator()(const Element< G > &elm, const Array< F > &coeff, Array< F > &val, const uint *i) const
AbsoluteComp(ElementFunction< F, G > &fun)
Constructor.
Definition function.hh:128
virtual uint n() const
Number of components.
Definition function.hh:130
virtual uint n() const
Number of components.
Definition function.hh:171
Absolute(ElementFunction< F, G > &fun)
Constructor.
Definition function.hh:169
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void operator()(const Element< G > &elm, const Array< F > &coeff, Array< F > &val, const uint *i) const
uint size() const
Returns the requested size of the array.
Definition array.hh:259
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition function.hh:67
virtual void operator()(const Element< G > &elm, const Array< F > &coeff, Array< F > &val, const uint *i) const =0
virtual uint n() const =0
Number of components.
Squared(ElementFunction< F, G > &fun)
Constructor.
Definition function.hh:81
virtual void operator()(const Element< G > &elm, const Array< F > &coeff, Array< F > &val, const uint *i) const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint n() const
Number of components.
Definition function.hh:83
#define conceptsAssert(cond, exc)
std::string typeOf(const T &t)
Definition output.hh:43
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320