12#ifndef DUMUX_IO_GRID_MANAGER_FOAM_HH
13#define DUMUX_IO_GRID_MANAGER_FOAM_HH
17#include <dune/foamgrid/foamgrid.hh>
18#include <dune/foamgrid/dgffoam.hh>
21#ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
46template<
int dim,
int dimworld>
47class GridManager<
Dune::FoamGrid<dim, dimworld>>
48:
public GridManagerBase<Dune::FoamGrid<dim, dimworld>>
51 using Grid = Dune::FoamGrid<dim, dimworld>;
52 using ParentType = GridManagerBase<Grid>;
57 void init(
const std::string& modelParamGroup =
"")
62 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
63 ParentType::maybeRefineGrid(modelParamGroup);
64 ParentType::loadBalance();
71 ParentType::template makeStructuredGrid<dim, dimworld>(ParentType::CellType::Simplex, modelParamGroup);
72 ParentType::maybeRefineGrid(modelParamGroup);
73 ParentType::loadBalance();
79 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup +
".";
80 DUNE_THROW(ParameterException,
"Please supply one of the parameters "
81 << prefix +
"Grid.UpperRight"
82 <<
", or a grid file in " << prefix +
"Grid.File");
103template<
int dimworld>
104class GridManager<
Dune::FoamGrid<1, dimworld>>
105:
public GridManagerBase<Dune::FoamGrid<1, dimworld>>
108 using Grid = Dune::FoamGrid<1, dimworld>;
109 using ParentType = GridManagerBase<Grid>;
114 void init(
const std::string& modelParamGroup =
"")
119 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
120 ParentType::maybeRefineGrid(modelParamGroup);
121 ParentType::loadBalance();
126 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>;
127 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.UpperRight");
128 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
129 using CellArray = std::array<unsigned int, 1>;
130 const auto cells = getParamFromGroup<CellArray>(modelParamGroup,
"Grid.Cells", std::array<unsigned int, 1>{{1}});
133 Dune::GridFactory<Grid> factory;
138 GlobalPosition step = upperRight;
139 step -= lowerLeft, step /= cells[0];
142 GlobalPosition globalPos = lowerLeft;
143 for (
unsigned int vIdx = 0; vIdx <= cells[0]; vIdx++, globalPos += step)
144 factory.insertVertex(globalPos);
147 for(
unsigned int eIdx = 0; eIdx < cells[0]; eIdx++)
148 factory.insertElement(geomType, {eIdx, eIdx+1});
150 ParentType::gridPtr() = std::shared_ptr<Grid>(factory.createGrid());
151 ParentType::maybeRefineGrid(modelParamGroup);
152 ParentType::loadBalance();
156namespace Grid::Capabilities {
160template<
int dim,
int dimworld>
161struct MultithreadingSupported<
Dune::FoamGrid<dim, dimworld>>
164 static bool eval(
const GV&)
Grid Grid
Definition: gridmanager_base.hh:57
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
dune-grid capabilities compatibility layer
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
constexpr Line line
Definition: couplingmanager1d3d_line.hh:31
Definition: common/pdesolver.hh:24
static bool eval(const GV &)
Definition: gridcapabilities.hh:69