Derivative.hpp 2.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include <type_traits>

#include <amdis/common/Concepts.hpp>
#include <amdis/common/DerivativeTraits.hpp>
#include <amdis/common/Index.hpp>

namespace AMDiS
{
  /// The derivative of a localfunction as localfunction itself
  template <class LocalFunction, class Type,
    REQUIRES(std::is_convertible<tag::derivative_type, Type>::value),
    class = void_t<decltype(std::declval<LocalFunction>().makeDerivative(std::declval<Type>()))> >
  auto derivative(LocalFunction const& lf, Type const& type)
  {
    return lf.makeDerivative(type);
  }

  namespace Concepts
  {
    /** \addtogroup Concepts
     *  @{
     **/

    namespace Definition
    {
      struct HasDerivative
      {
        template <class F, class T>
Praetorius, Simon's avatar
Praetorius, Simon committed
31
        auto require(F&& f, T&& t) -> decltype( derivative(f,t) );
32
33
34
35
36
      };

      struct HasLocalFunctionDerivative
      {
        template <class F, class T>
Praetorius, Simon's avatar
Praetorius, Simon committed
37
        auto require(F&& f, T&& t) -> decltype( derivative(localFunction(f),t) );
38
39
40
41
42
      };

      struct HasPartial
      {
        template <class F, class I>
Praetorius, Simon's avatar
Praetorius, Simon committed
43
        auto require(F&& f, I&& i) -> decltype( partial(f, i) );
44
45
46
47
48
49
50
51
52
      };

    } // end namespace Definition


    /// \brief GridFunction GF has free function `derivative(F)`
    template <class GF, class Type>
    constexpr bool HasDerivative = models<Definition::HasDerivative(GF,Type)>;

Praetorius, Simon's avatar
Praetorius, Simon committed
53
54
55
56
    template <class GF, class Type>
    using HasDerivative_t = models_t<Definition::HasDerivative(GF,Type)>;


57
58
59
60
    /// \brief GridFunction GF has free function `derivative(localFunction(F))`
    template <class GF, class Type>
    constexpr bool HasLocalFunctionDerivative = models<Definition::HasLocalFunctionDerivative(GF,Type)>;

Praetorius, Simon's avatar
Praetorius, Simon committed
61
62
63
64
    template <class GF, class Type>
    using HasLocalFunctionDerivative_t = models_t<Definition::HasLocalFunctionDerivative(GF,Type)>;


65
66
67
68
    /// \brief Functor F has free function `partial(F,_0)`
    template <class F>
    constexpr bool HasPartial = models<Definition::HasPartial(F,index_t<0>)>;

Praetorius, Simon's avatar
Praetorius, Simon committed
69
70
71
    template <class F>
    using HasPartial_t = models_t<Definition::HasPartial(F,index_t<0>)>;

72
73
74
75
76
    /** @} **/

  } // end namespace Concepts

} // end namespace AMDiS