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
32#include "WaterPvtThermal.hpp"
33#include "BrineCo2Pvt.hpp"
34#include "BrineH2Pvt.hpp"
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 break; \
42 } \
43 case WaterPvtApproach::ConstantCompressibilityBrine: { \
44 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>(); \
45 codeToCall; \
46 break; \
47 } \
48 case WaterPvtApproach::ThermalWater: { \
49 auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWater>(); \
50 codeToCall; \
51 break; \
52 } \
53 case WaterPvtApproach::BrineCo2: { \
54 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineCo2>(); \
55 codeToCall; \
56 break; \
57 } \
58 case WaterPvtApproach::BrineH2: { \
59 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineH2>(); \
60 codeToCall; \
61 break; \
62 } \
63 case WaterPvtApproach::NoWater: \
64 throw std::logic_error("Not implemented: Water PVT of this deck!"); \
65 }
66
67namespace Opm {
68
69enum class WaterPvtApproach {
70 NoWater,
71 ConstantCompressibilityBrine,
72 ConstantCompressibilityWater,
73 ThermalWater,
74 BrineCo2,
75 BrineH2
76};
77
78#if HAVE_ECL_INPUT
79class EclipseState;
80class Schedule;
81#endif
82
87template <class Scalar, bool enableThermal = true, bool enableBrine = true>
89{
90public:
92 {
93 approach_ = WaterPvtApproach::NoWater;
94 realWaterPvt_ = nullptr;
95 }
96
97 WaterPvtMultiplexer(WaterPvtApproach approach, void* realWaterPvt)
98 : approach_(approach)
99 , realWaterPvt_(realWaterPvt)
100 { }
101
103 {
104 *this = data;
105 }
106
108 {
109 switch (approach_) {
110 case WaterPvtApproach::ConstantCompressibilityWater: {
111 delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityWater>();
112 break;
113 }
114 case WaterPvtApproach::ConstantCompressibilityBrine: {
115 delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>();
116 break;
117 }
118 case WaterPvtApproach::ThermalWater: {
119 delete &getRealPvt<WaterPvtApproach::ThermalWater>();
120 break;
121 }
122 case WaterPvtApproach::BrineCo2: {
123 delete &getRealPvt<WaterPvtApproach::BrineCo2>();
124 break;
125 }
126 case WaterPvtApproach::BrineH2: {
127 delete &getRealPvt<WaterPvtApproach::BrineH2>();
128 break;
129 }
130 case WaterPvtApproach::NoWater:
131 break;
132 }
133 }
134
135#if HAVE_ECL_INPUT
141 void initFromState(const EclipseState& eclState, const Schedule& schedule);
142#endif // HAVE_ECL_INPUT
143
144 void initEnd()
145 { OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
146
150 unsigned numRegions() const
151 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.numRegions()); return 1; }
152
153 void setVapPars(const Scalar par1, const Scalar par2)
154 {
155 OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.setVapPars(par1, par2));
156 }
157
161 const Scalar waterReferenceDensity(unsigned regionIdx) const
162 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.waterReferenceDensity(regionIdx)); return 1000.; }
163
167 template <class Evaluation>
168 Evaluation internalEnergy(unsigned regionIdx,
169 const Evaluation& temperature,
170 const Evaluation& pressure,
171 const Evaluation& Rsw,
172 const Evaluation& saltconcentration) const
173 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rsw, saltconcentration)); return 0; }
174
178 template <class Evaluation>
179 Evaluation viscosity(unsigned regionIdx,
180 const Evaluation& temperature,
181 const Evaluation& pressure,
182 const Evaluation& Rsw,
183 const Evaluation& saltconcentration) const
184 {
185 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rsw, saltconcentration));
186 return 0;
187 }
188
192 template <class Evaluation>
193 Evaluation saturatedViscosity(unsigned regionIdx,
194 const Evaluation& temperature,
195 const Evaluation& pressure,
196 const Evaluation& saltconcentration) const
197 {
198 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure, saltconcentration));
199 return 0;
200 }
201
205 template <class Evaluation>
206 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
207 const Evaluation& temperature,
208 const Evaluation& pressure,
209 const Evaluation& Rsw,
210 const Evaluation& saltconcentration) const
211 {
212 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration));
213 return 0;
214 }
215
219 template <class Evaluation>
220 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
221 const Evaluation& temperature,
222 const Evaluation& pressure,
223 const Evaluation& saltconcentration) const
224 {
225 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
226 return 0;
227 }
228
232 template <class Evaluation>
233 Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
234 const Evaluation& temperature,
235 const Evaluation& pressure,
236 const Evaluation& saltconcentration) const
237 {
238 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, saltconcentration));
239 return 0;
240 }
241
249 template <class Evaluation>
250 Evaluation saturationPressure(unsigned regionIdx,
251 const Evaluation& temperature,
252 const Evaluation& Rs,
253 const Evaluation& saltconcentration) const
254 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs, saltconcentration)); return 0; }
255
256
260 template <class Evaluation>
261 Evaluation diffusionCoefficient(const Evaluation& temperature,
262 const Evaluation& pressure,
263 unsigned compIdx) const
264 {
265 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
266 return 0;
267 }
268
269 void setApproach(WaterPvtApproach appr)
270 {
271 switch (appr) {
272 case WaterPvtApproach::ConstantCompressibilityWater:
273 realWaterPvt_ = new ConstantCompressibilityWaterPvt<Scalar>;
274 break;
275
276 case WaterPvtApproach::ConstantCompressibilityBrine:
277 realWaterPvt_ = new ConstantCompressibilityBrinePvt<Scalar>;
278 break;
279
280 case WaterPvtApproach::ThermalWater:
281 realWaterPvt_ = new WaterPvtThermal<Scalar, enableBrine>;
282 break;
283
284 case WaterPvtApproach::BrineCo2:
285 realWaterPvt_ = new BrineCo2Pvt<Scalar>;
286 break;
287
288 case WaterPvtApproach::BrineH2:
289 realWaterPvt_ = new BrineH2Pvt<Scalar>;
290 break;
291
292 case WaterPvtApproach::NoWater:
293 throw std::logic_error("Not implemented: Water PVT of this deck!");
294 }
295
296 approach_ = appr;
297 }
298
304 WaterPvtApproach approach() const
305 { return approach_; }
306
307 // get the concrete parameter object for the water phase
308 template <WaterPvtApproach approachV>
309 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
310 {
311 assert(approach() == approachV);
312 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
313 }
314
315 template <WaterPvtApproach approachV>
316 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const
317 {
318 assert(approach() == approachV);
319 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
320 }
321
322 template <WaterPvtApproach approachV>
323 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
324 {
325 assert(approach() == approachV);
326 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
327 }
328
329 template <WaterPvtApproach approachV>
330 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const
331 {
332 assert(approach() == approachV);
333 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
334 }
335
336 template <WaterPvtApproach approachV>
337 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
338 {
339 assert(approach() == approachV);
340 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
341 }
342
343 template <WaterPvtApproach approachV>
344 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt() const
345 {
346 assert(approach() == approachV);
347 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
348 }
349
350 template <WaterPvtApproach approachV>
351 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
352 {
353 assert(approach() == approachV);
354 return *static_cast<BrineCo2Pvt<Scalar>* >(realWaterPvt_);
355 }
356
357 template <WaterPvtApproach approachV>
358 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt() const
359 {
360 assert(approach() == approachV);
361 return *static_cast<const BrineCo2Pvt<Scalar>* >(realWaterPvt_);
362 }
363
364 template <WaterPvtApproach approachV>
365 typename std::enable_if<approachV == WaterPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
366 {
367 assert(approach() == approachV);
368 return *static_cast<BrineH2Pvt<Scalar>* >(realWaterPvt_);
369 }
370
371 template <WaterPvtApproach approachV>
372 typename std::enable_if<approachV == WaterPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt() const
373 {
374 assert(approach() == approachV);
375 return *static_cast<const BrineH2Pvt<Scalar>* >(realWaterPvt_);
376 }
377
378 const void* realWaterPvt() const { return realWaterPvt_; }
379
380 WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& operator=(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
381 {
382 approach_ = data.approach_;
383 switch (approach_) {
384 case WaterPvtApproach::ConstantCompressibilityWater:
385 realWaterPvt_ = new ConstantCompressibilityWaterPvt<Scalar>(*static_cast<const ConstantCompressibilityWaterPvt<Scalar>*>(data.realWaterPvt_));
386 break;
387 case WaterPvtApproach::ConstantCompressibilityBrine:
388 realWaterPvt_ = new ConstantCompressibilityBrinePvt<Scalar>(*static_cast<const ConstantCompressibilityBrinePvt<Scalar>*>(data.realWaterPvt_));
389 break;
390 case WaterPvtApproach::ThermalWater:
391 realWaterPvt_ = new WaterPvtThermal<Scalar, enableBrine>(*static_cast<const WaterPvtThermal<Scalar, enableBrine>*>(data.realWaterPvt_));
392 break;
393 case WaterPvtApproach::BrineCo2:
394 realWaterPvt_ = new BrineCo2Pvt<Scalar>(*static_cast<const BrineCo2Pvt<Scalar>*>(data.realWaterPvt_));
395 break;
396 case WaterPvtApproach::BrineH2:
397 realWaterPvt_ = new BrineH2Pvt<Scalar>(*static_cast<const BrineH2Pvt<Scalar>*>(data.realWaterPvt_));
398 break;
399 default:
400 break;
401 }
402
403 return *this;
404 }
405
406private:
407 WaterPvtApproach approach_;
408 void* realWaterPvt_;
409};
410
411} // namespace Opm
412
413#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 liquid phase for a CO2-Brine s...
Definition BrineCo2Pvt.hpp:61
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a H2-Brine sy...
Definition BrineH2Pvt.hpp:53
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition ConstantCompressibilityBrinePvt.hpp:50
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:88
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition WaterPvtMultiplexer.hpp:89
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:179
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:220
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:193
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition WaterPvtMultiplexer.hpp:150
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:233
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:168
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:250
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition WaterPvtMultiplexer.hpp:304
const Scalar waterReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition WaterPvtMultiplexer.hpp:161
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:206
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:261
This class implements temperature dependence of the PVT properties of water.
Definition WaterPvtThermal.hpp:50
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30