GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/fluidmatrixinteractions/mp/mplinearmaterial.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 12 14 85.7%
Functions: 0 1 0.0%
Branches: 4 6 66.7%

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 Fluidmatrixinteractions
10 * \brief Implements a linear saturation-capillary pressure relation
11 *
12 * Implements a linear saturation-capillary pressure relation for
13 * M-phase fluid systems.
14 */
15 #ifndef DUMUX_MP_LINEAR_MATERIAL_HH
16 #define DUMUX_MP_LINEAR_MATERIAL_HH
17
18 #include <algorithm>
19 #include <dune/common/fvector.hh>
20 #include <dumux/material/fluidmatrixinteractions/fluidmatrixinteraction.hh>
21
22 namespace Dumux::FluidMatrix {
23
24 /*!
25 * \ingroup Fluidmatrixinteractions
26 * \brief Implements a linear saturation-capillary pressure relation
27 *
28 * Implements a linear saturation-capillary pressure relation for
29 * M-phase fluid systems.
30 *
31 */
32 template<class S, int numFluidPhases>
33 class MPLinearMaterial
34 : public Adapter<MPLinearMaterial<S, numFluidPhases>, MultiPhasePcKrSw>
35 {
36 struct Params
37 {
38 52 Params(const std::array<S, numFluidPhases>& pcMaxSat,
39 const std::array<S, numFluidPhases>& pcMinSat)
40 52 : pcMaxSat_(pcMaxSat), pcMinSat_(pcMinSat) {}
41
42 33876 S pcMaxSat(int phaseIdx) const { return pcMaxSat_[phaseIdx]; }
43 33876 S pcMinSat(int phaseIdx) const { return pcMinSat_[phaseIdx]; }
44 private:
45 std::array<S, numFluidPhases> pcMaxSat_;
46 std::array<S, numFluidPhases> pcMinSat_;
47 };
48
49 public:
50 using BasicParams = Params;
51 using Scalar = S;
52
53 52 MPLinearMaterial(const BasicParams& basicParams)
54 52 : basicParams_(basicParams)
55 {}
56
57 /*!
58 * \brief The linear capillary pressure-saturation curve.
59 *
60 * This material law is linear:
61 * \f[
62 p_C = (1 - \overline{S}_w) (p_{C,max} - p_{C,entry}) + p_{C,entry}
63 \f]
64 *
65 * \param state The fluid state
66 * \param wPhaseIdx The phase index of the wetting phase
67 */
68 template <class FluidState>
69 auto capillaryPressures(const FluidState& state, int wPhaseIdx = 0) const
70 {
71 static_assert(FluidState::numPhases == numFluidPhases, "FluidState doesn't match the number of fluid phases!");
72 5646 Dune::FieldVector<typename FluidState::Scalar, numFluidPhases> values;
73
4/6
✓ Branch 0 taken 9972 times.
✓ Branch 1 taken 3324 times.
✓ Branch 2 taken 6966 times.
✓ Branch 3 taken 2322 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22584 for (int phaseIdx = 0; phaseIdx < numFluidPhases; ++phaseIdx)
74 {
75 16938 const Scalar saturation = state.saturation(phaseIdx);
76 16938 values[phaseIdx] =
77 16938 saturation*basicParams_.pcMaxSat(phaseIdx) +
78 33876 (1 - saturation)*basicParams_.pcMinSat(phaseIdx);
79 }
80 return values;
81 }
82
83 /*!
84 * \brief The relative permeability of all phases.
85 * \param state The fluid state
86 * \param wPhaseIdx The phase index of the wetting phase
87 */
88 template <class FluidState>
89 auto relativePermeabilities(const FluidState& state, int wPhaseIdx = 0) const
90 {
91 static_assert(FluidState::numPhases == numFluidPhases, "FluidState doesn't match the number of fluid phases!");
92 using std::clamp;
93 Dune::FieldVector<typename FluidState::Scalar, FluidState::numPhases> values;
94 for (int phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
95 values[phaseIdx] = clamp(state.saturation(phaseIdx), 0.0, 1.0);
96 return values;
97 }
98 private:
99 BasicParams basicParams_;
100 };
101
102 } // end namespace Dumux::FluidMatrix
103
104 #endif
105