version 3.8
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// 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_GRIDINTERACTIONVOLUME_INDEXSETS_HH
13#define DUMUX_DISCRETIZATION_MPFA_O_GRIDINTERACTIONVOLUME_INDEXSETS_HH
14
15#include <memory>
16
17#include "dualgridindexset.hh"
18
19namespace Dumux {
20
30template<class FVG, class NI, class PI, class SI = PI>
32{
33 using SubControlVolumeFace = typename FVG::SubControlVolumeFace;
34 using PrimaryIVIndexSet = typename PI::Traits::IndexSet;
35 using SecondaryIVIndexSet = typename SI::Traits::IndexSet;
36
37public:
38 using GridGeometry = FVG;
41
42 using GridIndexType = typename NI::GridIndexType;
44
51 void update(GridGeometry& gridGeometry, DualGridIndexSet&& dualGridIdSet)
52 {
53 dualGridIndexSet_ = std::make_unique<DualGridIndexSet>(std::move(dualGridIdSet));
54
55 // clear containers
56 primaryIVIndexSets_.clear();
57 secondaryIVIndexSets_.clear();
58 scvfIndexMap_.clear();
59
60 // find out how many primary & secondary interaction volumes are needed
61 numPrimaryIV_ = 0;
62 numSecondaryIV_ = 0;
63 for (const auto& vertex : vertices(gridGeometry.gridView()))
64 {
65 const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex);
66 if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal))
67 numPrimaryIV_ += PrimaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]);
68 else
69 numSecondaryIV_ += SecondaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]);
70 }
71
72 // reserve memory
73 primaryIVIndexSets_.reserve(numPrimaryIV_);
74 secondaryIVIndexSets_.reserve(numSecondaryIV_);
75 scvfIndexMap_.resize(gridGeometry.numScvf());
76
77 // create interaction volume index sets around each vertex
78 for (const auto& vertex : vertices(gridGeometry.gridView()))
79 {
80 const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex);
81 if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal))
82 PrimaryInteractionVolume::addIVIndexSets(primaryIVIndexSets_,
83 scvfIndexMap_,
84 (*dualGridIndexSet_)[vIdxGlobal],
85 gridGeometry.flipScvfIndexSet());
86 else
87 SecondaryInteractionVolume::addIVIndexSets(secondaryIVIndexSets_,
88 scvfIndexMap_,
89 (*dualGridIndexSet_)[vIdxGlobal],
90 gridGeometry.flipScvfIndexSet());
91 }
92 }
93
95 const PrimaryIVIndexSet& primaryIndexSet(const SubControlVolumeFace& scvf) const
96 { return primaryIndexSet(scvf.index()); }
97
99 const PrimaryIVIndexSet& primaryIndexSet(const GridIndexType scvfIdx) const
100 { return primaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; }
101
103 const SecondaryIVIndexSet& secondaryIndexSet(const SubControlVolumeFace& scvf) const
104 { return secondaryIndexSet(scvf.index()); }
105
107 const SecondaryIVIndexSet& secondaryIndexSet(const GridIndexType scvfIdx) const
108 { return secondaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; }
109
111 std::size_t numPrimaryInteractionVolumes() const { return numPrimaryIV_; }
112 std::size_t numSecondaryInteractionVolumes() const { return numSecondaryIV_; }
113
114private:
115 std::vector<PrimaryIVIndexSet> primaryIVIndexSets_;
116 std::vector<SecondaryIVIndexSet> secondaryIVIndexSets_;
117 std::vector<GridIndexType> scvfIndexMap_;
118
119 std::size_t numPrimaryIV_;
120 std::size_t numSecondaryIV_;
121
122 std::unique_ptr<DualGridIndexSet> dualGridIndexSet_;
123};
124
125} // end namespace Dumux
126
127#endif
Class for the index sets of the dual grid in mpfa schemes.
Definition: dualgridindexset.hh:207
Class that holds all interaction volume index sets on a grid view.
Definition: gridinteractionvolumeindexsets.hh:32
PI PrimaryInteractionVolume
Definition: gridinteractionvolumeindexsets.hh:39
typename NI::GridIndexType GridIndexType
Definition: gridinteractionvolumeindexsets.hh:42
const SecondaryIVIndexSet & secondaryIndexSet(const GridIndexType scvfIdx) const
Return the iv index set in which a given scvf (index) is embedded in.
Definition: gridinteractionvolumeindexsets.hh:107
std::size_t numSecondaryInteractionVolumes() const
Definition: gridinteractionvolumeindexsets.hh:112
void update(GridGeometry &gridGeometry, DualGridIndexSet &&dualGridIdSet)
Construct all interaction volume index sets on the grid view.
Definition: gridinteractionvolumeindexsets.hh:51
const PrimaryIVIndexSet & primaryIndexSet(const GridIndexType scvfIdx) const
Return the iv index set in which a given scvf (index) is embedded in.
Definition: gridinteractionvolumeindexsets.hh:99
SI SecondaryInteractionVolume
Definition: gridinteractionvolumeindexsets.hh:40
const SecondaryIVIndexSet & secondaryIndexSet(const SubControlVolumeFace &scvf) const
Return the iv index set in which a given scvf is embedded in.
Definition: gridinteractionvolumeindexsets.hh:103
const PrimaryIVIndexSet & primaryIndexSet(const SubControlVolumeFace &scvf) const
Return the iv index set in which a given scvf is embedded in.
Definition: gridinteractionvolumeindexsets.hh:95
FVG GridGeometry
Definition: gridinteractionvolumeindexsets.hh:38
std::size_t numPrimaryInteractionVolumes() const
Returns number of primary/secondary interaction volumes on the grid view.
Definition: gridinteractionvolumeindexsets.hh:111
Class for the index sets of the dual grid in mpfa schemes.
Definition: adapt.hh:17