GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/porousmediumflow/1p/volumevariables.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 39 40 97.5%
Functions: 136 137 99.3%
Branches: 91 125 72.8%

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 OnePModel
10 * \brief Class to encapsulate the quantities required by the single-phase
11 * porous medium flow model per sub-control volume.
12 */
13
14 #ifndef DUMUX_1P_VOLUME_VARIABLES_HH
15 #define DUMUX_1P_VOLUME_VARIABLES_HH
16
17 #include <dumux/porousmediumflow/volumevariables.hh>
18 #include <dumux/porousmediumflow/nonisothermal/volumevariables.hh>
19 #include <dumux/material/fluidstates/immiscible.hh>
20 #include <dumux/material/solidstates/updatesolidvolumefractions.hh>
21
22 namespace Dumux {
23
24 /*!
25 * \ingroup OnePModel
26 * \brief Contains the quantities which are constant within a
27 * sub-control volume in the one-phase model.
28 *
29 * \tparam Traits Class encapsulating types to be used
30 */
31 template<class Traits>
32
12/15
✗ Branch 0 not taken.
✓ Branch 1 taken 302092 times.
✓ Branch 2 taken 136 times.
✓ Branch 3 taken 17732 times.
✓ Branch 4 taken 131084 times.
✓ Branch 5 taken 6872 times.
✓ Branch 6 taken 1759 times.
✓ Branch 7 taken 60755 times.
✓ Branch 8 taken 8136 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 97376 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3384 times.
✓ Branch 14 taken 1354 times.
✓ Branch 10 taken 477951 times.
19484541 class OnePVolumeVariables
33 : public PorousMediumFlowVolumeVariables< Traits>
34 , public EnergyVolumeVariables<Traits, OnePVolumeVariables<Traits> >
35 {
36 using ThisType = OnePVolumeVariables<Traits>;
37 using ParentType = PorousMediumFlowVolumeVariables<Traits>;
38 using EnergyVolVars = EnergyVolumeVariables<Traits, OnePVolumeVariables<Traits> >;
39
40 using Scalar = typename Traits::PrimaryVariables::value_type;
41 using PermeabilityType = typename Traits::PermeabilityType;
42 static constexpr int numFluidComps = ParentType::numFluidComponents();
43 public:
44 //! Export the underlying fluid system
45 using FluidSystem = typename Traits::FluidSystem;
46 //! Export the fluid state type
47 using FluidState = typename Traits::FluidState;
48 //! Export the indices
49 using Indices = typename Traits::ModelTraits::Indices;
50 //! Export type of solid state
51 using SolidState = typename Traits::SolidState;
52 //! Export type of solid system
53 using SolidSystem = typename Traits::SolidSystem;
54
55 /*!
56 * \brief Updates all quantities for a given control volume.
57 *
58 * \param elemSol A vector containing all primary variables connected to the element
59 * \param problem The object specifying the problem which ought to
60 * be simulated
61 * \param element An element which contains part of the control volume
62 * \param scv The sub-control volume
63 */
64 template<class ElemSol, class Problem, class Element, class Scv>
65 40231033 void update(const ElemSol& elemSol,
66 const Problem& problem,
67 const Element& element,
68 const Scv& scv)
69 {
70
9/13
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 60 times.
✓ Branch 12 taken 80 times.
✗ Branch 13 not taken.
✗ Branch 11 not taken.
✓ Branch 4 taken 1200 times.
✓ Branch 5 taken 644 times.
✓ Branch 2 taken 3262 times.
✗ Branch 3 not taken.
✓ Branch 0 taken 9498 times.
✓ Branch 1 taken 66324 times.
39829089 ParentType::update(elemSol, problem, element, scv);
71
72 // porosity
73 26954839 completeFluidState(elemSol, problem, element, scv, fluidState_, solidState_);
74
75 // porosity and permeability
76
2/2
✓ Branch 0 taken 9498 times.
✓ Branch 1 taken 66324 times.
40149733 updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
77 16124024 EnergyVolVars::updateSolidEnergyParams(elemSol, problem, element, scv, solidState_);
78
5/7
✓ Branch 1 taken 66404 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✓ Branch 0 taken 9498 times.
39747789 permeability_ = problem.spatialParams().permeability(element, scv, elemSol);
79 7747994 EnergyVolVars::updateEffectiveThermalConductivity();
80 32098159 }
81
82 /*!
83 * \brief Sets complete fluid state
84 *
85 * \param elemSol A vector containing all primary variables connected to the element
86 * \param problem The object specifying the problem which ought to
87 * be simulated
88 * \param element An element which contains part of the control volume
89 * \param scv The sub-control volume
90 * \param fluidState A container with the current (physical) state of the fluid
91 * \param solidState A container with the current (physical) state of the solid
92 */
93 template<class ElemSol, class Problem, class Element, class Scv>
94
5/9
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 80 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 80 times.
✗ Branch 13 not taken.
✓ Branch 2 taken 3262 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 644 times.
44660489 void completeFluidState(const ElemSol& elemSol,
95 const Problem& problem,
96 const Element& element,
97 const Scv& scv,
98 FluidState& fluidState,
99 SolidState& solidState)
100 {
101
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 EnergyVolVars::updateTemperature(elemSol, problem, element, scv, fluidState, solidState);
102
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 fluidState.setSaturation(/*phaseIdx=*/0, 1.);
103
104 45062433 const auto& priVars = elemSol[scv.localDofIndex()];
105
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 fluidState.setPressure(/*phaseIdx=*/0, priVars[Indices::pressureIdx]);
106
107 // saturation in a single phase is always 1 and thus redundant
108 // to set. But since we use the fluid state shared by the
109 // immiscible multi-phase models, so we have to set it here...
110 45062433 fluidState.setSaturation(/*phaseIdx=*/0, 1.0);
111
112 typename FluidSystem::ParameterCache paramCache;
113
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 paramCache.updatePhase(fluidState, /*phaseIdx=*/0);
114
115
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 Scalar value = FluidSystem::density(fluidState, paramCache, /*phaseIdx=*/0);
116 45062433 fluidState.setDensity(/*phaseIdx=*/0, value);
117
118
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 value = FluidSystem::viscosity(fluidState, paramCache, /*phaseIdx=*/0);
119 45062433 fluidState.setViscosity(/*phaseIdx=*/0, value);
120
121 // compute and set the enthalpy
122
2/4
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
44656583 value = EnergyVolVars::enthalpy(fluidState, paramCache, /*phaseIdx=*/0);
123
4/6
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 3262 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 644 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
44660489 fluidState.setEnthalpy(/*phaseIdx=*/0, value);
124 36621323 }
125
126 /*!
127 * \brief Returns the temperature \f$\mathrm{[K]}\f$ inside the sub-control volume.
128 *
129 * Note that we assume thermodynamic equilibrium, i.e. the
130 * temperatures of the rock matrix and of all fluid phases are
131 * identical.
132 */
133 6942480 Scalar temperature() const
134
1/2
✓ Branch 0 taken 529104 times.
✗ Branch 1 not taken.
5155650 { return fluidState_.temperature(); }
135
136 /*!
137 * \brief Returns the phase state for the control volume.
138 */
139 const SolidState &solidState() const
140
1/2
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
7341756 { return solidState_; }
141
142 /*!
143 * \brief Returns the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within
144 * the control volume.
145 */
146 158508812 Scalar pressure(int phaseIdx = 0) const
147
5/7
✓ Branch 1 taken 2689538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1092264 times.
✓ Branch 4 taken 32058562 times.
✓ Branch 6 taken 57 times.
✗ Branch 7 not taken.
✓ Branch 0 taken 38810 times.
156813658 { return fluidState_.pressure(phaseIdx); }
148
149 /*!
150 * \brief Returns the saturation.
151 */
152 Scalar saturation(int phaseIdx = 0) const
153 { return 1.0; }
154
155 /*!
156 * \brief Returns the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the
157 * control volume.
158 */
159 146698025 Scalar density(int phaseIdx = 0) const
160
9/9
✓ Branch 0 taken 1965281 times.
✓ Branch 1 taken 1685807 times.
✓ Branch 2 taken 32000106 times.
✓ Branch 3 taken 39147 times.
✓ Branch 5 taken 28060 times.
✓ Branch 6 taken 1475 times.
✓ Branch 7 taken 65 times.
✓ Branch 8 taken 1475 times.
✓ Branch 4 taken 22429 times.
145281977 { return fluidState_.density(phaseIdx); }
161
162 /*!
163 * \brief Returns the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the
164 * control volume.
165 */
166 34604050 Scalar viscosity(int phaseIdx = 0) const
167
2/2
✓ Branch 0 taken 955633 times.
✓ Branch 1 taken 33547664 times.
34604050 { return fluidState_.viscosity(phaseIdx); }
168
169 /*!
170 * \brief Returns the mobility \f$\mathrm{[1/(Pa s)]}\f$.
171 *
172 * This function enables the use of ImplicitDarcyFluxVariables
173 * with the 1p fully implicit model, ALTHOUGH the term mobility is
174 * usually not employed in the one phase context.
175 *
176 * \param phaseIdx The phase index
177 */
178 110635477 Scalar mobility(int phaseIdx = 0) const
179
2/2
✓ Branch 0 taken 33814 times.
✓ Branch 1 taken 46770 times.
110635477 { return 1.0/fluidState_.viscosity(phaseIdx); }
180
181 /*!
182 * \brief Returns the average porosity \f$\mathrm{[-]}\f$ within the control volume.
183 */
184 25931046 Scalar porosity() const
185 8230884 { return solidState_.porosity(); }
186
187 /*!
188 * \brief Returns the permeability within the control volume in \f$[m^2]\f$.
189 */
190 45955400 const PermeabilityType& permeability() const
191
4/5
✓ Branch 0 taken 94200 times.
✓ Branch 1 taken 22393200 times.
✓ Branch 3 taken 534400 times.
✗ Branch 4 not taken.
✓ Branch 2 taken 6000 times.
45955400 { return permeability_; }
192
193 /*!
194 * \brief Returns the fluid state of the control volume.
195 */
196 const FluidState &fluidState() const
197
4/4
✓ Branch 2 taken 3155 times.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 1475 times.
9825775 { return fluidState_; }
198
199 protected:
200 FluidState fluidState_;
201 SolidState solidState_;
202 PermeabilityType permeability_;
203 };
204
205 } // end namespace Dumux
206
207 #endif
208