GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/compositional/volumevariables.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 46 57 80.7%
Functions: 48 281 17.1%
Branches: 167 334 50.0%

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.
272112 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 40114708 void update(const ElementSolution &elemSol,
57 const Problem &problem,
58 const Element &element,
59 const SubControlVolume& scv)
60 {
61 40114708 ParentType::update(elemSol, problem, element, scv);
62
63 40114708 completeFluidState(elemSol, problem, element, scv, fluidState_);
64
65 typename FluidSystem::ParameterCache paramCache;
66 40114708 paramCache.updateAll(fluidState_);
67
68 40114708 auto getDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
69 {
70 42237748 return FluidSystem::binaryDiffusionCoefficient(this->fluidState_,
71 42237748 paramCache,
72 0,
73 compIIdx,
74 compJIdx);
75 };
76
77 40114708 diffCoefficient_.update(getDiffusionCoefficient);
78 40114708 }
79
80 /*!
81 * \brief Update the fluid state
82 */
83 template<class ElementSolution, class Problem, class Element, class SubControlVolume>
84 40114708 static void completeFluidState(const ElementSolution& elemSol,
85 const Problem& problem,
86 const Element& element,
87 const SubControlVolume& scv,
88 FluidState& fluidState)
89 {
90 58324746 fluidState.setTemperature(ParentType::temperature(elemSol, problem, element, scv));
91 80229416 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 40114708 fluidState.setSaturation(0, 1.0);
97
98 40114708 Scalar sumFracMinorComp = 0.0;
99
100
2/2
✓ Branch 0 taken 41176228 times.
✓ Branch 1 taken 40114708 times.
81290936 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 41176228 Scalar moleOrMassFraction = elemSol[0][Indices::conti0EqIdx+compIdx] + 1.0;
105 41176228 moleOrMassFraction = moleOrMassFraction - 1.0;
106 if(useMoles)
107 41176228 fluidState.setMoleFraction(0, compIdx, moleOrMassFraction);
108 else
109 fluidState.setMassFraction(0, compIdx, moleOrMassFraction);
110 41176228 sumFracMinorComp += moleOrMassFraction;
111 }
112 if(useMoles)
113 40114708 fluidState.setMoleFraction(0, 0, 1.0 - sumFracMinorComp);
114 else
115 fluidState.setMassFraction(0, 0, 1.0 - sumFracMinorComp);
116
117 typename FluidSystem::ParameterCache paramCache;
118 40114708 paramCache.updateAll(fluidState);
119
120 41176228 Scalar value = FluidSystem::density(fluidState, paramCache, 0);
121 41176228 fluidState.setDensity(0, value);
122
123 41176228 value = FluidSystem::molarDensity(fluidState, paramCache, 0);
124 41176228 fluidState.setMolarDensity(0, value);
125
126 41176228 value = FluidSystem::viscosity(fluidState, paramCache, 0);
127 62019378 fluidState.setViscosity(0, value);
128
129 // compute and set the enthalpy
130 40114708 const Scalar h = ParentType::enthalpy(fluidState, paramCache);
131 80229416 fluidState.setEnthalpy(0, h);
132 40114708 }
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 95740648 { 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
77/160
✓ Branch 4 taken 19400255 times.
✓ Branch 5 taken 2051801 times.
✓ Branch 6 taken 24554322 times.
✓ Branch 7 taken 2978142 times.
✓ Branch 8 taken 22392698 times.
✓ Branch 9 taken 15863346 times.
✓ Branch 10 taken 22977448 times.
✓ Branch 11 taken 16729358 times.
✓ Branch 12 taken 42516529 times.
✓ Branch 13 taken 1792961 times.
✓ Branch 14 taken 36777712 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 88441736 times.
✓ Branch 25 taken 41485934 times.
✓ Branch 26 taken 88441736 times.
✓ Branch 27 taken 41485934 times.
✓ Branch 28 taken 42595454 times.
✓ Branch 29 taken 40515890 times.
✓ Branch 30 taken 42603304 times.
✓ Branch 31 taken 40515890 times.
✓ Branch 32 taken 1011538 times.
✓ Branch 33 taken 29109136 times.
✓ Branch 34 taken 1011538 times.
✓ Branch 35 taken 29109136 times.
✓ Branch 36 taken 701228 times.
✓ Branch 37 taken 23702116 times.
✓ Branch 38 taken 693378 times.
✓ Branch 39 taken 23702116 times.
✓ Branch 40 taken 392238 times.
✓ Branch 41 taken 18417676 times.
✓ Branch 42 taken 392238 times.
✓ Branch 43 taken 18417676 times.
✓ Branch 44 taken 392238 times.
✓ Branch 45 taken 18417676 times.
✓ Branch 46 taken 392238 times.
✓ Branch 47 taken 18417676 times.
✓ Branch 48 taken 414088 times.
✓ Branch 49 taken 18417676 times.
✓ Branch 50 taken 414088 times.
✓ Branch 51 taken 18417676 times.
✓ Branch 52 taken 191680 times.
✓ Branch 53 taken 14789740 times.
✓ Branch 54 taken 191680 times.
✓ Branch 55 taken 14789740 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 5414920 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 5414920 times.
✓ Branch 60 taken 12600 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 12600 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 6600 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 6600 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 13000 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 13000 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 6600 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 13000 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 13000 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 13000 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 19200 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 19200 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 6400 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 6400 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 6400 times.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
2399351398 { 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 98373072 { 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
46/108
✓ Branch 0 taken 1360306 times.
✓ Branch 1 taken 23727852 times.
✓ Branch 2 taken 1635500 times.
✓ Branch 3 taken 27975300 times.
✓ Branch 4 taken 1879320 times.
✓ Branch 5 taken 31893300 times.
✓ Branch 6 taken 1867120 times.
✓ Branch 7 taken 31893300 times.
✓ Branch 8 taken 1510502 times.
✓ Branch 9 taken 37274584 times.
✓ Branch 10 taken 1510502 times.
✓ Branch 11 taken 37274584 times.
✓ Branch 12 taken 1510502 times.
✓ Branch 13 taken 37274584 times.
✓ Branch 14 taken 1510502 times.
✓ Branch 15 taken 37274584 times.
✓ Branch 16 taken 533614 times.
✓ Branch 17 taken 19725808 times.
✓ Branch 18 taken 291070 times.
✓ Branch 19 taken 15478360 times.
✓ Branch 20 taken 28100 times.
✓ Branch 21 taken 11560360 times.
✓ Branch 22 taken 7650 times.
✓ Branch 23 taken 11560360 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 11560360 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 11560360 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 11560360 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 11560360 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 11560360 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 11560360 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 11560360 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 11560360 times.
✓ Branch 40 taken 13000 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 13000 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 13000 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 13000 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 13000 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 13000 times.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
977558798 { 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 180936 Scalar massFraction(int compIdx) const
187
2/4
✓ Branch 0 taken 129668 times.
✓ Branch 1 taken 129668 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
297736 { 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.
553972144 { 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.
479679712 { 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 138584132 { 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.
166252942 { 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