GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/cellcentered/mpfa/interactionvolumedatahandle.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 29 32 90.6%
Functions: 0 38 0.0%
Branches: 58 96 60.4%

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 Data handle class for interaction volumes of mpfa methods.
11 * This class is passed to interaction volumes to store the necessary data in it.
12 */
13 #ifndef DUMUX_DISCRETIZATION_CC_MPFA_INTERACTIONVOLUMEDATAHANDLE_HH
14 #define DUMUX_DISCRETIZATION_CC_MPFA_INTERACTIONVOLUMEDATAHANDLE_HH
15
16 #include <cassert>
17 #include <vector>
18
19 #include <dune/common/dynvector.hh>
20
21 #include <dumux/common/parameters.hh>
22
23 namespace Dumux {
24 namespace CCMpfaDataHandleBases {
25
26 /*!
27 * \ingroup CCMpfaDiscretization
28 * \brief Common base class to all handles. Stores arrays of the
29 * matrices involved in the interaction volume-local systems
30 * of equations. Apart from the transmissibility matrix we
31 * store those matrices that are needed e.g. for later face
32 * pressure reconstruction.
33 * The fluxes as well as the local systems of equations can
34 * be expressed as functions of the intermediate unknown face
35 * face values \f$\bar{\mathbf{u}}\f$ and the known cell/Dirichlet
36 * values \f$\mathbf{u}\f$ using the matrices \f$\mathbf{A}\f$,
37 * \f$\mathbf{B}\f$, \f$\mathbf{C}\f$, \f$\mathbf{D}\f$ and the
38 * vector of Neumann fluxes \f$\mathbf{N}\f$ as follows:
39 *
40 * Fluxes: \f$\mathbf{f} = \mathbf{C}\bar{\mathbf{u}} + \mathbf{D}\mathbf{u}\f$
41 * Local eq system: \f$\mathbf{A}\bar{\mathbf{u}} = \mathbf{B}\mathbf{u} + \mathbf{N}\f$
42 *
43 * \tparam MVT The matrix/vector traits collecting type information used by the iv
44 * \tparam size1 first size specifier for the arrays
45 * \tparam size2 second size specifier for the arrays
46 */
47 template<class MVT, int size1, int size2>
48 class SystemMatricesHandle
49 {
50 using AMatrix = typename MVT::AMatrix;
51 using BMatrix = typename MVT::BMatrix;
52 using CMatrix = typename MVT::CMatrix;
53 using TMatrix = typename MVT::TMatrix;
54 using CellVector = typename MVT::CellVector;
55 using OutsideTij = std::vector< std::vector<CellVector> >;
56 using OmegaStorage = typename MVT::OmegaStorage;
57
58 public:
59 //! Access functions to context-dependent data
60 const CMatrix& CA() const { return CA_[contextIdx1_][contextIdx2_]; }
61 686908581 CMatrix& CA() { return CA_[contextIdx1_][contextIdx2_]; }
62
63 363 const AMatrix& A() const { return A_[contextIdx1_][contextIdx2_]; }
64 648751605 AMatrix& A() { return A_[contextIdx1_][contextIdx2_]; }
65
66 363 const BMatrix& AB() const { return AB_[contextIdx1_][contextIdx2_]; }
67 714937461 BMatrix& AB() { return AB_[contextIdx1_][contextIdx2_]; }
68
69
3/6
✓ Branch 3 taken 2000 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2000 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2000 times.
✗ Branch 8 not taken.
2148208611 const TMatrix& T() const { return T_[contextIdx1_][contextIdx2_]; }
70 546647145 TMatrix& T() { return T_[contextIdx1_][contextIdx2_]; }
71
72 446295513 const OutsideTij& tijOutside() const { return tijOutside_[contextIdx1_][contextIdx2_]; }
73 15303156 OutsideTij& tijOutside() { return tijOutside_[contextIdx1_][contextIdx2_]; }
74
75 const OmegaStorage& omegas() const { return wijk_[contextIdx1_][contextIdx2_]; }
76 455929089 OmegaStorage& omegas() { return wijk_[contextIdx1_][contextIdx2_]; }
77
78 //! functionality to set the context indices
79 void setContextIndex1(unsigned int idx) const { assert(idx < size1); contextIdx1_ = idx; }
80 void setContextIndex2(unsigned int idx) const { assert(idx < size2); contextIdx2_ = idx; }
81
82 protected:
83 //! indices to be set before accessing data
84 mutable unsigned int contextIdx1_{0};
85 mutable unsigned int contextIdx2_{0};
86
87 std::array< std::array<OmegaStorage, size2>, size1 > wijk_; //!< The omega factors that form the entries of the matrices
88
89 std::array< std::array<TMatrix, size2>, size1 > T_; //!< The transmissibility matrix
90 std::array< std::array<AMatrix, size2>, size1 > A_; //!< Inverse of the iv-local system matrix
91 std::array< std::array<BMatrix, size2>, size1 > AB_; //!< A_ left multiplied to B
92 std::array< std::array<CMatrix, size2>, size1 > CA_; //!< A_ right multiplied to C
93 std::array< std::array<OutsideTij, size2>, size1 > tijOutside_; //!< The transmissibilities for "outside" faces (on surface grids)
94 };
95
96 /*!
97 * \ingroup CCMpfaDiscretization
98 * \brief Common base class to all handles. Stores arrays of the vectors
99 * involved in the interaction volume-local systems of equations.
100 *
101 * \tparam MVT The matrix/vector traits collecting type information used by the iv
102 * \tparam size1 first size specifier for the arrays
103 * \tparam size2 second size specifier for the arrays
104 */
105 template<class MVT, int size1, int size2>
106 class SystemVectorsHandle
107 {
108 using CellVector = typename MVT::CellVector;
109
110 public:
111 //! Access to the iv-wide known cell/Dirichlet values
112
18/18
✓ Branch 0 taken 138244289 times.
✓ Branch 1 taken 142466621 times.
✓ Branch 2 taken 138244289 times.
✓ Branch 3 taken 142466621 times.
✓ Branch 4 taken 138244289 times.
✓ Branch 5 taken 142466621 times.
✓ Branch 6 taken 4112126 times.
✓ Branch 7 taken 3757222 times.
✓ Branch 8 taken 4112126 times.
✓ Branch 9 taken 3757222 times.
✓ Branch 10 taken 4112126 times.
✓ Branch 11 taken 3757222 times.
✓ Branch 12 taken 2781680 times.
✓ Branch 13 taken 2541328 times.
✓ Branch 14 taken 2781680 times.
✓ Branch 15 taken 2541328 times.
✓ Branch 16 taken 2781680 times.
✓ Branch 17 taken 2541328 times.
2594500887 const CellVector& uj() const { return u_[contextIdx1_][contextIdx2_]; }
113 315885414 CellVector& uj() { return u_[contextIdx1_][contextIdx2_]; }
114
115 protected:
116 //! functionality to set the context indices
117 void setContextIndex1(unsigned int idx) const { assert(idx < size1); contextIdx1_ = idx; }
118
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4177830 void setContextIndex2(unsigned int idx) const { assert(idx < size2); contextIdx2_ = idx; }
119
120 //! indices to be set before accessing data
121 mutable unsigned int contextIdx1_{0};
122 mutable unsigned int contextIdx2_{0};
123
124 //! The interaction volume-local known values
125 std::array< std::array<CellVector, size2>, size1 > u_;
126 };
127
128 } // end namespace CCMpfaDataHandleBases
129
130 //! Empty data handle class
131 class EmptyDataHandle {};
132
133 /*!
134 * \ingroup CCMpfaDiscretization
135 * \brief Data handle for quantities related to advection
136 */
137 template<class MatVecTraits, class PhysicsTraits, bool EnableAdvection>
138 class AdvectionDataHandle
139 : public CCMpfaDataHandleBases::SystemMatricesHandle<MatVecTraits, 1, 1>
140 , public CCMpfaDataHandleBases::SystemVectorsHandle<MatVecTraits, PhysicsTraits::numPhases, 1>
141 {
142 // we only have one local system for all phases since we
143 // solve them w.r.t. permeability tensor (unique for all phases)
144 using Base1 = CCMpfaDataHandleBases::SystemMatricesHandle<MatVecTraits, 1, 1>;
145
146 // we do have cell/Dirichlet values for all phases though!
147 static constexpr int numPhases = PhysicsTraits::numPhases;
148 using Base2 = CCMpfaDataHandleBases::SystemVectorsHandle<MatVecTraits, numPhases, 1>;
149
150 using UnknownVector = typename MatVecTraits::AMatrix::row_type;
151 using FaceVector = typename MatVecTraits::FaceVector;
152 using FaceScalar = typename FaceVector::value_type;
153 using OutsideGravityStorage = std::vector< std::vector<FaceScalar> >;
154
155 public:
156 //! Set the phase index of the context
157
9/9
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 546452508 times.
✓ Branch 2 taken 141025969 times.
✓ Branch 3 taken 145598256 times.
✓ Branch 4 taken 35790594 times.
✓ Branch 5 taken 26003255 times.
✓ Branch 6 taken 471288 times.
✓ Branch 7 taken 5535 times.
✓ Branch 8 taken 53661 times.
609367149 void setPhaseIndex(unsigned int phaseIdx) const { Base2::setContextIndex1(phaseIdx); }
158
159 //! The gravitational flux contributions for a phase on all faces
160 647106934 const FaceVector& g() const { return g_[Base2::contextIdx1_]; }
161 93507624 FaceVector& g() { return g_[Base2::contextIdx1_]; }
162
163 //! The deltaG vector for gravity within the iv-local eq-system
164
2/4
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121 times.
✗ Branch 3 not taken.
242 const UnknownVector& deltaG() const { return deltaG_[Base2::contextIdx1_]; }
165 93507624 UnknownVector& deltaG() { return deltaG_[Base2::contextIdx1_]; }
166
167 //! The gravitational acceleration for one phase on "outside" faces (used on surface grids)
168 159107800 const OutsideGravityStorage& gOutside() const { return outsideG_[Base2::contextIdx1_]; }
169 93507624 OutsideGravityStorage& gOutside() { return outsideG_[Base2::contextIdx1_]; }
170
171 private:
172 std::array< FaceVector, numPhases > g_; //!< The gravitational acceleration at each scvf (only for enabled gravity)
173 std::array< UnknownVector, numPhases > deltaG_; //!< The gravity coefficients forming part of iv-local eq-system
174 std::array< OutsideGravityStorage, numPhases > outsideG_; //!< The gravitational acceleration on "outside" faces (only on surface grids)
175 };
176
177 /*!
178 * \ingroup CCMpfaDiscretization
179 * \brief Data handle for quantities related to diffusion
180 */
181 template<class MatVecTraits, class PhysicsTraits, bool EnableDiffusion>
182 class DiffusionDataHandle
183 : public CCMpfaDataHandleBases::SystemMatricesHandle<MatVecTraits, PhysicsTraits::numPhases, PhysicsTraits::numComponents>
184 , public CCMpfaDataHandleBases::SystemVectorsHandle<MatVecTraits, PhysicsTraits::numPhases, PhysicsTraits::numComponents>
185 {
186 static constexpr int numPhases = PhysicsTraits::numPhases;
187 static constexpr int numComponents = PhysicsTraits::numComponents;
188 using Base1 = CCMpfaDataHandleBases::SystemMatricesHandle<MatVecTraits, numPhases, numComponents>;
189 using Base2 = CCMpfaDataHandleBases::SystemVectorsHandle<MatVecTraits, numPhases, numComponents>;
190
191 public:
192 //! diffusion caches need to set phase and component index
193 void setPhaseIndex(unsigned int phaseIdx) const
194
11/16
✗ Branch 0 not taken.
✓ Branch 1 taken 317762272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 317762272 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39442364 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 39442352 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 471286 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 471284 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 53664 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 53662 times.
357729586 { Base1::setContextIndex1(phaseIdx); Base2::setContextIndex1(phaseIdx); }
195 void setComponentIndex(unsigned int compIdx) const
196
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 317762272 times.
✓ Branch 2 taken 4112126 times.
✓ Branch 3 taken 3877312 times.
✓ Branch 4 taken 37680236 times.
✓ Branch 5 taken 1642040 times.
✓ Branch 6 taken 471284 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 53662 times.
357729586 { Base1::setContextIndex2(compIdx); Base2::setContextIndex2(compIdx); }
197 };
198
199 /*!
200 * \ingroup CCMpfaDiscretization
201 * \brief Data handle for quantities related to heat conduction
202 */
203 template<class MatVecTraits, class PhysicsTraits, bool enableHeatConduction>
204 class HeatConductionDataHandle
205 : public CCMpfaDataHandleBases::SystemMatricesHandle<MatVecTraits, 1, 1>
206 , public CCMpfaDataHandleBases::SystemVectorsHandle<MatVecTraits, 1, 1>
207 {};
208
209 //! Process-dependent data handles when related process is disabled
210 template<class MatVecTraits, class PhysicsTraits>
211 class AdvectionDataHandle<MatVecTraits, PhysicsTraits, false> : public EmptyDataHandle {};
212 template<class MatVecTraits, class PhysicsTraits>
213 class DiffusionDataHandle<MatVecTraits, PhysicsTraits, false> : public EmptyDataHandle {};
214 template<class MatVecTraits, class PhysicsTraits>
215 class HeatConductionDataHandle<MatVecTraits, PhysicsTraits, false> : public EmptyDataHandle {};
216
217 /*!
218 * \ingroup CCMpfaDiscretization
219 * \brief Class for the interaction volume data handle.
220 *
221 * \tparam MVT The matrix/vector traits collecting type information used by the iv
222 * \tparam PT The physics traits collecting data on the physical processes to be considered
223 */
224 template<class MVT, class PT>
225
0/13
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
8911188 class InteractionVolumeDataHandle
226 {
227
228 public:
229 //! export the underlying process-specific handle types
230 using AdvectionHandle = AdvectionDataHandle<MVT, PT, PT::enableAdvection>;
231 using DiffusionHandle = DiffusionDataHandle<MVT, PT, PT::enableMolecularDiffusion>;
232 using HeatConductionHandle = HeatConductionDataHandle<MVT, PT, PT::enableHeatConduction>;
233
234 //! return references to the handle containing data related to advection
235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
311491663 const AdvectionHandle& advectionHandle() const { return advectionHandle_; }
236
4/4
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 62362959 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 53661 times.
125920743 AdvectionHandle& advectionHandle() { return advectionHandle_; }
237
238 //! return references to the handle containing data related to diffusion
239 302288248 const DiffusionHandle& diffusionHandle() const { return diffusionHandle_; }
240
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39793570 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53664 times.
39847234 DiffusionHandle& diffusionHandle() { return diffusionHandle_; }
241
242 //! return references to the handle containing data related to heat conduction
243 20111872 const HeatConductionHandle& heatConductionHandle() const { return heatConductionHandle_; }
244 3031232 HeatConductionHandle& heatConductionHandle() { return heatConductionHandle_; }
245
246 private:
247 AdvectionHandle advectionHandle_;
248 DiffusionHandle diffusionHandle_;
249 HeatConductionHandle heatConductionHandle_;
250 };
251
252 } // end namespace Dumux
253
254 #endif
255