24#ifndef DUMUX_IO_GRID_MANAGER_FOAM_HH
25#define DUMUX_IO_GRID_MANAGER_FOAM_HH
29#include <dune/foamgrid/foamgrid.hh>
30#include <dune/foamgrid/dgffoam.hh>
33#ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
56template<
int dim,
int dimworld>
61 using Grid = Dune::FoamGrid<dim, dimworld>;
62 using ParentType = GridManagerBase<Grid>;
67 void init(
const std::string& modelParamGroup =
"")
73 ParentType::maybeRefineGrid(modelParamGroup);
74 ParentType::loadBalance();
82 ParentType::maybeRefineGrid(modelParamGroup);
83 ParentType::loadBalance();
89 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup +
".";
90 DUNE_THROW(ParameterException,
"Please supply one of the parameters "
91 << prefix +
"Grid.UpperRight"
92 <<
", or a grid file in " << prefix +
"Grid.File");
113template<
int dimworld>
118 using Grid = Dune::FoamGrid<1, dimworld>;
119 using ParentType = GridManagerBase<Grid>;
124 void init(
const std::string& modelParamGroup =
"")
130 ParentType::maybeRefineGrid(modelParamGroup);
131 ParentType::loadBalance();
136 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>;
139 using CellArray = std::array<unsigned int, 1>;
143 Dune::GridFactory<Grid> factory;
145 constexpr auto geomType = Dune::GeometryTypes::line;
148 GlobalPosition step = upperRight;
149 step -= lowerLeft, step /= cells[0];
152 GlobalPosition globalPos = lowerLeft;
153 for (
unsigned int vIdx = 0; vIdx <= cells[0]; vIdx++, globalPos += step)
154 factory.insertVertex(globalPos);
157 for(
unsigned int eIdx = 0; eIdx < cells[0]; eIdx++)
158 factory.insertElement(geomType, {eIdx, eIdx+1});
160 ParentType::gridPtr() = std::shared_ptr<Grid>(factory.createGrid());
161 ParentType::maybeRefineGrid(modelParamGroup);
162 ParentType::loadBalance();
Provides a grid manager for all supported grid managers with input file interfaces....
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:375
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:391
The grid manager (this is the class used by the user) for all supported grid managers that constructs...
Definition gridmanager_base.hh:320
The grid manager base interface (public) and methods common to most grid manager specializations (pro...
Definition gridmanager_base.hh:73
Grid Grid
Definition gridmanager_base.hh:75
void makeStructuredGrid(CellType cellType, const std::string &modelParamGroup)
Definition gridmanager_base.hh:267
void init(const std::string &modelParamGroup="")
Definition gridmanager_base.hh:81