GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/io/grid/gridmanager_yasp.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 113 134 84.3%
Functions: 29 29 100.0%
Branches: 100 266 37.6%

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 Grid manager specialization for YaspGrid
11 */
12 #ifndef DUMUX_IO_GRID_MANAGER_YASP_HH
13 #define DUMUX_IO_GRID_MANAGER_YASP_HH
14
15 #include <dune/common/math.hh>
16
17 #include <dune/grid/yaspgrid.hh>
18 #include <dune/grid/io/file/dgfparser/dgfyasp.hh>
19
20 #ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
21 #include <dumux/io/grid/gridmanager_base.hh>
22 #endif
23
24 #include <dumux/common/gridcapabilities.hh>
25
26 namespace Dumux {
27
28 /*!
29 * \ingroup InputOutput
30 * \brief Provides a grid manager for YaspGrids
31 * from information in the input file
32 *
33 * All keys are expected to be in group GridParameterGroup.
34 * The following keys are recognized:
35 * - File : a DGF file to load the coarse grid from
36 * - LowerLeft : lower left corner of the domain (only for EquidistantOffsetCoordinates, otherwise 0-origin)
37 * - UpperRight : upper right corner of the domain
38 * - Cells : the number of cells in each direction
39 * - Periodic : true or false for each direction
40 * - Overlap : overlap size in cells
41 * - Partitioning : a non-standard load-balancing, number of processors per direction
42 * - KeepPyhsicalOverlap : whether to keep the physical overlap
43 * in physical size or in number of cells upon refinement
44 * - Refinement : the number of global refines to apply initially.
45 *
46 */
47 template<class Coordinates, int dim>
48
4/6
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
619 class GridManager<Dune::YaspGrid<dim, Coordinates>>
49 : public GridManagerBase<Dune::YaspGrid<dim, Coordinates>>
50 {
51 using ct = typename Dune::YaspGrid<dim, Coordinates>::ctype;
52 using GlobalPosition = Dune::FieldVector<ct, dim>;
53 public:
54 using Grid = typename Dune::YaspGrid<dim, Coordinates>;
55 using ParentType = GridManagerBase<Grid>;
56
57 /*!
58 * \brief Make the grid. This is implemented by specializations of this method.
59 */
60 395 void init(const std::string& modelParamGroup = "")
61 {
62 // First try to create it from a DGF file in GridParameterGroup.File
63
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 331 times.
790 if (hasParamInGroup(modelParamGroup, "Grid.File"))
64 {
65 ParentType::makeGridFromDgfFile(getParamFromGroup<std::string>(modelParamGroup, "Grid.File"));
66 postProcessing_(modelParamGroup);
67 return;
68 }
69
70 // Then look for the necessary keys to construct from the input file
71
1/2
✓ Branch 2 taken 331 times.
✗ Branch 3 not taken.
790 else if (hasParamInGroup(modelParamGroup, "Grid.UpperRight"))
72 {
73 // get the upper right corner coordinates
74 395 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup, "Grid.UpperRight");
75
76 // number of cells in each direction
77 395 std::array<int, dim> cells; cells.fill(1);
78 395 cells = getParamFromGroup<std::array<int, dim>>(modelParamGroup, "Grid.Cells", cells);
79
80 // \todo TODO periodic boundaries with yasp (the periodicity concept of yasp grid is currently not supported, use dune-spgrid)
81 // const auto periodic = getParamFromGroup<std::bitset<dim>>(modelParamGroup, "Grid.Periodic", std::bitset<dim>{});
82 395 const std::bitset<dim> periodic;
83
84 // get the overlap
85 395 const int overlap = getParamFromGroup<int>(modelParamGroup, "Grid.Overlap", 1);
86
87 if constexpr (std::is_same_v<Dune::EquidistantCoordinates<ct, dim>, Coordinates>)
88 270 init(upperRight, cells, modelParamGroup, overlap, periodic);
89 else
90 {
91 236 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup, "Grid.LowerLeft", GlobalPosition(0.0));
92 125 init(lowerLeft, upperRight, cells, modelParamGroup, overlap, periodic);
93 }
94 }
95
96 // Didn't find a way to construct the grid
97 else
98 {
99 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
100
0/30
✗ 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 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
395 DUNE_THROW(ParameterException, "Please supply one of the parameters "
101 << prefix + "Grid.UpperRight"
102 << ", or a grid file in " << prefix + "Grid.File");
103
104 }
105 }
106
107 /*!
108 * \brief Make the grid using input data not read from the input file.
109 * \note Use this function for EquidistantCoordinates where lowerLeft is always zero.
110 */
111 240 void init(const GlobalPosition& upperRight,
112 const std::array<int, dim>& cells,
113 const std::string& modelParamGroup = "",
114 const int overlap = 1,
115 const std::bitset<dim> periodic = std::bitset<dim>{})
116 {
117 static_assert(std::is_same_v<Dune::EquidistantCoordinates<ct, dim>, Coordinates>,
118 "Use init function taking lowerLeft as argument when working with EquidistantOffsetCoordinates");
119
120
1/2
✓ Branch 2 taken 236 times.
✗ Branch 3 not taken.
480 if (!hasParamInGroup(modelParamGroup, "Grid.Partitioning"))
121 {
122 // construct using default load balancing
123
2/4
✓ Branch 2 taken 236 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 236 times.
✗ Branch 6 not taken.
480 ParentType::gridPtr() = std::make_unique<Grid>(upperRight, cells, periodic, overlap);
124 }
125 else
126 {
127 // construct using user defined partitioning
128 const auto partitioning = getParamFromGroup<std::array<int, dim>>(modelParamGroup, "Grid.Partitioning");
129 Dune::Yasp::FixedSizePartitioning<dim> lb(partitioning);
130 ParentType::gridPtr() = std::make_unique<Grid>(upperRight, cells, periodic, overlap, typename Grid::Communication(), &lb);
131 }
132
133 240 postProcessing_(modelParamGroup);
134 240 }
135
136 /*!
137 * \brief Make the grid using input data not read from the input file.
138 * \note Use this function for EquidistantOffsetCoordinates.
139 */
140 99 void init(const GlobalPosition& lowerLeft,
141 const GlobalPosition& upperRight,
142 const std::array<int, dim>& cells,
143 const std::string& modelParamGroup = "",
144 const int overlap = 1,
145 const std::bitset<dim> periodic = std::bitset<dim>{})
146 {
147 static_assert(std::is_same_v<Dune::EquidistantOffsetCoordinates<ct, dim>, Coordinates>,
148 "LowerLeft can only be specified with EquidistantOffsetCoordinates");
149
150
1/2
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
198 if (!hasParamInGroup(modelParamGroup, "Grid.Partitioning"))
151 {
152 // construct using default load balancing
153
2/4
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 99 times.
✗ Branch 6 not taken.
198 ParentType::gridPtr() = std::make_unique<Grid>(lowerLeft, upperRight, cells, periodic, overlap);
154 }
155 else
156 {
157 // construct using user defined partitioning
158 const auto partitioning = getParamFromGroup<std::array<int, dim>>(modelParamGroup, "Grid.Partitioning");
159 Dune::Yasp::FixedSizePartitioning<dim> lb(partitioning);
160 ParentType::gridPtr() = std::make_unique<Grid>(lowerLeft, upperRight, cells, periodic, overlap, typename Grid::Communication(), &lb);
161 }
162
163 99 postProcessing_(modelParamGroup);
164 99 }
165
166 private:
167
168 /*!
169 * \brief Postprocessing for YaspGrid
170 */
171 399 void postProcessing_(const std::string& modelParamGroup)
172 {
173 // Check if should refine the grid
174 399 const bool keepPhysicalOverlap = getParamFromGroup<bool>(modelParamGroup, "Grid.KeepPhysicalOverlap", true);
175 399 ParentType::grid().refineOptions(keepPhysicalOverlap);
176 399 ParentType::maybeRefineGrid(modelParamGroup);
177 399 ParentType::loadBalance();
178 399 }
179 };
180
181 /*!
182 * \ingroup InputOutput
183 * \brief Provides a grid manager for YaspGrids with different zones and grading
184 *
185 * All keys are expected to be in group GridParameterGroup.
186 * The following keys are recognized:
187 * - Positions0 : position array for x-coordinate
188 * - Positions1 : position array for y-coordinate
189 * - Positions2 : position array for z-coordinate
190 * - Cells0 : number of cells array for x-coordinate
191 * - Cells1 : number of cells array for y-coordinate
192 * - Cells2 : number of cells array for z-coordinate
193 * - Grading0 : grading factor array for x-coordinate
194 * - Grading1 : grading factor array for y-coordinate
195 * - Grading2 : grading factor array for z-coordinate
196 * - Verbosity : whether the grid construction should output to standard out
197 * - Periodic : true or false for each direction
198 * - Overlap : overlap size in cells
199 * - Partitioning : a non-standard load-balancing, number of processors per direction
200 * - KeepPyhsicalOverlap : whether to keep the physical overlap
201 * in physical size or in number of cells upon refinement
202 * - Refinement : the number of global refines to apply initially.
203 *
204 * The grading factor \f$ g \f$ specifies the ratio between the next and the current cell size:
205 * \f$ g = \frac{h_{i+1}}{h_i} \f$.
206 * Negative grading factors are converted to
207 * \f$ g = -\frac{1}{g_\textrm{negative}} \f$
208 * to avoid issues with imprecise fraction numbers.
209 */
210 template<class ctype, int dim>
211
4/6
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
168 class GridManager<Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> >>
212 : public GridManagerBase<Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> > >
213 {
214 public:
215 using Grid = typename Dune::YaspGrid<dim, Dune::TensorProductCoordinates<ctype, dim> >;
216 using ParentType = GridManagerBase<Grid>;
217
218 /*!
219 * \brief Make the grid. This is implemented by specializations of this method.
220 */
221 67 void init(const std::string& modelParamGroup = "")
222 {
223 // Only construction from the input file is possible
224 // Look for the necessary keys to construct from the input file
225 // The positions
226 67 std::array<std::vector<ctype>, dim> positions;
227
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 67 times.
190 for (int i = 0; i < dim; ++i)
228
3/6
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 123 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 123 times.
369 positions[i] = getParamFromGroup<std::vector<ctype>>(modelParamGroup, "Grid.Positions" + std::to_string(i));
229
230 // the number of cells (has a default)
231 67 std::array<std::vector<int>, dim> cells;
232
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 67 times.
190 for (int i = 0; i < dim; ++i)
233 {
234
1/2
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
123 cells[i].resize(positions[i].size()-1, 1.0);
235
2/4
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 123 times.
✗ Branch 6 not taken.
369 cells[i] = getParamFromGroup<std::vector<int>>(modelParamGroup, "Grid.Cells" + std::to_string(i), cells[i]);
236 }
237
238 // grading factor (has a default)
239 67 std::array<std::vector<ctype>, dim> grading;
240
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 67 times.
190 for (int i = 0; i < dim; ++i)
241 {
242
1/2
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
123 grading[i].resize(positions[i].size()-1, 1.0);
243
3/6
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 123 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 123 times.
369 grading[i] = getParamFromGroup<std::vector<ctype>>(modelParamGroup, "Grid.Grading" + std::to_string(i), grading[i]);
244 }
245
246 // call the generic function
247
1/2
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
67 init(positions, cells, grading, modelParamGroup);
248 134 }
249
250 /*!
251 * \brief Make the grid using input data not read from the input file.
252 */
253 101 void init(const std::array<std::vector<ctype>, dim>& positions,
254 const std::array<std::vector<int>, dim>& cells,
255 const std::array<std::vector<ctype>, dim>& grading,
256 const std::string& modelParamGroup = "")
257 {
258 // Additional parameters (they have a default)
259 101 const int overlap = getParamFromGroup<int>(modelParamGroup, "Grid.Overlap", 1);
260 101 const bool verbose = getParamFromGroup<bool>(modelParamGroup, "Grid.Verbosity", false);
261 // \todo TODO periodic boundaries with yasp (the periodicity concept of yasp grid is currently not supported, use dune-spgrid)
262 // const auto periodic = getParamFromGroup<std::bitset<dim>>(modelParamGroup, "Grid.Periodic", std::bitset<dim>{});
263 101 const std::bitset<dim> periodic;
264
265 // Some sanity checks
266
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 91 times.
303 for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
267 {
268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
202 if (cells[dimIdx].size() + 1 != positions[dimIdx].size())
269 {
270 DUNE_THROW(Dune::RangeError, "Make sure to specify correct \"Cells\" and \"Positions\" arrays");
271 }
272
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
202 if (grading[dimIdx].size() + 1 != positions[dimIdx].size())
273 {
274 DUNE_THROW(Dune::RangeError, "Make sure to specify correct \"Grading\" and \"Positions\" arrays");
275 }
276 ctype temp = std::numeric_limits<ctype>::lowest();
277
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 180 times.
640 for (unsigned int posIdx = 0; posIdx < positions[dimIdx].size(); ++posIdx)
278 {
279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
438 if (temp > positions[dimIdx][posIdx])
280 {
281 DUNE_THROW(Dune::RangeError, "Make sure to specify a monotone increasing \"Positions\" array");
282 }
283 438 temp = positions[dimIdx][posIdx];
284 }
285 }
286
287 101 const auto globalPositions = computeGlobalPositions_(positions, cells, grading, verbose);
288
289 // make the grid
290
2/4
✓ Branch 1 taken 91 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 91 times.
✗ Branch 5 not taken.
202 if (!hasParamInGroup(modelParamGroup, "Grid.Partitioning"))
291 {
292 // construct using default load balancing
293
2/4
✓ Branch 1 taken 91 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 91 times.
101 ParentType::gridPtr() = std::make_shared<Grid>(globalPositions, periodic, overlap);
294 }
295 else
296 {
297 // construct using user defined partitioning
298 const auto partitioning = getParamFromGroup<std::array<int, dim>>(modelParamGroup, "Grid.Partitioning");
299 Dune::Yasp::FixedSizePartitioning<dim> lb(partitioning);
300 ParentType::gridPtr() = std::make_shared<Grid>(globalPositions, periodic, overlap, typename Grid::Communication(), &lb);
301 }
302
303
1/2
✓ Branch 1 taken 91 times.
✗ Branch 2 not taken.
101 postProcessing_(modelParamGroup);
304 101 }
305
306 private:
307 /*!
308 * \brief Postprocessing for YaspGrid
309 */
310 101 void postProcessing_(const std::string& modelParamGroup)
311 {
312 // Check if should refine the grid
313 101 const bool keepPhysicalOverlap = getParamFromGroup<bool>(modelParamGroup, "Grid.KeepPhysicalOverlap", true);
314 101 ParentType::grid().refineOptions(keepPhysicalOverlap);
315 101 ParentType::maybeRefineGrid(modelParamGroup);
316 101 ParentType::loadBalance();
317 101 }
318
319 //! Compute the global position tensor grid from the given positions, cells, and grading factors
320 std::array<std::vector<ctype>, dim>
321 101 computeGlobalPositions_(const std::array<std::vector<ctype>, dim>& positions,
322 const std::array<std::vector<int>, dim>& cells,
323 const std::array<std::vector<ctype>, dim>& grading,
324 bool verbose = false)
325 {
326 101 std::array<std::vector<ctype>, dim> globalPositions;
327 using std::pow;
328 using Dune::power;
329
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 91 times.
303 for (int dimIdx = 0; dimIdx < dim; dimIdx++)
330 {
331
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 180 times.
438 for (int zoneIdx = 0; zoneIdx < cells[dimIdx].size(); ++zoneIdx)
332 {
333
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 139 times.
236 ctype lower = positions[dimIdx][zoneIdx];
334 236 ctype upper = positions[dimIdx][zoneIdx+1];
335 236 int numCells = cells[dimIdx][zoneIdx];
336 236 ctype gradingFactor = grading[dimIdx][zoneIdx];
337 236 ctype length = upper - lower;
338 236 ctype height = 1.0;
339 236 bool increasingCellSize = false;
340
341
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 139 times.
236 if (verbose)
342 {
343 75 std::cout << "dim " << dimIdx
344
4/8
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 75 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 75 times.
✗ Branch 11 not taken.
75 << " lower " << lower
345
2/4
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
75 << " upper " << upper
346 75 << " numCells " << numCells
347
3/6
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 75 times.
✗ Branch 8 not taken.
75 << " grading " << gradingFactor;
348 }
349
350
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 28 times.
236 if (gradingFactor > 1.0)
351 {
352 increasingCellSize = true;
353 }
354
355 // take absolute values and reverse cell size increment to achieve
356 // reverse behavior for negative values
357
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 164 times.
208 if (gradingFactor < 0.0)
358 {
359 using std::abs;
360 22 gradingFactor = abs(gradingFactor);
361
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 17 times.
22 if (gradingFactor < 1.0)
362 {
363 5 increasingCellSize = true;
364 }
365 }
366
367 // if the grading factor is exactly 1.0 do equal spacing
368
4/4
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 45 times.
236 if (gradingFactor > 1.0 - 1e-7 && gradingFactor < 1.0 + 1e-7)
369 {
370 181 height = 1.0 / numCells;
371
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 123 times.
181 if (verbose)
372 {
373
2/4
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
36 std::cout << " -> h " << height * length << std::endl;
374 }
375 }
376 // if grading factor is not 1.0, do power law spacing
377 else
378 {
379 55 height = (1.0 - gradingFactor) / (1.0 - power(gradingFactor, numCells));
380
381
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
55 if (verbose)
382 {
383
2/4
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
39 std::cout << " -> grading_eff " << gradingFactor
384
2/4
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
39 << " h_min " << height * power(gradingFactor, 0) * length
385
2/4
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
78 << " h_max " << height * power(gradingFactor, numCells-1) * length
386 236 << std::endl;
387 }
388 }
389
390 236 std::vector<ctype> localPositions;
391
1/2
✓ Branch 1 taken 214 times.
✗ Branch 2 not taken.
236 localPositions.push_back(0);
392
2/2
✓ Branch 0 taken 10113 times.
✓ Branch 1 taken 214 times.
10415 for (int i = 0; i < numCells-1; i++)
393 {
394 10179 ctype hI = height;
395
4/4
✓ Branch 0 taken 9564 times.
✓ Branch 1 taken 549 times.
✓ Branch 2 taken 5220 times.
✓ Branch 3 taken 4344 times.
10179 if (!(gradingFactor < 1.0 + 1e-7 && gradingFactor > 1.0 - 1e-7))
396 {
397
2/2
✓ Branch 0 taken 4414 times.
✓ Branch 1 taken 1355 times.
5769 if (increasingCellSize)
398 {
399 4414 hI *= power(gradingFactor, i);
400 }
401 else
402 {
403 2710 hI *= power(gradingFactor, numCells-i-1);
404 }
405 }
406
1/4
✓ Branch 1 taken 10113 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
10179 localPositions.push_back(localPositions[i] + hI);
407 }
408
409
2/2
✓ Branch 0 taken 10327 times.
✓ Branch 1 taken 214 times.
10651 for (int i = 0; i < localPositions.size(); i++)
410 {
411 10415 localPositions[i] *= length;
412 10415 localPositions[i] += lower;
413 }
414
415
2/2
✓ Branch 0 taken 10327 times.
✓ Branch 1 taken 214 times.
10651 for (unsigned int i = 0; i < localPositions.size(); ++i)
416 {
417
1/2
✓ Branch 1 taken 10327 times.
✗ Branch 2 not taken.
10415 globalPositions[dimIdx].push_back(localPositions[i]);
418 }
419 }
420
1/2
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
202 globalPositions[dimIdx].push_back(positions[dimIdx].back());
421 }
422
423 101 return globalPositions;
424 }
425 };
426
427 namespace Grid::Capabilities {
428
429 // To the best of our knowledge YaspGrid is view thread-safe
430 // This specialization can be removed after we depend on Dune release 2.9 and this is guaranteed by YaspGrid itself
431 template<class Coordinates, int dim>
432 struct MultithreadingSupported<Dune::YaspGrid<dim, Coordinates>>
433 {
434 template<class GV>
435 static bool eval(const GV& gv) // default is independent of the grid view
436 { return true; }
437 };
438
439 } // end namespace Grid::Capabilities
440
441 } // end namespace Dumux
442
443 #endif
444