GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/cellcentered/mpfa/omethod/localsubcontrolentities.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 34 34 100.0%
Functions: 16 16 100.0%
Branches: 120 140 85.7%

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 Classes for sub control entities of the mpfa-o method.
11 */
12 #ifndef DUMUX_DISCRETIZATION_CC_MPFA_O_LOCAL_SUBCONTROLENTITIES_HH
13 #define DUMUX_DISCRETIZATION_CC_MPFA_O_LOCAL_SUBCONTROLENTITIES_HH
14
15 #include <dune/common/fvector.hh>
16
17 namespace Dumux
18 {
19
20 /*!
21 * \ingroup CCMpfaDiscretization
22 * \brief Class for the interaction volume-local sub-control volume used
23 * in the mpfa-o scheme.
24 *
25 * \tparam IvIndexSet The type used for index sets within interaction volumes
26 * \tparam dim The dimensionality of the grid
27 * \tparam dimWorld The dimension of the world the grid is embedded in
28 */
29 template< class IvIndexSet, class Scalar, int dim, int dimWorld>
30 class CCMpfaOInteractionVolumeLocalScv
31 {
32
33 public:
34 // export some types
35 using GridIndexType = typename IvIndexSet::GridIndexType;
36 using LocalIndexType = typename IvIndexSet::LocalIndexType;
37 using GlobalCoordinate = Dune::FieldVector<Scalar, dimWorld>;
38 using ctype = typename GlobalCoordinate::value_type;
39 using LocalBasis = std::array< GlobalCoordinate, dim >;
40
41 static constexpr int myDimension = dim;
42 static constexpr int worldDimension = dimWorld;
43
44 //! The default constructor
45 CCMpfaOInteractionVolumeLocalScv() = default;
46
47 /*!
48 * \brief The constructor
49 *
50 * \param helper Helper class for mpfa schemes
51 * \param fvGeometry The element finite volume geometry
52 * \param scv The grid sub-control volume
53 * \param localIndex The iv-local index of this scvIdx
54 * \param indexSet The interaction volume index set
55 */
56 template<class MpfaHelper, class FVElementGeometry, class SubControlVolume>
57 38039443 CCMpfaOInteractionVolumeLocalScv(const MpfaHelper& helper,
58 const FVElementGeometry& fvGeometry,
59 const SubControlVolume& scv,
60 const LocalIndexType localIndex,
61 const IvIndexSet& indexSet)
62 38039443 : indexSet_(&indexSet)
63 38039443 , globalScvIndex_(scv.dofIndex())
64 38039443 , localDofIndex_(localIndex)
65 {
66 // center of the global scv
67 38039443 const auto& center = scv.center();
68
69 // set up local basis
70 38039443 LocalBasis localBasis;
71
2/2
✓ Branch 0 taken 76078886 times.
✓ Branch 1 taken 38039443 times.
114118329 for (unsigned int coordIdx = 0; coordIdx < myDimension; ++coordIdx)
72 {
73 76078886 const auto scvfIdx = indexSet.nodalIndexSet().gridScvfIndex(localDofIndex_, coordIdx);
74 76078886 const auto& scvf = fvGeometry.scvf(scvfIdx);
75 76078886 localBasis[coordIdx] = scvf.ipGlobal();
76 152157772 localBasis[coordIdx] -= center;
77 }
78
79 38039443 nus_ = helper.calculateInnerNormals(localBasis);
80 38039443 detX_ = helper.calculateDetX(localBasis);
81 38039443 }
82
83 //! detX is needed for setting up the omegas in the interaction volumes
84 330356504 ctype detX() const
85 434720630 { return detX_; }
86
87 //! grid index related to this scv
88 1369111513 GridIndexType gridScvIndex() const
89
35/36
✓ Branch 1 taken 3724563 times.
✓ Branch 2 taken 16448302 times.
✓ Branch 3 taken 20760831 times.
✓ Branch 4 taken 16880124 times.
✓ Branch 6 taken 637208 times.
✓ Branch 7 taken 2694330 times.
✓ Branch 8 taken 10744364 times.
✓ Branch 9 taken 15668614 times.
✓ Branch 10 taken 10868652 times.
✓ Branch 11 taken 14372760 times.
✓ Branch 12 taken 425104 times.
✓ Branch 13 taken 648688 times.
✓ Branch 15 taken 9953102 times.
✓ Branch 16 taken 3239656 times.
✓ Branch 17 taken 9904242 times.
✓ Branch 18 taken 336432 times.
✓ Branch 19 taken 831176 times.
✓ Branch 20 taken 13072 times.
✓ Branch 22 taken 918536 times.
✓ Branch 23 taken 331864 times.
✓ Branch 24 taken 305720 times.
✓ Branch 25 taken 1147967 times.
✓ Branch 26 taken 2618457 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 20296 times.
✓ Branch 29 taken 19608 times.
✓ Branch 30 taken 6536 times.
✓ Branch 31 taken 6536 times.
✓ Branch 32 taken 59340 times.
✓ Branch 33 taken 178020 times.
✓ Branch 34 taken 13760 times.
✓ Branch 35 taken 13072 times.
✓ Branch 0 taken 121 times.
✓ Branch 5 taken 16436973 times.
✓ Branch 14 taken 3844420 times.
✓ Branch 21 taken 889432 times.
1369111513 { return globalScvIndex_; }
90
91 //! returns the index in the set of cell unknowns of the iv
92 913610874 LocalIndexType localDofIndex() const
93
8/8
✓ Branch 0 taken 308470740 times.
✓ Branch 1 taken 44722878 times.
✓ Branch 2 taken 27393280 times.
✓ Branch 3 taken 35349936 times.
✓ Branch 4 taken 5702288 times.
✓ Branch 5 taken 26217876 times.
✓ Branch 6 taken 505688 times.
✓ Branch 7 taken 21328 times.
913610874 { return localDofIndex_; }
94
95 //! iv-local index of the coordir's scvf in this scv
96 824524168 LocalIndexType localScvfIndex(unsigned int coordDir) const
97 {
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824523368 times.
824523368 assert(coordDir < myDimension);
99 824524168 return indexSet_->localScvfIndex(localDofIndex_, coordDir);
100 }
101
102 //! the nu vectors are needed for setting up the omegas of the iv
103 869441260 const GlobalCoordinate& nu(unsigned int coordDir) const
104 {
105 assert(coordDir < myDimension);
106 869441260 return nus_[coordDir];
107 }
108
109 private:
110 const IvIndexSet* indexSet_;
111 GridIndexType globalScvIndex_;
112 LocalIndexType localDofIndex_;
113 LocalBasis nus_;
114 ctype detX_;
115 };
116
117 /*!
118 * \ingroup CCMpfaDiscretization
119 * \brief Class for the interaction volume-local sub-control volume face
120 * used in the mpfa-o scheme.
121 *
122 * \tparam IvIndexSet The type used for index sets within interaction volumes
123 */
124 template< class IvIndexSet >
125 struct CCMpfaOInteractionVolumeLocalScvf
126 {
127 using ScvfNeighborLocalIndexSet = typename IvIndexSet::ScvfNeighborLocalIndexSet;
128
129 public:
130 // export index types
131 using GridIndexType = typename IvIndexSet::GridIndexType;
132 using LocalIndexType = typename IvIndexSet::LocalIndexType;
133
134 //! The default constructor
135 CCMpfaOInteractionVolumeLocalScvf() = default;
136
137 /*!
138 * \brief The constructor
139 *
140 * \param scvf The grid sub-control volume face
141 * \param localScvIndices The iv-local neighboring scv indices
142 * \param localDofIdx This scvf's interaction volume-local dof index
143 * \param isDirichlet Specifies if this scv is on a Dirichlet boundary
144 */
145 template< class SubControlVolumeFace >
146 40779840 CCMpfaOInteractionVolumeLocalScvf(const SubControlVolumeFace& scvf,
147 const ScvfNeighborLocalIndexSet& localScvIndices,
148 const LocalIndexType localDofIdx,
149 const bool isDirichlet)
150
0/9
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 0 not taken.
40779840 : isDirichlet_(isDirichlet)
151 40748288 , scvfIdxGlobal_(scvf.index())
152 40590780 , localDofIndex_(localDofIdx)
153
0/9
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 0 not taken.
40590780 , neighborScvIndicesLocal_(&localScvIndices)
154 {}
155
156 //! This is either the iv-local index of the intermediate unknown (interior/Neumann face)
157 //! or the index of the Dirichlet boundary within the vol vars (Dirichlet faces)
158
28/28
✓ Branch 0 taken 15634380 times.
✓ Branch 1 taken 232507949 times.
✓ Branch 2 taken 169048071 times.
✓ Branch 3 taken 167289457 times.
✓ Branch 4 taken 168445765 times.
✓ Branch 5 taken 147711961 times.
✓ Branch 6 taken 27903702 times.
✓ Branch 7 taken 16033412 times.
✓ Branch 8 taken 20593864 times.
✓ Branch 9 taken 29173980 times.
✓ Branch 10 taken 28182020 times.
✓ Branch 11 taken 29721988 times.
✓ Branch 12 taken 10797872 times.
✓ Branch 13 taken 17491732 times.
✓ Branch 14 taken 6002236 times.
✓ Branch 15 taken 6539976 times.
✓ Branch 16 taken 13665726 times.
✓ Branch 17 taken 15536186 times.
✓ Branch 18 taken 9629126 times.
✓ Branch 19 taken 8271258 times.
✓ Branch 20 taken 9876482 times.
✓ Branch 21 taken 82904 times.
✓ Branch 22 taken 33368 times.
✓ Branch 23 taken 32680 times.
✓ Branch 24 taken 39904 times.
✓ Branch 25 taken 39904 times.
✓ Branch 26 taken 13072 times.
✓ Branch 27 taken 13072 times.
1526561461 LocalIndexType localDofIndex() const { return localDofIndex_; }
159
160 //! returns the grid view-global index of this scvf
161
2/2
✓ Branch 0 taken 1313786 times.
✓ Branch 1 taken 829920 times.
513928085 GridIndexType gridScvfIndex() const { return scvfIdxGlobal_; }
162
163 //! Returns the local indices of the scvs neighboring this scvf
164
16/16
✓ Branch 0 taken 3726044 times.
✓ Branch 1 taken 10714856 times.
✓ Branch 2 taken 1388728 times.
✓ Branch 3 taken 1862136 times.
✓ Branch 4 taken 1894670 times.
✓ Branch 5 taken 5434900 times.
✓ Branch 6 taken 889432 times.
✓ Branch 7 taken 877944 times.
✓ Branch 8 taken 302528 times.
✓ Branch 9 taken 311328 times.
✓ Branch 10 taken 40592 times.
✓ Branch 11 taken 39216 times.
✓ Branch 12 taken 889432 times.
✓ Branch 13 taken 877944 times.
✓ Branch 14 taken 20296 times.
✓ Branch 15 taken 19608 times.
432219637 const ScvfNeighborLocalIndexSet& neighboringLocalScvIndices() const { return *neighborScvIndicesLocal_; }
165
166 //! states if this is scvf is on a Dirichlet boundary
167
28/28
✓ Branch 0 taken 39456956 times.
✓ Branch 1 taken 292272723 times.
✓ Branch 2 taken 111068437 times.
✓ Branch 3 taken 290644131 times.
✓ Branch 4 taken 220977977 times.
✓ Branch 5 taken 119996061 times.
✓ Branch 6 taken 42094018 times.
✓ Branch 7 taken 10931450 times.
✓ Branch 8 taken 57068480 times.
✓ Branch 9 taken 3564656 times.
✓ Branch 10 taken 37263684 times.
✓ Branch 11 taken 9994236 times.
✓ Branch 12 taken 24099000 times.
✓ Branch 13 taken 5556596 times.
✓ Branch 14 taken 31243220 times.
✓ Branch 15 taken 1596084 times.
✓ Branch 16 taken 27251648 times.
✓ Branch 17 taken 185276 times.
✓ Branch 18 taken 2303692 times.
✓ Branch 19 taken 7904538 times.
✓ Branch 20 taken 17902660 times.
✓ Branch 21 taken 206328 times.
✓ Branch 22 taken 17453092 times.
✓ Branch 23 taken 83208 times.
✓ Branch 24 taken 71724 times.
✓ Branch 25 taken 8084 times.
✓ Branch 26 taken 23564 times.
✓ Branch 27 taken 2580 times.
1527772633 bool isDirichlet() const { return isDirichlet_; }
168
169 private:
170 bool isDirichlet_;
171 GridIndexType scvfIdxGlobal_;
172 LocalIndexType localDofIndex_;
173 const ScvfNeighborLocalIndexSet* neighborScvIndicesLocal_;
174 };
175
176 } // end namespace Dumux
177
178 #endif
179