GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/fluidmatrixinteractions/2p/linearmaterial.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 9 23 39.1%
Functions: 1 9 11.1%
Branches: 2 30 6.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 Linear capillary pressure and
11 * relative permeability <-> saturation relations
12 */
13 #ifndef DUMUX_MATERIAL_FLUIDMATRIX_LINEAR_MATERIAL_HH
14 #define DUMUX_MATERIAL_FLUIDMATRIX_LINEAR_MATERIAL_HH
15
16 #include <algorithm>
17 #include <dumux/common/parameters.hh>
18 #include <dumux/material/fluidmatrixinteractions/2p/materiallaw.hh>
19 #include <dumux/material/fluidmatrixinteractions/2p/noregularization.hh>
20
21 namespace Dumux::FluidMatrix {
22
23 /*!
24 * \ingroup Fluidmatrixinteractions
25 *
26 * \brief Linear capillary pressure and
27 * relative permeability <-> saturation relations
28 *
29 * The entry pressure is reached at \f$\mathrm{ \overline{S}_w = 1}\f$, the maximum
30 * capillary pressure is observed at \f$\mathrm{ \overline{S}_w = 0}\f$.
31 *
32 */
33 class LinearMaterial
34 {
35 public:
36 /*!
37 * \brief The parameter type
38 * \tparam Scalar The scalar type
39 */
40 template<class Scalar>
41 struct Params
42 {
43 1 Params(Scalar pcEntry, Scalar pcMax)
44
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 : pcEntry_(pcEntry), pcMax_(pcMax)
45 {}
46
47 Scalar pcEntry() const { return pcEntry_; }
48 void setPcEntry(Scalar pcEntry) { pcEntry_ = pcEntry; }
49
50 Scalar pcMax() const { return pcMax_; }
51 void setPcMax(Scalar pcMax) { pcMax_ = pcMax; }
52
53 bool operator== (const Params& p) const
54 {
55 return Dune::FloatCmp::eq(pcEntry(), p.pcEntry(), 1e-6)
56 && Dune::FloatCmp::eq(pcMax(), p.pcMax(), 1e-6);
57 }
58
59 private:
60 Scalar pcEntry_, pcMax_;
61 };
62
63 /*!
64 * \brief Construct from a subgroup from the global parameter tree
65 * \note This will give you nice error messages if a mandatory parameter is missing
66 */
67 template<class Scalar = double>
68 1 static Params<Scalar> makeParams(const std::string& paramGroup)
69 {
70 1 const auto pcEntry = getParamFromGroup<Scalar>(paramGroup, "LinearPcEntry");
71 1 const auto pcMax = getParamFromGroup<Scalar>(paramGroup, "LinearPcMax");
72 1 return {pcEntry, pcMax};
73 }
74
75 /*!
76 * \brief The capillary pressure-saturation curve
77 */
78 template<class Scalar>
79 static Scalar pc(Scalar swe, const Params<Scalar>& params)
80 {
81 return (1.0 - swe)*(params.pcMax() - params.pcEntry()) + params.pcEntry();
82 }
83
84 /*!
85 * \brief The inverse saturation-capillary pressure curve
86 */
87 template<class Scalar>
88 static Scalar swe(Scalar pc, const Params<Scalar>& params)
89 {
90
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
7174144 return 1.0 - (pc - params.pcEntry())/(params.pcMax() - params.pcEntry());
91 }
92
93 /*!
94 * \brief The capillary pressure at Swe = 1.0 also called end point capillary pressure
95 */
96 template<class Scalar>
97 static Scalar endPointPc(const Params<Scalar>& params)
98 7174144 { return params.pcEntry(); }
99
100 /*!
101 * \brief The partial derivative of the capillary pressure w.r.t. the effective saturation
102 */
103 template<class Scalar>
104 static Scalar dpc_dswe(Scalar swe, const Params<Scalar>& params)
105 {
106 return params.pcEntry() - params.pcMax();
107 }
108
109 /*!
110 * \brief The partial derivative of the effective saturation w.r.t. the capillary pressure
111 */
112 template<class Scalar>
113 static Scalar dswe_dpc(Scalar pc, const Params<Scalar>& params)
114 {
115 return 1.0/(params.pcEntry() - params.pcMax());
116 }
117
118 /*!
119 * \brief The relative permeability for the wetting phase
120 */
121 template<class Scalar>
122 static Scalar krw(Scalar swe, const Params<Scalar>& params)
123 {
124 using std::clamp;
125
1/10
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 7174144 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7174144 return clamp(swe, 0.0, 1.0);
126 }
127
128 /*!
129 * \brief The derivative of the relative permeability
130 */
131 template<class Scalar>
132 static Scalar dkrw_dswe(Scalar swe, const Params<Scalar>& params)
133 {
134 return 1.0;
135 }
136
137 /*!
138 * \brief The relative permeability for the non-wetting phase
139 */
140 template<class Scalar>
141 static Scalar krn(Scalar swe, const Params<Scalar>& params)
142 {
143 using std::clamp;
144 return clamp(1.0-swe, 0.0, 1.0);
145 }
146
147 /*!
148 * \brief The derivative of the relative permeability
149 */
150 template<class Scalar>
151 static Scalar dkrn_dswe(Scalar swe, const Params<Scalar>& params)
152 {
153 return -1.0;
154 }
155 };
156
157 template<typename Scalar = double>
158 using LinearMaterialDefault = TwoPMaterialLaw<Scalar, LinearMaterial, NoRegularization, TwoPEffToAbsDefaultPolicy>;
159
160 } // end namespace Dumux::FluidMatrix
161
162 #endif
163