My Project
Loading...
Searching...
No Matches
WaterPvtMultiplexer.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_WATER_PVT_MULTIPLEXER_HPP
28#define OPM_WATER_PVT_MULTIPLEXER_HPP
29
35
36#define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
37 switch (approach_) { \
38 case WaterPvtApproach::ConstantCompressibilityWater: { \
39 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityWater>(); \
40 codeToCall; \
41 __VA_ARGS__; \
42 } \
43 case WaterPvtApproach::ConstantCompressibilityBrine: { \
44 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>(); \
45 codeToCall; \
46 __VA_ARGS__; \
47 } \
48 case WaterPvtApproach::ThermalWater: { \
49 auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWater>(); \
50 codeToCall; \
51 __VA_ARGS__; \
52 } \
53 case WaterPvtApproach::BrineCo2: { \
54 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineCo2>(); \
55 codeToCall; \
56 __VA_ARGS__; \
57 } \
58 case WaterPvtApproach::BrineH2: { \
59 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineH2>(); \
60 codeToCall; \
61 __VA_ARGS__; \
62 } \
63 default: \
64 case WaterPvtApproach::NoWater: \
65 throw std::logic_error("Not implemented: Water PVT of this deck!"); \
66 }
67
68namespace Opm {
69
70enum class WaterPvtApproach {
71 NoWater,
72 ConstantCompressibilityBrine,
73 ConstantCompressibilityWater,
74 ThermalWater,
75 BrineCo2,
76 BrineH2
77};
78
79#if HAVE_ECL_INPUT
80class EclipseState;
81class Schedule;
82#endif
83
88template <class Scalar, bool enableThermal = true, bool enableBrine = true>
90{
91public:
93 : approach_(WaterPvtApproach::NoWater)
94 , realWaterPvt_(nullptr)
95 {
96 }
97
98 WaterPvtMultiplexer(WaterPvtApproach approach, void* realWaterPvt)
99 : approach_(approach)
100 , realWaterPvt_(realWaterPvt)
101 { }
102
104 {
105 *this = data;
106 }
107
109
110 bool mixingEnergy() const
111 {
112 return approach_ == WaterPvtApproach::ThermalWater;
113 }
114
115#if HAVE_ECL_INPUT
121 void initFromState(const EclipseState& eclState, const Schedule& schedule);
122#endif // HAVE_ECL_INPUT
123
124 void initEnd();
125
129 unsigned numRegions() const;
130
131 void setVapPars(const Scalar par1, const Scalar par2);
132
136 Scalar waterReferenceDensity(unsigned regionIdx) const;
137
141 template <class Evaluation>
142 Evaluation internalEnergy(unsigned regionIdx,
143 const Evaluation& temperature,
144 const Evaluation& pressure,
145 const Evaluation& Rsw,
146 const Evaluation& saltconcentration) const
147 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rsw, saltconcentration)); }
148
149 Scalar hVap(unsigned regionIdx) const;
150
154 template <class Evaluation>
155 Evaluation viscosity(unsigned regionIdx,
156 const Evaluation& temperature,
157 const Evaluation& pressure,
158 const Evaluation& Rsw,
159 const Evaluation& saltconcentration) const
160 {
161 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rsw, saltconcentration));
162 }
163
167 template <class Evaluation>
168 Evaluation saturatedViscosity(unsigned regionIdx,
169 const Evaluation& temperature,
170 const Evaluation& pressure,
171 const Evaluation& saltconcentration) const
172 {
173 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure, saltconcentration));
174 }
175
179 template <class Evaluation>
180 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
181 const Evaluation& temperature,
182 const Evaluation& pressure,
183 const Evaluation& Rsw,
184 const Evaluation& saltconcentration) const
185 {
186 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration));
187 }
188
192 template <class Evaluation>
193 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
194 const Evaluation& temperature,
195 const Evaluation& pressure,
196 const Evaluation& saltconcentration) const
197 {
198 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
199 }
200
204 template <class Evaluation>
205 Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
206 const Evaluation& temperature,
207 const Evaluation& pressure,
208 const Evaluation& saltconcentration) const
209 {
210 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, saltconcentration));
211 }
212
220 template <class Evaluation>
221 Evaluation saturationPressure(unsigned regionIdx,
222 const Evaluation& temperature,
223 const Evaluation& Rs,
224 const Evaluation& saltconcentration) const
225 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs, saltconcentration)); }
226
230 template <class Evaluation>
231 Evaluation diffusionCoefficient(const Evaluation& temperature,
232 const Evaluation& pressure,
233 unsigned compIdx) const
234 {
235 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
236 }
237
238 void setApproach(WaterPvtApproach appr);
239
245 WaterPvtApproach approach() const
246 { return approach_; }
247
248 // get the concrete parameter object for the water phase
249 template <WaterPvtApproach approachV>
250 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
251 {
252 assert(approach() == approachV);
253 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
254 }
255
256 template <WaterPvtApproach approachV>
257 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const
258 {
259 assert(approach() == approachV);
260 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
261 }
262
263 template <WaterPvtApproach approachV>
264 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
265 {
266 assert(approach() == approachV);
267 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
268 }
269
270 template <WaterPvtApproach approachV>
271 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const
272 {
273 assert(approach() == approachV);
274 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
275 }
276
277 template <WaterPvtApproach approachV>
278 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
279 {
280 assert(approach() == approachV);
281 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
282 }
283
284 template <WaterPvtApproach approachV>
285 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt() const
286 {
287 assert(approach() == approachV);
288 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
289 }
290
291 template <WaterPvtApproach approachV>
292 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
293 {
294 assert(approach() == approachV);
295 return *static_cast<BrineCo2Pvt<Scalar>* >(realWaterPvt_);
296 }
297
298 template <WaterPvtApproach approachV>
299 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt() const
300 {
301 assert(approach() == approachV);
302 return *static_cast<const BrineCo2Pvt<Scalar>* >(realWaterPvt_);
303 }
304
305 template <WaterPvtApproach approachV>
306 typename std::enable_if<approachV == WaterPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
307 {
308 assert(approach() == approachV);
309 return *static_cast<BrineH2Pvt<Scalar>* >(realWaterPvt_);
310 }
311
312 template <WaterPvtApproach approachV>
313 typename std::enable_if<approachV == WaterPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt() const
314 {
315 assert(approach() == approachV);
316 return *static_cast<const BrineH2Pvt<Scalar>* >(realWaterPvt_);
317 }
318
319 const void* realWaterPvt() const { return realWaterPvt_; }
320
321 WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>&
322 operator=(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data);
323
324private:
325 WaterPvtApproach approach_{WaterPvtApproach::NoWater};
326 void* realWaterPvt_{nullptr};
327};
328
329} // namespace Opm
330
331#endif
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a H2-Brine sy...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
This class implements temperature dependence of the PVT properties of water.
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition ConstantCompressibilityWaterPvt.hpp:47
Definition EclipseState.hpp:63
Definition Schedule.hpp:89
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition WaterPvtMultiplexer.hpp:90
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WaterPvtMultiplexer.hpp:155
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:193
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WaterPvtMultiplexer.hpp:168
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition WaterPvtMultiplexer.cpp:97
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the gas dissolution factor [m^3/m^3] of saturated water.
Definition WaterPvtMultiplexer.hpp:205
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition WaterPvtMultiplexer.hpp:142
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rs, const Evaluation &saltconcentration) const
Returns the saturation pressure [Pa] of water given the mass fraction of the gas component in the wat...
Definition WaterPvtMultiplexer.hpp:221
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition WaterPvtMultiplexer.hpp:245
Scalar waterReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition WaterPvtMultiplexer.cpp:111
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:180
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned compIdx) const
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition WaterPvtMultiplexer.hpp:231
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30