dune-pdelab  2.5-dev
scalarscaled.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_SCALARSCALED_HH
4 #define DUNE_PDELAB_FUNCTION_SCALARSCALED_HH
5 
7 
8 namespace Dune {
9  namespace PDELab {
10 
12 
15  template<typename GF>
17  : public GridFunctionBase<typename GF::Traits,
18  ScalarScaledGridFunctionAdapter<GF> >
19  {
20  typedef typename GF::Traits T;
22  Base;
23  typedef typename T::RangeFieldType RF;
24 
25  RF factor;
26  GF& gf;
27 
28  public:
29  typedef typename Base::Traits Traits;
30 
31  ScalarScaledGridFunctionAdapter(RF factor_, GF& gf_)
32  : factor(factor_), gf(gf_)
33  { }
34 
35  void evaluate(const typename Traits::ElementType &e,
36  const typename Traits::DomainType &x,
37  typename Traits::RangeType &y) const {
38  gf.evaluate(e,x,y);
39  y *= factor;
40  }
41 
42  const typename Traits::GridViewType& getGridView() const {
43  return gf.getGridView();
44  }
45 
46  template<typename Time>
47  void setTime(Time time) { gf.setTime(time); }
48  };
49 
50  } // namspace PDELab
51 } // namspace Dune
52 
53 #endif // DUNE_PDELAB_FUNCTION_SCALARSCALED_HH
Base::Traits Traits
Definition: scalarscaled.hh:29
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
void setTime(Time time)
Definition: scalarscaled.hh:47
const Traits::GridViewType & getGridView() const
Definition: scalarscaled.hh:42
const Entity & e
Definition: localfunctionspace.hh:111
Scale a GridFunction by a constant.
Definition: scalarscaled.hh:16
T Traits
Export type traits.
Definition: function.hh:191
ScalarScaledGridFunctionAdapter(RF factor_, GF &gf_)
Definition: scalarscaled.hh:31
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Definition: scalarscaled.hh:35
leaf of a function tree
Definition: function.hh:575