opm-common
Loading...
Searching...
No Matches
BlackOilFunctions.hpp
Go to the documentation of this file.
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 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef OPM_MATERIAL_FLUIDSYSTEMS_BLACKOILFUNCTIONS_HEADER_INCLUDED
28#define OPM_MATERIAL_FLUIDSYSTEMS_BLACKOILFUNCTIONS_HEADER_INCLUDED
29
30#include <opm/common/TimingMacros.hpp>
31
34
39
40#include <array>
41#include <cstddef>
42#include <memory>
43#include <stdexcept>
44#include <string>
45#include <string_view>
46#include <vector>
47
48namespace Opm::BlackOil
49{
50OPM_GENERATE_HAS_MEMBER(Rs, ) // Creates 'HasMember_Rs<T>'.
51OPM_GENERATE_HAS_MEMBER(Rv, ) // Creates 'HasMember_Rv<T>'.
52OPM_GENERATE_HAS_MEMBER(Rvw, ) // Creates 'HasMember_Rvw<T>'.
53OPM_GENERATE_HAS_MEMBER(Rsw, ) // Creates 'HasMember_Rsw<T>'.
54OPM_GENERATE_HAS_MEMBER(saltConcentration, )
55OPM_GENERATE_HAS_MEMBER(saltSaturation, )
56
57template <class FluidSystem, class FluidState, class LhsEval>
58LhsEval
59getRs_(typename std::enable_if<!HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState,
60 unsigned regionIdx)
61{
62 const auto& XoG = decay<LhsEval>(fluidState.massFraction(FluidSystem::oilPhaseIdx, FluidSystem::gasCompIdx));
63 return FluidSystem::convertXoGToRs(XoG, regionIdx);
64}
65
66template <class FluidSystem, class FluidState, class LhsEval>
67auto
68getRs_(typename std::enable_if<HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState, unsigned)
69 -> decltype(decay<LhsEval>(fluidState.Rs()))
70{
71 return decay<LhsEval>(fluidState.Rs());
72}
73
74template <class FluidSystem, class FluidState, class LhsEval>
75LhsEval
76getRv_(typename std::enable_if<!HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState,
77 unsigned regionIdx)
78{
79 const auto& XgO = decay<LhsEval>(fluidState.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::oilCompIdx));
80 return FluidSystem::convertXgOToRv(XgO, regionIdx);
81}
82
83template <class FluidSystem, class FluidState, class LhsEval>
84auto
85getRv_(typename std::enable_if<HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState, unsigned)
86 -> decltype(decay<LhsEval>(fluidState.Rv()))
87{
88 return decay<LhsEval>(fluidState.Rv());
89}
90
91template <class FluidSystem, class FluidState, class LhsEval>
92LhsEval
93getRvw_(typename std::enable_if<!HasMember_Rvw<FluidState>::value, const FluidState&>::type fluidState,
94 unsigned regionIdx)
95{
96 const auto& XgW = decay<LhsEval>(fluidState.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::waterCompIdx));
97 return FluidSystem::convertXgWToRvw(XgW, regionIdx);
98}
99
100template <class FluidSystem, class FluidState, class LhsEval>
101auto
102getRvw_(typename std::enable_if<HasMember_Rvw<FluidState>::value, const FluidState&>::type fluidState, unsigned)
103 -> decltype(decay<LhsEval>(fluidState.Rvw()))
104{
105 return decay<LhsEval>(fluidState.Rvw());
106}
107
108template <class FluidSystem, class FluidState, class LhsEval>
109LhsEval
110getRsw_(typename std::enable_if<!HasMember_Rsw<FluidState>::value, const FluidState&>::type fluidState,
111 unsigned regionIdx)
112{
113 const auto& XwG = decay<LhsEval>(fluidState.massFraction(FluidSystem::waterPhaseIdx, FluidSystem::gasCompIdx));
114 return FluidSystem::convertXwGToRsw(XwG, regionIdx);
115}
116
117template <class FluidSystem, class FluidState, class LhsEval>
118auto
119getRsw_(typename std::enable_if<HasMember_Rsw<FluidState>::value, const FluidState&>::type fluidState, unsigned)
120 -> decltype(decay<LhsEval>(fluidState.Rsw()))
121{
122 return decay<LhsEval>(fluidState.Rsw());
123}
124
125template <class FluidState, class LhsEval>
126LhsEval
127getSaltConcentration_(typename std::enable_if<!HasMember_saltConcentration<FluidState>::value, const FluidState&>::type,
128 unsigned)
129{
130 return 0.0;
131}
132
133template <class FluidState, class LhsEval>
134auto
135getSaltConcentration_(
136 typename std::enable_if<HasMember_saltConcentration<FluidState>::value, const FluidState&>::type fluidState,
137 unsigned) -> decltype(decay<LhsEval>(fluidState.saltConcentration()))
138{
139 return decay<LhsEval>(fluidState.saltConcentration());
140}
141
142template <class FluidSystem, class FluidState, class LhsEval>
143LhsEval
144getSaltSaturation_(typename std::enable_if<!HasMember_saltSaturation<FluidState>::value, const FluidState&>::type,
145 unsigned)
146{
147 return 0.0;
148}
149
150template <class FluidSystem, class FluidState, class LhsEval>
151auto
152getSaltSaturation_(
153 typename std::enable_if<HasMember_saltSaturation<FluidState>::value, const FluidState&>::type fluidState, unsigned)
154 -> decltype(decay<LhsEval>(fluidState.saltSaturation()))
155{
156 return decay<LhsEval>(fluidState.saltSaturation());
157}
158
159} // namespace Opm::BlackOil
160#endif
The base class for all fluid systems.
This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization.
#define OPM_GENERATE_HAS_MEMBER(MEMBER_NAME,...)
This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization.
Definition HasMemberGeneratorMacros.hpp:49
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
A parameter cache which does nothing.
Some templates to wrap the valgrind client request macros.