Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup PoreNetworkModels | ||
10 | * \brief Class for sub grid data attached to dgf or gmsh grid files | ||
11 | */ | ||
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 | |||
19 | namespace Dumux::PoreNetwork { | ||
20 | |||
21 | /*! | ||
22 | * \ingroup PoreNetworkModels | ||
23 | * \brief wrapper for subgrid data | ||
24 | */ | ||
25 | template<class HostGrid, class SubGrid> | ||
26 |
1/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | class SubGridData |
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 | |||
37 | public: | ||
38 | ✗ | SubGridData(const SubGrid& subGrid, | |
39 | std::shared_ptr<const GridData<HostGrid>> hostGridData) | ||
40 | : subGrid_(subGrid) | ||
41 | ✗ | , hostGridData_(hostGridData) | |
42 | {} | ||
43 | |||
44 | /*! | ||
45 | * \brief Call the parameters function of the DGF grid pointer if available for vertex data | ||
46 | * \note You can only pass vertices that exist on level 0! | ||
47 | */ | ||
48 | const std::vector<double>& parameters(const Vertex& vertex) const | ||
49 |
2/4✓ Branch 11 taken 864 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 864 times.
✗ Branch 15 not taken.
|
13970 | { return hostGridData_->parameters(vertex.impl().hostEntity()); } |
50 | |||
51 | /*! | ||
52 | * \brief Call the parameters function of the DGF grid pointer if available for element data | ||
53 | */ | ||
54 | const std::vector<double>& parameters(const Element& element) const | ||
55 |
8/15✓ Branch 1 taken 2184 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2184 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1007 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1007 times.
✓ Branch 11 taken 6500 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 6500 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1 times.
✗ Branch 21 not taken.
|
35400 | { return hostGridData_->parameters(element.impl().hostEntity()); } |
56 | |||
57 | /*! | ||
58 | * \brief Returns the value of an element parameter | ||
59 | */ | ||
60 | auto getParameter(const Element& element, const std::string& param) const | ||
61 |
2/4✓ Branch 1 taken 1625 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1625 times.
✗ Branch 5 not taken.
|
3250 | { return hostGridData_->getParameter(element.impl().hostEntity(), param); } |
62 | |||
63 | /*! | ||
64 | * \brief Returns the value of an vertex parameter | ||
65 | */ | ||
66 | auto getParameter(const Vertex& vertex, const std::string& param) const | ||
67 |
4/14✓ Branch 1 taken 560 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 560 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 556 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 556 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
|
2232 | { return hostGridData_->getParameter(vertex.impl().hostEntity(), param); } |
68 | |||
69 | /*! | ||
70 | * \brief Call the parameters function of the DGF grid pointer if available | ||
71 | */ | ||
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 | |||
76 | /*! | ||
77 | * \brief Computes and returns the label of a given throat | ||
78 | * | ||
79 | * \param element The element (throat) | ||
80 | */ | ||
81 | auto throatLabel(const Element& element) const | ||
82 | { return hostGridData_->throatLabel(element.impl().hostEntity()); } | ||
83 | |||
84 | /*! | ||
85 | * \brief Returns the boundary face marker index at given position | ||
86 | * | ||
87 | * \param pos The current position | ||
88 | */ | ||
89 | int boundaryFaceMarkerAtPos(const GlobalPosition& pos) const | ||
90 | { return hostGridData_->boundaryFaceMarkerAtPos(pos); } | ||
91 | |||
92 | /*! | ||
93 | * \brief Returns the coordination numbers for all pore bodies. | ||
94 | */ | ||
95 | 5 | std::vector<SmallLocalIndex> getCoordinationNumbers() const | |
96 | { | ||
97 | 5 | const auto gridView = subGrid_.leafGridView(); | |
98 | |||
99 |
1/2✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
10 | std::vector<SmallLocalIndex> coordinationNumbers(gridView.size(dim), 0); |
100 | |||
101 |
6/8✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8007 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 8007 times.
✓ Branch 6 taken 5 times.
✓ Branch 8 taken 8007 times.
✗ Branch 9 not taken.
|
8012 | for (const auto &element : elements(gridView)) |
102 | { | ||
103 |
2/2✓ Branch 0 taken 16014 times.
✓ Branch 1 taken 8007 times.
|
24021 | for (SmallLocalIndex vIdxLocal = 0; vIdxLocal < 2; ++vIdxLocal) |
104 | { | ||
105 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 16014 times.
✓ Branch 3 taken 16014 times.
✗ Branch 4 not taken.
|
16014 | const auto vIdxGlobal = gridView.indexSet().subIndex(element, vIdxLocal, dim); |
106 | 32028 | coordinationNumbers[vIdxGlobal] += 1; | |
107 | } | ||
108 | } | ||
109 | |||
110 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
|
15 | 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 | 5 | return coordinationNumbers; | |
114 | } | ||
115 | |||
116 | /*! | ||
117 | * \brief Return the index for a given parameter name | ||
118 | */ | ||
119 | int parameterIndex(const std::string& paramName) const | ||
120 |
32/68✓ Branch 1 taken 2184 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2184 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2184 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2184 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2185 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2185 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1007 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1007 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1008 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1008 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1008 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1008 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 2 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 2 times.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
|
19174 | { return hostGridData_->parameterIndex(paramName); } |
121 | |||
122 | /*! | ||
123 | * \brief Return the parameter group | ||
124 | * \todo For now we don't support two different parameter groups for the subgrids | ||
125 | */ | ||
126 | const std::string& paramGroup() const | ||
127 |
12/48✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 37 taken 5 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 5 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 5 times.
✗ Branch 44 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 5 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 5 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 5 times.
✗ Branch 65 not taken.
✓ Branch 70 taken 2 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 2 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 2 times.
✗ Branch 77 not taken.
|
57 | { return hostGridData_->paramGroup(); } |
128 | |||
129 | /*! | ||
130 | * \brief Return if a given element parameter is provided by the grid | ||
131 | */ | ||
132 | 4 | bool gridHasElementParameter(const std::string& param) const | |
133 | 8 | { return hostGridData_->gridHasElementParameter(param); } | |
134 | |||
135 | /*! | ||
136 | * \brief Return if a given vertex parameter is provided by the grid | ||
137 | */ | ||
138 | 2 | bool gridHasVertexParameter(const std::string& param) const | |
139 | 4 | { return hostGridData_->gridHasVertexParameter(param); } | |
140 | |||
141 | /*! | ||
142 | * \brief Returns the names of the vertex parameters | ||
143 | */ | ||
144 | const std::vector<std::string>& vertexParameterNames() const | ||
145 | 3 | { return hostGridData_->vertexParameterNames() ; } | |
146 | |||
147 | /*! | ||
148 | * \brief Returns the names of the element parameters | ||
149 | */ | ||
150 | const std::vector<std::string>& elementParameterNames() const | ||
151 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
3 | { return hostGridData_->elementParameterNames() ; } |
152 | |||
153 | private: | ||
154 | const SubGrid& subGrid_; | ||
155 | std::shared_ptr<const GridData<HostGrid>> hostGridData_; | ||
156 | }; | ||
157 | |||
158 | } // end namespace Dumux::PoreNetwork | ||
159 | |||
160 | #endif | ||
161 |