GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/fluidstates/saturationoverlay.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 19 33 57.6%
Functions: 0 14 0.0%
Branches: 23 44 52.3%

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 FluidStates
10 * \brief This is a fluid state which allows to set the fluid
11 * saturations and takes all other quantities from an other
12 * fluid state.
13 */
14 #ifndef DUMUX_SATURATION_OVERLAY_FLUID_STATE_HH
15 #define DUMUX_SATURATION_OVERLAY_FLUID_STATE_HH
16
17 namespace Dumux {
18
19 /*!
20 * \ingroup FluidStates
21 * \brief This is a fluid state which allows to set the fluid
22 * saturations and takes all other quantities from an other
23 * fluid state.
24 */
25 template <class FluidState>
26 class SaturationOverlayFluidState
27 {
28 public:
29 static constexpr int numPhases = FluidState::numPhases;
30 static constexpr int numComponents = FluidState::numComponents;
31
32 //! export the scalar type
33 using Scalar = typename FluidState::Scalar;
34
35 /*!
36 * \brief Constructor
37 *
38 * \param fs Fluidstate
39 * The overlay fluid state copies the saturation from the argument,
40 * so it initially behaves exactly like the underlying fluid
41 * state.
42 */
43 1 SaturationOverlayFluidState(const FluidState &fs)
44 1 : fs_(&fs)
45 {
46
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
47 4 saturation_[phaseIdx] = fs.saturation(phaseIdx);
48 }
49
50 // copy & move constructor / assignment operators
51 SaturationOverlayFluidState(const SaturationOverlayFluidState &fs) = default;
52 SaturationOverlayFluidState(SaturationOverlayFluidState &&fs) = default;
53 SaturationOverlayFluidState& operator=(const SaturationOverlayFluidState &fs) = default;
54 SaturationOverlayFluidState& operator=(SaturationOverlayFluidState &&fs) = default;
55
56 /*****************************************************
57 * Generic access to fluid properties (No assumptions
58 * on thermodynamic equilibrium required)
59 *****************************************************/
60 /*!
61 * \brief Returns the saturation \f$S_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[-]}\f$.
62 *
63 * The saturation is defined as the pore space occupied by the fluid divided by the total pore space:
64 * \f[S_\alpha := \frac{\phi \mathcal{V}_\alpha}{\phi \mathcal{V}}\f]
65 *
66 * \param phaseIdx the index of the phase
67 */
68 Scalar saturation(int phaseIdx) const
69
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 { return saturation_[phaseIdx]; }
70
71 /*!
72 * @copydoc CompositionalFluidState::moleFraction()
73 */
74 Scalar moleFraction(int phaseIdx, int compIdx) const
75 2 { return fs_->moleFraction(phaseIdx, compIdx); }
76
77 /*!
78 * @copydoc CompositionalFluidState::massFraction()
79 */
80 Scalar massFraction(int phaseIdx, int compIdx) const
81 1 { return fs_->massFraction(phaseIdx, compIdx); }
82
83 /*!
84 * @copydoc CompositionalFluidState::averageMolarMass()
85 */
86 Scalar averageMolarMass(int phaseIdx) const
87
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->averageMolarMass(phaseIdx); }
88
89 /*!
90 * @copydoc CompositionalFluidState::molarity()
91 */
92 Scalar molarity(int phaseIdx, int compIdx) const
93
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->molarity(phaseIdx, compIdx); }
94
95 /*!
96 * @copydoc CompositionalFluidState::fugacity()
97 */
98 Scalar fugacity(int phaseIdx, int compIdx) const
99
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->fugacity(phaseIdx, compIdx); }
100
101 /*!
102 * @copydoc CompositionalFluidState::fugacityCoefficient()
103 */
104 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
105
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->fugacityCoefficient(phaseIdx, compIdx); }
106
107 /*!
108 * @copydoc CompositionalFluidState::molarVolume()
109 */
110 Scalar molarVolume(int phaseIdx) const
111
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->molarVolume(phaseIdx); }
112
113 /*!
114 * @copydoc CompositionalFluidState::density()
115 */
116 Scalar density(int phaseIdx) const
117
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->density(phaseIdx); }
118
119 /*!
120 * @copydoc CompositionalFluidState::molarDensity()
121 */
122 Scalar molarDensity(int phaseIdx) const
123
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->molarDensity(phaseIdx); }
124
125 /*!
126 * @copydoc CompositionalFluidState::temperature()
127 */
128 Scalar temperature(int phaseIdx) const
129 2 { return fs_->temperature(phaseIdx); }
130
131 /*!
132 * @copydoc CompositionalFluidState::pressure()
133 */
134 Scalar pressure(int phaseIdx) const
135 2 { return fs_->pressure(phaseIdx); }
136
137 /*!
138 * @copydoc CompositionalFluidState::enthalpy()
139 */
140 Scalar enthalpy(int phaseIdx) const
141
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->enthalpy(phaseIdx); }
142
143 /*!
144 * @copydoc CompositionalFluidState::internalEnergy()
145 */
146 Scalar internalEnergy(int phaseIdx) const
147
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->internalEnergy(phaseIdx); }
148
149 /*!
150 * @copydoc CompositionalFluidState::viscosity()
151 */
152 Scalar viscosity(int phaseIdx) const
153
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 { return fs_->viscosity(phaseIdx); }
154
155
156 /*****************************************************
157 * Setter methods. Note that these are not part of the
158 * generic FluidState interface but specific for each
159 * implementation...
160 *****************************************************/
161 /*!
162 * \brief Set the saturation \f$\mathrm{[-]}\f$ of a fluid phase
163 */
164 void setSaturation(int phaseIdx, Scalar value)
165 { saturation_[phaseIdx] = value; }
166
167 protected:
168 const FluidState *fs_;
169 Scalar saturation_[numPhases] = {};
170 };
171
172 } // end namespace Dumux
173
174 #endif
175