matrixElementFormula.hh

Go to the documentation of this file.
1 
6 #ifndef matrixelementformula_hh
7 #define matrixelementformula_hh
8 
9 #include <vector>
10 #include "toolbox/sharedPointer.hh"
11 #include "elementFormula.hh"
13 
14 namespace concepts {
15 
16 
17  // ************************************************** MatrixElementFormula **
18 
23  template<typename F, int dim, typename G = typename Realtype<F>::type>
24  class MatrixElementFormula : public ElementFormula< Mapping<F, dim>, G >
25  {
26  public:
28 
30  {
31  for(int i=0; i < dim*dim; ++i)
33  }
34 
35 
42  MatrixElementFormula<F,dim,G>(const std::vector< ElementFormulaContainer<F> >& formulas)
43  : formulas_(formulas)
44  {
45  conceptsAssert(formulas_.size() == dim * dim, concepts::Assertion());
46  }
47 
54  const Real t = 0.0) const
55  {
56  Mapping<F, dim> ret;
57  for (int i=0; i < dim; ++i) {
58  for (int j=0; j < dim; ++j)
59  ret(i,j) =
60  !formulas_[i*dim + j].empty() ? formulas_[i*dim + j](elm, p, t) : F(0);
61  }
62  return ret;
63  }
64 
66  const Real t = 0.0) const
67  {
68  Mapping<F, dim> ret;
69  for (int i=0; i < dim; ++i) {
70  for (int j=0; j < dim; ++j)
71  ret(i,j) =
72  !formulas_[i*dim + j].empty() ? formulas_[i*dim + j](elm, p, t) : F(0);
73  }
74  return ret;
75  }
76 
78  const Real t = 0.0) const
79  {
80  Mapping<F, dim> ret;
81  for (int i=0; i < dim; ++i) {
82  for (int j=0; j < dim; ++j)
83  ret(i,j) =
84  !formulas_[i*dim + j].empty() ? formulas_[i*dim + j](elm, p, t) : F(0);
85  }
86  return ret;
87  }
88 
91  {
92  return new MatrixElementFormula<F, dim, G>(*this);
93  }
94 
95 #if 0
97  : formulas_(other.formulas_)
98  { }
99 #endif
100 
101  virtual ~MatrixElementFormula() { }
102 
103  const std::vector< ElementFormulaContainer<F> >& getFormulas()
104  {
105  return formulas_;
106  }
107 
109  {
110  conceptsAssert(i < dim*dim, concepts::Assertion());
111 
112  return formulas_[i*dim +j];
113  }
114  protected:
115  std::vector< ElementFormulaContainer<F> > formulas_;
116  };
117 
118 
119 } // namespace concepts
120 
121 
122 #endif // matrixelementformula_hh
const std::vector< ElementFormulaContainer< F > > & getFormulas()
virtual MatrixElementFormula< F, dim, G > * clone() const
Virtual copy constructor.
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
Element with cell.
Mapping< F, dim > operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
Evaluates the formula.
ElementFormulaContainer< F > & operator()(int i, int j)
Exception class for assertions.
Definition: exceptions.hh:258
Interface for a formula defined element by element.
Element formula returning a matrix.
std::vector< ElementFormulaContainer< F > > formulas_
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