Class documentation of Concepts

Loading...
Searching...
No Matches
frmE_product.hh
Go to the documentation of this file.
1
8#ifndef productelementformula_hh
9#define productelementformula_hh
10
11#include "basics/debug.hh"
12#include "basics/output.hh"
15#include "exceptions.hh"
16
17#define ProdElemFormConstr_D 0
18#define ProdElemFormDestr_D 0
19#define ProdElemFormClone_D 0
20
21namespace concepts {
22
23
24 // *********************************************************** FrmE_Product **
25
35 template<typename F,
36 typename H = F,
37 typename J = typename Datatype<F>::type,
38 typename G = typename Realtype<F>::type>
39 class FrmE_Product : public ElementFormula<F,G> {
40 public:
43 : frm1_(frm1), frm2_(frm2)
44 {
45 if (frm1.empty()) throw(PointerToEmptyElementFormula());
46 if (frm2.empty()) throw(PointerToEmptyElementFormula());
47 }
49 const J a)
50 : frm1_(frm1), frm2_(), a_(makeRCP(new J(a)))
51 {
52 DEBUGL(ProdElemFormConstr_D, "frm1 = " << frm1);
53 if (frm1.empty()) throw(PointerToEmptyElementFormula());
54 }
57 : frm1_(frm.frm1_), frm2_(frm.frm2_), a_(frm.a_) {}
58
59 virtual ~FrmE_Product() {
60 DEBUGL(ProdElemFormDestr_D, "Delete " << *this)
61 }
62
63 virtual F operator() (const ElementWithCell<G>& elm,
64 const Real p, const Real t = 0.0) const {
65 H v = frm1_(elm, p,t);
66
67 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
68
69 if (frm2_.empty())
70 return v * *a_;
71
72 return v * frm2_(elm, p,t);
73 }
74 virtual F operator() (const ElementWithCell<G>& elm,
75 const Real2d& p, const Real t = 0.0) const {
76 H v = frm1_(elm, p,t);
77
78 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
79
80 if (frm2_.empty())
81 return v * *a_;
82
83 return v * frm2_(elm, p,t);
84 }
85 virtual F operator() (const ElementWithCell<G>& elm,
86 const Real3d& p, const Real t = 0.0) const {
87 H v = frm1_(elm, p,t);
88
89 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
90
91 if (frm2_.empty())
92 return v * *a_;
93
94 return v * frm2_(elm, p,t);
95 }
96 virtual FrmE_Product<F,H,J,G>* clone() const {
97 DEBUGL(ProdElemFormClone_D, *this << " = *" << this);
98 return new FrmE_Product<F,H,J,G>(frm1_, frm2_, a_);
99 }
100 protected:
101 virtual std::ostream& info(std::ostream& os) const {
102 os << concepts::typeOf(*this) << "(" << frm1_;
103 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
104 if (!frm2_.empty())
105 os << " * " << frm2_;
106 if (a_.get())
107 os << " * " << *a_;
108 return os << ")";
109 }
110 private:
116 RCP<J> a_;
117
121 const RCP<J> a)
122 : frm1_(frm1), frm2_(frm2), a_(a)
123 {
124 DEBUGL(ProdElemFormConstr_D,
125 "frm1 = " << frm1 << ", frm2 = " << frm2 << ", a = " << a);
126 if (frm1.empty()) throw(PointerToEmptyElementFormula());
127 }
128 };
129
130 // ************************************************************ operator* **
131
133
134 ElementFormulaContainer<Real>
135 operator*(const ElementFormulaContainer<Real> frm, const Real a);
136
138 operator*(const ElementFormulaContainer<Cmplx> frm, const Real a);
139
141 operator*(const ElementFormulaContainer<Cmplx> frm, const Cmplx a);
142
144 operator*(const ElementFormulaContainer<Real> frm, const Cmplx a);
145
146 // ************
147
149 operator*(const ElementFormulaContainer<Real2d> frm, const Real a);
150
152 operator*(const ElementFormulaContainer<Cmplx2d> frm, const Real a);
153
155 operator*(const ElementFormulaContainer<Cmplx2d> frm, const Cmplx a);
156
158 operator*(const ElementFormulaContainer<Real2d> frm, const Cmplx a);
159
160 // ************
161
163 operator*(const ElementFormulaContainer<Real> frm, const Real2d a);
164
166 operator*(const ElementFormulaContainer<Cmplx> frm, const Real2d a);
167
169 operator*(const ElementFormulaContainer<Cmplx> frm, const Cmplx2d a);
170
172 operator*(const ElementFormulaContainer<Real> frm, const Cmplx2d a);
173
174 // ************
175
177 operator*(const ElementFormulaContainer<MapReal2d> frm, const Real a);
178
180 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Real a);
181
183 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Cmplx a);
184
186 operator*(const ElementFormulaContainer<MapReal2d> frm, const Cmplx a);
187
188 // ************
189
191 operator*(const Real a, const ElementFormulaContainer<MapReal2d> frm);
192
194 operator*(const Real a, const ElementFormulaContainer<MapCmplx2d> frm);
195
197 operator*(const Cmplx a, const ElementFormulaContainer<MapCmplx2d> frm);
198
200 operator*(const Cmplx a, const ElementFormulaContainer<MapReal2d> frm);
201
202 // ************
203 // The vector in CONCEPTS is columnwise, therefore only A*a is valid
204
205 // @author Mengyu Wang, 2012
206
208 operator*(const ElementFormulaContainer<MapReal2d> frm, const Real2d a);
209
211 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Real2d a);
212
214 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Cmplx2d a);
215
217 operator*(const ElementFormulaContainer<MapReal2d> frm, const Cmplx2d a);
218
220
224
226 operator*(const ElementFormulaContainer<Cmplx> frm1,
228
230 operator*(const ElementFormulaContainer<Real> frm1,
232
234 operator*(const ElementFormulaContainer<Cmplx> frm1,
236
237 // ************
238
242
246
250
254
255 // ************
256
258 operator*(const ElementFormulaContainer<Real> frm1,
260
262 operator*(const ElementFormulaContainer<Cmplx> frm1,
264
266 operator*(const ElementFormulaContainer<Real> frm1,
268
270 operator*(const ElementFormulaContainer<Cmplx> frm1,
272
273 // ************
274
278
282
286
290
291 // ************
292
296
300
304
308
309 // ************
310
312 operator*(const ElementFormulaContainer<Real> frm1,
314
316 operator*(const ElementFormulaContainer<Real> frm1,
318
320 operator*(const ElementFormulaContainer<Cmplx> frm1,
322
324 operator*(const ElementFormulaContainer<Cmplx> frm1,
326
327 // ************
328 // The vector in CONCEPTS is columnwise, therefore only A*v is valid
329
330 // @author Mengyu Wang, 2012
331
335
339
343
347
348 // ************************************************************ operator/ **
349
351
355
359
363
367
369
373
377
381
385
386
387} // namespace concepts
388
389
390#endif // productelementformula_hh
FrmE_Product(const FrmE_Product< F, H, J, G > &frm)
Copy constructor.
virtual F operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
virtual FrmE_Product< F, H, J, G > * clone() const
Virtual copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
#define conceptsAssert(cond, exc)
#define DEBUGL(doit, msg)
Definition debug.hh:40
std::string typeOf(const T &t)
Definition output.hh:43
ElementFormulaContainer< Real > operator/(const ElementFormulaContainer< Real > frm1, const ElementFormulaContainer< Real > frm2)
Division of a element formulas by a scalar element formula via /-operator.
double Real
Definition typedefs.hh:39
RCP< T > makeRCP(T *x)
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition typedefs.hh:42