GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/io/vtk/function.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 98 108 90.7%
Functions: 635 3311 19.2%
Branches: 230 958 24.0%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup InputOutput
10 * \brief Dune style VTK functions
11 */
12 #ifndef DUMUX_IO_VTK_FUNCTION_HH
13 #define DUMUX_IO_VTK_FUNCTION_HH
14
15 #include <string>
16 #include <memory>
17
18 #include <dune/common/typetraits.hh>
19 #include <dune/common/fvector.hh>
20 #include <dune/common/reservedvector.hh>
21
22 #include <dune/grid/common/mcmgmapper.hh>
23 #include <dune/grid/io/file/vtk/common.hh>
24 #include <dune/grid/io/file/vtk/function.hh>
25
26 #include <dumux/io/vtk/precision.hh>
27 #include <dumux/discretization/nonconformingfecache.hh>
28
29 namespace Dumux::Vtk {
30
31 namespace Detail {
32
33 template<class Field>
34 99421 double accessEntry(const Field& f, [[maybe_unused]] int mycomp, [[maybe_unused]] int i)
35 {
36 if constexpr (Dune::IsIndexable<std::decay_t<decltype(std::declval<Field>()[0])>>{})
37 {
38 if constexpr (Dune::IsIndexable<std::decay_t<decltype(std::declval<Field>()[0][0])>>{})
39 DUNE_THROW(Dune::InvalidStateException, "Invalid field type");
40 else
41 12835078 return f[i][mycomp];
42 }
43 else
44 128467713 return f[i];
45 }
46
47 } // end namespace Detail
48
49 /*!
50 * \ingroup InputOutput
51 * \brief a VTK function that supports both scalar and vector values for each element
52 *
53 * \tparam GridView The Dune grid view type
54 * \tparam Mapper The type used for mapping elements to indices in the field
55 * \tparam F The field type (either vector of scalars or vectors)
56 */
57 template <typename GridView, typename Mapper, typename F>
58 struct VectorP0VTKFunction : Dune::VTKFunction<GridView>
59 {
60 enum { dim = GridView::dimension };
61 using ctype = typename GridView::ctype;
62 using Element = typename GridView::template Codim<0>::Entity;
63
64 public:
65
66 //! return number of components
67 374898 int ncomps() const final { return nComps_; }
68
69 //! get name
70 386867 std::string name() const final { return name_; }
71
72 //! evaluate
73 119312866 double evaluate(int mycomp, const Element& e, const Dune::FieldVector<ctype, dim>&) const final
74 119312866 { return Detail::accessEntry(field_, mycomp, mapper_.index(e)); }
75
76 //! get output precision for the field
77 128207 Dumux::Vtk::Precision precision() const final
78 128207 { return precision_; }
79
80 //! Constructor
81 116739 VectorP0VTKFunction(const GridView& gridView,
82 const Mapper& mapper,
83 const F& field,
84 const std::string& name,
85 int nComps,
86 Dumux::Vtk::Precision precision = Dumux::Vtk::Precision::float32)
87
2/3
✓ Branch 1 taken 532 times.
✓ Branch 2 taken 57846 times.
✗ Branch 3 not taken.
116739 : field_(field), name_(name), nComps_(nComps), mapper_(mapper), precision_(precision)
88 {
89
3/5
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 57846 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 532 times.
117803 if (field.size()!=(unsigned int)(mapper.size()))
90 DUNE_THROW(Dune::IOError, "VectorP0VTKFunction: size mismatch between field "
91 << name << " (" << field.size() << ") and mapper (" << mapper.size() << ")");
92 116739 }
93
94 private:
95 const F& field_;
96 const std::string name_;
97 int nComps_;
98 const Mapper& mapper_;
99 Dumux::Vtk::Precision precision_;
100 };
101
102 /*!
103 * \ingroup InputOutput
104 * \brief a VTK function that supports both scalar and vector values for each vertex
105 *
106 * \tparam GridView The Dune grid view type
107 * \tparam Mapper The type used for mapping vertices to indices in the field
108 * \tparam F The field type (either vector of scalars or vectors)
109 */
110 template <typename GridView, typename Mapper, typename F>
111 struct VectorP1VTKFunction : Dune::VTKFunction<GridView>
112 {
113 enum { dim = GridView::dimension };
114 using ctype = typename GridView::ctype;
115 using Element = typename GridView::template Codim<0>::Entity;
116
117 public:
118
119 //! return number of components
120 193961 int ncomps() const final { return nComps_; }
121
122 //! get name
123 196402 std::string name() const final { return name_; }
124
125 //! evaluate
126 41604476 double evaluate(int mycomp, const Element& e, const Dune::FieldVector<ctype, dim>& xi) const final
127 {
128 41604476 const unsigned int dim = Element::mydimension;
129 41604476 const unsigned int nVertices = e.subEntities(dim);
130
131 41604476 std::vector<Dune::FieldVector<ctype, 1>> cornerValues(nVertices);
132
2/2
✓ Branch 0 taken 81611158 times.
✓ Branch 1 taken 20806072 times.
204797896 for (unsigned i = 0; i < nVertices; ++i)
133
1/2
✓ Branch 1 taken 81602728 times.
✗ Branch 2 not taken.
163193420 cornerValues[i] = Detail::accessEntry(field_, mycomp, mapper_.subIndex(e, i, dim));
134
135 // (Ab)use the MultiLinearGeometry class to do multi-linear interpolation between scalars
136
1/2
✓ Branch 1 taken 20806072 times.
✗ Branch 2 not taken.
41604476 const Dune::MultiLinearGeometry<ctype, dim, 1> interpolation(e.type(), std::move(cornerValues));
137
1/2
✓ Branch 1 taken 20769646 times.
✗ Branch 2 not taken.
41677328 return interpolation.global(xi);
138 83136100 }
139
140 //! get output precision for the field
141 65118 Dumux::Vtk::Precision precision() const final
142 65118 { return precision_; }
143
144 //! Constructor
145 60492 VectorP1VTKFunction(const GridView& gridView,
146 const Mapper& mapper,
147 const F& field,
148 const std::string& name,
149 int nComps,
150 Dumux::Vtk::Precision precision = Dumux::Vtk::Precision::float32)
151
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 30238 times.
✗ Branch 3 not taken.
60492 : field_(field), name_(name), nComps_(nComps), mapper_(mapper), precision_(precision)
152 {
153
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 30247 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
60516 if (field.size()!=(unsigned int)( mapper.size() ))
154 DUNE_THROW(Dune::IOError, "VectorP1VTKFunction: size mismatch between field "
155 << name << " (" << field.size() << ") and mapper (" << mapper.size() << ")");
156 60492 }
157 private:
158 const F& field_;
159 const std::string name_;
160 int nComps_;
161 const Mapper& mapper_;
162 Dumux::Vtk::Precision precision_;
163 };
164
165 /*!
166 * \ingroup InputOutput
167 * \brief A VTK function that supports both scalar and vector values for each vertex.
168 * This expects the data to be organized by a two-dimensional field storing for
169 * each element the element-local nodal values. This can be used for the output
170 * of fields that are non-conforming due to e.g. constitutive relationships and
171 * where no extra degrees of freedom exist to display the discontinuities.
172 *
173 * \tparam GridView The Dune grid view type
174 * \tparam Mapper The type used for mapping elements to indices in the field
175 * \tparam F The field type (either vector of scalars or vectors)
176 */
177 template <typename GridView, typename Mapper, typename F>
178 struct VectorP1NonConformingVTKFunction : Dune::VTKFunction<GridView>
179 {
180 enum { dim = GridView::dimension };
181 using ctype = typename GridView::ctype;
182 using Element = typename GridView::template Codim<0>::Entity;
183
184 public:
185
186 //! return number of components
187 21732 int ncomps() const final { return nComps_; }
188
189 //! get name
190 8132 std::string name() const final { return name_; }
191
192 //! evaluate
193 20248256 double evaluate(int mycomp, const Element& e, const Dune::FieldVector<ctype, dim>& xi) const final
194 {
195 20248256 const unsigned int dim = Element::mydimension;
196 20248256 const unsigned int nVertices = e.subEntities(dim);
197
198 20248256 std::vector<Dune::FieldVector<ctype, 1>> cornerValues(nVertices);
199
2/2
✓ Branch 0 taken 34338624 times.
✓ Branch 1 taken 10124128 times.
88925504 for (unsigned i = 0; i < nVertices; ++i)
200
1/2
✓ Branch 1 taken 29244464 times.
✗ Branch 2 not taken.
68677248 cornerValues[i] = accessEntry_(mycomp, mapper_.index(e), i);
201
202 // (Ab)use the MultiLinearGeometry class to do multi-linear interpolation between scalars
203
1/2
✓ Branch 1 taken 10124128 times.
✗ Branch 2 not taken.
20248256 const Dune::MultiLinearGeometry<ctype, dim, 1> interpolation(e.type(), std::move(cornerValues));
204
1/2
✓ Branch 1 taken 10124128 times.
✗ Branch 2 not taken.
20248256 return interpolation.global(xi);
205 40496512 }
206
207 //! get output precision for the field
208 7244 Dumux::Vtk::Precision precision() const final
209 7244 { return precision_; }
210
211 //! Constructor
212 7244 VectorP1NonConformingVTKFunction(const GridView& gridView,
213 const Mapper& mapper,
214 const F& field,
215 const std::string& name,
216 int nComps,
217 Dumux::Vtk::Precision precision = Dumux::Vtk::Precision::float32)
218
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3622 times.
✗ Branch 3 not taken.
7244 : field_(field), name_(name), nComps_(nComps), mapper_(mapper), precision_(precision)
219 {
220
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3622 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
7244 if (field.size()!=(unsigned int)(mapper.size()))
221 DUNE_THROW(Dune::IOError, "VectorP1NonConformingVTKFunction: size mismatch between field "
222 << name << " (" << field.size() << ") and mapper (" << mapper.size() << ")");
223 7244 }
224 private:
225 //! access to the field
226 34338624 double accessEntry_([[maybe_unused]] int mycomp, [[maybe_unused]] int eIdx, [[maybe_unused]] int cornerIdx) const
227 {
228 if constexpr (Dune::IsIndexable<decltype(std::declval<F>()[0])>{})
229 {
230 if constexpr (Dune::IsIndexable<decltype(std::declval<F>()[0][0])>{})
231 return field_[eIdx][cornerIdx][mycomp];
232 else
233 34338624 return field_[eIdx][cornerIdx];
234 }
235 else
236 DUNE_THROW(Dune::InvalidStateException, "Invalid field type");
237 }
238
239 const F& field_;
240 const std::string name_;
241 int nComps_;
242 const Mapper& mapper_;
243 Dumux::Vtk::Precision precision_;
244
245 };
246
247 /*!
248 * \ingroup InputOutput
249 * \brief A VTK function that supports both scalar and vector values for each face.
250 * This expects the data to be organized by a two-dimensional field storing for
251 * each element the element-local nodal values. Used for non-conforming spaces
252 * such as Rannacher-Turek and Crouzeix-Raviart.
253 *
254 * \tparam GridView The Dune grid view type
255 * \tparam Mapper The type used for mapping elements to indices in the field
256 * \tparam F The field type (either vector of scalars or vectors)
257 */
258 template <typename GridView, typename Mapper, typename F>
259 struct VectorP1FaceNonConformingVTKFunction : Dune::VTKFunction<GridView>
260 {
261 static constexpr int dim = GridView::dimension;
262 using ctype = typename GridView::ctype;
263 using Element = typename GridView::template Codim<0>::Entity;
264
265 public:
266
267 //! return number of components
268 96 int ncomps() const final { return nComps_; }
269
270 //! get name
271 108 std::string name() const final { return name_; }
272
273 //! evaluate
274 1560064 double evaluate(int mycomp, const Element& e, const Dune::FieldVector<ctype, dim>& localPos) const final
275 {
276 1560064 const unsigned int dim = Element::mydimension;
277 4219456 const unsigned int nFaces = e.subEntities(1);
278
279 // assemble coefficient vector
280 using Coefficients = Dune::ReservedVector<ctype, 2*dim>;
281
2/2
✓ Branch 0 taken 2340096 times.
✓ Branch 1 taken 780032 times.
6240256 Coefficients faceValues;
282
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1560064 faceValues.resize(nFaces);
283
2/2
✓ Branch 0 taken 3120128 times.
✓ Branch 1 taken 780032 times.
7800320 for (int i = 0; i < nFaces; ++i)
284 6240256 faceValues[i] = accessEntry_(mycomp, mapper_.index(e), i);
285
286 using ShapeValues = std::vector<Dune::FieldVector<ctype, 1>>;
287 1560064 ShapeValues N;
288
4/11
✓ Branch 1 taken 780032 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 780032 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 780032 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 443232 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 9 not taken.
1560064 feCache_.get(e.type()).localBasis().evaluateFunction(localPos, N);
289 1560064 double result = 0.0;
290
2/2
✓ Branch 0 taken 3120128 times.
✓ Branch 1 taken 780032 times.
7800320 for (int i = 0; i < N.size(); ++i)
291 6240256 result += faceValues[i]*N[i];
292
1/2
✓ Branch 0 taken 780032 times.
✗ Branch 1 not taken.
1560064 return result;
293 1560064 }
294
295 //! get output precision for the field
296 36 Dumux::Vtk::Precision precision() const final
297 36 { return precision_; }
298
299 //! Constructor
300 36 VectorP1FaceNonConformingVTKFunction(
301 const GridView& gridView,
302 const Mapper& mapper,
303 const F& field,
304 const std::string& name,
305 int nComps,
306 Dumux::Vtk::Precision precision = Dumux::Vtk::Precision::float32
307 )
308
1/2
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
36 : field_(field), name_(name), nComps_(nComps), mapper_(mapper), precision_(precision)
309 {
310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
36 if (field.size()!=(unsigned int)(mapper.size()))
311 DUNE_THROW(Dune::IOError, "VectorP1FaceNonConformingVTKFunction: size mismatch between field "
312 << name << " (" << field.size() << ") and mapper (" << mapper.size() << ")");
313 36 }
314 private:
315 //! access to the field
316 3120128 double accessEntry_([[maybe_unused]] int mycomp, [[maybe_unused]] int eIdx, [[maybe_unused]] int faceIdx) const
317 {
318 if constexpr (Dune::IsIndexable<decltype(std::declval<F>()[0])>{})
319 {
320 if constexpr (Dune::IsIndexable<decltype(std::declval<F>()[0][0])>{})
321 1344000 return field_[eIdx][faceIdx][mycomp];
322 else
323 1776128 return field_[eIdx][faceIdx];
324 }
325 else
326 DUNE_THROW(Dune::InvalidStateException, "Invalid field type");
327 }
328
329 const F& field_;
330 const std::string name_;
331 int nComps_;
332 const Mapper& mapper_;
333 Dumux::Vtk::Precision precision_;
334 NonconformingFECache<ctype, ctype, dim> feCache_ = {};
335 };
336
337 /*!
338 * \ingroup InputOutput
339 * \brief struct that can hold any field that fulfills the VTKFunction interface
340 *
341 * \tparam GridView The Dune grid view type
342 */
343 template<class GridView>
344
152/507
✓ Branch 0 taken 40831 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2190 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 2218 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3346 times.
✓ Branch 11 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 28722 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 9 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 677 times.
✓ Branch 23 taken 3931 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 674 times.
✓ Branch 26 taken 123 times.
✓ Branch 27 taken 36 times.
✓ Branch 28 taken 2652 times.
✓ Branch 30 taken 222 times.
✓ Branch 31 taken 6 times.
✓ Branch 33 taken 526 times.
✓ Branch 34 taken 104 times.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✓ Branch 41 taken 571 times.
✓ Branch 42 taken 7 times.
✓ Branch 43 taken 53 times.
✓ Branch 44 taken 47 times.
✓ Branch 45 taken 72 times.
✓ Branch 46 taken 480 times.
✓ Branch 47 taken 21 times.
✓ Branch 48 taken 1773 times.
✓ Branch 49 taken 50 times.
✓ Branch 50 taken 2 times.
✓ Branch 51 taken 1812 times.
✓ Branch 53 taken 1750 times.
✓ Branch 54 taken 69 times.
✓ Branch 56 taken 140 times.
✗ Branch 57 not taken.
✓ Branch 59 taken 119 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 17 times.
✓ Branch 62 taken 12 times.
✓ Branch 63 taken 5 times.
✓ Branch 64 taken 16 times.
✓ Branch 65 taken 184 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 6 times.
✓ Branch 68 taken 25 times.
✓ Branch 69 taken 102 times.
✗ Branch 70 not taken.
✓ Branch 71 taken 14 times.
✓ Branch 72 taken 19 times.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 114 times.
✓ Branch 77 taken 6 times.
✓ Branch 79 taken 32 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 35 times.
✓ Branch 83 taken 4 times.
✓ Branch 84 taken 1 times.
✓ Branch 85 taken 22 times.
✗ Branch 86 not taken.
✓ Branch 87 taken 3 times.
✓ Branch 88 taken 6 times.
✓ Branch 89 taken 11 times.
✓ Branch 90 taken 3 times.
✓ Branch 91 taken 1 times.
✓ Branch 92 taken 9 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 24 times.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✓ Branch 97 taken 1 times.
✓ Branch 99 taken 43 times.
✓ Branch 100 taken 2 times.
✓ Branch 102 taken 2 times.
✗ Branch 103 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✓ Branch 108 taken 43 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 2 times.
✓ Branch 111 taken 19 times.
✗ Branch 112 not taken.
✓ Branch 113 taken 7 times.
✗ Branch 114 not taken.
✓ Branch 115 taken 12 times.
✗ Branch 116 not taken.
✓ Branch 117 taken 2 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✓ Branch 122 taken 5 times.
✗ Branch 123 not taken.
✓ Branch 125 taken 1 times.
✗ Branch 126 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✓ Branch 138 taken 16 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 2 times.
✓ Branch 141 taken 33 times.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✓ Branch 145 taken 1 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 1 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 11 times.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✓ Branch 161 taken 19 times.
✗ Branch 162 not taken.
✓ Branch 163 taken 2 times.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✓ Branch 168 taken 1 times.
✗ Branch 169 not taken.
✓ Branch 171 taken 1 times.
✗ Branch 172 not taken.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✓ Branch 184 taken 10 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 2 times.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✓ Branch 191 taken 1 times.
✗ Branch 192 not taken.
✓ Branch 194 taken 1 times.
✗ Branch 195 not taken.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✓ Branch 207 taken 13 times.
✗ Branch 208 not taken.
✓ Branch 209 taken 2 times.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✓ Branch 214 taken 1 times.
✗ Branch 215 not taken.
✓ Branch 217 taken 1 times.
✗ Branch 218 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✓ Branch 230 taken 17 times.
✗ Branch 231 not taken.
✓ Branch 232 taken 2 times.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✓ Branch 237 taken 1 times.
✗ Branch 238 not taken.
✓ Branch 240 taken 1 times.
✗ Branch 241 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 20 times.
✗ Branch 254 not taken.
✓ Branch 255 taken 2 times.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✓ Branch 260 taken 1 times.
✗ Branch 261 not taken.
✓ Branch 263 taken 1 times.
✗ Branch 264 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✗ Branch 274 not taken.
✗ Branch 275 not taken.
✓ Branch 276 taken 15 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 2 times.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✓ Branch 283 taken 1 times.
✗ Branch 284 not taken.
✓ Branch 286 taken 1 times.
✗ Branch 287 not taken.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✓ Branch 299 taken 18 times.
✗ Branch 300 not taken.
✓ Branch 301 taken 2 times.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✓ Branch 306 taken 1 times.
✗ Branch 307 not taken.
✓ Branch 309 taken 1 times.
✗ Branch 310 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✓ Branch 322 taken 22 times.
✗ Branch 323 not taken.
✓ Branch 324 taken 2 times.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✓ Branch 329 taken 1 times.
✗ Branch 330 not taken.
✓ Branch 332 taken 1 times.
✗ Branch 333 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✓ Branch 345 taken 25 times.
✗ Branch 346 not taken.
✓ Branch 347 taken 2 times.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✓ Branch 352 taken 1 times.
✗ Branch 353 not taken.
✓ Branch 355 taken 1 times.
✗ Branch 356 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✓ Branch 368 taken 11 times.
✗ Branch 369 not taken.
✓ Branch 370 taken 2 times.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✓ Branch 375 taken 1 times.
✗ Branch 376 not taken.
✓ Branch 378 taken 1 times.
✗ Branch 379 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✓ Branch 391 taken 14 times.
✗ Branch 392 not taken.
✓ Branch 393 taken 2 times.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✓ Branch 398 taken 1 times.
✗ Branch 399 not taken.
✓ Branch 401 taken 1 times.
✗ Branch 402 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✓ Branch 414 taken 18 times.
✗ Branch 415 not taken.
✓ Branch 416 taken 2 times.
✗ Branch 417 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✓ Branch 421 taken 1 times.
✗ Branch 422 not taken.
✓ Branch 424 taken 1 times.
✗ Branch 425 not taken.
✗ Branch 427 not taken.
✗ Branch 428 not taken.
✗ Branch 429 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✓ Branch 437 taken 21 times.
✗ Branch 438 not taken.
✓ Branch 439 taken 2 times.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✓ Branch 444 taken 1 times.
✗ Branch 445 not taken.
✓ Branch 447 taken 1 times.
✗ Branch 448 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✓ Branch 460 taken 11 times.
✗ Branch 461 not taken.
✓ Branch 462 taken 2 times.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✓ Branch 467 taken 1 times.
✗ Branch 468 not taken.
✓ Branch 470 taken 1 times.
✗ Branch 471 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✓ Branch 483 taken 14 times.
✗ Branch 484 not taken.
✓ Branch 485 taken 2 times.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✓ Branch 490 taken 1 times.
✗ Branch 491 not taken.
✓ Branch 493 taken 1 times.
✗ Branch 494 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✓ Branch 506 taken 18 times.
✗ Branch 507 not taken.
✓ Branch 508 taken 2 times.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✓ Branch 513 taken 1 times.
✗ Branch 514 not taken.
✓ Branch 516 taken 1 times.
✗ Branch 517 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✓ Branch 529 taken 21 times.
✗ Branch 530 not taken.
✓ Branch 531 taken 2 times.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✓ Branch 536 taken 1 times.
✗ Branch 537 not taken.
✓ Branch 539 taken 1 times.
✗ Branch 540 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 12 not taken.
✓ Branch 29 taken 4 times.
✗ Branch 32 not taken.
✓ Branch 35 taken 36 times.
✓ Branch 52 taken 13 times.
✗ Branch 55 not taken.
✓ Branch 58 taken 2 times.
✗ Branch 75 not taken.
✗ Branch 78 not taken.
✗ Branch 81 not taken.
✗ Branch 98 not taken.
✗ Branch 101 not taken.
✗ Branch 104 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 121 not taken.
✗ Branch 124 not taken.
✗ Branch 127 not taken.
✗ Branch 144 not taken.
✗ Branch 167 not taken.
✗ Branch 173 not taken.
186162 class Field
345 {
346 static constexpr int dim = GridView::dimension;
347 using ctype = typename GridView::ctype;
348 using Element = typename GridView::template Codim<0>::Entity;
349
350 public:
351 // template constructor selects the right VTKFunction implementation
352 template <typename F, class Mapper>
353 184509 Field(const GridView& gridView, const Mapper& mapper, F const& f,
354 const std::string& name, int numComp = 1, int codim = 0,
355 Dune::VTK::DataMode dm = Dune::VTK::conforming,
356 Dumux::Vtk::Precision precision = Dumux::Vtk::Precision::float32)
357
2/2
✓ Branch 0 taken 33867 times.
✓ Branch 1 taken 58396 times.
184509 : codim_(codim)
358 {
359 if constexpr (dim > 1)
360 {
361
2/2
✓ Branch 0 taken 22754 times.
✓ Branch 1 taken 55496 times.
156483 if (codim == dim)
362 {
363
2/2
✓ Branch 0 taken 20552 times.
✓ Branch 1 taken 2202 times.
45508 if (dm == Dune::VTK::conforming)
364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20552 times.
41104 field_ = std::make_shared< VectorP1VTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
365 else
366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2202 times.
4404 field_ = std::make_shared< VectorP1NonConformingVTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
367 }
368
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 55478 times.
110975 else if (codim == 1)
369 {
370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
36 if (dm == Dune::VTK::conforming)
371
1/22
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 34 taken 18 times.
✗ Branch 35 not taken.
36 DUNE_THROW(Dune::NotImplemented, "Only non-conforming output is implemented");
372 else
373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
36 field_ = std::make_shared< VectorP1FaceNonConformingVTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
374 }
375
1/2
✓ Branch 0 taken 55478 times.
✗ Branch 1 not taken.
110939 else if (codim == 0)
376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55478 times.
110939 field_ = std::make_shared< VectorP0VTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
377 else
378 DUNE_THROW(Dune::NotImplemented, "Only element, face or vertex quantities allowed.");
379 }
380 else
381 {
382
2/2
✓ Branch 0 taken 11113 times.
✓ Branch 1 taken 2900 times.
28026 if (codim == dim)
383 {
384
2/2
✓ Branch 0 taken 9693 times.
✓ Branch 1 taken 1420 times.
22226 if (dm == Dune::VTK::conforming)
385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9693 times.
19386 field_ = std::make_shared< VectorP1VTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
386 else
387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1420 times.
2840 field_ = std::make_shared< VectorP1NonConformingVTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
388 }
389
1/2
✓ Branch 0 taken 2900 times.
✗ Branch 1 not taken.
5800 else if (codim == 0)
390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2900 times.
5800 field_ = std::make_shared< VectorP0VTKFunction<GridView, Mapper, F> >(gridView, mapper, f, name, numComp, precision);
391 else
392 DUNE_THROW(Dune::NotImplemented, "Only element or vertex quantities allowed.");
393 }
394 184509 }
395
396 //! return the name of this field
397
8/15
✓ Branch 5 taken 387 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 387 times.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 9 times.
✗ Branch 13 not taken.
✓ Branch 1 taken 592 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 592 times.
✓ Branch 16 taken 18 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 18 times.
✗ Branch 20 not taken.
✗ Branch 11 not taken.
194446 std::string name () const { return field_->name(); }
398
399 //! return the number of components of this field
400 int ncomps() const { return field_->ncomps(); }
401
402 //! return the precision of this field
403 Dumux::Vtk::Precision precision() const
404 { return field_->precision(); }
405
406 //! codimension of the entities on which the field values live
407
7/50
✓ Branch 0 taken 1862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3643 times.
✓ Branch 3 taken 2268 times.
✓ Branch 4 taken 685 times.
✓ Branch 5 taken 151 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
8639 int codim() const { return codim_; }
408
409 //! element-local evaluation of the field
410 double evaluate(int mycomp,
411 const Element &element,
412 const Dune::FieldVector< ctype, dim > &xi) const
413 { return field_->evaluate(mycomp, element, xi); }
414
415 //! returns the underlying vtk function
416 100310 std::shared_ptr<const Dune::VTKFunction<GridView>> get() const
417
7/32
✓ Branch 2 taken 32587 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 58408 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 1929 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 7208 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 6 times.
✗ Branch 23 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 30 taken 170 times.
✗ Branch 31 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
100310 { return field_; }
418
419 private:
420 int codim_;
421 // can point to anything fulfilling the VTKFunction interface
422 std::shared_ptr<Dune::VTKFunction<GridView>> field_;
423 };
424
425 } // end namespace Dumux::Vtk
426
427 #endif
428