My Project
Loading...
Searching...
No Matches
OilPvtMultiplexer.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_OIL_PVT_MULTIPLEXER_HPP
28#define OPM_OIL_PVT_MULTIPLEXER_HPP
29
36
37namespace Opm {
38
39#if HAVE_ECL_INPUT
40class EclipseState;
41class Schedule;
42#endif
43
44#define OPM_OIL_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
45 switch (approach_) { \
46 case OilPvtApproach::ConstantCompressibilityOil: { \
47 auto& pvtImpl = getRealPvt<OilPvtApproach::ConstantCompressibilityOil>(); \
48 codeToCall; \
49 __VA_ARGS__; \
50 } \
51 case OilPvtApproach::DeadOil: { \
52 auto& pvtImpl = getRealPvt<OilPvtApproach::DeadOil>(); \
53 codeToCall; \
54 __VA_ARGS__; \
55 } \
56 case OilPvtApproach::LiveOil: { \
57 auto& pvtImpl = getRealPvt<OilPvtApproach::LiveOil>(); \
58 codeToCall; \
59 __VA_ARGS__; \
60 } \
61 case OilPvtApproach::ThermalOil: { \
62 auto& pvtImpl = getRealPvt<OilPvtApproach::ThermalOil>(); \
63 codeToCall; \
64 __VA_ARGS__; \
65 } \
66 case OilPvtApproach::BrineCo2: { \
67 auto& pvtImpl = getRealPvt<OilPvtApproach::BrineCo2>(); \
68 codeToCall; \
69 __VA_ARGS__; \
70 } \
71 case OilPvtApproach::BrineH2: { \
72 auto& pvtImpl = getRealPvt<OilPvtApproach::BrineH2>(); \
73 codeToCall; \
74 __VA_ARGS__; \
75 } \
76 default: \
77 case OilPvtApproach::NoOil: \
78 throw std::logic_error("Not implemented: Oil PVT of this deck!"); \
79 }
80
81enum class OilPvtApproach {
82 NoOil,
83 LiveOil,
84 DeadOil,
85 ConstantCompressibilityOil,
86 ThermalOil,
87 BrineCo2,
88 BrineH2
89};
90
103template <class Scalar, bool enableThermal = true>
105{
106public:
108 : approach_(OilPvtApproach::NoOil)
109 , realOilPvt_(nullptr)
110 {
111 }
112
113 OilPvtMultiplexer(OilPvtApproach approach, void* realOilPvt)
114 : approach_(approach)
115 , realOilPvt_(realOilPvt)
116 { }
117
119 {
120 *this = data;
121 }
122
124
125 bool mixingEnergy() const
126 {
127 return approach_ == OilPvtApproach::ThermalOil;
128 }
129#if HAVE_ECL_INPUT
135 void initFromState(const EclipseState& eclState, const Schedule& schedule);
136#endif // HAVE_ECL_INPUT
137
138
139 void initEnd();
140
144 unsigned numRegions() const;
145
146 void setVapPars(const Scalar par1, const Scalar par2);
147
151 Scalar oilReferenceDensity(unsigned regionIdx) const;
152
156 template <class Evaluation>
157 Evaluation internalEnergy(unsigned regionIdx,
158 const Evaluation& temperature,
159 const Evaluation& pressure,
160 const Evaluation& Rs) const
161 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rs)); }
162
163 Scalar hVap(unsigned regionIdx) const
164 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.hVap(regionIdx)); }
168 template <class Evaluation>
169 Evaluation viscosity(unsigned regionIdx,
170 const Evaluation& temperature,
171 const Evaluation& pressure,
172 const Evaluation& Rs) const
173 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rs)); }
174
178 template <class Evaluation>
179 Evaluation saturatedViscosity(unsigned regionIdx,
180 const Evaluation& temperature,
181 const Evaluation& pressure) const
182 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
183
187 template <class Evaluation>
188 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
189 const Evaluation& temperature,
190 const Evaluation& pressure,
191 const Evaluation& Rs) const
192 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rs)); }
193
197 template <class Evaluation>
198 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
199 const Evaluation& temperature,
200 const Evaluation& pressure) const
201 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
202
206 template <class Evaluation>
207 Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
208 const Evaluation& temperature,
209 const Evaluation& pressure) const
210 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure)); }
211
215 template <class Evaluation>
216 Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
217 const Evaluation& temperature,
218 const Evaluation& pressure,
219 const Evaluation& oilSaturation,
220 const Evaluation& maxOilSaturation) const
221 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
222
230 template <class Evaluation>
231 Evaluation saturationPressure(unsigned regionIdx,
232 const Evaluation& temperature,
233 const Evaluation& Rs) const
234 { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs)); }
235
239 template <class Evaluation>
240 Evaluation diffusionCoefficient(const Evaluation& temperature,
241 const Evaluation& pressure,
242 unsigned compIdx) const
243 {
244 OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
245 }
246
247 void setApproach(OilPvtApproach appr);
248
254 OilPvtApproach approach() const
255 { return approach_; }
256
257 // get the concrete parameter object for the oil phase
258 template <OilPvtApproach approachV>
259 typename std::enable_if<approachV == OilPvtApproach::LiveOil, LiveOilPvt<Scalar> >::type& getRealPvt()
260 {
261 assert(approach() == approachV);
262 return *static_cast<LiveOilPvt<Scalar>* >(realOilPvt_);
263 }
264
265 template <OilPvtApproach approachV>
266 typename std::enable_if<approachV == OilPvtApproach::LiveOil, const LiveOilPvt<Scalar> >::type& getRealPvt() const
267 {
268 assert(approach() == approachV);
269 return *static_cast<LiveOilPvt<Scalar>* >(realOilPvt_);
270 }
271
272 template <OilPvtApproach approachV>
273 typename std::enable_if<approachV == OilPvtApproach::DeadOil, DeadOilPvt<Scalar> >::type& getRealPvt()
274 {
275 assert(approach() == approachV);
276 return *static_cast<DeadOilPvt<Scalar>* >(realOilPvt_);
277 }
278
279 template <OilPvtApproach approachV>
280 typename std::enable_if<approachV == OilPvtApproach::DeadOil, const DeadOilPvt<Scalar> >::type& getRealPvt() const
281 {
282 assert(approach() == approachV);
283 return *static_cast<DeadOilPvt<Scalar>* >(realOilPvt_);
284 }
285
286 template <OilPvtApproach approachV>
287 typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOil, ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt()
288 {
289 assert(approach() == approachV);
290 return *static_cast<ConstantCompressibilityOilPvt<Scalar>* >(realOilPvt_);
291 }
292
293 template <OilPvtApproach approachV>
294 typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOil, const ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt() const
295 {
296 assert(approach() == approachV);
297 return *static_cast<ConstantCompressibilityOilPvt<Scalar>* >(realOilPvt_);
298 }
299
300 template <OilPvtApproach approachV>
301 typename std::enable_if<approachV == OilPvtApproach::ThermalOil, OilPvtThermal<Scalar> >::type& getRealPvt()
302 {
303 assert(approach() == approachV);
304 return *static_cast<OilPvtThermal<Scalar>* >(realOilPvt_);
305 }
306
307 template <OilPvtApproach approachV>
308 typename std::enable_if<approachV == OilPvtApproach::ThermalOil, const OilPvtThermal<Scalar> >::type& getRealPvt() const
309 {
310 assert(approach() == approachV);
311 return *static_cast<const OilPvtThermal<Scalar>* >(realOilPvt_);
312 }
313
314 template <OilPvtApproach approachV>
315 typename std::enable_if<approachV == OilPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
316 {
317 assert(approach() == approachV);
318 return *static_cast<BrineCo2Pvt<Scalar>* >(realOilPvt_);
319 }
320
321 template <OilPvtApproach approachV>
322 typename std::enable_if<approachV == OilPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt() const
323 {
324 assert(approach() == approachV);
325 return *static_cast<const BrineCo2Pvt<Scalar>* >(realOilPvt_);
326 }
327
328 const void* realOilPvt() const { return realOilPvt_; }
329
330 template <OilPvtApproach approachV>
331 typename std::enable_if<approachV == OilPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
332 {
333 assert(approach() == approachV);
334 return *static_cast<BrineH2Pvt<Scalar>* >(realOilPvt_);
335 }
336
337 template <OilPvtApproach approachV>
338 typename std::enable_if<approachV == OilPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt() const
339 {
340 assert(approach() == approachV);
341 return *static_cast<const BrineH2Pvt<Scalar>* >(realOilPvt_);
342 }
343
344 OilPvtMultiplexer<Scalar,enableThermal>&
345 operator=(const OilPvtMultiplexer<Scalar,enableThermal>& data);
346
347private:
348 OilPvtApproach approach_{OilPvtApproach::NoOil};
349 void* realOilPvt_{nullptr};
350};
351
352} // namespace Opm
353
354#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 oil phase without dissolved ga...
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
This class represents the Pressure-Volume-Temperature relations of the oil phas with dissolved gas.
This class implements temperature dependence of the PVT properties of oil.
Definition EclipseState.hpp:62
This class represents the Pressure-Volume-Temperature relations of the oil phas with dissolved gas.
Definition LiveOilPvt.hpp:51
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Definition OilPvtMultiplexer.hpp:105
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:102
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the specific enthalpy [J/kg] oil given a set of parameters.
Definition OilPvtMultiplexer.hpp:157
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition OilPvtMultiplexer.hpp:188
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition OilPvtMultiplexer.hpp:179
OilPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition OilPvtMultiplexer.hpp:254
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition OilPvtMultiplexer.hpp:198
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the gas dissolution factor [m^3/m^3] of saturated oil.
Definition OilPvtMultiplexer.hpp:207
Scalar oilReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:116
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition OilPvtMultiplexer.hpp:169
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rs) const
Returns the saturation pressure [Pa] of oil given the mass fraction of the gas component in the oil p...
Definition OilPvtMultiplexer.hpp:231
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &oilSaturation, const Evaluation &maxOilSaturation) const
Returns the gas dissolution factor [m^3/m^3] of saturated oil.
Definition OilPvtMultiplexer.hpp:216
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 OilPvtMultiplexer.hpp:240
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30