version 3.10-dev
subgriddata.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_IO_GRID_PORENETWORK_SUBGRID_DATA_HH
13#define DUMUX_IO_GRID_PORENETWORK_SUBGRID_DATA_HH
14
15#include <vector>
16#include <memory>
17#include "griddata.hh"
18
19namespace Dumux::PoreNetwork {
20
25template<class HostGrid, class SubGrid>
27{
28 static constexpr int dim = SubGrid::dimension;
29 static constexpr int dimWorld = SubGrid::dimensionworld;
30 using Intersection = typename SubGrid::LeafIntersection;
31 using Element = typename SubGrid::template Codim<0>::Entity;
32 using Vertex = typename SubGrid::template Codim<dim>::Entity;
33 using GridView = typename SubGrid::LeafGridView;
34 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
35 using SmallLocalIndex = typename IndexTraits<GridView>::SmallLocalIndex;
36
37public:
38 SubGridData(const SubGrid& subGrid,
39 std::shared_ptr<const GridData<HostGrid>> hostGridData)
40 : subGrid_(subGrid)
41 , hostGridData_(hostGridData)
42 {}
43
48 const std::vector<double>& parameters(const Vertex& vertex) const
49 { return hostGridData_->parameters(vertex.impl().hostEntity()); }
50
54 const std::vector<double>& parameters(const Element& element) const
55 { return hostGridData_->parameters(element.impl().hostEntity()); }
56
60 auto getParameter(const Element& element, const std::string& param) const
61 { return hostGridData_->getParameter(element.impl().hostEntity(), param); }
62
66 auto getParameter(const Vertex& vertex, const std::string& param) const
67 { return hostGridData_->getParameter(vertex.impl().hostEntity(), param); }
68
72 template <class GridImp, class IntersectionImp>
73 const Dune::DGFBoundaryParameter::type& parameters(const Dune::Intersection<GridImp, IntersectionImp>& intersection) const
74 { return hostGridData_->parameters(intersection); }
75
81 auto throatLabel(const Element& element) const
82 { return hostGridData_->throatLabel(element.impl().hostEntity()); }
83
89 int boundaryFaceMarkerAtPos(const GlobalPosition& pos) const
90 { return hostGridData_->boundaryFaceMarkerAtPos(pos); }
91
95 std::vector<SmallLocalIndex> getCoordinationNumbers() const
96 {
97 const auto gridView = subGrid_.leafGridView();
98
99 std::vector<SmallLocalIndex> coordinationNumbers(gridView.size(dim), 0);
100
101 for (const auto &element : elements(gridView))
102 {
103 for (SmallLocalIndex vIdxLocal = 0; vIdxLocal < 2; ++vIdxLocal)
104 {
105 const auto vIdxGlobal = gridView.indexSet().subIndex(element, vIdxLocal, dim);
106 coordinationNumbers[vIdxGlobal] += 1;
107 }
108 }
109
110 if (std::any_of(coordinationNumbers.begin(), coordinationNumbers.end(), [](auto i){ return i == 0; }))
111 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");
112
113 return coordinationNumbers;
114 }
115
119 int parameterIndex(const std::string& paramName) const
120 { return hostGridData_->parameterIndex(paramName); }
121
126 const std::string& paramGroup() const
127 { return hostGridData_->paramGroup(); }
128
132 bool gridHasElementParameter(const std::string& param) const
133 { return hostGridData_->gridHasElementParameter(param); }
134
138 bool gridHasVertexParameter(const std::string& param) const
139 { return hostGridData_->gridHasVertexParameter(param); }
140
144 const std::vector<std::string>& vertexParameterNames() const
145 { return hostGridData_->vertexParameterNames() ; }
146
150 const std::vector<std::string>& elementParameterNames() const
151 { return hostGridData_->elementParameterNames() ; }
152
153private:
154 const SubGrid& subGrid_;
155 std::shared_ptr<const GridData<HostGrid>> hostGridData_;
156};
157
158} // end namespace Dumux::PoreNetwork
159
160#endif
wrapper for subgrid data
Definition: subgriddata.hh:27
auto getParameter(const Element &element, const std::string &param) const
Returns the value of an element parameter.
Definition: subgriddata.hh:60
std::vector< SmallLocalIndex > getCoordinationNumbers() const
Returns the coordination numbers for all pore bodies.
Definition: subgriddata.hh:95
int parameterIndex(const std::string &paramName) const
Return the index for a given parameter name.
Definition: subgriddata.hh:119
SubGridData(const SubGrid &subGrid, std::shared_ptr< const GridData< HostGrid > > hostGridData)
Definition: subgriddata.hh:38
bool gridHasElementParameter(const std::string &param) const
Return if a given element parameter is provided by the grid.
Definition: subgriddata.hh:132
const std::string & paramGroup() const
Return the parameter group.
Definition: subgriddata.hh:126
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:54
auto throatLabel(const Element &element) const
Computes and returns the label of a given throat.
Definition: subgriddata.hh:81
const std::vector< std::string > & vertexParameterNames() const
Returns the names of the vertex parameters.
Definition: subgriddata.hh:144
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:48
auto getParameter(const Vertex &vertex, const std::string &param) const
Returns the value of an vertex parameter.
Definition: subgriddata.hh:66
bool gridHasVertexParameter(const std::string &param) const
Return if a given vertex parameter is provided by the grid.
Definition: subgriddata.hh:138
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:73
const std::vector< std::string > & elementParameterNames() const
Returns the names of the element parameters.
Definition: subgriddata.hh:150
int boundaryFaceMarkerAtPos(const GlobalPosition &pos) const
Returns the boundary face marker index at given position.
Definition: subgriddata.hh:89
Definition: discretization/porenetwork/fvelementgeometry.hh:24
Class for grid data attached to dgf or gmsh grid files.
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:29