GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/mpfa/gridinteractionvolumeindexsets.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 28 30 93.3%
Functions: 14 24 58.3%
Branches: 77 102 75.5%

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-FileCopyrightInfo: 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
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 30 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 30 times.
✗ Branch 14 not taken.
240 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
4/4
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 48 times.
52 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/8
✓ Branch 2 taken 25983 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 19410 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 53055 times.
105111 for (const auto& vertex : vertices(gridGeometry.gridView()))
64 {
65 158048 const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex);
66
4/4
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 690 times.
✓ Branch 3 taken 160 times.
79874 if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal))
67
3/6
✓ Branch 1 taken 53055 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53055 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 53055 times.
✗ Branch 8 not taken.
236592 numPrimaryIV_ += PrimaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]);
68 else
69 480 numSecondaryIV_ += SecondaryInteractionVolume::numIVAtVertex((*dualGridIndexSet_)[vIdxGlobal]);
70 }
71
72 // reserve memory
73 50 primaryIVIndexSets_.reserve(numPrimaryIV_);
74 50 secondaryIVIndexSets_.reserve(numSecondaryIV_);
75 100 scvfIndexMap_.resize(gridGeometry.numScvf());
76
77 // create interaction volume index sets around each vertex
78
8/10
✓ Branch 2 taken 25983 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 19410 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 53055 times.
✓ Branch 15 taken 53055 times.
✗ Branch 16 not taken.
85701 for (const auto& vertex : vertices(gridGeometry.gridView()))
79 {
80 158048 const auto vIdxGlobal = gridGeometry.vertexMapper().index(vertex);
81
4/4
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 690 times.
✓ Branch 3 taken 160 times.
79874 if (!gridGeometry.vertexUsesSecondaryInteractionVolume(vIdxGlobal))
82
1/2
✓ Branch 1 taken 53055 times.
✗ Branch 2 not taken.
78864 PrimaryInteractionVolume::addIVIndexSets(primaryIVIndexSets_,
83 scvfIndexMap_,
84
3/6
✓ Branch 1 taken 53055 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 53055 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 53055 times.
✗ Branch 8 not taken.
236592 (*dualGridIndexSet_)[vIdxGlobal],
85 gridGeometry.flipScvfIndexSet());
86 else
87 160 SecondaryInteractionVolume::addIVIndexSets(secondaryIVIndexSets_,
88 scvfIndexMap_,
89 480 (*dualGridIndexSet_)[vIdxGlobal],
90 gridGeometry.flipScvfIndexSet());
91 }
92 50 }
93
94 //! Return the iv index set in which a given scvf is embedded in
95 const PrimaryIVIndexSet& primaryIndexSet(const SubControlVolumeFace& scvf) const
96 1916064668 { return primaryIndexSet(scvf.index()); }
97
98 //! Return the iv index set in which a given scvf (index) is embedded in
99 const PrimaryIVIndexSet& primaryIndexSet(const GridIndexType scvfIdx) const
100
27/32
✓ Branch 0 taken 522040756 times.
✓ Branch 1 taken 16713882 times.
✓ Branch 2 taken 522040756 times.
✓ Branch 3 taken 16713114 times.
✓ Branch 4 taken 522041524 times.
✓ Branch 5 taken 16713114 times.
✓ Branch 7 taken 32040 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 31272 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 31672 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 34694150 times.
✓ Branch 16 taken 3311714 times.
✓ Branch 17 taken 34694150 times.
✓ Branch 18 taken 3311314 times.
✓ Branch 19 taken 34694550 times.
✓ Branch 20 taken 3311314 times.
✓ Branch 21 taken 151187294 times.
✓ Branch 22 taken 6380314 times.
✓ Branch 23 taken 151187294 times.
✓ Branch 24 taken 6380314 times.
✓ Branch 25 taken 151187294 times.
✓ Branch 26 taken 6380314 times.
✓ Branch 33 taken 31091712 times.
✓ Branch 34 taken 1879944 times.
✓ Branch 35 taken 31091712 times.
✓ Branch 36 taken 1879944 times.
✓ Branch 37 taken 31091712 times.
✓ Branch 38 taken 1879944 times.
2874097002 { return primaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; }
101
102 //! Return the iv index set in which a given scvf is embedded in
103 const SecondaryIVIndexSet& secondaryIndexSet(const SubControlVolumeFace& scvf) const
104 536144 { return secondaryIndexSet(scvf.index()); }
105
106 //! Return the iv index set in which a given scvf (index) is embedded in
107 const SecondaryIVIndexSet& secondaryIndexSet(const GridIndexType scvfIdx) const
108
3/6
✓ Branch 7 taken 10336 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 10336 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 10336 times.
✗ Branch 14 not taken.
804216 { return secondaryIVIndexSets_[scvfIndexMap_[scvfIdx]]; }
109
110 //! Returns number of primary/secondary interaction volumes on the grid view
111 std::size_t numPrimaryInteractionVolumes() const { return numPrimaryIV_; }
112 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