3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
interactionvolumeindexset.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_DISCRETIZATION_MPFA_O_INTERACTIONVOLUME_INDEXSET_HH
25#define DUMUX_DISCRETIZATION_MPFA_O_INTERACTIONVOLUME_INDEXSET_HH
26
27#include <dune/common/reservedvector.hh>
28
30
31namespace Dumux {
32
39template< class DualGridNodalIndexSet >
41{
42public:
44 using NodalIndexSet = DualGridNodalIndexSet;
45
47 using LocalIndexType = typename DualGridNodalIndexSet::LocalIndexType;
48 using GridIndexType = typename DualGridNodalIndexSet::GridIndexType;
49
51 using NodalGridStencilType = typename DualGridNodalIndexSet::NodalGridStencilType;
52 using NodalLocalStencilType = typename DualGridNodalIndexSet::NodalLocalStencilType;
53 using NodalGridScvfStencilType = typename DualGridNodalIndexSet::NodalGridScvfStencilType;
54
56 using ScvfNeighborLocalIndexSet = typename DualGridNodalIndexSet::ScvfNeighborLocalIndexSet;
57
59 template< class FlipScvfIndexSet >
60 CCMpfaOInteractionVolumeIndexSet(const NodalIndexSet& nodalIndexSet, const FlipScvfIndexSet& flipScvfIndexSet)
61 : nodalIndexSet_(nodalIndexSet)
62 {
63 const auto numNodalScvfs = nodalIndexSet.numScvfs();
64
65 // kee track of which nodal scvfs have been handled already
66 nodeToIvScvf_.resize(numNodalScvfs);
67 std::vector<bool> isHandled(numNodalScvfs, false);
68
69 // go over faces in nodal index set, check if iv-local face has been
70 // inserted already for this scvf and if not, insert index mapping
71 numFaces_ = 0;
72 for (LocalIndexType i = 0; i < numNodalScvfs; ++i)
73 {
74 // check if the nodal scvf still has to be handled
75 if (isHandled[i])
76 continue;
77
78 // for scvfs touching the boundary there are no "outside" scvfs
79 if (nodalIndexSet.scvfIsOnBoundary(i))
80 {
81 scvfNeighborScvLocalIndices_.push_back({nodalIndexSet.insideScvLocalIndex(i)});
82 nodeToIvScvf_[i] = ivToNodeScvf_.size();
83 isHandled[i] = true;
84 ivToNodeScvf_.push_back(i);
85 numFaces_++;
86 continue;
87 }
88
89 // insert a new iv-local face
90 const auto curIvLocalScvfIdx = ivToNodeScvf_.size();
91 nodeToIvScvf_[i] = curIvLocalScvfIdx;
92 isHandled[i] = true;
93
94 // construct local index sets
95 const auto& flipScvfIndices = flipScvfIndexSet[nodalIndexSet.gridScvfIndex(i)];
96 const auto numFlipIndices = flipScvfIndices.size();
97
98 ScvfNeighborLocalIndexSet neighborsLocal;
99 neighborsLocal.resize(numFlipIndices + 1);
100 neighborsLocal[0] = nodalIndexSet.insideScvLocalIndex(i);
101
102 // mappings for all flip scvf
103 for (unsigned int j = 0; j < numFlipIndices; ++j)
104 {
105 const auto outsideScvfIdx = flipScvfIndices[j];
106 for (unsigned int nodeLocalIdx = 0; nodeLocalIdx < nodalIndexSet.numScvfs(); ++nodeLocalIdx)
107 {
108 if (nodalIndexSet.gridScvfIndex(nodeLocalIdx) == outsideScvfIdx)
109 {
110 neighborsLocal[j+1] = nodalIndexSet.insideScvLocalIndex(nodeLocalIdx);
111 nodeToIvScvf_[nodeLocalIdx] = curIvLocalScvfIdx;
112 isHandled[nodeLocalIdx] = true;
113 break; // go to next outside scvf
114 }
115 }
116 }
117
118 scvfNeighborScvLocalIndices_.push_back(neighborsLocal);
119 ivToNodeScvf_.push_back(i);
120 numFaces_++;
121 }
122 }
123
126 { return nodalIndexSet_; }
127
130 { return nodalIndexSet_.gridScvIndices(); }
131
134 { return nodalIndexSet_.gridScvfIndices(); }
135
137 std::size_t numFaces() const
138 { return numFaces_; }
139
141 std::size_t numScvs() const
142 { return nodalIndexSet_.numScvs(); }
143
146 {
147 assert(ivLocalScvIdx < numScvs());
148 return gridScvIndices()[ivLocalScvIdx];
149 }
150
153 {
154 assert(ivLocalScvfIdx < numFaces());
155 return nodalIndexSet_.gridScvfIndex( ivToNodeScvf_[ivLocalScvfIdx] );
156 }
157
159 LocalIndexType localScvfIndex(LocalIndexType scvIdxLocal, unsigned int i) const
160 {
161 assert(nodalIndexSet_.localScvfIndex(scvIdxLocal, i) < nodeToIvScvf_.size());
162 return nodeToIvScvf_[ nodalIndexSet_.localScvfIndex(scvIdxLocal, i) ];
163 }
164
167 {
168 assert(ivLocalScvfIdx < numFaces());
169 return scvfNeighborScvLocalIndices_[ivLocalScvfIdx];
170 }
171
172private:
173 using NI = NodalIndexSet;
174
175 std::size_t numFaces_;
176 const NI& nodalIndexSet_;
177 // Index maps from and to nodal index set. For the map to the
178 // nodal set we use the same storage type as we know the nodal
179 // has more faces, thus sufficient guaranteed here!
180 typename NI::Traits::template NodalScvfDataStorage< LocalIndexType > ivToNodeScvf_;
181 typename NI::Traits::template NodalScvfDataStorage< LocalIndexType > nodeToIvScvf_;
182 // maps to each scvf a list of neighbouring scv indices
183 // ordering: 0 - inside scv idx; 1..n - outside scv indices
184 typename NI::Traits::template NodalScvfDataStorage< ScvfNeighborLocalIndexSet > scvfNeighborScvLocalIndices_;
185};
186
187} // end namespace Dumux
188
189#endif
Class for the index sets of the dual grid in mpfa schemes.
Definition: adapt.hh:29
The interaction volume index set class for the mpfa-o scheme.
Definition: interactionvolumeindexset.hh:41
const NodalGridStencilType & gridScvIndices() const
returns the global scv indices connected to this dual grid node
Definition: interactionvolumeindexset.hh:129
GridIndexType gridScvfIndex(LocalIndexType ivLocalScvfIdx) const
returns a grid scvf idx for a given iv-local scvf index
Definition: interactionvolumeindexset.hh:152
CCMpfaOInteractionVolumeIndexSet(const NodalIndexSet &nodalIndexSet, const FlipScvfIndexSet &flipScvfIndexSet)
The constructor.
Definition: interactionvolumeindexset.hh:60
const NodalGridScvfStencilType & gridScvfIndices() const
returns the global scvf indices embedded in this interaction volume
Definition: interactionvolumeindexset.hh:133
const ScvfNeighborLocalIndexSet & neighboringLocalScvIndices(LocalIndexType ivLocalScvfIdx) const
returns the local indices of the neighboring scvs of an scvf
Definition: interactionvolumeindexset.hh:166
typename DualGridNodalIndexSet::LocalIndexType LocalIndexType
Export the types used for local/grid indices.
Definition: interactionvolumeindexset.hh:47
typename DualGridNodalIndexSet::NodalGridStencilType NodalGridStencilType
Export the stencil types used.
Definition: interactionvolumeindexset.hh:51
GridIndexType gridScvIndex(LocalIndexType ivLocalScvIdx) const
returns a grid scv idx for a given iv-local scv index
Definition: interactionvolumeindexset.hh:145
LocalIndexType localScvfIndex(LocalIndexType scvIdxLocal, unsigned int i) const
returns the iv-local scvf idx of the i-th scvf embedded in a local scv
Definition: interactionvolumeindexset.hh:159
typename DualGridNodalIndexSet::NodalLocalStencilType NodalLocalStencilType
Definition: interactionvolumeindexset.hh:52
typename DualGridNodalIndexSet::NodalGridScvfStencilType NodalGridScvfStencilType
Definition: interactionvolumeindexset.hh:53
std::size_t numFaces() const
returns the number of faces in the interaction volume
Definition: interactionvolumeindexset.hh:137
DualGridNodalIndexSet NodalIndexSet
Export the type used for the nodal grid index sets.
Definition: interactionvolumeindexset.hh:44
typename DualGridNodalIndexSet::ScvfNeighborLocalIndexSet ScvfNeighborLocalIndexSet
Export the type used for the neighbor scv index sets of the scvfs.
Definition: interactionvolumeindexset.hh:56
typename DualGridNodalIndexSet::GridIndexType GridIndexType
Definition: interactionvolumeindexset.hh:48
const NodalIndexSet & nodalIndexSet() const
returns the corresponding nodal index set
Definition: interactionvolumeindexset.hh:125
std::size_t numScvs() const
returns the number of scvs in the interaction volume
Definition: interactionvolumeindexset.hh:141