DerivativeTraits.hpp 1.18 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include <dune/functions/common/defaultderivativetraits.hh>

namespace Dune
{
  template <class K, int n>
  class FieldVector;

  template <class K, int n, int m>
  class FieldMatrix;
}

namespace AMDiS
{
  namespace tag
  {
    struct gradient {};
    struct divergence {};
    struct partial { std::size_t comp = 0; };

    // register possible types for derivative traits
    struct derivative_type : gradient, divergence, partial {};
  }

  template <class Sig, class Type>
  struct DerivativeTraits;

  template <class R, class D>
  struct DerivativeTraits<R(D), tag::gradient>
      : public Dune::Functions::DefaultDerivativeTraits<R(D)>
  {};

  template <class R, class D>
  struct DerivativeTraits<R(D), tag::partial>
  {
    using Range = R;
  };

  template <class K, class D>
  struct DerivativeTraits<K(D), tag::divergence>
  {
    // error
  };

  template <class K, int n, class D>
  struct DerivativeTraits<Dune::FieldVector<K,n>(D), tag::divergence>
  {
    using Range = K;
  };

  template <class K, int n, int m, class D>
  struct DerivativeTraits<Dune::FieldMatrix<K,n,m>(D), tag::divergence>
  {
    using Range = Dune::FieldVector<K,m>;
  };

} // end namespace AMDiS