My Project
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
34
35#include <opm/common/TimingMacros.hpp>
36
39
44
45#include <array>
46#include <cstddef>
47#include <memory>
48#include <stdexcept>
49#include <string>
50#include <string_view>
51#include <vector>
52
53namespace Opm::BlackOil
54{
55OPM_GENERATE_HAS_MEMBER(Rs, ) // Creates 'HasMember_Rs<T>'.
56OPM_GENERATE_HAS_MEMBER(Rv, ) // Creates 'HasMember_Rv<T>'.
57OPM_GENERATE_HAS_MEMBER(Rvw, ) // Creates 'HasMember_Rvw<T>'.
58OPM_GENERATE_HAS_MEMBER(Rsw, ) // Creates 'HasMember_Rsw<T>'.
59OPM_GENERATE_HAS_MEMBER(saltConcentration, )
60OPM_GENERATE_HAS_MEMBER(saltSaturation, )
61
62template <class FluidSystem, class FluidState, class LhsEval>
63LhsEval
64getRs_(typename std::enable_if<!HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState,
65 unsigned regionIdx)
66{
67 const auto& XoG = decay<LhsEval>(fluidState.massFraction(FluidSystem::oilPhaseIdx, FluidSystem::gasCompIdx));
68 return FluidSystem::convertXoGToRs(XoG, regionIdx);
69}
70
71template <class FluidSystem, class FluidState, class LhsEval>
72auto
73getRs_(typename std::enable_if<HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState, unsigned)
74 -> decltype(decay<LhsEval>(fluidState.Rs()))
75{
76 return decay<LhsEval>(fluidState.Rs());
77}
78
79template <class FluidSystem, class FluidState, class LhsEval>
80LhsEval
81getRv_(typename std::enable_if<!HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState,
82 unsigned regionIdx)
83{
84 const auto& XgO = decay<LhsEval>(fluidState.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::oilCompIdx));
85 return FluidSystem::convertXgOToRv(XgO, regionIdx);
86}
87
88template <class FluidSystem, class FluidState, class LhsEval>
89auto
90getRv_(typename std::enable_if<HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState, unsigned)
91 -> decltype(decay<LhsEval>(fluidState.Rv()))
92{
93 return decay<LhsEval>(fluidState.Rv());
94}
95
96template <class FluidSystem, class FluidState, class LhsEval>
97LhsEval
98getRvw_(typename std::enable_if<!HasMember_Rvw<FluidState>::value, const FluidState&>::type fluidState,
99 unsigned regionIdx)
100{
101 const auto& XgW = decay<LhsEval>(fluidState.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::waterCompIdx));
102 return FluidSystem::convertXgWToRvw(XgW, regionIdx);
103}
104
105template <class FluidSystem, class FluidState, class LhsEval>
106auto
107getRvw_(typename std::enable_if<HasMember_Rvw<FluidState>::value, const FluidState&>::type fluidState, unsigned)
108 -> decltype(decay<LhsEval>(fluidState.Rvw()))
109{
110 return decay<LhsEval>(fluidState.Rvw());
111}
112
113template <class FluidSystem, class FluidState, class LhsEval>
114LhsEval
115getRsw_(typename std::enable_if<!HasMember_Rsw<FluidState>::value, const FluidState&>::type fluidState,
116 unsigned regionIdx)
117{
118 const auto& XwG = decay<LhsEval>(fluidState.massFraction(FluidSystem::waterPhaseIdx, FluidSystem::gasCompIdx));
119 return FluidSystem::convertXwGToRsw(XwG, regionIdx);
120}
121
122template <class FluidSystem, class FluidState, class LhsEval>
123auto
124getRsw_(typename std::enable_if<HasMember_Rsw<FluidState>::value, const FluidState&>::type fluidState, unsigned)
125 -> decltype(decay<LhsEval>(fluidState.Rsw()))
126{
127 return decay<LhsEval>(fluidState.Rsw());
128}
129
130template <class FluidSystem, class FluidState, class LhsEval>
131LhsEval
132getSaltConcentration_(typename std::enable_if<!HasMember_saltConcentration<FluidState>::value, const FluidState&>::type,
133 unsigned)
134{
135 return 0.0;
136}
137
138template <class FluidSystem, class FluidState, class LhsEval>
139auto
140getSaltConcentration_(
141 typename std::enable_if<HasMember_saltConcentration<FluidState>::value, const FluidState&>::type fluidState,
142 unsigned) -> decltype(decay<LhsEval>(fluidState.saltConcentration()))
143{
144 return decay<LhsEval>(fluidState.saltConcentration());
145}
146
147template <class FluidSystem, class FluidState, class LhsEval>
148LhsEval
149getSaltSaturation_(typename std::enable_if<!HasMember_saltSaturation<FluidState>::value, const FluidState&>::type,
150 unsigned)
151{
152 return 0.0;
153}
154
155template <class FluidSystem, class FluidState, class LhsEval>
156auto
157getSaltSaturation_(
158 typename std::enable_if<HasMember_saltSaturation<FluidState>::value, const FluidState&>::type fluidState, unsigned)
159 -> decltype(decay<LhsEval>(fluidState.saltSaturation()))
160{
161 return decay<LhsEval>(fluidState.saltSaturation());
162}
163
164} // namespace Opm::BlackOil
165#endif
The base class for all fluid systems.
The class which specifies the default phase and component indices for the black-oil fluid system.
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
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.
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Some templates to wrap the valgrind client request macros.
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...