AMDiS  2.10
The Adaptive Multi-Dimensional Simulation Toolbox
FieldMatVec.hpp
1 #pragma once
2 
3 #include <amdis/common/FieldMatVec.hpp>
4 #include <amdis/operations/Arithmetic.hpp>
5 #include <amdis/operations/Basic.hpp>
6 #include <amdis/operations/CMath.hpp>
7 #include <amdis/operations/Composer.hpp>
8 
9 namespace AMDiS
10 {
11  namespace Operation
12  {
17  struct Dot
19  {
20  template <class T0, class T1, int N>
21  constexpr auto operator()(Dune::FieldVector<T0,N> const& lhs, Dune::FieldVector<T1,N> const& rhs) const
22  {
23  return lhs.dot(rhs);
24  }
25 
26  friend constexpr int order(Dot const&, int d1, int d2)
27  {
28  return d1 + d2;
29  }
30 
31  friend constexpr auto partial(Dot const&, index_t<0>)
32  {
33  return Arg<1>{};
34  }
35 
36  friend constexpr auto partial(Dot const&, index_t<1>)
37  {
38  return Arg<0>{};
39  }
40  };
41 
42  // -------------------------------------------------------------------------
43 
45  struct UnaryDot
46  {
47  template <class V>
48  constexpr auto operator()(V const& vec) const
49  {
50  using Dune::unary_dot;
51  return unary_dot(vec);
52  }
53 
54  friend constexpr int order(UnaryDot const&, int d)
55  {
56  return 2*d;
57  }
58 
59  friend auto partial(UnaryDot const&, index_t<0>)
60  {
61  return compose(Multiplies{}, StaticConstant<int,2>{}, Id{});
62  }
63  };
64 
65  // -------------------------------------------------------------------------
66 
68  struct TwoNorm
69  : public Composer<Sqrt, UnaryDot>
70  {
71  constexpr TwoNorm()
73  {}
74 
75  template <class V>
76  constexpr auto operator()(V const& vec) const
77  {
78  using Dune::two_norm;
79  return two_norm(vec);
80  }
81  };
82 
83  // -------------------------------------------------------------------------
84 
85  struct Trans
86  {
87  template <class M>
88  constexpr auto operator()(M const& mat) const
89  {
90  using Dune::trans;
91  return trans(mat);
92  }
93 
94  friend constexpr int order(Trans const&, int d)
95  {
96  return d;
97  }
98  };
99 
100 
103  } // end namespace Operation
104 } // end namespace AMDiS
Composition of Functors.
Definition: Composer.hpp:29
Definition: AdaptBase.hpp:6
Definition: FieldMatVec.hpp:85
Functor that represents A*B.
Definition: Arithmetic.hpp:100
Functor representing a static constant value.
Definition: Basic.hpp:37
(Unary-)Functor representing the euclidean 2-norm
Definition: FieldMatVec.hpp:68
(Unary-)Functor representing the euclidean dot-product
Definition: FieldMatVec.hpp:45
(Unary-)Functor representing the identity
Definition: Basic.hpp:64