GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/io/grid/gridmanager_sp.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 26 30 86.7%
Functions: 2 2 100.0%
Branches: 33 134 24.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-FileCopyrightInfo: 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 SPGrid
11 */
12 #ifndef DUMUX_IO_GRID_MANAGER_SP_HH
13 #define DUMUX_IO_GRID_MANAGER_SP_HH
14
15 // SPGrid specific includes
16 #if HAVE_DUNE_SPGRID
17 #include <dune/grid/spgrid.hh>
18 #include <dune/grid/spgrid/dgfparser.hh>
19 #endif
20
21 #ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
22 #include <dumux/io/grid/gridmanager_base.hh>
23 #endif
24
25 namespace Dumux {
26
27 #if HAVE_DUNE_SPGRID
28
29 /*!
30 * \ingroup InputOutput
31 * \brief Provides a grid manager for SPGrid
32 *
33 * The following keys are recognized:
34 * - File : A DGF or gmsh file to load from, type detection by file extension
35 *
36 */
37 template<class ct, int dim, template< int > class Ref, class Comm>
38
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
14 class GridManager<Dune::SPGrid<ct, dim, Ref, Comm>>
39 : public GridManagerBase<Dune::SPGrid<ct, dim, Ref, Comm>>
40 {
41 public:
42 using Grid = Dune::SPGrid<ct, dim, Ref, Comm>;
43 using ParentType = GridManagerBase<Grid>;
44
45 /*!
46 * \brief Make the grid. This is implemented by specializations of this method.
47 */
48 7 void init(const std::string& paramGroup = "")
49 {
50 7 const auto overlap = getParamFromGroup<int>(paramGroup, "Grid.Overlap", 1);
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (overlap == 0)
52 DUNE_THROW(Dune::NotImplemented, "dune-spgrid does currently not support zero overlap!");
53
54 // try to create it from file
55
8/14
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 6 times.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
21 if (hasParamInGroup(paramGroup, "Grid.File"))
56 {
57
2/6
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 ParentType::makeGridFromDgfFile(getParamFromGroup<std::string>(paramGroup, "Grid.File"));
58 6 ParentType::maybeRefineGrid(paramGroup);
59 6 ParentType::loadBalance();
60 6 return;
61 }
62 // Didn't find a way to construct the grid
63
6/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
3 else if (hasParamInGroup(paramGroup, "Grid.UpperRight"))
64 {
65 using GlobalPosition = Dune::FieldVector<ct, dim>;
66 2 const auto lowerLeft = getParamFromGroup<GlobalPosition>(paramGroup, "Grid.LowerLeft", GlobalPosition(0.0));
67 1 const auto upperRight = getParamFromGroup<GlobalPosition>(paramGroup, "Grid.UpperRight");
68
69 using IntArray = std::array<int, dim>;
70 1 IntArray cells; cells.fill(1);
71 1 cells = getParamFromGroup<IntArray>(paramGroup, "Grid.Cells", cells);
72
73 2 const auto periodic = getParamFromGroup<std::bitset<dim>>(paramGroup, "Grid.Periodic", std::bitset<dim>{});
74 1 init(lowerLeft, upperRight, cells, paramGroup, overlap, periodic);
75 }
76 else
77 {
78 const auto prefix = paramGroup.empty() ? paramGroup : paramGroup + ".";
79 DUNE_THROW(ParameterException, "Please supply a grid file in " << prefix << "Grid.File or " << prefix << "Grid.UpperRight/Cells.");
80 }
81 }
82
83 1 void init(const Dune::FieldVector<ct, dim>& lowerLeft,
84 const Dune::FieldVector<ct, dim>& upperRight,
85 const std::array<int, dim>& cells,
86 const std::string& paramGroup = "",
87 const int overlap = 1,
88 const std::bitset<dim> periodic = std::bitset<dim>{})
89 {
90
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (overlap == 0)
91 DUNE_THROW(Dune::NotImplemented, "dune-spgrid does currently not support zero overlap!");
92 using IntArray = std::array<int, dim>;
93 1 IntArray spOverlap; spOverlap.fill(overlap);
94 using Domain = typename Grid::Domain;
95 1 std::vector< typename Domain::Cube > cubes;
96
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 cubes.push_back( typename Domain::Cube( lowerLeft, upperRight ) );
97
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
3 Domain domain( cubes, typename Domain::Topology( static_cast<unsigned int>(periodic.to_ulong()) ) );
98
4/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1 ParentType::gridPtr() = std::make_shared<Grid>( domain, cells, spOverlap );
99
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 ParentType::maybeRefineGrid(paramGroup);
100
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 ParentType::loadBalance();
101 1 }
102 };
103
104 #endif // HAVE_DUNE_SPGRID
105
106 } // end namespace Dumux
107
108 #endif
109