12#ifndef DUMUX_IO_GRID_MANAGER_MMESH_HH
13#define DUMUX_IO_GRID_MANAGER_MMESH_HH
16#include <dune/mmesh/mmesh.hh>
19#ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
43class GridManager<
Dune::MovingMesh<dim>>
44:
public GridManagerBase<Dune::MovingMesh<dim>>
47 using Grid = Dune::MovingMesh<dim>;
48 using ParentType = GridManagerBase<Grid>;
53 void init(
const std::string& modelParamGroup =
"")
58 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
59 ParentType::maybeRefineGrid(modelParamGroup);
60 ParentType::loadBalance();
67 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dim>;
68 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.UpperRight");
69 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
71 using CellArray = std::array<unsigned int, dim>;
72 CellArray numCells; numCells.fill(1);
73 numCells = getParamFromGroup<CellArray>(modelParamGroup,
"Grid.Cells", numCells);
76 std::array<unsigned int, dim> numVertices = numCells;
77 for (
int i = 0; i < dim; ++i)
80 Dune::MMeshImplicitGridFactory<Grid> factory;
83 Dune::FactoryUtilities::MultiIndex<dim> index(numVertices);
84 for (
int i = 0; i < index.cycle(); ++i, ++index)
86 GlobalPosition pos(0);
87 for (
int j=0; j<dim; j++)
88 pos[j] = lowerLeft[j] + index[j] * (upperRight[j]-lowerLeft[j])/(numVertices[j]-1);
90 factory.insertVertex(pos);
93 this->
gridPtr() = std::unique_ptr<Grid>(factory.createGrid());
94 ParentType::maybeRefineGrid(modelParamGroup);
95 ParentType::loadBalance();
101 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup +
".";
102 DUNE_THROW(ParameterException,
"Please supply one of the parameters "
103 << prefix +
"Grid.UpperRight"
104 <<
", or a grid file in " << prefix +
"Grid.File");
Grid Grid
Definition: gridmanager_base.hh:57
std::shared_ptr< Grid > & gridPtr()
Returns a reference to the grid pointer (std::shared_ptr<Grid>)
Definition: gridmanager_base.hh:155
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:63
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:165
Definition: common/pdesolver.hh:24