version 3.8
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// 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_DISCRETIZATION_MPFA_O_INTERACTIONVOLUME_INDEXSET_HH
13#define DUMUX_DISCRETIZATION_MPFA_O_INTERACTIONVOLUME_INDEXSET_HH
14
15#include <dune/common/reservedvector.hh>
16
18
19namespace Dumux {
20
27template< class DualGridNodalIndexSet >
29{
30public:
32 using NodalIndexSet = DualGridNodalIndexSet;
33
35 using LocalIndexType = typename DualGridNodalIndexSet::LocalIndexType;
36 using GridIndexType = typename DualGridNodalIndexSet::GridIndexType;
37
39 using NodalGridStencilType = typename DualGridNodalIndexSet::NodalGridStencilType;
40 using NodalLocalStencilType = typename DualGridNodalIndexSet::NodalLocalStencilType;
41 using NodalGridScvfStencilType = typename DualGridNodalIndexSet::NodalGridScvfStencilType;
42
44 using ScvfNeighborLocalIndexSet = typename DualGridNodalIndexSet::ScvfNeighborLocalIndexSet;
45
47 template< class FlipScvfIndexSet >
48 CCMpfaOInteractionVolumeIndexSet(const NodalIndexSet& nodalIndexSet, const FlipScvfIndexSet& flipScvfIndexSet)
49 : nodalIndexSet_(nodalIndexSet)
50 {
51 const auto numNodalScvfs = nodalIndexSet.numScvfs();
52
53 // kee track of which nodal scvfs have been handled already
54 nodeToIvScvf_.resize(numNodalScvfs);
55 std::vector<bool> isHandled(numNodalScvfs, false);
56
57 // go over faces in nodal index set, check if iv-local face has been
58 // inserted already for this scvf and if not, insert index mapping
59 numFaces_ = 0;
60 for (LocalIndexType i = 0; i < numNodalScvfs; ++i)
61 {
62 // check if the nodal scvf still has to be handled
63 if (isHandled[i])
64 continue;
65
66 // for scvfs touching the boundary there are no "outside" scvfs
67 if (nodalIndexSet.scvfIsOnBoundary(i))
68 {
69 scvfNeighborScvLocalIndices_.push_back({nodalIndexSet.insideScvLocalIndex(i)});
70 nodeToIvScvf_[i] = ivToNodeScvf_.size();
71 isHandled[i] = true;
72 ivToNodeScvf_.push_back(i);
73 numFaces_++;
74 continue;
75 }
76
77 // insert a new iv-local face
78 const auto curIvLocalScvfIdx = ivToNodeScvf_.size();
79 nodeToIvScvf_[i] = curIvLocalScvfIdx;
80 isHandled[i] = true;
81
82 // construct local index sets
83 const auto& flipScvfIndices = flipScvfIndexSet[nodalIndexSet.gridScvfIndex(i)];
84 const auto numFlipIndices = flipScvfIndices.size();
85
86 ScvfNeighborLocalIndexSet neighborsLocal;
87 neighborsLocal.resize(numFlipIndices + 1);
88 neighborsLocal[0] = nodalIndexSet.insideScvLocalIndex(i);
89
90 // mappings for all flip scvf
91 for (unsigned int j = 0; j < numFlipIndices; ++j)
92 {
93 const auto outsideScvfIdx = flipScvfIndices[j];
94 for (unsigned int nodeLocalIdx = 0; nodeLocalIdx < nodalIndexSet.numScvfs(); ++nodeLocalIdx)
95 {
96 if (nodalIndexSet.gridScvfIndex(nodeLocalIdx) == outsideScvfIdx)
97 {
98 neighborsLocal[j+1] = nodalIndexSet.insideScvLocalIndex(nodeLocalIdx);
99 nodeToIvScvf_[nodeLocalIdx] = curIvLocalScvfIdx;
100 isHandled[nodeLocalIdx] = true;
101 break; // go to next outside scvf
102 }
103 }
104 }
105
106 scvfNeighborScvLocalIndices_.push_back(neighborsLocal);
107 ivToNodeScvf_.push_back(i);
108 numFaces_++;
109 }
110 }
111
114 { return nodalIndexSet_; }
115
118 { return nodalIndexSet_.gridScvIndices(); }
119
122 { return nodalIndexSet_.gridScvfIndices(); }
123
125 std::size_t numFaces() const
126 { return numFaces_; }
127
129 std::size_t numScvs() const
130 { return nodalIndexSet_.numScvs(); }
131
134 {
135 assert(ivLocalScvIdx < numScvs());
136 return gridScvIndices()[ivLocalScvIdx];
137 }
138
141 {
142 assert(ivLocalScvfIdx < numFaces());
143 return nodalIndexSet_.gridScvfIndex( ivToNodeScvf_[ivLocalScvfIdx] );
144 }
145
147 LocalIndexType localScvfIndex(LocalIndexType scvIdxLocal, unsigned int i) const
148 {
149 assert(nodalIndexSet_.localScvfIndex(scvIdxLocal, i) < nodeToIvScvf_.size());
150 return nodeToIvScvf_[ nodalIndexSet_.localScvfIndex(scvIdxLocal, i) ];
151 }
152
155 {
156 assert(ivLocalScvfIdx < numFaces());
157 return scvfNeighborScvLocalIndices_[ivLocalScvfIdx];
158 }
159
160private:
161 using NI = NodalIndexSet;
162
163 std::size_t numFaces_;
164 const NI& nodalIndexSet_;
165 // Index maps from and to nodal index set. For the map to the
166 // nodal set we use the same storage type as we know the nodal
167 // has more faces, thus sufficient guaranteed here!
168 typename NI::Traits::template NodalScvfDataStorage< LocalIndexType > ivToNodeScvf_;
169 typename NI::Traits::template NodalScvfDataStorage< LocalIndexType > nodeToIvScvf_;
170 // maps to each scvf a list of neighbouring scv indices
171 // ordering: 0 - inside scv idx; 1..n - outside scv indices
172 typename NI::Traits::template NodalScvfDataStorage< ScvfNeighborLocalIndexSet > scvfNeighborScvLocalIndices_;
173};
174
175} // end namespace Dumux
176
177#endif
The interaction volume index set class for the mpfa-o scheme.
Definition: interactionvolumeindexset.hh:29
const NodalGridStencilType & gridScvIndices() const
returns the global scv indices connected to this dual grid node
Definition: interactionvolumeindexset.hh:117
GridIndexType gridScvfIndex(LocalIndexType ivLocalScvfIdx) const
returns a grid scvf idx for a given iv-local scvf index
Definition: interactionvolumeindexset.hh:140
CCMpfaOInteractionVolumeIndexSet(const NodalIndexSet &nodalIndexSet, const FlipScvfIndexSet &flipScvfIndexSet)
The constructor.
Definition: interactionvolumeindexset.hh:48
const NodalGridScvfStencilType & gridScvfIndices() const
returns the global scvf indices embedded in this interaction volume
Definition: interactionvolumeindexset.hh:121
const ScvfNeighborLocalIndexSet & neighboringLocalScvIndices(LocalIndexType ivLocalScvfIdx) const
returns the local indices of the neighboring scvs of an scvf
Definition: interactionvolumeindexset.hh:154
typename DualGridNodalIndexSet::LocalIndexType LocalIndexType
Export the types used for local/grid indices.
Definition: interactionvolumeindexset.hh:35
typename DualGridNodalIndexSet::NodalGridStencilType NodalGridStencilType
Export the stencil types used.
Definition: interactionvolumeindexset.hh:39
GridIndexType gridScvIndex(LocalIndexType ivLocalScvIdx) const
returns a grid scv idx for a given iv-local scv index
Definition: interactionvolumeindexset.hh:133
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:147
typename DualGridNodalIndexSet::NodalLocalStencilType NodalLocalStencilType
Definition: interactionvolumeindexset.hh:40
typename DualGridNodalIndexSet::NodalGridScvfStencilType NodalGridScvfStencilType
Definition: interactionvolumeindexset.hh:41
std::size_t numFaces() const
returns the number of faces in the interaction volume
Definition: interactionvolumeindexset.hh:125
DualGridNodalIndexSet NodalIndexSet
Export the type used for the nodal grid index sets.
Definition: interactionvolumeindexset.hh:32
typename DualGridNodalIndexSet::ScvfNeighborLocalIndexSet ScvfNeighborLocalIndexSet
Export the type used for the neighbor scv index sets of the scvfs.
Definition: interactionvolumeindexset.hh:44
typename DualGridNodalIndexSet::GridIndexType GridIndexType
Definition: interactionvolumeindexset.hh:36
const NodalIndexSet & nodalIndexSet() const
returns the corresponding nodal index set
Definition: interactionvolumeindexset.hh:113
std::size_t numScvs() const
returns the number of scvs in the interaction volume
Definition: interactionvolumeindexset.hh:129
Class for the index sets of the dual grid in mpfa schemes.
Definition: adapt.hh:17