dune-pdelab  2.0.0
division.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_DIVISION_HH
4 #define DUNE_PDELAB_FUNCTION_DIVISION_HH
5 
6 #include <dune/common/static_assert.hh>
7 
9 
10 namespace Dune {
11  namespace PDELab {
12 
14 
18  template<typename GF1, typename GF2>
20  : public GridFunctionBase<typename GF1::Traits,
21  DivisionGridFunctionAdapter<GF1,GF2> >
22  {
23  dune_static_assert(GF2::Traits::dimRange == 1, "Range dimension must be "
24  "1 for the divisor of a DivisionGridFunctionAdapter");
25  typedef typename GF1::Traits T;
27  > Base;
28 
29  GF1& gf1;
30  GF2& gf2;
31 
32  public:
33  typedef typename Base::Traits Traits;
34 
35  DivisionGridFunctionAdapter(GF1& gf1_, GF2& gf2_)
36  : gf1(gf1_), gf2(gf2_)
37  { }
38 
39  void evaluate(const typename Traits::ElementType &e,
40  const typename Traits::DomainType &x,
41  typename Traits::RangeType &y) const {
42  gf1.evaluate(e,x,y);
43  typename GF2::Traits::RangeType y2;
44  gf2.evaluate(e,x,y2);
45  y /= y2;
46  }
47 
48  const typename Traits::GridViewType& getGridView() const {
49  return gf1.getGridView();
50  }
51 
52  template<typename Time>
53  void setTime(Time time) {
54  gf1.setTime(time);
55  gf2.setTime(time);
56  }
57  };
58 
59  } // namspace PDELab
60 } // namspace Dune
61 
62 #endif // DUNE_PDELAB_FUNCTION_DIVISION_HH
Base::Traits Traits
Definition: division.hh:33
DivisionGridFunctionAdapter(GF1 &gf1_, GF2 &gf2_)
Definition: division.hh:35
void setTime(Time time)
Definition: division.hh:53
leaf of a function tree
Definition: function.hh:577
const Traits::GridViewType & getGridView() const
Definition: division.hh:48
T Traits
Export type traits.
Definition: function.hh:192
Substract two GridFunctions.
Definition: division.hh:19
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Definition: division.hh:39
const E & e
Definition: interpolate.hh:172