27#ifndef OPM_ECL_TWO_PHASE_MATERIAL_HPP
28#define OPM_ECL_TWO_PHASE_MATERIAL_HPP
32#include <opm/common/TimingMacros.hpp>
48template <
class TraitsT,
49 class GasOilMaterialLawT,
50 class OilWaterMaterialLawT,
51 class GasWaterMaterialLawT,
52 class ParamsT = EclTwoPhaseMaterialParams<TraitsT,
53 typename GasOilMaterialLawT::Params,
54 typename OilWaterMaterialLawT::Params,
55 typename GasWaterMaterialLawT::Params> >
59 using GasOilMaterialLaw = GasOilMaterialLawT;
60 using OilWaterMaterialLaw = OilWaterMaterialLawT;
61 using GasWaterMaterialLaw = GasWaterMaterialLawT;
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(GasWaterMaterialLaw::numPhases == 2,
74 "The number of phases considered by the gas-water capillary "
75 "pressure law must be two!");
76 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
77 typename OilWaterMaterialLaw::Scalar>::value,
78 "The two two-phase capillary pressure laws must use the same "
79 "type of floating point values.");
81 using Traits = TraitsT;
82 using Params = ParamsT;
83 using Scalar =
typename Traits::Scalar;
85 static constexpr int numPhases = 3;
86 static constexpr int waterPhaseIdx = Traits::wettingPhaseIdx;
87 static constexpr int oilPhaseIdx = Traits::nonWettingPhaseIdx;
88 static constexpr int gasPhaseIdx = Traits::gasPhaseIdx;
114 template <
class ContainerT,
class Flu
idState>
115 static Scalar relpermOilInOilGasSystem(
const Params& ,
116 const FluidState& ) {
117 throw std::logic_error {
118 "relpermOilInOilGasSystem() is specific to three phases"
121 template <
class ContainerT,
class Flu
idState>
122 static Scalar relpermOilInOilWaterSystem(
const Params& ,
123 const FluidState& ) {
124 throw std::logic_error {
125 "relpermOilInOilWaterSystem() is specific to three phases"
144 template <
class ContainerT,
class Flu
idState>
146 const Params& params,
147 const FluidState& fluidState)
149 OPM_TIMEFUNCTION_LOCAL();
150 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
152 switch (params.approach()) {
153 case EclTwoPhaseApproach::GasOil: {
154 const Evaluation& So =
155 decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
157 values[oilPhaseIdx] = 0.0;
158 values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(), So);
162 case EclTwoPhaseApproach::OilWater: {
163 const Evaluation&
Sw =
164 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
166 values[waterPhaseIdx] = 0.0;
167 values[oilPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(),
Sw);
171 case EclTwoPhaseApproach::GasWater: {
172 const Evaluation&
Sw =
173 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
175 values[waterPhaseIdx] = 0.0;
176 values[gasPhaseIdx] = GasWaterMaterialLaw::twoPhaseSatPcnw(params.gasWaterParams(),
Sw);
190 static void oilWaterHysteresisParams(Scalar& soMax,
193 const Params& params)
195 soMax = 1.0 - params.oilWaterParams().krnSwMdc();
196 swMax = params.oilWaterParams().krwSwMdc();
197 swMin = params.oilWaterParams().pcSwMdc();
198 Valgrind::CheckDefined(soMax);
199 Valgrind::CheckDefined(swMax);
200 Valgrind::CheckDefined(swMin);
210 static void setOilWaterHysteresisParams(
const Scalar& soMax,
215 params.oilWaterParams().update(swMin, swMax, 1.0 - soMax);
226 static void gasOilHysteresisParams(Scalar& sgmax,
229 const Params& params)
231 sgmax = 1.0 - params.gasOilParams().krnSwMdc();
232 shmax = params.gasOilParams().krwSwMdc();
233 somin = params.gasOilParams().pcSwMdc();
234 Valgrind::CheckDefined(sgmax);
235 Valgrind::CheckDefined(shmax);
236 Valgrind::CheckDefined(somin);
245 static void setGasOilHysteresisParams(
const Scalar& sgmax,
250 params.gasOilParams().update(somin , shmax, 1.0 - sgmax);
253 static Scalar trappedGasSaturation(
const Params& params,
bool maximumTrapping){
254 if(params.approach() == EclTwoPhaseApproach::GasOil)
255 return params.gasOilParams().SnTrapped(maximumTrapping);
256 if(params.approach() == EclTwoPhaseApproach::GasWater)
257 return params.gasWaterParams().SnTrapped(maximumTrapping);
261 static Scalar strandedGasSaturation(
const Params& params, Scalar
Sg, Scalar Kg){
262 if(params.approach() == EclTwoPhaseApproach::GasOil)
263 return params.gasOilParams().SnStranded(
Sg, Kg);
264 if(params.approach() == EclTwoPhaseApproach::GasWater)
265 return params.gasWaterParams().SnStranded(
Sg, Kg);
269 static Scalar trappedOilSaturation(
const Params& params,
bool maximumTrapping){
270 if(params.approach() == EclTwoPhaseApproach::GasOil)
271 return params.gasOilParams().SwTrapped();
272 if(params.approach() == EclTwoPhaseApproach::OilWater)
273 return params.oilWaterParams().SnTrapped(maximumTrapping);
277 static Scalar trappedWaterSaturation(
const Params& params){
278 if(params.approach() == EclTwoPhaseApproach::GasWater)
279 return params.gasWaterParams().SwTrapped();
280 if(params.approach() == EclTwoPhaseApproach::OilWater)
281 return params.oilWaterParams().SwTrapped();
295 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
296 static Evaluation
pcgn(
const Params& ,
299 throw std::logic_error(
"Not implemented: pcgn()");
311 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
312 static Evaluation
pcnw(
const Params& ,
315 throw std::logic_error(
"Not implemented: pcnw()");
321 template <
class ContainerT,
class Flu
idState>
326 throw std::logic_error(
"Not implemented: saturations()");
332 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
333 static Evaluation
Sg(
const Params& ,
336 throw std::logic_error(
"Not implemented: Sg()");
342 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
343 static Evaluation
Sn(
const Params& ,
346 throw std::logic_error(
"Not implemented: Sn()");
352 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
353 static Evaluation
Sw(
const Params& ,
356 throw std::logic_error(
"Not implemented: Sw()");
374 template <
class ContainerT,
class Flu
idState>
376 const Params& params,
377 const FluidState& fluidState)
379 OPM_TIMEFUNCTION_LOCAL();
380 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
382 switch (params.approach()) {
383 case EclTwoPhaseApproach::GasOil: {
384 const Evaluation& So =
385 decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
387 values[oilPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), So);
388 values[gasPhaseIdx] = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), So);
392 case EclTwoPhaseApproach::OilWater: {
393 const Evaluation&
Sw =
394 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
396 values[waterPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
397 values[oilPhaseIdx] = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(),
Sw);
401 case EclTwoPhaseApproach::GasWater: {
402 const Evaluation&
Sw =
403 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
405 values[waterPhaseIdx] = GasWaterMaterialLaw::twoPhaseSatKrw(params.gasWaterParams(),
Sw);
406 values[gasPhaseIdx] = GasWaterMaterialLaw::twoPhaseSatKrn(params.gasWaterParams(),
Sw);
416 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
417 static Evaluation
krg(
const Params& ,
420 throw std::logic_error(
"Not implemented: krg()");
426 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
427 static Evaluation
krw(
const Params& ,
430 throw std::logic_error(
"Not implemented: krw()");
436 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
437 static Evaluation
krn(
const Params& ,
440 throw std::logic_error(
"Not implemented: krn()");
451 template <
class Flu
idState>
454 OPM_TIMEFUNCTION_LOCAL();
455 switch (params.approach()) {
456 case EclTwoPhaseApproach::GasOil: {
457 Scalar So = scalarValue(fluidState.saturation(oilPhaseIdx));
459 return params.gasOilParams().update(So, So, So);
462 case EclTwoPhaseApproach::OilWater: {
463 Scalar
Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
465 return params.oilWaterParams().update(
Sw,
Sw,
Sw);
468 case EclTwoPhaseApproach::GasWater: {
469 Scalar
Sw = scalarValue(fluidState.saturation(waterPhaseIdx));
471 return params.gasWaterParams().update(
Sw,
Sw,
Sw);
Implementation for the parameters required by the material law for two-phase simulations.
Some templates to wrap the valgrind client request macros.
Implements a multiplexer class that provides ECL saturation functions for twophase simulations.
Definition EclTwoPhaseMaterial.hpp:57
static constexpr bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition EclTwoPhaseMaterial.hpp:108
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition EclTwoPhaseMaterial.hpp:375
static constexpr bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition EclTwoPhaseMaterial.hpp:92
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition EclTwoPhaseMaterial.hpp:353
static Evaluation pcgn(const Params &, const FluidState &)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition EclTwoPhaseMaterial.hpp:296
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition EclTwoPhaseMaterial.hpp:322
static Evaluation krn(const Params &, const FluidState &)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition EclTwoPhaseMaterial.hpp:437
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition EclTwoPhaseMaterial.hpp:343
static constexpr bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition EclTwoPhaseMaterial.hpp:100
static constexpr bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition EclTwoPhaseMaterial.hpp:104
static Evaluation krg(const Params &, const FluidState &)
The relative permeability of the gas phase.
Definition EclTwoPhaseMaterial.hpp:417
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition EclTwoPhaseMaterial.hpp:333
static bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition EclTwoPhaseMaterial.hpp:452
static void capillaryPressures(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
Implements the multiplexer three phase capillary pressure law used by the ECLipse simulator.
Definition EclTwoPhaseMaterial.hpp:145
static constexpr bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition EclTwoPhaseMaterial.hpp:112
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:312
static Evaluation krw(const Params &, const FluidState &)
The relative permeability of the wetting phase.
Definition EclTwoPhaseMaterial.hpp:427
static constexpr bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition EclTwoPhaseMaterial.hpp:96
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30