My Project
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
35#define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall) \
36 switch (approach_) { \
37 case WaterPvtApproach::ConstantCompressibilityWater: { \
38 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityWater>(); \
39 codeToCall; \
40 break; \
41 } \
42 case WaterPvtApproach::ConstantCompressibilityBrine: { \
43 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>(); \
44 codeToCall; \
45 break; \
46 } \
47 case WaterPvtApproach::ThermalWater: { \
48 auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWater>(); \
49 codeToCall; \
50 break; \
51 } \
52 case WaterPvtApproach::BrineCo2: { \
53 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineCo2>(); \
54 codeToCall; \
55 break; \
56 } \
57 case WaterPvtApproach::NoWater: \
58 throw std::logic_error("Not implemented: Water PVT of this deck!"); \
59 }
60
61namespace Opm {
62
63enum class WaterPvtApproach {
64 NoWater,
65 ConstantCompressibilityBrine,
66 ConstantCompressibilityWater,
67 ThermalWater,
68 BrineCo2
69};
70
71#if HAVE_ECL_INPUT
72class EclipseState;
73class Schedule;
74#endif
75
80template <class Scalar, bool enableThermal = true, bool enableBrine = true>
82{
83public:
85 {
86 approach_ = WaterPvtApproach::NoWater;
87 realWaterPvt_ = nullptr;
88 }
89
90 WaterPvtMultiplexer(WaterPvtApproach approach, void* realWaterPvt)
91 : approach_(approach)
92 , realWaterPvt_(realWaterPvt)
93 { }
94
96 {
97 *this = data;
98 }
99
101 {
102 switch (approach_) {
103 case WaterPvtApproach::ConstantCompressibilityWater: {
104 delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityWater>();
105 break;
106 }
107 case WaterPvtApproach::ConstantCompressibilityBrine: {
108 delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>();
109 break;
110 }
111 case WaterPvtApproach::ThermalWater: {
112 delete &getRealPvt<WaterPvtApproach::ThermalWater>();
113 break;
114 }
115 case WaterPvtApproach::BrineCo2: {
116 delete &getRealPvt<WaterPvtApproach::BrineCo2>();
117 break;
118 }
119 case WaterPvtApproach::NoWater:
120 break;
121 }
122 }
123
124#if HAVE_ECL_INPUT
130 void initFromState(const EclipseState& eclState, const Schedule& schedule);
131#endif // HAVE_ECL_INPUT
132
133 void initEnd()
134 { OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
135
139 unsigned numRegions() const
140 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.numRegions()); return 1; }
141
145 const Scalar waterReferenceDensity(unsigned regionIdx) const
146 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.waterReferenceDensity(regionIdx)); return 1000.; }
147
151 template <class Evaluation>
152 Evaluation internalEnergy(unsigned regionIdx,
153 const Evaluation& temperature,
154 const Evaluation& pressure,
155 const Evaluation& Rsw,
156 const Evaluation& saltconcentration) const
157 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rsw, saltconcentration)); return 0; }
158
162 template <class Evaluation>
163 Evaluation viscosity(unsigned regionIdx,
164 const Evaluation& temperature,
165 const Evaluation& pressure,
166 const Evaluation& Rsw,
167 const Evaluation& saltconcentration) const
168 {
169 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rsw, saltconcentration));
170 return 0;
171 }
172
176 template <class Evaluation>
177 Evaluation saturatedViscosity(unsigned regionIdx,
178 const Evaluation& temperature,
179 const Evaluation& pressure,
180 const Evaluation& saltconcentration) const
181 {
182 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure, saltconcentration));
183 return 0;
184 }
185
189 template <class Evaluation>
190 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
191 const Evaluation& temperature,
192 const Evaluation& pressure,
193 const Evaluation& Rsw,
194 const Evaluation& saltconcentration) const
195 {
196 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration));
197 return 0;
198 }
199
203 template <class Evaluation>
204 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
205 const Evaluation& temperature,
206 const Evaluation& pressure,
207 const Evaluation& saltconcentration) const
208 {
209 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
210 return 0;
211 }
212
216 template <class Evaluation>
217 Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
218 const Evaluation& temperature,
219 const Evaluation& pressure,
220 const Evaluation& saltconcentration) const
221 {
222 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, saltconcentration));
223 return 0;
224 }
225
233 template <class Evaluation>
234 Evaluation saturationPressure(unsigned regionIdx,
235 const Evaluation& temperature,
236 const Evaluation& Rs,
237 const Evaluation& saltconcentration) const
238 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs, saltconcentration)); return 0; }
239
240
244 template <class Evaluation>
245 Evaluation diffusionCoefficient(const Evaluation& temperature,
246 const Evaluation& pressure,
247 unsigned compIdx) const
248 {
249 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
250 return 0;
251 }
252
253 void setApproach(WaterPvtApproach appr)
254 {
255 switch (appr) {
256 case WaterPvtApproach::ConstantCompressibilityWater:
257 realWaterPvt_ = new ConstantCompressibilityWaterPvt<Scalar>;
258 break;
259
260 case WaterPvtApproach::ConstantCompressibilityBrine:
261 realWaterPvt_ = new ConstantCompressibilityBrinePvt<Scalar>;
262 break;
263
264 case WaterPvtApproach::ThermalWater:
265 realWaterPvt_ = new WaterPvtThermal<Scalar, enableBrine>;
266 break;
267
268 case WaterPvtApproach::BrineCo2:
269 realWaterPvt_ = new BrineCo2Pvt<Scalar>;
270 break;
271
272 case WaterPvtApproach::NoWater:
273 throw std::logic_error("Not implemented: Water PVT of this deck!");
274 }
275
276 approach_ = appr;
277 }
278
284 WaterPvtApproach approach() const
285 { return approach_; }
286
287 // get the concrete parameter object for the water phase
288 template <WaterPvtApproach approachV>
289 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
290 {
291 assert(approach() == approachV);
292 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
293 }
294
295 template <WaterPvtApproach approachV>
296 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const
297 {
298 assert(approach() == approachV);
299 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
300 }
301
302 template <WaterPvtApproach approachV>
303 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
304 {
305 assert(approach() == approachV);
306 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
307 }
308
309 template <WaterPvtApproach approachV>
310 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const
311 {
312 assert(approach() == approachV);
313 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
314 }
315
316 template <WaterPvtApproach approachV>
317 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
318 {
319 assert(approach() == approachV);
320 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
321 }
322
323 template <WaterPvtApproach approachV>
324 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt() const
325 {
326 assert(approach() == approachV);
327 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
328 }
329
330 template <WaterPvtApproach approachV>
331 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
332 {
333 assert(approach() == approachV);
334 return *static_cast<BrineCo2Pvt<Scalar>* >(realWaterPvt_);
335 }
336
337 template <WaterPvtApproach approachV>
338 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt() const
339 {
340 assert(approach() == approachV);
341 return *static_cast<const BrineCo2Pvt<Scalar>* >(realWaterPvt_);
342 }
343
344 const void* realWaterPvt() const { return realWaterPvt_; }
345
346 WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& operator=(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
347 {
348 approach_ = data.approach_;
349 switch (approach_) {
350 case WaterPvtApproach::ConstantCompressibilityWater:
351 realWaterPvt_ = new ConstantCompressibilityWaterPvt<Scalar>(*static_cast<const ConstantCompressibilityWaterPvt<Scalar>*>(data.realWaterPvt_));
352 break;
353 case WaterPvtApproach::ConstantCompressibilityBrine:
354 realWaterPvt_ = new ConstantCompressibilityBrinePvt<Scalar>(*static_cast<const ConstantCompressibilityBrinePvt<Scalar>*>(data.realWaterPvt_));
355 break;
356 case WaterPvtApproach::ThermalWater:
357 realWaterPvt_ = new WaterPvtThermal<Scalar, enableBrine>(*static_cast<const WaterPvtThermal<Scalar, enableBrine>*>(data.realWaterPvt_));
358 break;
359 case WaterPvtApproach::BrineCo2:
360 realWaterPvt_ = new BrineCo2Pvt<Scalar>(*static_cast<const BrineCo2Pvt<Scalar>*>(data.realWaterPvt_));
361 break;
362 default:
363 break;
364 }
365
366 return *this;
367 }
368
369private:
370 WaterPvtApproach approach_;
371 void* realWaterPvt_;
372};
373
374} // namespace Opm
375
376#endif
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
Definition: BrineCo2Pvt.hpp:57
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:55
Definition: Schedule.hpp:130
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition: WaterPvtMultiplexer.hpp:82
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:163
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:204
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:177
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: WaterPvtMultiplexer.hpp:139
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:217
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:152
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:234
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition: WaterPvtMultiplexer.hpp:284
const Scalar waterReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition: WaterPvtMultiplexer.hpp:145
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:190
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:245
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