dune-vtk 2.12
Loading...
Searching...
No Matches
gridfunctions/common.hh
Go to the documentation of this file.
1#pragma once
2
6
7namespace Dune::Vtk
8{
10 struct PointContext {};
11
13 struct CellContext {};
14
16
26 template <class GridCreator, class Range, class Context>
28 {
29 using type = void;
30 };
31
32
33 template <class Element, class Range, class Domain>
35 {
36 using DerivativeRange = typename Functions::DefaultDerivativeTraits<Range(Domain)>::Range;
37 void bind (Element const& element) { /* do nothing */ };
38 void unbind () { /* do nothing */ }
39 DerivativeRange operator() (Domain const& local) const
40 {
42 "The derivative is not implemented.");
43 }
44 };
45
46 namespace Impl
47 {
48 template <class Range>
49 struct ConstructRange
50 {
51 template <class Field>
52 static Range apply (int size, Field const& value);
53 };
54
55
56 template <class Range, class Field>
57 Range constructRange (int size, Field const& value)
58 {
59 return ConstructRange<Range>::apply (size,value);
60 }
61
62 template <class T, int n>
63 struct ConstructRange<Dune::FieldVector<T,n>>
64 {
65 template <class Field>
66 static Dune::FieldVector<T,n> apply ([[maybe_unused]] int size, Field const& value)
67 {
68 assert(size == n);
69 return Dune::FieldVector<T,n>(value);
70 }
71 };
72
73 template <class T>
74 struct ConstructRange<Dune::DynamicVector<T>>
75 {
76 template <class Field>
77 static Dune::DynamicVector<T> apply (int size, Field const& value)
78 {
79 return Dune::DynamicVector<T>(size,T(value));
80 }
81 };
82
83
84 template <class Range>
85 struct ResizeRange
86 {
87 static void apply (Range& range, int size);
88 };
89
90
91 template <class Range>
92 void resizeRange (Range& range, int size)
93 {
94 ResizeRange<Range>::apply(range,size);
95 }
96
97 template <class T, int n>
98 struct ResizeRange<Dune::FieldVector<T,n>>
99 {
100 static void apply ([[maybe_unused]] Dune::FieldVector<T,n>& range, [[maybe_unused]] int size)
101 {
102 assert(n == size);
103 }
104 };
105
106 template <class T>
107 struct ResizeRange<Dune::DynamicVector<T>>
108 {
109 static void apply (Dune::DynamicVector<T>& range, int size)
110 {
111 range.resize(size);
112 }
113 };
114
115 } // end namespace Impl
116
117} // end namespace Dune::Vtk
Definition writer.hh:16
int size() const
static constexpr IntegralRange< T > range(T from, T to) noexcept
virtual void operator()()=0
#define DUNE_THROW(E,...)
LocalIndex & local()
Context indicating that a GridFunction generates a local-function from point data.
Definition gridfunctions/common.hh:10
Context indicating that a GridFunction generates a local-function from cell data.
Definition gridfunctions/common.hh:13
Type-Traits to associate a GridFunction to a GridCreator.
Definition gridfunctions/common.hh:28
void type
Definition gridfunctions/common.hh:29
Definition gridfunctions/common.hh:35
void unbind()
Definition gridfunctions/common.hh:38
void bind(Element const &element)
Definition gridfunctions/common.hh:37
typename Functions::DefaultDerivativeTraits< Range(Domain)>::Range DerivativeRange
Definition gridfunctions/common.hh:36
T apply(T... args)