24#ifndef DUMUX_IO_GRID_PORENETWORK_SUBGRID_DATA_HH
25#define DUMUX_IO_GRID_PORENETWORK_SUBGRID_DATA_HH
37template<
class HostGr
id,
class SubGr
id>
40 static constexpr int dim = SubGrid::dimension;
41 static constexpr int dimWorld = SubGrid::dimensionworld;
42 using Intersection =
typename SubGrid::LeafIntersection;
43 using Element =
typename SubGrid::template Codim<0>::Entity;
44 using Vertex =
typename SubGrid::template Codim<dim>::Entity;
45 using GridView =
typename SubGrid::LeafGridView;
46 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
53 , hostGridData_(hostGridData)
60 const std::vector<double>&
parameters(
const Vertex& vertex)
const
61 {
return hostGridData_->parameters(vertex.impl().hostEntity()); }
66 const std::vector<double>&
parameters(
const Element& element)
const
67 {
return hostGridData_->parameters(element.impl().hostEntity()); }
72 auto getParameter(
const Element& element,
const std::string& param)
const
73 {
return hostGridData_->getParameter(element.impl().hostEntity(), param); }
78 auto getParameter(
const Vertex& vertex,
const std::string& param)
const
79 {
return hostGridData_->getParameter(vertex.impl().hostEntity(), param); }
84 template <
class Gr
idImp,
class IntersectionImp>
85 const Dune::DGFBoundaryParameter::type&
parameters(
const Dune::Intersection<GridImp, IntersectionImp>& intersection)
const
86 {
return hostGridData_->parameters(intersection); }
94 {
return hostGridData_->throatLabel(element.impl().hostEntity()); }
102 {
return hostGridData_->boundaryFaceMarkerAtPos(pos); }
109 const auto gridView = subGrid_.leafGridView();
111 std::vector<SmallLocalIndex> coordinationNumbers(gridView.size(dim), 0);
113 for (
const auto &element : elements(gridView))
115 for (SmallLocalIndex vIdxLocal = 0; vIdxLocal < 2; ++vIdxLocal)
117 const auto vIdxGlobal = gridView.indexSet().subIndex(element, vIdxLocal, dim);
118 coordinationNumbers[vIdxGlobal] += 1;
122 if (std::any_of(coordinationNumbers.begin(), coordinationNumbers.end(), [](
auto i){ return i == 0; }))
123 DUNE_THROW(Dune::InvalidStateException,
"One of the pores is not connected to another pore. SanitizeGrid will not help in this case. Check your grid file");
125 return coordinationNumbers;
132 {
return hostGridData_->parameterIndex(paramName); }
139 {
return hostGridData_->paramGroup(); }
145 {
return hostGridData_->gridHasElementParameter(param); }
151 {
return hostGridData_->gridHasVertexParameter(param); }
157 {
return hostGridData_->vertexParameterNames() ; }
163 {
return hostGridData_->elementParameterNames() ; }
166 const SubGrid& subGrid_;
167 std::shared_ptr<const GridData<HostGrid>> hostGridData_;
Definition: discretization/porenetwork/fvelementgeometry.hh:34
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:41
wrapper for subgrid data
Definition: subgriddata.hh:39
auto getParameter(const Element &element, const std::string ¶m) const
Returns the value of an element parameter.
Definition: subgriddata.hh:72
std::vector< SmallLocalIndex > getCoordinationNumbers() const
Returns the coordination numbers for all pore bodies.
Definition: subgriddata.hh:107
int parameterIndex(const std::string ¶mName) const
Return the index for a given parameter name.
Definition: subgriddata.hh:131
SubGridData(const SubGrid &subGrid, std::shared_ptr< const GridData< HostGrid > > hostGridData)
Definition: subgriddata.hh:50
bool gridHasElementParameter(const std::string ¶m) const
Return if a given element parameter is provided by the grid.
Definition: subgriddata.hh:144
const std::string & paramGroup() const
Return the parameter group.
Definition: subgriddata.hh:138
const std::vector< double > & parameters(const Element &element) const
Call the parameters function of the DGF grid pointer if available for element data.
Definition: subgriddata.hh:66
auto throatLabel(const Element &element) const
Computes and returns the label of a given throat.
Definition: subgriddata.hh:93
const std::vector< std::string > & vertexParameterNames() const
Returns the names of the vertex parameters.
Definition: subgriddata.hh:156
const std::vector< double > & parameters(const Vertex &vertex) const
Call the parameters function of the DGF grid pointer if available for vertex data.
Definition: subgriddata.hh:60
auto getParameter(const Vertex &vertex, const std::string ¶m) const
Returns the value of an vertex parameter.
Definition: subgriddata.hh:78
bool gridHasVertexParameter(const std::string ¶m) const
Return if a given vertex parameter is provided by the grid.
Definition: subgriddata.hh:150
const Dune::DGFBoundaryParameter::type & parameters(const Dune::Intersection< GridImp, IntersectionImp > &intersection) const
Call the parameters function of the DGF grid pointer if available.
Definition: subgriddata.hh:85
const std::vector< std::string > & elementParameterNames() const
Returns the names of the element parameters.
Definition: subgriddata.hh:162
int boundaryFaceMarkerAtPos(const GlobalPosition &pos) const
Returns the boundary face marker index at given position.
Definition: subgriddata.hh:101
Class for grid data attached to dgf or gmsh grid files.