GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/fluidmatrixinteractions/2p/efftoabsdefaultpolicy.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 16 22 72.7%
Functions: 2 6 33.3%
Branches: 41 58 70.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 This is a policy for 2p material laws how to convert absolute to relative
11 * saturations and vice versa.
12 *
13 */
14 #ifndef DUMUX_MATERIAL_FLUIDMATRIX_TWOP_EFF_TO_ABS_DEFAULT_POLICY_HH
15 #define DUMUX_MATERIAL_FLUIDMATRIX_TWOP_EFF_TO_ABS_DEFAULT_POLICY_HH
16
17 #include <dune/common/float_cmp.hh>
18 #include <dumux/common/parameters.hh>
19
20 namespace Dumux::FluidMatrix {
21
22 /*!
23 * \ingroup Fluidmatrixinteractions
24 *
25 * \brief This is a policy for 2p material laws how to convert absolute to relative
26 * saturations and vice versa.
27 *
28 * Material laws (like VanGenuchten or BrooksCorey) are defined for effective saturations.
29 * The numeric calculations however are performed with absolute saturations. The policy class converts
30 * the saturations. This allows for changing the calculation of the effective
31 * saturations easily, as this is subject of discussion / may be problem specific.
32 */
33 class TwoPEffToAbsDefaultPolicy
34 {
35 public:
36 /*!
37 * \brief The parameter type
38 * \tparam Scalar The scalar type
39 * \note The efftoabs policy need two parameters: \f$\mathrm{S_{w,r}}, \mathrm{S_{n,r}}\f$.
40 * For the respective formulas check out the description of the free function.
41 */
42 template<class Scalar>
43 struct Params
44 {
45 203 Params(const Scalar swr = 0.0, const Scalar snr = 0.0)
46
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
202 : swr_(swr), snr_(snr)
47 {}
48
49 /*!
50 * \brief Return the residual wetting saturation.
51 */
52 Scalar swr() const
53 { return swr_; }
54
55 /*!
56 * \brief Set the residual wetting saturation.
57 */
58 void setSwr(Scalar v)
59
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
201 { swr_ = v; }
60
61 /*!
62 * \brief Return the residual non-wetting saturation.
63 */
64 Scalar snr() const
65 { return snr_; }
66
67 /*!
68 * \brief Set the residual non-wetting saturation.
69 */
70 void setSnr(Scalar v)
71
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
201 { snr_ = v; }
72
73 30741 bool operator== (const Params& p) const
74 {
75
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30741 times.
30741 return Dune::FloatCmp::eq(swr(), p.swr(), 1e-6)
76
3/6
✓ Branch 0 taken 30741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30741 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30741 times.
30741 && Dune::FloatCmp::eq(snr(), p.snr(), 1e-6);
77 }
78 private:
79 Scalar swr_;
80 Scalar snr_;
81 };
82
83 /*!
84 * \brief Construct from a subgroup from the global parameter tree
85 * \note This will give you nice error messages if a mandatory parameter is missing
86 */
87 template<class Scalar>
88 199 static Params<Scalar> makeParams(const std::string& paramGroup)
89 {
90 398 Params<Scalar> params;
91 199 params.setSwr(getParamFromGroup<Scalar>(paramGroup, "Swr", 0.0));
92 199 params.setSnr(getParamFromGroup<Scalar>(paramGroup, "Snr", 0.0));
93 199 return params;
94 }
95
96 /*!
97 * \brief Convert an absolute wetting saturation to an effective one.
98 *
99 * \param sw Absolute saturation of the wetting phase \f$\mathrm{[{S}_w]}\f$.
100 * \param params A container object that is populated with the appropriate coefficients for the respective law.
101 * Therefore, in the (problem specific) spatialParameters first, the material law is chosen,
102 * and then the params container is constructed accordingly. Afterwards the values are set there, too.
103 * \return Effective saturation of the wetting phase.
104 */
105 template<class Scalar>
106 static Scalar swToSwe(const Scalar sw, const Params<Scalar>& params)
107 {
108
25/27
✗ Branch 0 not taken.
✓ Branch 1 taken 270 times.
✓ Branch 2 taken 1875097 times.
✓ Branch 3 taken 136300949 times.
✓ Branch 4 taken 132162989 times.
✓ Branch 5 taken 431609 times.
✓ Branch 6 taken 130768017 times.
✓ Branch 7 taken 1422924 times.
✓ Branch 8 taken 7580618 times.
✓ Branch 9 taken 22 times.
✓ Branch 10 taken 178 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 100 times.
✓ Branch 14 taken 96 times.
✓ Branch 15 taken 100 times.
✓ Branch 16 taken 100 times.
✓ Branch 17 taken 100 times.
✓ Branch 18 taken 104 times.
✓ Branch 19 taken 100 times.
✓ Branch 20 taken 96 times.
✓ Branch 21 taken 100 times.
✓ Branch 22 taken 100 times.
✓ Branch 23 taken 100 times.
✓ Branch 24 taken 100 times.
✓ Branch 26 taken 66 times.
✓ Branch 27 taken 635 times.
1393601934 return (sw - params.swr())/(1.0 - params.swr() - params.snr());
109 }
110
111 /*!
112 * \brief Convert an effective wetting saturation to an absolute one.
113 *
114 * \param swe Effective saturation of the non-wetting phase \f$\mathrm{[\overline{S}_n]}\f$.
115 * \param params A container object that is populated with the appropriate coefficients for the respective law.
116 * Therefore, in the (problem specific) spatialParameters first, the material law is chosen,
117 * and then the params container is constructed accordingly. Afterwards the values are set there, too.
118 * \return Absolute saturation of the non-wetting phase.
119 */
120 template<class Scalar>
121 static Scalar sweToSw(const Scalar swe, const Params<Scalar>& params)
122 {
123
10/15
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 96 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 192 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 96 times.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
811460895 return swe*(1.0 - params.swr() - params.snr()) + params.swr();
124 }
125
126 /*!
127 * \brief Derivative of the effective saturation w.r.t. the absolute saturation.
128 *
129 * \param params A container object that is populated with the appropriate coefficients for the respective law.
130 * Therefore, in the (problem specific) spatialParameters first, the material law is chosen,
131 * and then the params container is constructed accordingly. Afterwards the values are set there, too.
132 * \return Derivative of the effective saturation w.r.t. the absolute saturation.
133 */
134 template<class Scalar>
135 static Scalar dswe_dsw(const Params<Scalar>& params)
136 {
137 40243334 return 1.0/(1.0 - params.swr() - params.snr());
138 }
139
140 /*!
141 * \brief Derivative of the absolute saturation w.r.t. the effective saturation.
142 *
143 * \param params A container object that is populated with the appropriate coefficients for the respective law.
144 * Therefore, in the (problem specific) spatialParameters first, the material law is chosen,
145 * and then the params container is constructed accordingly. Afterwards the values are set there, too.
146 * \return Derivative of the absolute saturation w.r.t. the effective saturation.
147 */
148 template<class Scalar>
149 static Scalar dsw_dswe(const Params<Scalar>& params)
150 {
151 41607808 return 1.0 - params.swr() - params.snr();
152 }
153 };
154
155 } // end namespace Dumux::FluidMatrix
156
157 #endif
158