dune-pdelab  2.0.0
sqrt.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_FUNCTION_SQRT_HH
4 #define DUNE_PDELAB_FUNCTION_SQRT_HH
5 
6 #include <dune/common/static_assert.hh>
7 
9 
10 namespace Dune {
11  namespace PDELab {
12 
14 
17  template<typename GF>
19  : public GridFunctionBase<typename GF::Traits,
20  SqrtGridFunctionAdapter<GF> >
21  {
22  dune_static_assert(GF::Traits::dimRange == 1, "Dimension of range must "
23  "be 1 to take the sqrt");
24 
25  typedef typename GF::Traits T;
27  Base;
28  typedef typename T::RangeFieldType RF;
29 
30  GF& gf;
31 
32  public:
33  typedef typename Base::Traits Traits;
34 
36  : gf(gf_)
37  { }
38 
39  void evaluate(const typename Traits::ElementType &e,
40  const typename Traits::DomainType &x,
41  typename Traits::RangeType &y) const {
42  gf.evaluate(e,x,y);
43  y[0] = std::sqrt(y[0]);
44  }
45 
46  const typename Traits::GridViewType& getGridView() const {
47  return gf.getGridView();
48  }
49 
50  template<typename Time>
51  void setTime(Time time) { gf.setTime(time); }
52  };
53 
54  } // namspace PDELab
55 } // namspace Dune
56 
57 #endif // DUNE_PDELAB_FUNCTION_SQRT_HH
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Definition: sqrt.hh:39
const Traits::GridViewType & getGridView() const
Definition: sqrt.hh:46
leaf of a function tree
Definition: function.hh:577
Base::Traits Traits
Definition: sqrt.hh:33
T Traits
Export type traits.
Definition: function.hh:192
void setTime(Time time)
Definition: sqrt.hh:51
SqrtGridFunctionAdapter(GF &gf_)
Definition: sqrt.hh:35
const E & e
Definition: interpolate.hh:172
Take sqrt of a GridFunction.
Definition: sqrt.hh:18