GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/material/fluidmatrixinteractions/fluidmatrixinteraction.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 32 33 97.0%
Functions: 2 3 66.7%
Branches: 27 40 67.5%

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 Fluidmatrixinteractions
10 * \brief Wrapper type to combine an arbitrary number of different laws
11 * for fluid-matrix interaction (e.g., pc-Sw-curves).
12 */
13
14 #ifndef DUMUX_MATERIAL_FLUIDMATRIX_INTERACTIONS_FLUIDMATRIX_INTERACTION_HH
15 #define DUMUX_MATERIAL_FLUIDMATRIX_INTERACTIONS_FLUIDMATRIX_INTERACTION_HH
16
17 #include <type_traits>
18 #include <utility>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup Fluidmatrixinteractions
24 * \brief Wrapper type to combine an arbitrary number of different laws
25 * for fluid-matrix interaction (e.g., pc-Sw-curves).
26 */
27 template<class... Laws>
28 2514509 struct FluidMatrixInteraction : public Laws...
29 {
30 546084260 explicit FluidMatrixInteraction(Laws&&... laws) : Laws(std::forward<Laws>(laws))... {}
31 };
32
33 /*!
34 * \ingroup Fluidmatrixinteractions
35 * \brief Helper function to create an FluidMatrixInteraction object containing an arbitrary number
36 * of fluid matrix interaction laws (e.g., pc-Sw curves and interfacial area laws).
37 * To be used in the spatial parameters.
38 */
39 template<class... Laws>
40 543021464 auto makeFluidMatrixInteraction(Laws&&... laws)
41 {
42 546756114 return FluidMatrixInteraction(wrap(std::forward<Laws>(laws))...);
43 }
44
45 } // end namespace Dumux
46
47 namespace Dumux::FluidMatrix {
48
49 /*!
50 * \ingroup Fluidmatrixinteractions
51 * \brief Adapter to inherit from, allowing the inheriting class to be wrapped
52 * by the @ref makeFluidMatrixInteraction function.
53 */
54 template<class A, template<class> class Wrapper>
55 struct Adapter
56 {
57 template<class T, std::enable_if_t<std::is_same_v<A, std::decay_t<T>>, int> = 0>
58 546084260 friend auto wrap(T&& t) { return Wrapper(std::forward<T>(t)); }
59 };
60
61 /*!
62 * \ingroup Fluidmatrixinteractions
63 * \brief Wrapper type for laws providing pc-Sw and kr-Sw rules.
64 */
65 template<class T>
66 6125592 class PcKrSw
67 {
68 public:
69 using Scalar = typename std::decay_t<T>::Scalar;
70
71 using PcKrSwType = T;
72
73
9/10
✓ Branch 0 taken 1011219 times.
✓ Branch 1 taken 117515107 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 16567 times.
✓ Branch 4 taken 26928903 times.
✓ Branch 5 taken 1600126 times.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3014525 times.
✓ Branch 11 taken 30537881 times.
449314639 explicit PcKrSw(T&& impl) : impl_(std::forward<T>(impl)) {}
74
75
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1531398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
164180691 Scalar pc(const Scalar sw) const { return impl_.pc(sw); }
76 1426464 Scalar dpc_dsw(const Scalar sw) const { return impl_.dpc_dsw(sw); }
77
4/4
✓ Branch 0 taken 1445908 times.
✓ Branch 1 taken 4381177 times.
✓ Branch 2 taken 3571 times.
✓ Branch 3 taken 535091 times.
88687552 Scalar endPointPc() const { return impl_.endPointPc(); }
78
2/5
✓ Branch 1 taken 503787 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 0 not taken.
83325398 Scalar sw(const Scalar pc) const { return impl_.sw(pc); }
79 25068204 Scalar dsw_dpc(const Scalar pc) const { return impl_.dsw_dpc(pc); }
80
1/3
✓ Branch 1 taken 8106068 times.
✗ Branch 2 not taken.
✗ Branch 0 not taken.
245501886 Scalar krw(const Scalar sw) const { return impl_.krw(sw); }
81 17451680 Scalar dkrw_dsw(const Scalar sw) const { return impl_.dkrw_dsw(sw); }
82
1/2
✓ Branch 1 taken 983124 times.
✗ Branch 2 not taken.
162679704 Scalar krn(const Scalar sw) const { return impl_.krn(sw); }
83 873504 Scalar dkrn_dsw(const Scalar sw) const { return impl_.dkrn_dsw(sw); }
84
85
4/4
✓ Branch 0 taken 88740 times.
✓ Branch 1 taken 86842 times.
✓ Branch 2 taken 1617 times.
✓ Branch 3 taken 4527 times.
181726 const T& pcSwCurve() const { return impl_; }
86 const T& krSwCurve() const { return impl_; }
87
88 private:
89 T impl_;
90 };
91
92 /*!
93 * \ingroup Fluidmatrixinteractions
94 * \brief Deduction guide for the PcKrSw class.
95 * Makes sure that PcKrSw stores a copy of T if
96 * the constructor is called with a temporary object.
97 */
98 template<typename T>
99 PcKrSw(T&&) -> PcKrSw<T>;
100
101 /*!
102 * \ingroup Fluidmatrixinteractions
103 * \brief Wrapper type for multiphase interface laws providing pc-S and kr-S rules.
104 */
105 template<class T>
106 class MultiPhasePcKrSw
107 {
108 public:
109 using Scalar = typename std::decay_t<T>::Scalar;
110
111 4166181 explicit MultiPhasePcKrSw(T&& impl) : impl_(std::forward<T>(impl)) {}
112
113 template<class FS>
114 1984949 auto capillaryPressures(const FS& fs, int wp) const { return impl_.capillaryPressures(fs, wp); }
115 template<class FS>
116 1980040 auto relativePermeabilities(const FS& fs, int wp) const { return impl_.relativePermeabilities(fs, wp); }
117
118 const T& multiPhasePcKrS() const { return impl_; }
119
120 private:
121 T impl_;
122 };
123
124 /*!
125 * \ingroup Fluidmatrixinteractions
126 * \brief Deduction guide for the MultiPhasePcKrSw class.
127 * Makes sure that MultiPhasePcKrSw stores a copy of T if
128 * the constructor is called with a temporary object.
129 */
130 template<typename T>
131 MultiPhasePcKrSw(T&&) -> MultiPhasePcKrSw<T>;
132
133 /*!
134 * \ingroup Fluidmatrixinteractions
135 * \brief Wrapper type for 3p interface laws providing pc-S and kr-S rules.
136 */
137 template<class T>
138 struct ThreePhasePcKrSw
139 {
140 using Scalar = typename std::decay_t<T>::Scalar;
141 using value_type = T;
142
143 using PcKrSwType = T;
144
145 14316774 explicit ThreePhasePcKrSw(T&& impl) : impl_(std::forward<T>(impl)) {}
146
147 9523433 Scalar pcgw(const Scalar sw, const Scalar sn) const { return impl_.pcgw(sw, sn); }
148 9496913 Scalar pcnw(const Scalar sw, const Scalar sn) const { return impl_.pcnw(sw, sn); }
149 9496913 Scalar pcgn(const Scalar sw, const Scalar sn) const { return impl_.pcgn(sw, sn); }
150
4/4
✓ Branch 0 taken 4887295 times.
✓ Branch 1 taken 4609618 times.
✓ Branch 2 taken 370 times.
✓ Branch 3 taken 3854578 times.
18993826 Scalar pcAlpha(const Scalar sw, const Scalar sn) const { return impl_.pcAlpha(sw, sn); }
151
152 Scalar krw(const Scalar sw, const Scalar sn) const { return impl_.krw(sw, sn); }
153 Scalar krn(const Scalar sw, const Scalar sn) const { return impl_.krn(sw, sn); }
154 Scalar krg(const Scalar sw, const Scalar sn) const { return impl_.krn(sw, sn); }
155 28490733 Scalar kr(const int phaseIdx, const Scalar sw, const Scalar sn) const { return impl_.kr(phaseIdx, sw, sn); }
156
157 const T& pcSwCurve() const { return impl_; }
158 const T& krSwCurve() const { return impl_; }
159 private:
160 T impl_;
161 };
162
163 /*!
164 * \ingroup Fluidmatrixinteractions
165 * \brief Deduction guide for the ThreePhasePcKrSw class.
166 * Makes sure that ThreePhasePcKrSw stores a copy of T if
167 * the constructor is called with a temporary object.
168 */
169 template<typename T>
170 ThreePhasePcKrSw(T&&) -> ThreePhasePcKrSw<T>;
171
172 /*!
173 * \ingroup Fluidmatrixinteractions
174 * \brief Wrapper type for laws providing rules for the wetting-nonwetting interfacial area.
175 */
176 template<class T>
177 class WettingNonwettingInterfacialAreaPcSw
178 {
179 public:
180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394268 times.
3148823 explicit WettingNonwettingInterfacialAreaPcSw(T&& impl) : impl_(std::forward<T>(impl)) {}
181 786240 const T& wettingNonwettingInterface() const { return impl_; }
182 private:
183 T impl_;
184 };
185
186 /*!
187 * \ingroup Fluidmatrixinteractions
188 * \brief Deduction guide for the WettingNonwettingInterfacialAreaPcSw class.
189 * Makes sure that WettingNonwettingInterfacialAreaPcSw stores a copy of T if
190 * the constructor is called with a temporary object.
191 */
192 template<typename T>
193 WettingNonwettingInterfacialAreaPcSw(T&&) -> WettingNonwettingInterfacialAreaPcSw<T>;
194
195 /*!
196 * \ingroup Fluidmatrixinteractions
197 * \brief Wrapper type for laws providing rules for the wetting-solid interfacial area.
198 */
199 template<class T>
200 class WettingSolidInterfacialAreaPcSw
201 {
202 public:
203 2360287 explicit WettingSolidInterfacialAreaPcSw(T&& impl) : impl_(std::forward<T>(impl)) {}
204 const T& wettingSolidInterface() const { return impl_; }
205 private:
206 T impl_;
207 };
208
209 /*!
210 * \ingroup Fluidmatrixinteractions
211 * \brief Deduction guide for the WettingSolidInterfacialAreaPcSw class.
212 * Makes sure that WettingSolidInterfacialAreaPcSw stores a copy of T if
213 * the constructor is called with a temporary object.
214 */
215 template<typename T>
216 WettingSolidInterfacialAreaPcSw(T&&) -> WettingSolidInterfacialAreaPcSw<T>;
217
218 /*!
219 * \ingroup Fluidmatrixinteractions
220 * \brief Wrapper type for laws providing rules for the nonwetting-solid interfacial area.
221 */
222 template<class T>
223 class NonwettingSolidInterfacialAreaPcSw
224 {
225 public:
226 2360287 explicit NonwettingSolidInterfacialAreaPcSw(T&& impl) : impl_(std::forward<T>(impl)) {}
227 786240 const T& nonwettingSolidInterface() const { return impl_; }
228 private:
229 T impl_;
230 };
231
232 /*!
233 * \ingroup Fluidmatrixinteractions
234 * \brief Deduction guide for the NonwettingSolidInterfacialAreaPcSw class.
235 * Makes sure that NonwettingSolidInterfacialAreaPcSw stores a copy of T if
236 * the constructor is called with a temporary object.
237 */
238 template<typename T>
239 NonwettingSolidInterfacialAreaPcSw(T&&) -> NonwettingSolidInterfacialAreaPcSw<T>;
240
241
242 /*!
243 * \ingroup Fluidmatrixinteractions
244 * \brief Wrapper type for adsorption laws.
245 */
246 template<class T>
247 class Adsorption
248 {
249 public:
250 using value_type = T;
251
252 1179193 explicit Adsorption(T&& impl) : impl_(std::forward<T>(impl)) {}
253 const T& adsorptionModel() const { return impl_; }
254 private:
255 T impl_;
256 };
257
258 /*!
259 * \ingroup Fluidmatrixinteractions
260 * \brief Deduction guide for the Adsorption class.
261 * Makes sure that Adsorption stores a copy of T if
262 * the constructor is called with a temporary object.
263 */
264 template<typename T>
265 Adsorption(T&&) -> Adsorption<T>;
266
267 } // end namespace Dumux::FluidMatrix
268
269 #endif
270