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>
57class GridManager<
Dune::FoamGrid<dim, dimworld>>
58:
public GridManagerBase<Dune::FoamGrid<dim, dimworld>>
61 using Grid = Dune::FoamGrid<dim, dimworld>;
62 using ParentType = GridManagerBase<Grid>;
67 void init(
const std::string& modelParamGroup =
"")
72 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
73 ParentType::maybeRefineGrid(modelParamGroup);
74 ParentType::loadBalance();
81 ParentType::template makeStructuredGrid<dim, dimworld>(ParentType::CellType::Simplex, modelParamGroup);
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>
114class GridManager<
Dune::FoamGrid<1, dimworld>>
115:
public GridManagerBase<Dune::FoamGrid<1, dimworld>>
118 using Grid = Dune::FoamGrid<1, dimworld>;
119 using ParentType = GridManagerBase<Grid>;
124 void init(
const std::string& modelParamGroup =
"")
129 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
130 ParentType::maybeRefineGrid(modelParamGroup);
131 ParentType::loadBalance();
136 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>;
137 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.UpperRight");
138 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
139 using CellArray = std::array<unsigned int, 1>;
140 const auto cells = getParamFromGroup<CellArray>(modelParamGroup,
"Grid.Cells", std::array<unsigned int, 1>{{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....
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
Definition: common/pdesolver.hh:35
Grid Grid
Definition: gridmanager_base.hh:75
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:81