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
55template<
int dim,
int dimworld>
56class GridManager<
Dune::FoamGrid<dim, dimworld>>
57:
public GridManagerBase<Dune::FoamGrid<dim, dimworld>>
60 using Grid = Dune::FoamGrid<dim, dimworld>;
61 using ParentType = GridManagerBase<Grid>;
66 void init(
const std::string& modelParamGroup =
"")
71 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
72 ParentType::maybeRefineGrid(modelParamGroup);
73 ParentType::loadBalance();
80 ParentType::template makeStructuredGrid<dim, dimworld>(ParentType::CellType::Simplex, modelParamGroup);
81 ParentType::maybeRefineGrid(modelParamGroup);
82 ParentType::loadBalance();
88 const auto prefix = modelParamGroup ==
"" ? modelParamGroup : modelParamGroup +
".";
89 DUNE_THROW(ParameterException,
"Please supply one of the parameters "
90 << prefix +
"Grid.UpperRight"
91 <<
", or a grid file in " << prefix +
"Grid.File");
111template<
int dimworld>
112class GridManager<
Dune::FoamGrid<1, dimworld>>
113:
public GridManagerBase<Dune::FoamGrid<1, dimworld>>
116 using Grid = Dune::FoamGrid<1, dimworld>;
117 using ParentType = GridManagerBase<Grid>;
122 void init(
const std::string& modelParamGroup =
"")
127 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
128 ParentType::maybeRefineGrid(modelParamGroup);
129 ParentType::loadBalance();
134 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>;
135 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.UpperRight");
136 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
137 using CellArray = std::array<unsigned int, 1>;
138 const auto cells = getParamFromGroup<CellArray>(modelParamGroup,
"Grid.Cells", std::array<unsigned int, 1>{{1}});
141 Dune::GridFactory<Grid> factory;
143 constexpr auto geomType = Dune::GeometryTypes::line;
146 GlobalPosition step = upperRight;
147 step -= lowerLeft, step /= cells[0];
150 GlobalPosition globalPos = lowerLeft;
151 for (
unsigned int vIdx = 0; vIdx <= cells[0]; vIdx++, globalPos += step)
152 factory.insertVertex(globalPos);
155 for(
unsigned int eIdx = 0; eIdx < cells[0]; eIdx++)
156 factory.insertElement(geomType, {eIdx, eIdx+1});
158 ParentType::gridPtr() = std::shared_ptr<Grid>(factory.createGrid());
159 ParentType::maybeRefineGrid(modelParamGroup);
160 ParentType::loadBalance();
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