24#ifndef DUMUX_IO_GRID_MANAGER_SP_HH
25#define DUMUX_IO_GRID_MANAGER_SP_HH
29#include <dune/grid/spgrid.hh>
30#include <dune/grid/spgrid/dgfparser.hh>
33#ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
48template<
class ct,
int dim,
template<
int >
class Ref,
class Comm>
49class GridManager<
Dune::SPGrid<ct, dim, Ref, Comm>>
50:
public GridManagerBase<Dune::SPGrid<ct, dim, Ref, Comm>>
53 using Grid = Dune::SPGrid<ct, dim, Ref, Comm>;
54 using ParentType = GridManagerBase<Grid>;
59 void init(
const std::string& paramGroup =
"")
61 const auto overlap = getParamFromGroup<int>(paramGroup,
"Grid.Overlap", 1);
63 DUNE_THROW(Dune::NotImplemented,
"dune-spgrid does currently not support zero overlap!");
68 ParentType::makeGridFromDgfFile(getParamFromGroup<std::string>(paramGroup,
"Grid.File"));
69 ParentType::maybeRefineGrid(paramGroup);
70 ParentType::loadBalance();
76 using GlobalPosition = Dune::FieldVector<ct, dim>;
77 const auto lowerLeft = getParamFromGroup<GlobalPosition>(paramGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
78 const auto upperRight = getParamFromGroup<GlobalPosition>(paramGroup,
"Grid.UpperRight");
80 using IntArray = std::array<int, dim>;
81 IntArray cells; cells.fill(1);
82 cells = getParamFromGroup<IntArray>(paramGroup,
"Grid.Cells", cells);
84 const auto periodic = getParamFromGroup<std::bitset<dim>>(paramGroup,
"Grid.Periodic", std::bitset<dim>{});
85 IntArray spOverlap; spOverlap.fill(overlap);
87 using Domain =
typename Grid::Domain;
88 std::vector< typename Domain::Cube > cubes;
89 cubes.push_back(
typename Domain::Cube( lowerLeft, upperRight ) );
90 Domain domain( cubes,
typename Domain::Topology(
static_cast<unsigned int>(periodic.to_ulong()) ) );
91 ParentType::gridPtr() = std::make_shared<Grid>( domain, cells, spOverlap );
92 ParentType::maybeRefineGrid(paramGroup);
93 ParentType::loadBalance();
97 const auto prefix = paramGroup ==
"" ? paramGroup : paramGroup +
".";
98 DUNE_THROW(ParameterException,
"Please supply a grid file in " << prefix <<
"Grid.File or " << prefix <<
"Grid.UpperRight/Cells.");
Provides a grid manager for all supported grid managers with input file interfaces....
bool hasParamInGroup(const std::string ¶mGroup, const std::string ¶m)
Check whether a key exists in the parameter tree with a model group prefix.
Definition: parameters.hh:454
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Definition: common/properties/model.hh:34
Grid Grid
Definition: gridmanager_base.hh:67
void init(const std::string &modelParamGroup="")
Make the grid. Implement this method in the specialization of this class for a grid type.
Definition: gridmanager_base.hh:73