AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Derivative.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <amdis/common/Concepts.hpp>
6#include <amdis/common/DerivativeTraits.hpp>
7#include <amdis/common/Index.hpp>
8
9namespace AMDiS
10{
12 template <class LocalFunction, class Type,
13 REQUIRES(std::is_convertible_v<tag::derivative_type, Type>)>
14 auto derivativeOf(LocalFunction const& lf, Type const& type)
15 -> decltype(lf.makeDerivative(type))
16 {
17 return lf.makeDerivative(type);
18 }
19
22 template <class LocalFunction>
23 auto derivative(LocalFunction const& lf)
24 -> decltype(lf.makeDerivative(tag::gradient{}))
25 {
26 return lf.makeDerivative(tag::gradient{});
27 }
28
29
30 namespace Concepts
31 {
36 namespace Definition
37 {
39 {
40 template <class F, class T>
41 auto require(F&& f, T&& t) -> decltype( derivativeOf(f,t) );
42 };
43
45 {
46 template <class F, class T>
47 auto require(F&& f, T&& t) -> decltype( derivativeOf(localFunction(f),t) );
48 };
49
51 {
52 template <class F, class I>
53 auto require(F&& f, I&& i) -> decltype( partial(f, i) );
54 };
55
56 } // end namespace Definition
57
58
60 template <class GF, class Type>
61 constexpr bool HasDerivative = models<Definition::HasDerivative(GF,Type)>;
62
63 template <class GF, class Type>
64 using HasDerivative_t = models_t<Definition::HasDerivative(GF,Type)>;
65
66
68 template <class GF, class Type>
70
71 template <class GF, class Type>
72 using HasLocalFunctionDerivative_t = models_t<Definition::HasLocalFunctionDerivative(GF,Type)>;
73
74
76 template <class F>
77 constexpr bool HasPartial = models<Definition::HasPartial(F,index_t<0>)>;
78
79 template <class F>
80 using HasPartial_t = models_t<Definition::HasPartial(F,index_t<0>)>;
81
84 } // end namespace Concepts
85
86} // end namespace AMDiS
constexpr bool HasDerivative
GridFunction GF has free function derivativeOf(F,type)
Definition: Derivative.hpp:61
constexpr bool HasLocalFunctionDerivative
GridFunction GF has free function derivativeOf(localFunction(F))
Definition: Derivative.hpp:69
constexpr bool HasPartial
Functor F has free function partial(F,_0)
Definition: Derivative.hpp:77
Definition: Derivative.hpp:39
Definition: Derivative.hpp:51