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  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_ECL_TWO_PHASE_MATERIAL_HPP
26 #define OPM_ECL_TWO_PHASE_MATERIAL_HPP
27 
29 
32 
33 #include <opm/common/Exceptions.hpp>
34 #include <opm/common/ErrorMacros.hpp>
35 
36 #include <algorithm>
37 
38 namespace Opm {
39 
49 template <class TraitsT,
50  class GasOilMaterialLawT,
51  class OilWaterMaterialLawT,
52  class ParamsT = EclTwoPhaseMaterialParams<TraitsT,
53  typename GasOilMaterialLawT::Params,
54  typename OilWaterMaterialLawT::Params> >
55 class EclTwoPhaseMaterial : public TraitsT
56 {
57 public:
58  typedef GasOilMaterialLawT GasOilMaterialLaw;
59  typedef OilWaterMaterialLawT OilWaterMaterialLaw;
60 
61  // some safety checks
62  static_assert(TraitsT::numPhases == 3,
63  "The number of phases considered by this capillary pressure "
64  "law is always three!");
65  static_assert(GasOilMaterialLaw::numPhases == 2,
66  "The number of phases considered by the gas-oil capillary "
67  "pressure law must be two!");
68  static_assert(OilWaterMaterialLaw::numPhases == 2,
69  "The number of phases considered by the oil-water capillary "
70  "pressure law must be two!");
71  static_assert(std::is_same<typename GasOilMaterialLaw::Scalar,
72  typename OilWaterMaterialLaw::Scalar>::value,
73  "The two two-phase capillary pressure laws must use the same "
74  "type of floating point values.");
75 
76  typedef TraitsT Traits;
77  typedef ParamsT Params;
78  typedef typename Traits::Scalar Scalar;
79 
80  static const int numPhases = 3;
81  static const int waterPhaseIdx = Traits::wettingPhaseIdx;
82  static const int oilPhaseIdx = Traits::nonWettingPhaseIdx;
83  static const int gasPhaseIdx = Traits::gasPhaseIdx;
84 
87  static const bool implementsTwoPhaseApi = false;
88 
91  static const bool implementsTwoPhaseSatApi = false;
92 
95  static const bool isSaturationDependent = true;
96 
99  static const bool isPressureDependent = false;
100 
103  static const bool isTemperatureDependent = false;
104 
107  static const bool isCompositionDependent = false;
108 
123  template <class ContainerT, class FluidState>
124  static void capillaryPressures(ContainerT &values,
125  const Params &params,
126  const FluidState &fluidState)
127  {
128  typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
130 
131  switch (params.approach()) {
132  case EclTwoPhaseGasOil: {
133  const Evaluation& So =
134  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(oilPhaseIdx));
135 
136  values[oilPhaseIdx] = 0.0;
137  values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(), So);
138  break;
139  }
140 
141  case EclTwoPhaseOilWater: {
142  const Evaluation& Sw =
143  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(waterPhaseIdx));
144 
145  values[waterPhaseIdx] = 0.0;
146  values[oilPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(), Sw);
147  break;
148  }
149 
150  case EclTwoPhaseGasWater: {
151  const Evaluation& Sw =
152  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(waterPhaseIdx));
153 
154  values[waterPhaseIdx] = 0.0;
155  values[gasPhaseIdx] =
156  OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(), Sw)
157  + GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(), 0.0);
158  break;
159  }
160  }
161  }
162 
172  template <class FluidState, class Evaluation = typename FluidState::Scalar>
173  static Evaluation pcgn(const Params& /* params */,
174  const FluidState& /* fs */)
175  {
176  OPM_THROW(std::logic_error, "Not implemented: pcgn()");
177  }
178 
188  template <class FluidState, class Evaluation = typename FluidState::Scalar>
189  static Evaluation pcnw(const Params& /* params */,
190  const FluidState& /* fs */)
191  {
192  OPM_THROW(std::logic_error, "Not implemented: pcnw()");
193  }
194 
198  template <class ContainerT, class FluidState>
199  static void saturations(ContainerT& /* values */,
200  const Params& /* params */,
201  const FluidState& /* fs */)
202  {
203  OPM_THROW(std::logic_error, "Not implemented: saturations()");
204  }
205 
209  template <class FluidState, class Evaluation = typename FluidState::Scalar>
210  static Evaluation Sg(const Params& /* params */,
211  const FluidState& /* fluidState */)
212  {
213  OPM_THROW(std::logic_error, "Not implemented: Sg()");
214  }
215 
219  template <class FluidState, class Evaluation = typename FluidState::Scalar>
220  static Evaluation Sn(const Params& /* params */,
221  const FluidState& /* fluidState */)
222  {
223  OPM_THROW(std::logic_error, "Not implemented: Sn()");
224  }
225 
229  template <class FluidState, class Evaluation = typename FluidState::Scalar>
230  static Evaluation Sw(const Params& /* params */,
231  const FluidState& /* fluidState */)
232  {
233  OPM_THROW(std::logic_error, "Not implemented: Sw()");
234  }
235 
251  template <class ContainerT, class FluidState>
252  static void relativePermeabilities(ContainerT &values,
253  const Params &params,
254  const FluidState &fluidState)
255  {
256  typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
257  typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
258 
259  switch (params.approach()) {
260  case EclTwoPhaseGasOil: {
261  const Evaluation& So =
262  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(oilPhaseIdx));
263 
264  values[oilPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), So);
265  values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), So);
266  break;
267  }
268 
269  case EclTwoPhaseOilWater: {
270  const Evaluation& Sw =
271  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(waterPhaseIdx));
272 
273  values[waterPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), Sw);
274  values[oilPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), Sw);
275  break;
276  }
277 
278  case EclTwoPhaseGasWater: {
279  const Evaluation& Sw =
280  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(waterPhaseIdx));
281 
282  values[waterPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), Sw);
283  values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), Sw);
284  break;
285  }
286  }
287  }
288 
292  template <class FluidState, class Evaluation = typename FluidState::Scalar>
293  static Evaluation krg(const Params& /* params */,
294  const FluidState& /* fluidState */)
295  {
296  OPM_THROW(std::logic_error, "Not implemented: krg()");
297  }
298 
302  template <class FluidState, class Evaluation = typename FluidState::Scalar>
303  static Evaluation krw(const Params& /* params */,
304  const FluidState& /* fluidState */)
305  {
306  OPM_THROW(std::logic_error, "Not implemented: krw()");
307  }
308 
312  template <class FluidState, class Evaluation = typename FluidState::Scalar>
313  static Evaluation krn(const Params& /* params */,
314  const FluidState& /* fluidState */)
315  {
316  OPM_THROW(std::logic_error, "Not implemented: krn()");
317  }
318 
319 
327  template <class FluidState>
328  static void updateHysteresis(Params &params, const FluidState &fluidState)
329  {
330  typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
331 
332  switch (params.approach()) {
333  case EclTwoPhaseGasOil: {
334  Scalar So = FsToolbox::value(fluidState.saturation(oilPhaseIdx));
335 
336  params.oilWaterParams().update(/*pcSw=*/0.0, /*krwSw=*/0.0, /*krnSw=*/0.0);
337  params.gasOilParams().update(/*pcSw=*/So, /*krwSw=*/So, /*krnSw=*/So);
338  break;
339  }
340 
341  case EclTwoPhaseOilWater: {
342  Scalar Sw = FsToolbox::value(fluidState.saturation(waterPhaseIdx));
343 
344  params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/Sw);
345  params.gasOilParams().update(/*pcSw=*/0.0, /*krwSw=*/0.0, /*krnSw=*/0.0);
346  break;
347  }
348 
349  case EclTwoPhaseGasWater: {
350  Scalar Sw = FsToolbox::value(fluidState.saturation(waterPhaseIdx));
351 
352  params.oilWaterParams().update(/*pcSw=*/Sw, /*krwSw=*/Sw, /*krnSw=*/0);
353  params.gasOilParams().update(/*pcSw=*/1.0, /*krwSw=*/0.0, /*krnSw=*/Sw);
354  break;
355  }
356  }
357  }
358 };
359 } // namespace Opm
360 
361 #endif
Definition: EclTwoPhaseMaterialParams.hpp:35
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
Some templates to wrap the valgrind client request macros.
Implementation for the parameters required by the material law for two-phase simulations.
Definition: EclTwoPhaseMaterialParams.hpp:34
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclTwoPhaseMaterial.hpp:55
GasOilMaterialLawT GasOilMaterialLaw
Definition: EclTwoPhaseMaterial.hpp:58
OilWaterMaterialLawT OilWaterMaterialLaw
Definition: EclTwoPhaseMaterial.hpp:59
Definition: EclTwoPhaseMaterialParams.hpp:36
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...