frmE_sum.hh

Go to the documentation of this file.
1 
8 #ifndef sumelementformula_hh
9 #define sumelementformula_hh
10 
11 #include "basics/typedefs.hh"
12 #include "basics/output.hh"
15 #include "exceptions.hh"
16 
17 #define SumElemFormConstr_D 0
18 #define SumElemFormDestr_D 0
19 #define SumElemFormClone_D 0
20 
21 namespace concepts {
22 
23 
24  // **************************************************************** FrmE_Sum **
25 
34  template<class F, class H = F, class J = F,
35  class G = typename Realtype<F>::type>
36  class FrmE_Sum : public ElementFormula<F,G> {
37  public:
39  const ElementFormulaContainer<J> frm2)
40  : frm1_(frm1), frm2_(frm2), a_(0.0)
41  {
42  if (frm1.empty()) throw(PointerToEmptyElementFormula());
43  if (frm2.empty()) throw(PointerToEmptyElementFormula());
44  }
46  const F a)
47  : frm1_(frm1), frm2_(), a_(a)
48  {
49  DEBUGL(SumElemFormConstr_D, "frm1 = " << frm1);
50  if (frm1.empty()) throw(PointerToEmptyElementFormula());
51  }
52  virtual ~FrmE_Sum() {
53  DEBUGL(SumElemFormDestr_D, "Delete " << *this)
54  }
55 
56 
57  virtual F operator() (const ElementWithCell<G>& elm, const Real p,
58  const Real t = 0.0) const
59  {
60  F v = frm1_(elm, p,t);
61  if (!frm2_.empty())
62  v += frm2_(elm, p,t);
63 
64  return v + a_;
65  }
66  virtual F operator() (const ElementWithCell<G>& elm, const Real2d& p,
67  const Real t = 0.0) const
68  {
69  F v = frm1_(elm, p,t);
70  if (!frm2_.empty())
71  v += frm2_(elm, p,t);
72 
73  return v + a_;
74  }
75  virtual F operator() (const ElementWithCell<G>& elm, const Real3d& p,
76  const Real t = 0.0) const
77  {
78  F v = frm1_(elm, p,t);
79  if (!frm2_.empty())
80  v += frm2_(elm, p,t);
81 
82  return v + a_;
83  }
84 
85  virtual FrmE_Sum<F,H,J,G>* clone() const {
86  DEBUGL(SumElemFormClone_D, *this << " = *" << this);
87  return new FrmE_Sum<F,H,J,G>(frm1_, frm2_, a_);
88  }
89  protected:
90  virtual std::ostream& info(std::ostream& os) const {
91  os << typeOf(*this) << "(" << frm1_;
92  if (!frm2_.empty())
93  os << " + " << frm2_;
94  if (!(a_ == F(0.0)))
95  os << " + " << a_;
96  return os << ")";
97  }
98  private:
104  F a_;
105 
108  const ElementFormulaContainer<J> frm2,
109  const F a)
110  : frm1_(frm1), frm2_(frm2), a_(a)
111  {
113  "frm1 = " << frm1 << ", frm2 = " << frm2 << ", a = " << a);
114  if (frm1.empty()) throw(PointerToEmptyElementFormula());
115  }
116  };
117 
118 
119  // ************************************************************ operator+ **
120 
122 
123  ElementFormulaContainer<Real>
125 
128 
131 
134 
135  // ************
136 
139 
142 
145 
148 
149 
154  const ElementFormulaContainer<Real> frm2);
155 
158  const ElementFormulaContainer<Real> frm2);
159 
162  const ElementFormulaContainer<Cmplx> frm2);
163 
166  const ElementFormulaContainer<Cmplx> frm2);
167 
168  // ************
169 
173 
177 
181 
185 
187 
190 
193 
196 
199 
200  // ************
201 
204 
207 
210 
213 
218  const ElementFormulaContainer<Real> frm2);
219 
222  const ElementFormulaContainer<Real> frm2);
223 
226  const ElementFormulaContainer<Cmplx> frm2);
227 
230  const ElementFormulaContainer<Cmplx> frm2);
231 
232  // ************
233 
237 
241 
245 
249 
250 } // namespace concepts
251 
252 
253 #endif // sumelementformula_hh
FrmE_Sum(const ElementFormulaContainer< H > frm1, const ElementFormulaContainer< J > frm2)
Definition: frmE_sum.hh:38
ElementFormulaContainer< H > frm1_
First element formula.
Definition: frmE_sum.hh:100
ElementFormulaContainer< J > frm2_
Second element formula.
Definition: frmE_sum.hh:102
#define SumElemFormConstr_D
Definition: frmE_sum.hh:17
#define SumElemFormDestr_D
Definition: frmE_sum.hh:18
ElementFormulaContainer< Real > operator-(const ElementFormulaContainer< Real > frm, const Real a)
Simple subtracting of a element formulas and a constant via –operator.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: frmE_sum.hh:90
Element with cell.
#define DEBUGL(doit, msg)
bool empty() const
Returns true if no formula is stored.
Interface for a formula defined element by element.
FrmE_Sum(const ElementFormulaContainer< H > frm1, const F a)
Definition: frmE_sum.hh:45
virtual F operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
Definition: frmE_sum.hh:57
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
Class for a sum of element formulas.
Definition: frmE_sum.hh:36
virtual FrmE_Sum< F, H, J, G > * clone() const
Virtual constructor.
Definition: frmE_sum.hh:85
FrmE_Sum(const ElementFormulaContainer< H > frm1, const ElementFormulaContainer< J > frm2, const F a)
Private constructor.
Definition: frmE_sum.hh:107
#define SumElemFormClone_D
Definition: frmE_sum.hh:19
virtual ~FrmE_Sum()
Definition: frmE_sum.hh:52
Frm_Sum< Real > operator+(const Formula< Real > &frm, const Real a)
Simple adding two formulas by +-operator.
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
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