All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EclTwoPhaseMaterial.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_ECL_TWO_PHASE_MATERIAL_HPP
28 #define OPM_ECL_TWO_PHASE_MATERIAL_HPP
29 
31 
32 #include <opm/common/Valgrind.hpp>
34 
35 #include <opm/common/Exceptions.hpp>
36 #include <opm/common/ErrorMacros.hpp>
37 
38 #include <algorithm>
39 
40 namespace Opm {
41 
51 template <class TraitsT,
52  class GasOilMaterialLawT,
53  class OilWaterMaterialLawT,
54  class ParamsT = EclTwoPhaseMaterialParams<TraitsT,
55  typename GasOilMaterialLawT::Params,
56  typename OilWaterMaterialLawT::Params> >
57 class EclTwoPhaseMaterial : public TraitsT
58 {
59 public:
60  typedef GasOilMaterialLawT GasOilMaterialLaw;
61  typedef OilWaterMaterialLawT OilWaterMaterialLaw;
62 
63  // some safety checks
64  static_assert(TraitsT::numPhases == 3,
65  "The number of phases considered by this capillary pressure "
66  "law is always three!");
67  static_assert(GasOilMaterialLaw::numPhases == 2,
68  "The number of phases considered by the gas-oil capillary "
69  "pressure law must be two!");
70  static_assert(OilWaterMaterialLaw::numPhases == 2,
71  "The number of phases considered by the oil-water capillary "
72  "pressure law must be two!");
73  static_assert(std::is_same<typename GasOilMaterialLaw::Scalar,
74  typename OilWaterMaterialLaw::Scalar>::value,
75  "The two two-phase capillary pressure laws must use the same "
76  "type of floating point values.");
77 
78  typedef TraitsT Traits;
79  typedef ParamsT Params;
80  typedef typename Traits::Scalar Scalar;
81 
82  static const int numPhases = 3;
83  static const int waterPhaseIdx = Traits::wettingPhaseIdx;
84  static const int oilPhaseIdx = Traits::nonWettingPhaseIdx;
85  static const int gasPhaseIdx = Traits::gasPhaseIdx;
86 
89  static const bool implementsTwoPhaseApi = false;
90 
93  static const bool implementsTwoPhaseSatApi = false;
94 
97  static const bool isSaturationDependent = true;
98 
101  static const bool isPressureDependent = false;
102 
105  static const bool isTemperatureDependent = false;
106 
109  static const bool isCompositionDependent = false;
110 
125  template <class ContainerT, class FluidState>
126  static void capillaryPressures(ContainerT& values,
127  const Params& params,
128  const FluidState& fluidState)
129  {
130  typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
131 
132  switch (params.approach()) {
133  case EclTwoPhaseGasOil: {
134  const Evaluation& So =
135  Opm::decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
136 
137  values[oilPhaseIdx] = 0.0;
138  values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(), So);
139  break;
140  }
141 
142  case EclTwoPhaseOilWater: {
143  const Evaluation& Sw =
144  Opm::decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
145 
146  values[waterPhaseIdx] = 0.0;
147  values[oilPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(), Sw);
148  break;
149  }
150 
151  case EclTwoPhaseGasWater: {
152  const Evaluation& Sw =
153  Opm::decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
154 
155  values[waterPhaseIdx] = 0.0;
156  values[gasPhaseIdx] =
157  OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(), Sw)
158  + GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(), 0.0);
159  break;
160  }
161 
162  }
163  }
164 
165  /*
166  * Hysteresis parameters for oil-water
167  * @see EclHysteresisTwoPhaseLawParams::pcSwMdc(...)
168  * @see EclHysteresisTwoPhaseLawParams::krnSwMdc(...)
169  * \param params Parameters
170  */
171  static void oilWaterHysteresisParams(Scalar& pcSwMdc,
172  Scalar& krnSwMdc,
173  const Params& params)
174  {
175  pcSwMdc = params.oilWaterParams().pcSwMdc();
176  krnSwMdc = params.oilWaterParams().krnSwMdc();
177 
178  Valgrind::CheckDefined(pcSwMdc);
179  Valgrind::CheckDefined(krnSwMdc);
180  }
181 
182  /*
183  * Hysteresis parameters for oil-water
184  * @see EclHysteresisTwoPhaseLawParams::pcSwMdc(...)
185  * @see EclHysteresisTwoPhaseLawParams::krnSwMdc(...)
186  * \param params Parameters
187  */
188  static void setOilWaterHysteresisParams(const Scalar& pcSwMdc,
189  const Scalar& krnSwMdc,
190  Params& params)
191  {
192  const Scalar krwSw = 2.0; //Should not be used
193  params.oilWaterParams().update(pcSwMdc, krwSw, krnSwMdc);
194  }
195 
196  /*
197  * Hysteresis parameters for gas-oil
198  * @see EclHysteresisTwoPhaseLawParams::pcSwMdc(...)
199  * @see EclHysteresisTwoPhaseLawParams::krnSwMdc(...)
200  * \param params Parameters
201  */
202  static void gasOilHysteresisParams(Scalar& pcSwMdc,
203  Scalar& krnSwMdc,
204  const Params& params)
205  {
206  pcSwMdc = params.gasOilParams().pcSwMdc();
207  krnSwMdc = params.gasOilParams().krnSwMdc();
208 
209  Valgrind::CheckDefined(pcSwMdc);
210  Valgrind::CheckDefined(krnSwMdc);
211  }
212 
213  /*
214  * Hysteresis parameters for gas-oil
215  * @see EclHysteresisTwoPhaseLawParams::pcSwMdc(...)
216  * @see EclHysteresisTwoPhaseLawParams::krnSwMdc(...)
217  * \param params Parameters
218  */
219  static void setGasOilHysteresisParams(const Scalar& pcSwMdc,
220  const Scalar& krnSwMdc,
221  Params& params)
222  {
223  const Scalar krwSw = 2.0; //Should not be used
224  params.gasOilParams().update(pcSwMdc, krwSw, krnSwMdc);
225  }
226 
236  template <class FluidState, class Evaluation = typename FluidState::Scalar>
237  static Evaluation pcgn(const Params& /* params */,
238  const FluidState& /* fs */)
239  {
240  OPM_THROW(std::logic_error, "Not implemented: pcgn()");
241  }
242 
252  template <class FluidState, class Evaluation = typename FluidState::Scalar>
253  static Evaluation pcnw(const Params& /* params */,
254  const FluidState& /* fs */)
255  {
256  OPM_THROW(std::logic_error, "Not implemented: pcnw()");
257  }
258 
262  template <class ContainerT, class FluidState>
263  static void saturations(ContainerT& /* values */,
264  const Params& /* params */,
265  const FluidState& /* fs */)
266  {
267  OPM_THROW(std::logic_error, "Not implemented: saturations()");
268  }
269 
273  template <class FluidState, class Evaluation = typename FluidState::Scalar>
274  static Evaluation Sg(const Params& /* params */,
275  const FluidState& /* fluidState */)
276  {
277  OPM_THROW(std::logic_error, "Not implemented: Sg()");
278  }
279 
283  template <class FluidState, class Evaluation = typename FluidState::Scalar>
284  static Evaluation Sn(const Params& /* params */,
285  const FluidState& /* fluidState */)
286  {
287  OPM_THROW(std::logic_error, "Not implemented: Sn()");
288  }
289 
293  template <class FluidState, class Evaluation = typename FluidState::Scalar>
294  static Evaluation Sw(const Params& /* params */,
295  const FluidState& /* fluidState */)
296  {
297  OPM_THROW(std::logic_error, "Not implemented: Sw()");
298  }
299 
315  template <class ContainerT, class FluidState>
316  static void relativePermeabilities(ContainerT& values,
317  const Params& params,
318  const FluidState& fluidState)
319  {
320  typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
321 
322  switch (params.approach()) {
323  case EclTwoPhaseGasOil: {
324  const Evaluation& So =
325  Opm::decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
326 
327  values[oilPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), So);
328  values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), So);
329  break;
330  }
331 
332  case EclTwoPhaseOilWater: {
333  const Evaluation& Sw =
334  Opm::decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
335 
336  values[waterPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), Sw);
337  values[oilPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), Sw);
338  break;
339  }
340 
341  case EclTwoPhaseGasWater: {
342  const Evaluation& Sw =
343  Opm::decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
344 
345  values[waterPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), Sw);
346  values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), Sw);
347  break;
348  }
349  }
350  }
351 
355  template <class FluidState, class Evaluation = typename FluidState::Scalar>
356  static Evaluation krg(const Params& /* params */,
357  const FluidState& /* fluidState */)
358  {
359  OPM_THROW(std::logic_error, "Not implemented: krg()");
360  }
361 
365  template <class FluidState, class Evaluation = typename FluidState::Scalar>
366  static Evaluation krw(const Params& /* params */,
367  const FluidState& /* fluidState */)
368  {
369  OPM_THROW(std::logic_error, "Not implemented: krw()");
370  }
371 
375  template <class FluidState, class Evaluation = typename FluidState::Scalar>
376  static Evaluation krn(const Params& /* params */,
377  const FluidState& /* fluidState */)
378  {
379  OPM_THROW(std::logic_error, "Not implemented: krn()");
380  }
381 
382 
390  template <class FluidState>
391  static void updateHysteresis(Params& params, const FluidState& fluidState)
392  {
393  switch (params.approach()) {
394  case EclTwoPhaseGasOil: {
395  Scalar So = Opm::scalarValue(fluidState.saturation(oilPhaseIdx));
396 
397  params.gasOilParams().update(/*pcSw=*/So, /*krwSw=*/So, /*krnSw=*/So);
398  break;
399  }
400 
401  case EclTwoPhaseOilWater: {
402  Scalar Sw = Opm::scalarValue(fluidState.saturation(waterPhaseIdx));
403 
404  params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
405  break;
406  }
407 
408  case EclTwoPhaseGasWater: {
409  Scalar Sw = Opm::scalarValue(fluidState.saturation(waterPhaseIdx));
410 
411  params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/0);
412  params.gasOilParams().update(/*pcSw=*/1.0, /*krwSw=*/0.0, /*krnSw=*/Sw);
413  break;
414  }
415  }
416  }
417 };
418 } // namespace Opm
419 
420 #endif
static Evaluation krw(const Params &, const FluidState &)
The relative permeability of the wetting phase.
Definition: EclTwoPhaseMaterial.hpp:366
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
static Evaluation krg(const Params &, const FluidState &)
The relative permeability of the gas phase.
Definition: EclTwoPhaseMaterial.hpp:356
static void capillaryPressures(ContainerT &values, const Params &params, const FluidState &fluidState)
Implements the multiplexer three phase capillary pressure law used by the ECLipse simulator...
Definition: EclTwoPhaseMaterial.hpp:126
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclTwoPhaseMaterial.hpp:274
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclTwoPhaseMaterial.hpp:263
static Evaluation pcnw(const Params &, const FluidState &)
Capillary pressure between the non-wetting liquid (i.e., oil) and the wetting liquid (i...
Definition: EclTwoPhaseMaterial.hpp:253
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition...
Definition: EclTwoPhaseMaterial.hpp:109
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure...
Definition: EclTwoPhaseMaterial.hpp:101
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: EclTwoPhaseMaterial.hpp:97
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclTwoPhaseMaterial.hpp:284
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: EclTwoPhaseMaterial.hpp:93
static Evaluation krn(const Params &, const FluidState &)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition: EclTwoPhaseMaterial.hpp:376
static void relativePermeabilities(ContainerT &values, const Params &params, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclTwoPhaseMaterial.hpp:316
static void updateHysteresis(Params &params, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclTwoPhaseMaterial.hpp:391
static Evaluation pcgn(const Params &, const FluidState &)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclTwoPhaseMaterial.hpp:237
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition: EclTwoPhaseMaterial.hpp:294
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclTwoPhaseMaterial.hpp:57
Implementation for the parameters required by the material law for two-phase simulations.
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition: EclTwoPhaseMaterial.hpp:105
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: EclTwoPhaseMaterial.hpp:89