3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
gridinteractionvolumeindexsets.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_GRIDINTERACTIONVOLUME_INDEXSETS_HH
25#define DUMUX_DISCRETIZATION_MPFA_O_GRIDINTERACTIONVOLUME_INDEXSETS_HH
26
27#include <memory>
28
29#include "dualgridindexset.hh"
30
31namespace Dumux {
32
42template<class FVG, class NI, class PI, class SI = PI>
44{
45 using SubControlVolumeFace = typename FVG::SubControlVolumeFace;
46 using PrimaryIVIndexSet = typename PI::Traits::IndexSet;
47 using SecondaryIVIndexSet = typename SI::Traits::IndexSet;
48
49public:
50 using GridGeometry = FVG;
53
54 using GridIndexType = typename NI::GridIndexType;
56
63 void update(GridGeometry& gridGeometry, DualGridIndexSet&& dualGridIdSet)
64 {
65 dualGridIndexSet_ = std::make_unique<DualGridIndexSet>(std::move(dualGridIdSet));
66
67 // clear containers
68 primaryIVIndexSets_.clear();
69 secondaryIVIndexSets_.clear();
70 scvfIndexMap_.clear();
71
72 // find out how many primary & secondary interaction volumes are needed
73 numPrimaryIV_ = 0;
74 numSecondaryIV_ = 0;
75 for (const auto& vertex : vertices(gridGeometry.gridView()))
76 {
77 const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex);
78 if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal))
79 numPrimaryIV_ += PrimaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]);
80 else
81 numSecondaryIV_ += SecondaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]);
82 }
83
84 // reserve memory
85 primaryIVIndexSets_.reserve(numPrimaryIV_);
86 secondaryIVIndexSets_.reserve(numSecondaryIV_);
87 scvfIndexMap_.resize(gridGeometry.numScvf());
88
89 // create interaction volume index sets around each vertex
90 for (const auto& vertex : vertices(gridGeometry.gridView()))
91 {
92 const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex);
93 if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal))
94 PrimaryInteractionVolume::addIVIndexSets(primaryIVIndexSets_,
95 scvfIndexMap_,
96 (*dualGridIndexSet_)[vIdxGlobal],
97 gridGeometry.flipScvfIndexSet());
98 else
99 SecondaryInteractionVolume::addIVIndexSets(secondaryIVIndexSets_,
100 scvfIndexMap_,
101 (*dualGridIndexSet_)[vIdxGlobal],
102 gridGeometry.flipScvfIndexSet());
103 }
104 }
105
107 const PrimaryIVIndexSet& primaryIndexSet(const SubControlVolumeFace& scvf) const
108 { return primaryIndexSet(scvf.index()); }
109
111 const PrimaryIVIndexSet& primaryIndexSet(const GridIndexType scvfIdx) const
112 { return primaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; }
113
115 const SecondaryIVIndexSet& secondaryIndexSet(const SubControlVolumeFace& scvf) const
116 { return secondaryIndexSet(scvf.index()); }
117
119 const SecondaryIVIndexSet& secondaryIndexSet(const GridIndexType scvfIdx) const
120 { return secondaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; }
121
123 std::size_t numPrimaryInteractionVolumes() const { return numPrimaryIV_; }
124 std::size_t numSecondaryInteractionVolumes() const { return numSecondaryIV_; }
125
126private:
127 std::vector<PrimaryIVIndexSet> primaryIVIndexSets_;
128 std::vector<SecondaryIVIndexSet> secondaryIVIndexSets_;
129 std::vector<GridIndexType> scvfIndexMap_;
130
131 std::size_t numPrimaryIV_;
132 std::size_t numSecondaryIV_;
133
134 std::unique_ptr<DualGridIndexSet> dualGridIndexSet_;
135};
136
137} // end namespace Dumux
138
139#endif
Class for the index sets of the dual grid in mpfa schemes.
Definition: adapt.hh:29
Class for the index sets of the dual grid in mpfa schemes.
Definition: dualgridindexset.hh:219
Class that holds all interaction volume index sets on a grid view.
Definition: gridinteractionvolumeindexsets.hh:44
PI PrimaryInteractionVolume
Definition: gridinteractionvolumeindexsets.hh:51
typename NI::GridIndexType GridIndexType
Definition: gridinteractionvolumeindexsets.hh:54
const SecondaryIVIndexSet & secondaryIndexSet(const GridIndexType scvfIdx) const
Return the iv index set in which a given scvf (index) is embedded in.
Definition: gridinteractionvolumeindexsets.hh:119
std::size_t numSecondaryInteractionVolumes() const
Definition: gridinteractionvolumeindexsets.hh:124
void update(GridGeometry &gridGeometry, DualGridIndexSet &&dualGridIdSet)
Construct all interaction volume index sets on the grid view.
Definition: gridinteractionvolumeindexsets.hh:63
const PrimaryIVIndexSet & primaryIndexSet(const GridIndexType scvfIdx) const
Return the iv index set in which a given scvf (index) is embedded in.
Definition: gridinteractionvolumeindexsets.hh:111
SI SecondaryInteractionVolume
Definition: gridinteractionvolumeindexsets.hh:52
const SecondaryIVIndexSet & secondaryIndexSet(const SubControlVolumeFace &scvf) const
Return the iv index set in which a given scvf is embedded in.
Definition: gridinteractionvolumeindexsets.hh:115
const PrimaryIVIndexSet & primaryIndexSet(const SubControlVolumeFace &scvf) const
Return the iv index set in which a given scvf is embedded in.
Definition: gridinteractionvolumeindexsets.hh:107
FVG GridGeometry
Definition: gridinteractionvolumeindexsets.hh:50
std::size_t numPrimaryInteractionVolumes() const
Returns number of primary/secondary interaction volumes on the grid view.
Definition: gridinteractionvolumeindexsets.hh:123