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"
13 #include "toolbox/sharedPointer.hh"
15 #include "exceptions.hh"
16 
17 #define ProdElemFormConstr_D 0
18 #define ProdElemFormDestr_D 0
19 #define ProdElemFormClone_D 0
20 
21 namespace 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:
42  const ElementFormulaContainer<J> frm2)
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:
117 
120  const ElementFormulaContainer<J> frm2,
121  const RCP<J> a)
122  : frm1_(frm1), frm2_(frm2), a_(a)
123  {
125  "frm1 = " << frm1 << ", frm2 = " << frm2 << ", a = " << a);
126  if (frm1.empty()) throw(PointerToEmptyElementFormula());
127  }
128  };
129 
130  // ************************************************************ operator* **
131 
133 
134  ElementFormulaContainer<Real>
136 
139 
142 
145 
146  // ************
147 
150 
153 
156 
159 
160  // ************
161 
164 
167 
170 
173 
174  // ************
175 
178 
181 
184 
187 
188  // ************
189 
192 
195 
198 
201 
202  // ************
203  // The vector in CONCEPTS is columnwise, therefore only A*a is valid
204 
205  // @author Mengyu Wang, 2012
206 
209 
212 
215 
218 
220 
223  const ElementFormulaContainer<Real> frm2);
224 
227  const ElementFormulaContainer<Real> frm2);
228 
231  const ElementFormulaContainer<Cmplx> frm2);
232 
235  const ElementFormulaContainer<Cmplx> frm2);
236 
237  // ************
238 
241  const ElementFormulaContainer<Real> frm2);
242 
245  const ElementFormulaContainer<Real> frm2);
246 
249  const ElementFormulaContainer<Cmplx> frm2);
250 
253  const ElementFormulaContainer<Cmplx> frm2);
254 
255  // ************
256 
260 
264 
268 
272 
273  // ************
274 
278 
282 
286 
290 
291  // ************
292 
295  const ElementFormulaContainer<Real> frm2);
296 
299  const ElementFormulaContainer<Real> frm2);
300 
303  const ElementFormulaContainer<Cmplx> frm2);
304 
307  const ElementFormulaContainer<Cmplx> frm2);
308 
309  // ************
310 
314 
318 
322 
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 
354  const ElementFormulaContainer<Real> frm2);
355 
358  const ElementFormulaContainer<Real> frm2);
359 
362  const ElementFormulaContainer<Cmplx> frm2);
363 
366  const ElementFormulaContainer<Cmplx> frm2);
367 
369 
372  const ElementFormulaContainer<Real> frm2);
373 
376  const ElementFormulaContainer<Real> frm2);
377 
380  const ElementFormulaContainer<Cmplx> frm2);
381 
384  const ElementFormulaContainer<Cmplx> frm2);
385 
386 
387 } // namespace concepts
388 
389 
390 #endif // productelementformula_hh
FrmE_Product(const ElementFormulaContainer< H > frm1, const ElementFormulaContainer< J > frm2, const RCP< J > a)
Private constructor.
ElementFormulaContainer< H > frm1_
First ElementFormula.
ElementFormulaContainer< J > frm2_
Second ElementFormula.
FrmE_Product(const FrmE_Product< F, H, J, G > &frm)
Copy constructor.
Definition: frmE_product.hh:56
virtual FrmE_Product< F, H, J, G > * clone() const
Virtual constructor.
Definition: frmE_product.hh:96
ElementFormulaContainer< Real > operator/(const ElementFormulaContainer< Real > frm1, const ElementFormulaContainer< Real > frm2)
Division of a element formulas by a scalar element formula via /-operator.
#define ProdElemFormClone_D
Definition: frmE_product.hh:19
#define ProdElemFormDestr_D
Definition: frmE_product.hh:18
Point< typename Combtype< F, Real >::type, dim > operator*(const Real x, const Point< F, dim > &y)
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
FrmE_Product(const ElementFormulaContainer< H > frm1, const J a)
Definition: frmE_product.hh:48
Element with cell.
#define DEBUGL(doit, msg)
bool empty() const
Returns true if no formula is stored.
#define ProdElemFormConstr_D
Definition: frmE_product.hh:17
Exception class for assertions.
Definition: exceptions.hh:258
Interface for a formula defined element by element.
Product of two element formulas or an element formula and a factor.
Definition: frmE_product.hh:39
RCP< J > a_
Constant factor instead of an ElementFormula (not necessary scalar)
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
RCP< T > makeRCP(T *x)
Function to create a RCP which deletes the object when no RCP points on it anymore.
Reference-counting pointer.
Definition: bf_iddiv.hh:15
virtual F operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
Definition: frmE_product.hh:63
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
FrmE_Product(const ElementFormulaContainer< H > frm1, const ElementFormulaContainer< J > frm2)
Definition: frmE_product.hh:41
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Exception class to express that the RCP pointer points to 0.
Definition: exceptions.hh:55
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