24#ifndef DUMUX_IO_GRID_MANAGER_MMESH_HH
25#define DUMUX_IO_GRID_MANAGER_MMESH_HH
28#include <dune/mmesh/mmesh.hh>
31#ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
55class GridManager<
Dune::MovingMesh<dim>>
56:
public GridManagerBase<Dune::MovingMesh<dim>>
59 using Grid = Dune::MovingMesh<dim>;
60 using ParentType = GridManagerBase<Grid>;
65 void init(
const std::string& modelParamGroup =
"")
70 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
71 ParentType::maybeRefineGrid(modelParamGroup);
72 ParentType::loadBalance();
79 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dim>;
80 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.UpperRight");
81 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
83 using CellArray = std::array<unsigned int, dim>;
84 CellArray numCells; numCells.fill(1);
85 numCells = getParamFromGroup<CellArray>(modelParamGroup,
"Grid.Cells", numCells);
88 std::array<unsigned int, dim> numVertices = numCells;
89 for (
int i = 0; i < dim; ++i)
92 Dune::MMeshImplicitGridFactory<Grid> factory;
95 Dune::FactoryUtilities::MultiIndex<dim> index(numVertices);
96 for (
int i = 0; i < index.cycle(); ++i, ++index)
98 GlobalPosition pos(0);
99 for (
int j=0; j<dim; j++)
100 pos[j] = lowerLeft[j] + index[j] * (upperRight[j]-lowerLeft[j])/(numVertices[j]-1);
102 factory.insertVertex(pos);
105 this->
gridPtr() = std::unique_ptr<Grid>(factory.createGrid());
106 ParentType::maybeRefineGrid(modelParamGroup);
107 ParentType::loadBalance();
113 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup +
".";
114 DUNE_THROW(ParameterException,
"Please supply one of the parameters "
115 << prefix +
"Grid.UpperRight"
116 <<
", or a grid file in " << prefix +
"Grid.File");
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:177
Definition: common/pdesolver.hh:36
Grid Grid
Definition: gridmanager_base.hh:69
std::shared_ptr< Grid > & gridPtr()
Returns a reference to the grid pointer (std::shared_ptr<Grid>)
Definition: gridmanager_base.hh:146
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:75