GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/fluidmatrixinteractions/mp/mpadapter.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 7 14 50.0%
Functions: 0 10 0.0%
Branches: 5 10 50.0%

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 Makes the capillary pressure-saturation relations available under the M-phase API for material laws
11 *
12 * Makes the capillary pressure-saturation relations
13 * available under the M-phase API for material laws
14 */
15 #ifndef DUMUX_MP_ADAPTER_HH
16 #define DUMUX_MP_ADAPTER_HH
17
18 #include <dune/common/fvector.hh>
19 #include <dumux/common/typetraits/typetraits.hh>
20 #include <dumux/material/fluidmatrixinteractions/fluidmatrixinteraction.hh>
21
22 namespace Dumux::FluidMatrix {
23
24 /*!
25 * \ingroup Fluidmatrixinteractions
26 * \brief An adapter for mpnc to use the capillary pressure-saturation relationships
27 */
28 template <class MaterialLaw, int numFluidPhases = std::decay_t<MaterialLaw>::numFluidPhases()>
29 class MPAdapter
30 {
31 static_assert(AlwaysFalse<MaterialLaw>::value, "Adapter not implemented for the specified number of phases");
32 };
33
34
35 template<class MaterialLaw>
36 class MPAdapter<MaterialLaw, 2>
37 : public Adapter<MPAdapter<MaterialLaw, 2>, MultiPhasePcKrSw>
38 {
39 public:
40 using Scalar = typename std::decay_t<MaterialLaw>::Scalar;
41
42 4751235 MPAdapter(MaterialLaw&& pcKrS)
43 4751235 : pcKrS_(std::forward<MaterialLaw>(pcKrS))
44 {}
45
46 /*!
47 * \brief The capillary pressure-saturation curve.
48 * \param state Fluidstate
49 * \param wPhaseIdx the phase index of the wetting phase
50 */
51 template <class FluidState>
52 auto capillaryPressures(const FluidState& state, int wPhaseIdx) const
53 {
54 1985217 Dune::FieldVector<typename FluidState::Scalar, 2> values;
55
56 1985217 const int nPhaseIdx = 1 - wPhaseIdx;
57 // non-wetting phase gets the capillary pressure added
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
1985217 values[nPhaseIdx] = 0;
59 // wetting phase does not get anything added
60
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1567 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1567 times.
✗ Branch 7 not taken.
5144416 values[wPhaseIdx] = - pcKrS_.pc(state.saturation(wPhaseIdx));
61
62 256 return values;
63 }
64
65 /*!
66 * \brief The relative permeability of all phases.
67 * \param state Fluidstate
68 * \param wPhaseIdx The phase index of the wetting phase
69 */
70 template <class FluidState>
71 auto relativePermeabilities(const FluidState& state, int wPhaseIdx) const
72 {
73 Dune::FieldVector<typename FluidState::Scalar, 2> values;
74
75 const int nPhaseIdx = 1 - wPhaseIdx;
76 values[wPhaseIdx] = pcKrS_.krw(state.saturation(wPhaseIdx));
77 values[nPhaseIdx] = pcKrS_.krn(state.saturation(wPhaseIdx));
78
79 return values;
80 }
81 private:
82 MaterialLaw pcKrS_;
83 };
84
85 /*!
86 * \ingroup Fluidmatrixinteractions
87 * \brief Deduction guide for the MPAdapter class.
88 * Makes sure that MPAdapter stores a copy of T if
89 * the constructor is called with a temporary object.
90 */
91 template<typename T>
92 MPAdapter(T&&) -> MPAdapter<T>;
93
94 } // end namespace Dumux::FluidMatrix
95
96
97 #endif
98