dune-vtk 2.12
Loading...
Searching...
No Matches
componentmapper.hh
Go to the documentation of this file.
1#pragma once
2
3#include <cassert>
4#include <type_traits>
5
10
11namespace Dune::Vtk {
12
14{
15 // Evaluate a component of a vector valued data
16 template <class T, int N, int M>
17 static double map (int comp, FieldMatrix<T,N,M> const& mat)
18 {
19 int r = comp / 3;
20 int c = comp % 3;
21 return r < N && c < M ? double(mat[r][c]) : 0.0;
22 }
23
24 // Evaluate a component of a vector valued data
25 template <class T, int N>
26 static double map (int comp, FieldVector<T,N> const& vec)
27 {
28 return comp < N ? double(vec[comp]) : 0.0;
29 }
30
31 // Evaluate a component of a vector valued data
32 template <class T,
34 static double map (int comp, T const& value)
35 {
36 return value[comp];
37 }
38
39 // Return the scalar values
40 template <class T,
42 static double map (int comp, T const& value)
43 {
44 assert(comp == 0);
45 return value;
46 }
47
48
49 template <class D, class F>
50 static auto mapImpl (int comp, D const& x, F const& f, Dune::PriorityTag<2>)
51 -> decltype(f.evaluate(comp,x))
52 {
53 return f.evaluate(comp,x);
54 }
55
56 template <class D, class F>
57 static auto mapImpl (int comp, D const& x, F const& f, Dune::PriorityTag<1>)
58 -> decltype(map(comp, f(x)))
59 {
60 return map(comp, f(x));
61 }
62
63 template <class D, class F>
64 static double mapImpl (int comp, D const& x, F const& f, Dune::PriorityTag<0>)
65 {
66 DUNE_THROW(Dune::NotImplemented, "Evaluation of the grid function is not implemented");
67 return 0.0;
68 }
69
70 template <class D, class F>
71 static double map (int comp, D const& x, F const& f)
72 {
73 return mapImpl(comp,x,f,Dune::PriorityTag<3>{});
74 }
75};
76
77} // end namespace Dune::Vtk
Definition writer.hh:16
Matrix & mat
static constexpr size_type M()
static constexpr size_type N()
#define DUNE_THROW(E,...)
Definition componentmapper.hh:14
static auto mapImpl(int comp, D const &x, F const &f, Dune::PriorityTag< 1 >) -> decltype(map(comp, f(x)))
Definition componentmapper.hh:57
static auto mapImpl(int comp, D const &x, F const &f, Dune::PriorityTag< 2 >) -> decltype(f.evaluate(comp, x))
Definition componentmapper.hh:50
static double map(int comp, FieldMatrix< T, N, M > const &mat)
Definition componentmapper.hh:17
static double mapImpl(int comp, D const &x, F const &f, Dune::PriorityTag< 0 >)
Definition componentmapper.hh:64
static double map(int comp, D const &x, F const &f)
Definition componentmapper.hh:71
static double map(int comp, FieldVector< T, N > const &vec)
Definition componentmapper.hh:26
static double map(int comp, T const &value)
Definition componentmapper.hh:34