27 #ifndef OPM_ECL_TWO_PHASE_MATERIAL_HPP 28 #define OPM_ECL_TWO_PHASE_MATERIAL_HPP 32 #include <opm/common/TimingMacros.hpp> 33 #include <opm/common/utility/gpuDecorators.hpp> 49 template <
class TraitsT,
50 class GasOilMaterialLawT,
51 class OilWaterMaterialLawT,
52 class GasWaterMaterialLawT,
53 class ParamsT = EclTwoPhaseMaterialParams<TraitsT,
54 typename GasOilMaterialLawT::Params,
55 typename OilWaterMaterialLawT::Params,
56 typename GasWaterMaterialLawT::Params> >
60 using GasOilMaterialLaw = GasOilMaterialLawT;
61 using OilWaterMaterialLaw = OilWaterMaterialLawT;
62 using GasWaterMaterialLaw = GasWaterMaterialLawT;
65 static_assert(TraitsT::numPhases == 3,
66 "The number of phases considered by this capillary pressure " 67 "law is always three!");
68 static_assert(GasOilMaterialLaw::numPhases == 2,
69 "The number of phases considered by the gas-oil capillary " 70 "pressure law must be two!");
71 static_assert(OilWaterMaterialLaw::numPhases == 2,
72 "The number of phases considered by the oil-water capillary " 73 "pressure law must be two!");
74 static_assert(GasWaterMaterialLaw::numPhases == 2,
75 "The number of phases considered by the gas-water capillary " 76 "pressure law must be two!");
77 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
78 typename OilWaterMaterialLaw::Scalar>::
value,
79 "The two two-phase capillary pressure laws must use the same " 80 "type of floating point values.");
82 using Traits = TraitsT;
83 using Params = ParamsT;
84 using Scalar =
typename Traits::Scalar;
86 static constexpr
int numPhases = 3;
87 static constexpr
int waterPhaseIdx = Traits::wettingPhaseIdx;
88 static constexpr
int oilPhaseIdx = Traits::nonWettingPhaseIdx;
89 static constexpr
int gasPhaseIdx = Traits::gasPhaseIdx;
115 template <
class ContainerT,
class Flu
idState>
116 static Scalar relpermOilInOilGasSystem(
const Params& ,
117 const FluidState& ) {
118 throw std::logic_error {
119 "relpermOilInOilGasSystem() is specific to three phases" 122 template <
class ContainerT,
class Flu
idState>
123 static Scalar relpermOilInOilWaterSystem(
const Params& ,
124 const FluidState& ) {
125 throw std::logic_error {
126 "relpermOilInOilWaterSystem() is specific to three phases" 145 template <
class ContainerT,
class FluidState,
class ...Args>
147 const Params& params,
148 const FluidState& fluidState)
150 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
151 using Evaluation =
typename std::remove_reference<decltype(values[0])>::type;
153 switch (params.approach()) {
154 case EclTwoPhaseApproach::GasOil: {
155 const Evaluation& So =
156 decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
158 values[oilPhaseIdx] = 0.0;
159 values[gasPhaseIdx] = GasOilMaterialLaw::template twoPhaseSatPcnw<Evaluation, Args...>(params.gasOilParams(), So);
163 case EclTwoPhaseApproach::OilWater: {
164 const Evaluation&
Sw =
165 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
167 values[waterPhaseIdx] = 0.0;
168 values[oilPhaseIdx] = OilWaterMaterialLaw::template twoPhaseSatPcnw<Evaluation, Args...>(params.oilWaterParams(),
Sw);
172 case EclTwoPhaseApproach::GasWater: {
173 const Evaluation&
Sw =
174 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
176 values[waterPhaseIdx] = 0.0;
177 values[gasPhaseIdx] = GasWaterMaterialLaw::template twoPhaseSatPcnw<Evaluation, Args...>(params.gasWaterParams(),
Sw);
191 static void oilWaterHysteresisParams(Scalar& soMax,
194 const Params& params)
196 if constexpr (Traits::enableHysteresis) {
197 soMax = 1.0 - params.oilWaterParams().krnSwMdc();
198 swMax = params.oilWaterParams().krwSwMdc();
199 swMin = params.oilWaterParams().pcSwMdc();
200 Valgrind::CheckDefined(soMax);
201 Valgrind::CheckDefined(swMax);
202 Valgrind::CheckDefined(swMin);
213 static void setOilWaterHysteresisParams(
const Scalar& soMax,
218 if constexpr (Traits::enableHysteresis) {
219 params.oilWaterParams().update(swMin, swMax, 1.0 - soMax);
231 static void gasOilHysteresisParams(Scalar& sgmax,
234 const Params& params)
236 if constexpr (Traits::enableHysteresis) {
237 sgmax = 1.0 - params.gasOilParams().krnSwMdc();
238 shmax = params.gasOilParams().krwSwMdc();
239 somin = params.gasOilParams().pcSwMdc();
240 Valgrind::CheckDefined(sgmax);
241 Valgrind::CheckDefined(shmax);
242 Valgrind::CheckDefined(somin);
252 static void setGasOilHysteresisParams(
const Scalar& sgmax,
257 if constexpr (Traits::enableHysteresis) {
258 params.gasOilParams().update(somin , shmax, 1.0 - sgmax);
262 static Scalar trappedGasSaturation(
const Params& params,
bool maximumTrapping){
263 if(params.approach() == EclTwoPhaseApproach::GasOil)
264 return params.gasOilParams().SnTrapped(maximumTrapping);
265 if(params.approach() == EclTwoPhaseApproach::GasWater)
266 return params.gasWaterParams().SnTrapped(maximumTrapping);
270 static Scalar strandedGasSaturation(
const Params& params, Scalar
Sg, Scalar Kg){
271 if(params.approach() == EclTwoPhaseApproach::GasOil)
272 return params.gasOilParams().SnStranded(
Sg, Kg);
273 if(params.approach() == EclTwoPhaseApproach::GasWater)
274 return params.gasWaterParams().SnStranded(
Sg, Kg);
278 static Scalar trappedOilSaturation(
const Params& params,
bool maximumTrapping){
279 if(params.approach() == EclTwoPhaseApproach::GasOil)
280 return params.gasOilParams().SwTrapped();
281 if(params.approach() == EclTwoPhaseApproach::OilWater)
282 return params.oilWaterParams().SnTrapped(maximumTrapping);
286 static Scalar trappedWaterSaturation(
const Params& params){
287 if(params.approach() == EclTwoPhaseApproach::GasWater)
288 return params.gasWaterParams().SwTrapped();
289 if(params.approach() == EclTwoPhaseApproach::OilWater)
290 return params.oilWaterParams().SwTrapped();
304 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
305 static Evaluation
pcgn(
const Params& ,
308 throw std::logic_error(
"Not implemented: pcgn()");
320 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
321 static Evaluation
pcnw(
const Params& ,
324 throw std::logic_error(
"Not implemented: pcnw()");
330 template <
class ContainerT,
class Flu
idState>
335 throw std::logic_error(
"Not implemented: saturations()");
341 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
342 static Evaluation
Sg(
const Params& ,
345 throw std::logic_error(
"Not implemented: Sg()");
351 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
352 static Evaluation
Sn(
const Params& ,
355 throw std::logic_error(
"Not implemented: Sn()");
361 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
362 static Evaluation
Sw(
const Params& ,
365 throw std::logic_error(
"Not implemented: Sw()");
383 template <
class ContainerT,
class FluidState,
class ...Args>
385 const Params& params,
386 const FluidState& fluidState)
388 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
389 using Evaluation =
typename std::remove_reference<decltype(values[0])>::type;
391 switch (params.approach()) {
392 case EclTwoPhaseApproach::GasOil: {
393 const Evaluation& So =
394 decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
396 values[oilPhaseIdx] = GasOilMaterialLaw::template twoPhaseSatKrw<Evaluation, Args...>(params.gasOilParams(), So);
397 values[gasPhaseIdx] = GasOilMaterialLaw::template twoPhaseSatKrn<Evaluation, Args...>(params.gasOilParams(), So);
401 case EclTwoPhaseApproach::OilWater: {
402 const Evaluation& sw =
403 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
405 values[waterPhaseIdx] = OilWaterMaterialLaw::template twoPhaseSatKrw<Evaluation, Args...>(params.oilWaterParams(), sw);
406 values[oilPhaseIdx] = OilWaterMaterialLaw::template twoPhaseSatKrn<Evaluation, Args...>(params.oilWaterParams(), sw);
410 case EclTwoPhaseApproach::GasWater: {
411 const Evaluation& sw =
412 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
414 values[waterPhaseIdx] = GasWaterMaterialLaw::template twoPhaseSatKrw<Evaluation, Args...>(params.gasWaterParams(), sw);
415 values[gasPhaseIdx] = GasWaterMaterialLaw::template twoPhaseSatKrn<Evaluation, Args...>(params.gasWaterParams(), sw);
425 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
426 static Evaluation
krg(
const Params& ,
429 throw std::logic_error(
"Not implemented: krg()");
435 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
436 static Evaluation
krw(
const Params& ,
439 throw std::logic_error(
"Not implemented: krw()");
445 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
446 static Evaluation
krn(
const Params& ,
449 throw std::logic_error(
"Not implemented: krn()");
460 template <
class Flu
idState>
463 if constexpr (Traits::enableHysteresis) {
464 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
465 switch (params.approach()) {
466 case EclTwoPhaseApproach::GasOil: {
467 Scalar So = scalarValue(fluidState.saturation(oilPhaseIdx));
468 return params.gasOilParams().update(So, So, So);
470 case EclTwoPhaseApproach::OilWater: {
471 Scalar sw = scalarValue(fluidState.saturation(waterPhaseIdx));
472 return params.oilWaterParams().update(sw, sw, sw);
474 case EclTwoPhaseApproach::GasWater: {
475 Scalar sw = scalarValue(fluidState.saturation(waterPhaseIdx));
476 return params.gasWaterParams().update(sw, sw, sw);
static Evaluation krw(const Params &, const FluidState &)
The relative permeability of the wetting phase.
Definition: EclTwoPhaseMaterial.hpp:436
static constexpr bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure...
Definition: EclTwoPhaseMaterial.hpp:105
static constexpr bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition...
Definition: EclTwoPhaseMaterial.hpp:113
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition: EclTwoPhaseMaterial.hpp:362
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclTwoPhaseMaterial.hpp:352
static constexpr bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: EclTwoPhaseMaterial.hpp:97
static Evaluation krn(const Params &, const FluidState &)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition: EclTwoPhaseMaterial.hpp:446
static constexpr bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition: EclTwoPhaseMaterial.hpp:109
static Evaluation krg(const Params &, const FluidState &)
The relative permeability of the gas phase.
Definition: EclTwoPhaseMaterial.hpp:426
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
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:321
static Evaluation pcgn(const Params &, const FluidState &)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclTwoPhaseMaterial.hpp:305
static constexpr bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: EclTwoPhaseMaterial.hpp:101
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclTwoPhaseMaterial.hpp:331
static OPM_HOST_DEVICE 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:146
static OPM_HOST_DEVICE void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclTwoPhaseMaterial.hpp:384
Some templates to wrap the valgrind client request macros.
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclTwoPhaseMaterial.hpp:342
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 bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclTwoPhaseMaterial.hpp:461
static constexpr bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: EclTwoPhaseMaterial.hpp:93