frmE_matrix.hh

Go to the documentation of this file.
1 
8 #ifndef frme_matrix_hh
9 #define frme_matrix_hh
10 
11 #include "elementFormula.hh"
13 
14 namespace concepts {
15 
16  // *************************************************** FrmE_PointToMapping **
17 
33  template<int dim, class F, class G = typename Realtype<F>::type>
34  class FrmE_PointToMapping : public ElementFormula<Mapping<F,dim>,G> {
35  public:
39  bool transpose = false)
40  : frm_(frm)
41  {}
42 
43  virtual ~FrmE_PointToMapping() {}
44 
46  const Real p, const Real t = 0.0) const
47  {
48  return compute_(elm, p, t);
49  }
50 
52  const Real2d &p, const Real t = 0.0) const
53  {
54  return compute_(elm, p, t);
55  }
56 
58  const Real3d &p, const Real t = 0.0) const
59  {
60  return compute_(elm, p, t);
61  }
62 
65  }
66 
67  protected:
68  virtual std::ostream& info(std::ostream &os) const {
69  return os << concepts::typeOf(*this) << "(" << frm_ << ")";
70  }
71  private:
75  bool transpose_;
76 
77  template<class H>
79  const H& p, const Real t = 0.0) const
80  {
81  Point<F, dim*dim> point = frm_(elm, p, t);
82  DEBUGL(0, "point = " << point);
84  if (transpose_) {
85  for(uint i = 0; i < dim; ++i)
86  for(uint j = 0; j < dim; ++j)
87  m(i,j) = point[i+j*dim];
88  } else {
89  for(uint i = 0; i < dim; ++i)
90  for(uint j = 0; j < dim; ++j)
91  m(i,j) = point[j+i*dim];
92  }
93  DEBUGL(0, "m = " << m);
94  return m;
95  }
96  };
97 
98  // *************************************************** FrmE_PointsToMapping **
99 
100  template<int dim, class F, class G = typename Realtype<F>::type>
101  class FrmE_PointsToMapping : public ElementFormula<Mapping<F,dim>,G> {
102  };
103 
104  template<class F, class G>
105  class FrmE_PointsToMapping<2, F, G> : public ElementFormula<Mapping<F,2>,G> {
106  public:
109  const ElementFormulaContainer<Point<F,2>,G> frm2,
110  bool transpose = false) :
111  frm1_(frm1), frm2_(frm2), transpose_(transpose) {}
112 
114 
116  const Real p, const Real t = 0.0) const
117  {
118  const Mapping<F,2> m(frm1_(elm, p, t), frm2_(elm, p, t));
119  return transpose_ ? m.transpose() : m;
120  }
121 
123  const Real2d &p, const Real t = 0.0) const
124  {
125  const Mapping<F,2> m(frm1_(elm, p, t), frm2_(elm, p, t));
126  return transpose_ ? m.transpose() : m;
127  }
128 
130  const Real3d &p, const Real t = 0.0) const
131  {
132  const Mapping<F,2> m(frm1_(elm, p, t), frm2_(elm, p, t));
133  return transpose_ ? m.transpose() : m;
134  }
135 
137  return new FrmE_PointsToMapping<2, F, G>(frm1_, frm2_, transpose_);
138  }
139 
140  protected:
141  virtual std::ostream& info(std::ostream &os) const {
142  return os << concepts::typeOf(*this) << "(" << frm1_ << ", " << frm2_
143  << ", transpose = " << transpose_ << ")";
144  }
145  private:
150  };
151 
152  // ************************************************************* FrmE_Trace **
153 
154  template<int dim, class F, class G = typename Realtype<F>::type>
155  class FrmE_Trace : public ElementFormula<F,G> {
156  public:
159  frm_(frm) {}
160 
161  virtual ~FrmE_Trace() {}
162 
163  virtual F operator ()(const ElementWithCell<G> &elm,
164  const Real p, const Real t = 0.0) const
165  {
166  return frm_(elm, p, t).trace();
167  }
168 
169  virtual F operator ()(const ElementWithCell<G> &elm,
170  const Real2d &p, const Real t = 0.0) const
171  {
172  return frm_(elm, p, t).trace();
173  }
174 
175  virtual F operator ()(const ElementWithCell<G> &elm,
176  const Real3d &p, const Real t = 0.0) const
177  {
178  return frm_(elm, p, t).trace();
179  }
180 
181  virtual FrmE_Trace<dim,F,G>* clone() const {
182  return new FrmE_Trace<dim, F, G>(frm_);
183  }
184 
185  protected:
186  virtual std::ostream& info(std::ostream &os) const {
187  return os << concepts::typeOf(*this) << "(" << frm_ << ")";
188  }
189  private:
192  };
193 
194 } // namespace concepts
195 
196 #endif // frme_matrix_hh
virtual Mapping< F, dim > operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
Definition: frmE_matrix.hh:45
Class which maps an element formula of type Point (a vector) to one of type Mapping (a matrix).
Definition: frmE_matrix.hh:34
Basic class for a Point or a vector.
Mapping< F, dim > compute_(const ElementWithCell< G > &elm, const H &p, const Real t=0.0) const
Definition: frmE_matrix.hh:78
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: frmE_matrix.hh:186
ElementFormulaContainer< Mapping< F, dim >, G > frm_
The element formula of the matrix.
Definition: frmE_matrix.hh:191
bool transpose_
The flag if the transposed is to be taken.
Definition: frmE_matrix.hh:75
virtual FrmE_Trace< dim, F, G > * clone() const
Virtual constructor.
Definition: frmE_matrix.hh:181
Element with cell.
#define DEBUGL(doit, msg)
ElementFormulaContainer< Point< F, dim *dim >, G > frm_
The original formula.
Definition: frmE_matrix.hh:73
bool transpose_
Flag if the transpose of the matrix has to be taken.
Definition: frmE_matrix.hh:149
Mapping< F, DimX, DimY > transpose() const
Returns the transpose of the matrix.
Interface for a formula defined element by element.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: frmE_matrix.hh:68
Mapping< F, dim > & transpose(Mapping< F, dim > &m)
Definition: operations.hh:54
FrmE_PointsToMapping(const ElementFormulaContainer< Point< F, 2 >, G > frm1, const ElementFormulaContainer< Point< F, 2 >, G > frm2, bool transpose=false)
Constructor with two vectors.
Definition: frmE_matrix.hh:108
FrmE_Trace(const ElementFormulaContainer< Mapping< F, dim >, G > frm)
Constructor with an element formula giving back a mapping.
Definition: frmE_matrix.hh:158
ElementFormulaContainer< Point< F, 2 >, G > frm2_
Definition: frmE_matrix.hh:147
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: frmE_matrix.hh:141
virtual F operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
Definition: frmE_matrix.hh:163
virtual Mapping< F, dim > operator()(const ElementWithCell< typename Realtype< F >::type > &elm, const Real p, const Real t=0.0) const=0
Evaluates the formula.
FrmE_PointToMapping(const ElementFormulaContainer< Point< F, dim *dim >, G > &frm, bool transpose=false)
Constructor.
Definition: frmE_matrix.hh:38
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
virtual FrmE_PointsToMapping< 2, F, G > * clone() const
Virtual constructor.
Definition: frmE_matrix.hh:136
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
virtual FrmE_PointToMapping< dim, F, G > * clone() const
Virtual constructor.
Definition: frmE_matrix.hh:63
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