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
58template<
int dim,
int dimworld>
59class GridManager<
Dune::FoamGrid<dim, dimworld>>
60:
public GridManagerBase<Dune::FoamGrid<dim, dimworld>>
63 using Grid = Dune::FoamGrid<dim, dimworld>;
64 using ParentType = GridManagerBase<Grid>;
69 void init(
const std::string& modelParamGroup =
"")
74 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
75 ParentType::maybeRefineGrid(modelParamGroup);
76 ParentType::loadBalance();
83 ParentType::template makeStructuredGrid<dim, dimworld>(ParentType::CellType::Simplex, modelParamGroup);
84 ParentType::maybeRefineGrid(modelParamGroup);
85 ParentType::loadBalance();
91 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup +
".";
92 DUNE_THROW(ParameterException,
"Please supply one of the parameters "
93 << prefix +
"Grid.UpperRight"
94 <<
", or a grid file in " << prefix +
"Grid.File");
115template<
int dimworld>
116class GridManager<
Dune::FoamGrid<1, dimworld>>
117:
public GridManagerBase<Dune::FoamGrid<1, dimworld>>
120 using Grid = Dune::FoamGrid<1, dimworld>;
121 using ParentType = GridManagerBase<Grid>;
126 void init(
const std::string& modelParamGroup =
"")
131 ParentType::makeGridFromFile(getParamFromGroup<std::string>(modelParamGroup,
"Grid.File"), modelParamGroup);
132 ParentType::maybeRefineGrid(modelParamGroup);
133 ParentType::loadBalance();
138 using GlobalPosition = Dune::FieldVector<typename Grid::ctype, dimworld>;
139 const auto upperRight = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.UpperRight");
140 const auto lowerLeft = getParamFromGroup<GlobalPosition>(modelParamGroup,
"Grid.LowerLeft", GlobalPosition(0.0));
141 using CellArray = std::array<unsigned int, 1>;
142 const auto cells = getParamFromGroup<CellArray>(modelParamGroup,
"Grid.Cells", std::array<unsigned int, 1>{{1}});
145 Dune::GridFactory<Grid> factory;
150 GlobalPosition step = upperRight;
151 step -= lowerLeft, step /= cells[0];
154 GlobalPosition globalPos = lowerLeft;
155 for (
unsigned int vIdx = 0; vIdx <= cells[0]; vIdx++, globalPos += step)
156 factory.insertVertex(globalPos);
159 for(
unsigned int eIdx = 0; eIdx < cells[0]; eIdx++)
160 factory.insertElement(geomType, {eIdx, eIdx+1});
162 ParentType::gridPtr() = std::shared_ptr<Grid>(factory.createGrid());
163 ParentType::maybeRefineGrid(modelParamGroup);
164 ParentType::loadBalance();
168namespace Grid::Capabilities {
172template<
int dim,
int dimworld>
173struct MultithreadingSupported<
Dune::FoamGrid<dim, dimworld>>
176 static bool eval(
const GV&)
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:177
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Definition: deprecated.hh:149
constexpr Line line
Definition: couplingmanager1d3d_line.hh:43
static bool eval(const GV &)
Definition: gridcapabilities.hh:81
Grid Grid
Definition: gridmanager_base.hh:69
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