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-FileCopyrightText: 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 CCMpfaDiscretization | ||
10 | * \brief Class for the grid interaction volume index sets of mpfa schemes. | ||
11 | */ | ||
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 | |||
19 | namespace Dumux { | ||
20 | |||
21 | /*! | ||
22 | * \ingroup CCMpfaDiscretization | ||
23 | * \brief Class that holds all interaction volume index sets on a grid view. | ||
24 | * | ||
25 | * \tparam FVG the finite volume grid geometry | ||
26 | * \tparam NI the type used for nodal index sets | ||
27 | * \tparam PI primary interaction volume type | ||
28 | * \tparam SI secondary interaction volume type | ||
29 | */ | ||
30 | template<class FVG, class NI, class PI, class SI = PI> | ||
31 |
1/3✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 0 not taken.
|
48 | class CCMpfaGridInteractionVolumeIndexSets |
32 | { | ||
33 | using SubControlVolumeFace = typename FVG::SubControlVolumeFace; | ||
34 | using PrimaryIVIndexSet = typename PI::Traits::IndexSet; | ||
35 | using SecondaryIVIndexSet = typename SI::Traits::IndexSet; | ||
36 | |||
37 | public: | ||
38 | using GridGeometry = FVG; | ||
39 | using PrimaryInteractionVolume = PI; | ||
40 | using SecondaryInteractionVolume = SI; | ||
41 | |||
42 | using GridIndexType = typename NI::GridIndexType; | ||
43 | using DualGridIndexSet = CCMpfaDualGridIndexSet< NI >; | ||
44 | |||
45 | /*! | ||
46 | * \brief Construct all interaction volume index sets on the grid view | ||
47 | * | ||
48 | * \param gridGeometry The finite volume geometry on the grid view | ||
49 | * \param dualGridIdSet The index sets of the dual grid on the grid view | ||
50 | */ | ||
51 | 50 | void update(GridGeometry& gridGeometry, DualGridIndexSet&& dualGridIdSet) | |
52 | { | ||
53 | 50 | dualGridIndexSet_ = std::make_unique<DualGridIndexSet>(std::move(dualGridIdSet)); | |
54 | |||
55 | // clear containers | ||
56 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 48 times.
|
50 | primaryIVIndexSets_.clear(); |
57 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
|
50 | secondaryIVIndexSets_.clear(); |
58 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 48 times.
|
50 | scvfIndexMap_.clear(); |
59 | |||
60 | // find out how many primary & secondary interaction volumes are needed | ||
61 | 50 | numPrimaryIV_ = 0; | |
62 | 50 | numSecondaryIV_ = 0; | |
63 |
7/9✓ Branch 2 taken 20280 times.
✓ Branch 3 taken 18 times.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 18 times.
✓ Branch 8 taken 53055 times.
✓ Branch 14 taken 53055 times.
✗ Branch 15 not taken.
✓ Branch 1 taken 5721 times.
|
159002 | for (const auto& vertex : vertices(gridGeometry.gridView())) |
64 | { | ||
65 |
2/2✓ Branch 1 taken 690 times.
✓ Branch 2 taken 160 times.
|
79024 | const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex); |
66 |
2/2✓ Branch 0 taken 690 times.
✓ Branch 1 taken 160 times.
|
850 | if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal)) |
67 |
1/2✓ Branch 1 taken 53055 times.
✗ Branch 2 not taken.
|
78864 | numPrimaryIV_ += PrimaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]); |
68 | else | ||
69 | 160 | numSecondaryIV_ += SecondaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]); | |
70 | } | ||
71 | |||
72 | // reserve memory | ||
73 | 50 | primaryIVIndexSets_.reserve(numPrimaryIV_); | |
74 | 50 | secondaryIVIndexSets_.reserve(numSecondaryIV_); | |
75 | 50 | scvfIndexMap_.resize(gridGeometry.numScvf()); | |
76 | |||
77 | // create interaction volume index sets around each vertex | ||
78 |
8/10✓ Branch 2 taken 19428 times.
✓ Branch 3 taken 18 times.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 53055 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 26121 times.
✓ Branch 7 taken 12 times.
✓ Branch 1 taken 6573 times.
|
136927 | for (const auto& vertex : vertices(gridGeometry.gridView())) |
79 | { | ||
80 |
2/3✓ Branch 1 taken 690 times.
✓ Branch 2 taken 53215 times.
✗ Branch 3 not taken.
|
79024 | const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex); |
81 |
2/2✓ Branch 0 taken 690 times.
✓ Branch 1 taken 160 times.
|
850 | if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal)) |
82 |
2/4✓ Branch 1 taken 53055 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 26934 times.
✗ Branch 5 not taken.
|
106648 | PrimaryInteractionVolume::addIVIndexSets(primaryIVIndexSets_, |
83 | scvfIndexMap_, | ||
84 | 78864 | (*dualGridIndexSet_)[vIdxGlobal], | |
85 |
1/2✓ Branch 1 taken 53055 times.
✗ Branch 2 not taken.
|
78864 | gridGeometry.flipScvfIndexSet()); |
86 | else | ||
87 | 160 | SecondaryInteractionVolume::addIVIndexSets(secondaryIVIndexSets_, | |
88 | scvfIndexMap_, | ||
89 | 160 | (*dualGridIndexSet_)[vIdxGlobal], | |
90 | 160 | gridGeometry.flipScvfIndexSet()); | |
91 | } | ||
92 | 50 | } | |
93 | |||
94 | //! Return the iv index set in which a given scvf is embedded in | ||
95 |
7/9✓ Branch 0 taken 522040756 times.
✓ Branch 1 taken 16950474 times.
✓ Branch 5 taken 151187694 times.
✓ Branch 6 taken 6458682 times.
✓ Branch 9 taken 31091712 times.
✓ Branch 10 taken 1899784 times.
✓ Branch 3 taken 1080 times.
✗ Branch 4 not taken.
✗ Branch 2 not taken.
|
921075462 | const PrimaryIVIndexSet& primaryIndexSet(const SubControlVolumeFace& scvf) const |
96 | 959160286 | { return primaryIndexSet(scvf.index()); } | |
97 | |||
98 | //! Return the iv index set in which a given scvf (index) is embedded in | ||
99 | 959160286 | const PrimaryIVIndexSet& primaryIndexSet(const GridIndexType scvfIdx) const | |
100 |
9/11✓ Branch 0 taken 522040756 times.
✓ Branch 1 taken 16950474 times.
✓ Branch 5 taken 34694550 times.
✓ Branch 6 taken 3390674 times.
✓ Branch 7 taken 151187294 times.
✓ Branch 8 taken 6458682 times.
✓ Branch 11 taken 31091712 times.
✓ Branch 12 taken 1899784 times.
✓ Branch 3 taken 1080 times.
✗ Branch 4 not taken.
✗ Branch 2 not taken.
|
959160286 | { return primaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; } |
101 | |||
102 | //! Return the iv index set in which a given scvf is embedded in | ||
103 | 268072 | const SecondaryIVIndexSet& secondaryIndexSet(const SubControlVolumeFace& scvf) const | |
104 | 268072 | { return secondaryIndexSet(scvf.index()); } | |
105 | |||
106 | //! Return the iv index set in which a given scvf (index) is embedded in | ||
107 | 268072 | const SecondaryIVIndexSet& secondaryIndexSet(const GridIndexType scvfIdx) const | |
108 | 268072 | { return secondaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; } | |
109 | |||
110 | //! Returns number of primary/secondary interaction volumes on the grid view | ||
111 | 15 | std::size_t numPrimaryInteractionVolumes() const { return numPrimaryIV_; } | |
112 | 15 | std::size_t numSecondaryInteractionVolumes() const { return numSecondaryIV_; } | |
113 | |||
114 | private: | ||
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 | ||
128 |