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  Copyright (C) 2015 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef OPM_WATER_PVT_MULTIPLEXER_HPP
26 #define OPM_WATER_PVT_MULTIPLEXER_HPP
27 
29 
30 #define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall) \
31  switch (waterPvtApproach_) { \
32  case ConstantCompressibilityWaterPvt: { \
33  auto &pvtImpl = getRealWaterPvt<ConstantCompressibilityWaterPvt>(); \
34  codeToCall; \
35  break; \
36  } \
37  case NoWaterPvt: \
38  OPM_THROW(std::logic_error, "Not implemented: Water PVT of this deck!"); \
39  }
40 
41 namespace Opm {
46 template <class Scalar>
48 {
49 public:
53  };
54 
56  {
57  waterPvtApproach_ = NoWaterPvt;
58  }
59 
61  {
62  switch (waterPvtApproach_) {
64  delete &getRealWaterPvt<ConstantCompressibilityWaterPvt>();
65  break;
66  }
67  case NoWaterPvt:
68  break;
69  }
70  }
71 
72 #if HAVE_OPM_PARSER
73 
78  void initFromDeck(DeckConstPtr deck, EclipseStateConstPtr eclState)
79  {
80  if (deck->hasKeyword("PVTW"))
82 
83  OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initFromDeck(deck, eclState));
84  }
85 #endif // HAVE_OPM_PARSER
86 
87  void initEnd()
88  { OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
89 
93  template <class Evaluation>
94  Evaluation viscosity(unsigned regionIdx,
95  const Evaluation& temperature,
96  const Evaluation& pressure) const
97  { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure)); return 0; }
98 
102  template <class Evaluation>
103  Evaluation formationVolumeFactor(unsigned regionIdx,
104  const Evaluation& temperature,
105  const Evaluation& pressure) const
106  { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.formationVolumeFactor(regionIdx, temperature, pressure)); return 0; }
107 
111  template <class Evaluation>
112  Evaluation density(unsigned regionIdx,
113  const Evaluation& temperature,
114  const Evaluation& pressure) const
115  { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.density(regionIdx, temperature, pressure)); return 0; }
116 
121  template <class Evaluation>
122  Evaluation fugacityCoefficientOil(unsigned regionIdx,
123  const Evaluation& temperature,
124  const Evaluation& pressure) const
125  { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.fugacityCoefficientOil(regionIdx, temperature, pressure)); return 0; }
130  template <class Evaluation>
131  Evaluation fugacityCoefficientGas(unsigned regionIdx,
132  const Evaluation& temperature,
133  const Evaluation& pressure) const
134  { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.fugacityCoefficientGas(regionIdx, temperature, pressure)); return 0; }
139  template <class Evaluation>
140  Evaluation fugacityCoefficientWater(unsigned regionIdx,
141  const Evaluation& temperature,
142  const Evaluation& pressure) const
143  { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.fugacityCoefficientWater(regionIdx, temperature, pressure)); return 0; }
144 
146  {
147  switch (waterPvtApproach) {
150  break;
151 
152  case NoWaterPvt:
153  OPM_THROW(std::logic_error, "Not implemented: Water PVT of this deck!");
154  }
155 
156  waterPvtApproach_ = waterPvtApproach;
157  }
158 
160  { return waterPvtApproach_; }
161 
162  // get the parameter object for the dry water case
163  template <WaterPvtApproach approachV>
164  typename std::enable_if<approachV == ConstantCompressibilityWaterPvt, Opm::ConstantCompressibilityWaterPvt<Scalar> >::type& getRealWaterPvt()
165  {
166  assert(waterPvtApproach() == approachV);
167  return *static_cast<Opm::ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
168  }
169 
170  template <WaterPvtApproach approachV>
171  typename std::enable_if<approachV == ConstantCompressibilityWaterPvt, const Opm::ConstantCompressibilityWaterPvt<Scalar> >::type& getRealWaterPvt() const
172  {
173  assert(waterPvtApproach() == approachV);
174  return *static_cast<Opm::ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
175  }
176 
177 private:
178  WaterPvtApproach waterPvtApproach_;
179  void *realWaterPvt_;
180 };
181 
182 #undef OPM_WATER_PVT_MULTIPLEXER_CALL
183 
184 } // namespace Opm
185 
186 #endif
WaterPvtApproach
Definition: WaterPvtMultiplexer.hpp:50
Definition: Air_Mesitylene.hpp:31
#define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall)
Definition: WaterPvtMultiplexer.hpp:30
WaterPvtApproach waterPvtApproach() const
Definition: WaterPvtMultiplexer.hpp:159
Evaluation fugacityCoefficientOil(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the fugacity coefficient [-] of the oil component in the water phase given a pressure and a t...
Definition: WaterPvtMultiplexer.hpp:122
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: ConstantCompressibilityWaterPvt.hpp:43
Evaluation fugacityCoefficientWater(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the fugacity coefficient [-] of the water component in the water phase given a pressure and a...
Definition: WaterPvtMultiplexer.hpp:140
void setApproach(WaterPvtApproach waterPvtApproach)
Definition: WaterPvtMultiplexer.hpp:145
Evaluation viscosity(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: WaterPvtMultiplexer.hpp:94
Evaluation density(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the density [kg/m^3] of the fluid phase given a set of parameters.
Definition: WaterPvtMultiplexer.hpp:112
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition: WaterPvtMultiplexer.hpp:47
std::enable_if< approachV==ConstantCompressibilityWaterPvt, const Opm::ConstantCompressibilityWaterPvt< Scalar > >::type & getRealWaterPvt() const
Definition: WaterPvtMultiplexer.hpp:171
Definition: WaterPvtMultiplexer.hpp:51
WaterPvtMultiplexer()
Definition: WaterPvtMultiplexer.hpp:55
Evaluation fugacityCoefficientGas(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the fugacity coefficient [-] of the gas component in the water phase given a pressure and a t...
Definition: WaterPvtMultiplexer.hpp:131
void initEnd()
Definition: WaterPvtMultiplexer.hpp:87
std::enable_if< approachV==ConstantCompressibilityWaterPvt, Opm::ConstantCompressibilityWaterPvt< Scalar > >::type & getRealWaterPvt()
Definition: WaterPvtMultiplexer.hpp:164
~WaterPvtMultiplexer()
Definition: WaterPvtMultiplexer.hpp:60
Evaluation formationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition: WaterPvtMultiplexer.hpp:103
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...