vectorElementFormula.hh

Go to the documentation of this file.
1 
8 #ifndef vectorelementformula_hh
9 #define vectorelementformula_hh
10 
11 #include <vector>
12 #include "toolbox/sharedPointer.hh"
13 #include "elementFormula.hh"
15 
16 namespace concepts {
17 
18 
19  // *********************************************** VectorElementFormulaBase **
20 
25  template<typename F, int dim, typename G = typename Realtype<F>::type>
26  class VectorElementFormulaBase : public ElementFormula< Point<F, dim>, G >
27  {
28  public:
30  {
31  for(int i=0; i < dim; ++i)
33  }
34 
40  (const std::vector<ElementFormulaContainer<F,G> >& formulas)
41  : formulas_(formulas)
42  {
44  }
45 
52  const Real t = 0.0) const
53  {
54  Point<F, dim> ret;
55  for (int i=0; i < dim; ++i)
56  ret[i] = !formulas_[i].empty() ? formulas_[i](elm, p, t) : F(0);
57  return ret;
58  }
59 
61  const Real t = 0.0) const
62  {
63  Point<F, dim> ret;
64  for (int i=0; i < dim; ++i)
65  ret[i] = !formulas_[i].empty() ? formulas_[i](elm, p, t) : F(0);
66 
67  return ret;
68  }
69 
71  const Real t = 0.0) const
72  {
73  Point<F, dim> ret;
74  for (int i=0; i < dim; ++i)
75  ret[i] = !formulas_[i].empty() ? formulas_[i](elm, p, t) : F(0);
76 
77  return ret;
78  }
79 
82  {
83  return new VectorElementFormulaBase<F, dim, G>(*this);
84  }
85 
86 #if 0
88  : formulas_(other.formulas_)
89  { }
90 #endif
91 
93 
94  const std::vector<ElementFormulaContainer<F, G> >& getFormulas()
95  {
96  return formulas_;
97  }
98 
100  {
102 
103  return formulas_[i];
104  }
105 
106  protected:
107  std::vector<ElementFormulaContainer<F, G> > formulas_;
108 
109  virtual std::ostream& info(std::ostream& os) const {
110  os << concepts::typeOf(*this) << "([";
111  for (int i=0; i < dim; ++i) {
112  if (!formulas_[i].empty())
113  os << formulas_[i].frm();
114  else
115  os << "0";
116  if (i < dim - 1)
117  os << ", ";
118  }
119  return os << "])";
120  }
121  };
122 
123  // ************************************************ VectorElementFormula *****
124 
125  template<typename F, int dim, typename G = typename Realtype<F>::type>
126  class VectorElementFormula : public VectorElementFormulaBase<F,dim,G> {};
127 
128 
129  // ************************************************ VectorElementFormula<2> **
130 
131  template<typename F, typename G>
132  class VectorElementFormula<F,2,G> : public VectorElementFormulaBase<F,2,G>
133  {
134  public:
136 
138  (const std::vector<ElementFormulaContainer<F,G> >& formulas)
139  : VectorElementFormulaBase<F,2,G>(formulas) {}
140 
142  const ElementFormulaContainer<F,G>& frm2)
144  (*this)[0] = frm1;
145  (*this)[1] = frm2;
146  }
147  };
148 
149 
150  // ************************************************ VectorElementFormula<3> **
151 
152  template<typename F, typename G>
153  class VectorElementFormula<F,3,G> : public VectorElementFormulaBase<F,3,G>
154  {
155  public:
157 
159  (const std::vector<ElementFormulaContainer<F,G> >& formulas)
160  : VectorElementFormulaBase<F,3,G>(formulas) {}
161 
163  const ElementFormulaContainer<F,G> frm2,
164  const ElementFormulaContainer<F,G> frm3)
166  (*this)[0] = frm1;
167  (*this)[1] = frm2;
168  (*this)[2] = frm3;
169  }
170  };
171 
172 
173 } // namespace concepts
174 
175 
176 #endif // vectorelementformula_hh
Element formula returning a vector.
Basic class for a Point or a vector.
std::vector< ElementFormulaContainer< F, G > > formulas_
ElementFormulaContainer< F, G > & operator[](int i)
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
Element with cell.
virtual VectorElementFormulaBase< F, dim, G > * clone() const
Virtual copy constructor.
Exception class for assertions.
Definition: exceptions.hh:258
Interface for a formula defined element by element.
const std::vector< ElementFormulaContainer< F, G > > & getFormulas()
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
Point< F, dim > operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
Evaluates the formula.
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