GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/compositional/volumevariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 48 57 84.2%
Functions: 84 281 29.9%
Branches: 225 334 67.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 FreeflowNCModel
10 *
11 * \copydoc Dumux::FreeflowNCVolumeVariables
12 */
13 #ifndef DUMUX_FREEFLOW_NC_VOLUMEVARIABLES_HH
14 #define DUMUX_FREEFLOW_NC_VOLUMEVARIABLES_HH
15
16 #include <array>
17 #include <dune/common/exceptions.hh>
18 #include <dumux/freeflow/volumevariables.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup FreeflowNCModel
24 * \brief Volume variables for the single-phase, multi-component free-flow model.
25 */
26 template <class Traits>
27
3/6
✓ Branch 1 taken 82912 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 82912 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 82912 times.
✗ Branch 8 not taken.
272862 class FreeflowNCVolumeVariables : public FreeFlowVolumeVariables< Traits, FreeflowNCVolumeVariables<Traits> >
28 {
29 using ThisType = FreeflowNCVolumeVariables<Traits>;
30 using ParentType = FreeFlowVolumeVariables<Traits, ThisType>;
31
32 using Scalar = typename Traits::PrimaryVariables::value_type;
33
34 static constexpr bool useMoles = Traits::ModelTraits::useMoles();
35 static constexpr int numFluidComps = ParentType::numFluidComponents();
36 using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
37
38 public:
39 //! export the underlying fluid system
40 using FluidSystem = typename Traits::FluidSystem;
41 //! export the fluid state type
42 using FluidState = typename Traits::FluidState;
43 //! export the indices type
44 using Indices = typename Traits::ModelTraits::Indices;
45
46 /*!
47 * \brief Update all quantities for a given control volume
48 *
49 * \param elemSol A vector containing all primary variables connected to the element
50 * \param problem The object specifying the problem which ought to
51 * be simulated
52 * \param element An element which contains part of the control volume
53 * \param scv The sub-control volume
54 */
55 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
56 40937608 void update(const ElementSolution &elemSol,
57 const Problem &problem,
58 const Element &element,
59 const SubControlVolume& scv)
60 {
61 40937608 ParentType::update(elemSol, problem, element, scv);
62
63 40937608 completeFluidState(elemSol, problem, element, scv, fluidState_);
64
65 typename FluidSystem::ParameterCache paramCache;
66 40937608 paramCache.updateAll(fluidState_);
67
68 40937608 auto getDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
69 {
70 43058698 return FluidSystem::binaryDiffusionCoefficient(this->fluidState_,
71 43058698 paramCache,
72 0,
73 compIIdx,
74 compJIdx);
75 };
76
77 40937608 diffCoefficient_.update(getDiffusionCoefficient);
78 40937608 }
79
80 /*!
81 * \brief Update the fluid state
82 */
83 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
84 40937608 static void completeFluidState(const ElementSolution& elemSol,
85 const Problem& problem,
86 const Element& element,
87 const SubControlVolume& scv,
88 FluidState& fluidState)
89 {
90 59968596 fluidState.setTemperature(ParentType::temperature(elemSol, problem, element, scv));
91 81875216 fluidState.setPressure(0, elemSol[0][Indices::pressureIdx]);
92
93 // saturation in a single phase is always 1 and thus redundant
94 // to set. But since we use the fluid state shared by the
95 // immiscible multi-phase models, so we have to set it here...
96 40937608 fluidState.setSaturation(0, 1.0);
97
98 40937608 Scalar sumFracMinorComp = 0.0;
99
100
2/2
✓ Branch 0 taken 41997178 times.
✓ Branch 1 taken 40935658 times.
82936736 for(int compIdx = 1; compIdx < ParentType::numFluidComponents(); ++compIdx)
101 {
102 // temporary add 1.0 to remove spurious differences in mole fractions
103 // which are below the numerical accuracy
104 41999128 Scalar moleOrMassFraction = elemSol[0][Indices::conti0EqIdx+compIdx] + 1.0;
105 41999128 moleOrMassFraction = moleOrMassFraction - 1.0;
106 if(useMoles)
107 41995228 fluidState.setMoleFraction(0, compIdx, moleOrMassFraction);
108 else
109 3900 fluidState.setMassFraction(0, compIdx, moleOrMassFraction);
110 41999128 sumFracMinorComp += moleOrMassFraction;
111 }
112 if(useMoles)
113 40933708 fluidState.setMoleFraction(0, 0, 1.0 - sumFracMinorComp);
114 else
115 3900 fluidState.setMassFraction(0, 0, 1.0 - sumFracMinorComp);
116
117 typename FluidSystem::ParameterCache paramCache;
118 40937608 paramCache.updateAll(fluidState);
119
120 41999128 Scalar value = FluidSystem::density(fluidState, paramCache, 0);
121 41999128 fluidState.setDensity(0, value);
122
123 41999128 value = FluidSystem::molarDensity(fluidState, paramCache, 0);
124 41999128 fluidState.setMolarDensity(0, value);
125
126 41999128 value = FluidSystem::viscosity(fluidState, paramCache, 0);
127 62844228 fluidState.setViscosity(0, value);
128
129 // compute and set the enthalpy
130 40937608 const Scalar h = ParentType::enthalpy(fluidState, paramCache);
131 81875216 fluidState.setEnthalpy(0, h);
132 40937608 }
133
134 /*!
135 * \brief Return the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within
136 * the control volume.
137 */
138 Scalar pressure(int phaseIdx = 0) const
139 97455348 { return fluidState_.pressure(0); }
140
141 /*!
142 * \brief Return the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the
143 * control volume.
144 */
145 Scalar density(int phaseIdx = 0) const
146
107/160
✓ Branch 4 taken 19400255 times.
✓ Branch 5 taken 2051801 times.
✓ Branch 6 taken 24554322 times.
✓ Branch 7 taken 2978142 times.
✓ Branch 8 taken 22831548 times.
✓ Branch 9 taken 16281296 times.
✓ Branch 10 taken 23416298 times.
✓ Branch 11 taken 17147308 times.
✓ Branch 12 taken 44613529 times.
✓ Branch 13 taken 1792961 times.
✓ Branch 14 taken 38874712 times.
✓ Branch 15 taken 608 times.
✓ Branch 16 taken 2831367 times.
✓ Branch 17 taken 4859157 times.
✓ Branch 18 taken 2831367 times.
✓ Branch 19 taken 4859157 times.
✓ Branch 20 taken 56831135 times.
✓ Branch 21 taken 18987265 times.
✓ Branch 22 taken 56831135 times.
✓ Branch 23 taken 18987265 times.
✓ Branch 24 taken 88501486 times.
✓ Branch 25 taken 42534434 times.
✓ Branch 26 taken 88501486 times.
✓ Branch 27 taken 42534434 times.
✓ Branch 28 taken 42655204 times.
✓ Branch 29 taken 41564390 times.
✓ Branch 30 taken 42663079 times.
✓ Branch 31 taken 41564390 times.
✓ Branch 32 taken 1071313 times.
✓ Branch 33 taken 30157636 times.
✓ Branch 34 taken 1071288 times.
✓ Branch 35 taken 30157636 times.
✓ Branch 36 taken 761003 times.
✓ Branch 37 taken 24750616 times.
✓ Branch 38 taken 753153 times.
✓ Branch 39 taken 24750616 times.
✓ Branch 40 taken 392238 times.
✓ Branch 41 taken 18417676 times.
✓ Branch 42 taken 392263 times.
✓ Branch 43 taken 18417676 times.
✓ Branch 44 taken 392263 times.
✓ Branch 45 taken 18417676 times.
✓ Branch 46 taken 392238 times.
✓ Branch 47 taken 18417676 times.
✓ Branch 48 taken 414113 times.
✓ Branch 49 taken 18417676 times.
✓ Branch 50 taken 414113 times.
✓ Branch 51 taken 18417676 times.
✓ Branch 52 taken 191680 times.
✓ Branch 53 taken 14789740 times.
✓ Branch 54 taken 191705 times.
✓ Branch 55 taken 14789740 times.
✓ Branch 56 taken 25 times.
✓ Branch 57 taken 5414920 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 5414920 times.
✓ Branch 60 taken 14425 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 14425 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 6600 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 6625 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 13025 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 13000 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 6625 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 13025 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 13025 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 13025 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 19225 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 19225 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 13000 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 13000 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 13000 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 13000 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 13000 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 13000 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 6400 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 6400 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 6425 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 6425 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 6425 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 25 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 25 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 25 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 25 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 25 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 25 times.
✗ Branch 117 not taken.
✓ Branch 118 taken 25 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 25 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 25 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 25 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 25 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 25 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 25 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 25 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 25 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 25 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 25 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 25 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 25 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 25 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 25 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 25 times.
✗ Branch 149 not taken.
✓ Branch 150 taken 25 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 25 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 25 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 25 times.
✗ Branch 157 not taken.
✓ Branch 158 taken 25 times.
✗ Branch 159 not taken.
✓ Branch 160 taken 25 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 25 times.
✗ Branch 163 not taken.
2449590170 { return fluidState_.density(0); }
147
148 /*!
149 * \brief Return temperature \f$\mathrm{[K]}\f$ inside the sub-control volume.
150 *
151 * Note that we assume thermodynamic equilibrium, i.e. the
152 * temperatures of the rock matrix and of all fluid phases are
153 * identical.
154 */
155 Scalar temperature() const
156 102710372 { return fluidState_.temperature(); }
157
158 /*!
159 * \brief Return the effective dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the
160 * control volume.
161 */
162 Scalar effectiveViscosity() const
163 84339240 { return viscosity(); }
164
165 /*!
166 * \brief Return the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the
167 * control volume.
168 */
169 Scalar viscosity(int phaseIdx = 0) const
170
74/108
✓ Branch 0 taken 1420056 times.
✓ Branch 1 taken 24776352 times.
✓ Branch 2 taken 1695250 times.
✓ Branch 3 taken 29023800 times.
✓ Branch 4 taken 1939095 times.
✓ Branch 5 taken 32941800 times.
✓ Branch 6 taken 1926895 times.
✓ Branch 7 taken 32941800 times.
✓ Branch 8 taken 1570277 times.
✓ Branch 9 taken 38323084 times.
✓ Branch 10 taken 1570277 times.
✓ Branch 11 taken 38323084 times.
✓ Branch 12 taken 1570277 times.
✓ Branch 13 taken 38323084 times.
✓ Branch 14 taken 1570277 times.
✓ Branch 15 taken 38323084 times.
✓ Branch 16 taken 535439 times.
✓ Branch 17 taken 19725808 times.
✓ Branch 18 taken 292895 times.
✓ Branch 19 taken 15478360 times.
✓ Branch 20 taken 28125 times.
✓ Branch 21 taken 11560360 times.
✓ Branch 22 taken 7675 times.
✓ Branch 23 taken 11560360 times.
✓ Branch 24 taken 25 times.
✓ Branch 25 taken 11560360 times.
✓ Branch 26 taken 25 times.
✓ Branch 27 taken 11560360 times.
✓ Branch 28 taken 25 times.
✓ Branch 29 taken 11560360 times.
✓ Branch 30 taken 25 times.
✓ Branch 31 taken 11560360 times.
✓ Branch 32 taken 25 times.
✓ Branch 33 taken 11560360 times.
✓ Branch 34 taken 25 times.
✓ Branch 35 taken 11560360 times.
✓ Branch 36 taken 25 times.
✓ Branch 37 taken 11560360 times.
✓ Branch 38 taken 25 times.
✓ Branch 39 taken 11560360 times.
✓ Branch 40 taken 13025 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 13025 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 13000 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 13000 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 13000 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 13000 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 13000 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 13000 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 13000 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 13000 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 13025 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 13025 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 13025 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 13025 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 25 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 25 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 25 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 25 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 25 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 25 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 25 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 25 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 25 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 25 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 25 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 25 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 25 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 25 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 25 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 25 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 25 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 25 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 25 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 25 times.
✗ Branch 107 not taken.
994770148 { return fluidState_.viscosity(0); }
171
172 /*!
173 * \brief Returns the mass fraction of a component in the phase \f$\mathrm{[-]}\f$
174 *
175 * \param phaseIdx the index of the phase
176 * \param compIdx the index of the component
177 */
178 Scalar massFraction(int phaseIdx, int compIdx) const
179
0/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4175480 { return fluidState_.massFraction(0, compIdx); }
180
181 /*!
182 * \brief Returns the mass fraction of a component in the phase \f$\mathrm{[-]}\f$
183 *
184 * \param compIdx the index of the component
185 */
186 185736 Scalar massFraction(int compIdx) const
187
2/4
✓ Branch 0 taken 131768 times.
✓ Branch 1 taken 131768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
302536 { return fluidState_.massFraction(0, compIdx); }
188
189 /*!
190 * \brief Returns the mole fraction of a component in the phase \f$\mathrm{[-]}\f$
191 *
192 * \param phaseIdx the index of the phase
193 * \param compIdx the index of the component
194 */
195 Scalar moleFraction(int phaseIdx, int compIdx) const
196
12/12
✓ Branch 0 taken 174476 times.
✓ Branch 1 taken 86084 times.
✓ Branch 2 taken 174476 times.
✓ Branch 3 taken 86084 times.
✓ Branch 4 taken 119393 times.
✓ Branch 5 taken 284535 times.
✓ Branch 6 taken 119393 times.
✓ Branch 7 taken 284535 times.
✓ Branch 12 taken 20506 times.
✓ Branch 13 taken 23494 times.
✓ Branch 14 taken 20506 times.
✓ Branch 15 taken 23494 times.
2443568 { return fluidState_.moleFraction(0, compIdx); }
197
198 /*!
199 * \brief Returns the mole fraction of a component in the phase \f$\mathrm{[-]}\f$
200 *
201 * \param compIdx the index of the component
202 */
203 Scalar moleFraction(int compIdx) const
204
8/16
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 877920 times.
✓ Branch 13 taken 877920 times.
✓ Branch 14 taken 877920 times.
✓ Branch 15 taken 877920 times.
✓ Branch 16 taken 877920 times.
✓ Branch 17 taken 877920 times.
✓ Branch 18 taken 877920 times.
✓ Branch 19 taken 877920 times.
562839344 { return fluidState_.moleFraction(0, compIdx); }
205
206 /*!
207 * \brief Returns the mass density of a given phase \f$\mathrm{[kg/m^3]}\f$
208 */
209 Scalar molarDensity(int phaseIdx = 0) const
210
10/12
✓ Branch 0 taken 270759 times.
✓ Branch 1 taken 165937 times.
✓ Branch 2 taken 270759 times.
✓ Branch 3 taken 165937 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 170512 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 170512 times.
✓ Branch 8 taken 43616 times.
✓ Branch 9 taken 57664 times.
✓ Branch 10 taken 43616 times.
✓ Branch 11 taken 57664 times.
488546312 { return fluidState_.molarDensity(0); }
211
212 /*!
213 * \brief Returns the molar mass of a given component.
214 *
215 * \param compIdx the index of the component
216 */
217 Scalar molarMass(int compIdx) const
218 { return FluidSystem::molarMass(compIdx); }
219
220 /*!
221 * \brief Returns the average molar mass \f$\mathrm{[kg/mol]}\f$ of the fluid phase.
222 *
223 * \param phaseIdx The phase index
224 */
225 Scalar averageMolarMass(const int phaseIdx = 0) const
226 16912160 { return fluidState_.averageMolarMass(phaseIdx); }
227
228 /*!
229 * \brief Returns the binary diffusion coefficients for a phase in \f$[m^2/s]\f$.
230 */
231 Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
232 142853782 { return diffCoefficient_(0, compIIdx, compJIdx); }
233
234 /*!
235 * \brief Returns the effective diffusion coefficients for a phase in \f$[m^2/s]\f$.
236 */
237 Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
238
4/4
✓ Branch 2 taken 166760 times.
✓ Branch 3 taken 3871720 times.
✓ Branch 4 taken 6692226 times.
✓ Branch 5 taken 10225356 times.
31825122 { return diffusionCoefficient(0, compIIdx, compJIdx); }
239
240 /*!
241 * \brief Return the fluid state of the control volume.
242 */
243 const FluidState& fluidState() const
244
3/4
✓ Branch 0 taken 12248 times.
✓ Branch 1 taken 72 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 48356 times.
173638542 { return fluidState_; }
245
246 protected:
247 FluidState fluidState_;
248 // Binary diffusion coefficient
249 DiffusionCoefficients diffCoefficient_;
250 };
251
252 } // end namespace Dumux
253
254 #endif
255