DerivativeGridFunction.hpp 1.71 KB
 Praetorius, Simon committed Dec 20, 2017 1 2 3 4 5 6 #pragma once #include #include  Praetorius, Simon committed Dec 21, 2017 7 8 #include  Praetorius, Simon committed Dec 20, 2017 9 10 11 namespace AMDiS { /**  Praetorius, Simon committed Dec 21, 2017 12  * \addtogroup GridFunctions  Praetorius, Simon committed Dec 20, 2017 13 14 15 16 17 18 19 20 21 22 23 24 25  * @{ **/ /// \brief A Gridfunction that returns the derivative when calling localFunction template class DerivativeGridFunction { using GridFctRange = typename GridFct::Range; using GridFctDomain = typename GridFct::Domain; public: using Range = typename Dune::Functions::DefaultDerivativeTraits::Range; using Domain = GridFctDomain;  Praetorius, Simon committed Dec 21, 2017 26  using LocalFunction = std::decay_t())))>;  Praetorius, Simon committed Dec 20, 2017 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42  using EntitySet = typename GridFct::EntitySet; public: explicit DerivativeGridFunction(GridFct const& gridFct) : gridFct_(gridFct) {} Range operator()(Domain const& x) const { error_exit("Not implemented"); return Range(0); } friend LocalFunction localFunction(DerivativeGridFunction const& gf) {  Praetorius, Simon committed Dec 21, 2017 43 44 45 46 47 48  return derivative(localFunction(gf.gridFct_)); } friend int order(DerivativeGridFunction const& gf) { return std::max(0, order(gf.gridFct_)-1);  Praetorius, Simon committed Dec 20, 2017 49 50 51 52 53 54 55 56 57 58 59 60 61  } EntitySet const& entitySet() const { return gridFct_.entitySet(); } private: GridFct gridFct_; }; /// Generator function for \ref DerivativeGridFunction expressions  Praetorius, Simon committed Dec 21, 2017 62 63 64 65  template && Concepts::HasLocalFunctionDerivative)> auto derivative(GridFct const& gridFct)  Praetorius, Simon committed Dec 20, 2017 66  {  Praetorius, Simon committed Dec 21, 2017 67  return DerivativeGridFunction{gridFct};  Praetorius, Simon committed Dec 20, 2017 68 69 70 71 72  } /** @} **/ } // end namespace AMDiS