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,
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 FluidState,
class ...Args>
146 const Params& params,
147 const FluidState& fluidState)
149 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
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::template twoPhaseSatPcnw<Evaluation, Args...>(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::template twoPhaseSatPcnw<Evaluation, Args...>(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::template twoPhaseSatPcnw<Evaluation, Args...>(params.
gasWaterParams(),
Sw);
190 static void oilWaterHysteresisParams(Scalar& soMax,
193 const Params& params)
195 if constexpr (Traits::enableHysteresis) {
196 soMax = 1.0 - params.oilWaterParams().krnSwMdc();
197 swMax = params.oilWaterParams().krwSwMdc();
198 swMin = params.oilWaterParams().pcSwMdc();
212 static void setOilWaterHysteresisParams(
const Scalar& soMax,
217 if constexpr (Traits::enableHysteresis) {
218 params.oilWaterParams().update(swMin, swMax, 1.0 - soMax);
230 static void gasOilHysteresisParams(Scalar& sgmax,
233 const Params& params)
235 if constexpr (Traits::enableHysteresis) {
236 sgmax = 1.0 - params.gasOilParams().krnSwMdc();
237 shmax = params.gasOilParams().krwSwMdc();
238 somin = params.gasOilParams().pcSwMdc();
239 Valgrind::CheckDefined(sgmax);
240 Valgrind::CheckDefined(shmax);
241 Valgrind::CheckDefined(somin);
251 static void setGasOilHysteresisParams(
const Scalar& sgmax,
256 if constexpr (Traits::enableHysteresis) {
257 params.gasOilParams().update(somin , shmax, 1.0 - sgmax);
261 static Scalar trappedGasSaturation(
const Params& params,
bool maximumTrapping){
262 if(params.approach() == EclTwoPhaseApproach::GasOil)
263 return params.gasOilParams().SnTrapped(maximumTrapping);
264 if(params.approach() == EclTwoPhaseApproach::GasWater)
265 return params.gasWaterParams().SnTrapped(maximumTrapping);
269 static Scalar strandedGasSaturation(
const Params& params, Scalar
Sg, Scalar Kg){
270 if(params.approach() == EclTwoPhaseApproach::GasOil)
271 return params.gasOilParams().SnStranded(
Sg, Kg);
272 if(params.approach() == EclTwoPhaseApproach::GasWater)
273 return params.gasWaterParams().SnStranded(
Sg, Kg);
277 static Scalar trappedOilSaturation(
const Params& params,
bool maximumTrapping){
278 if(params.approach() == EclTwoPhaseApproach::GasOil)
279 return params.gasOilParams().SwTrapped();
280 if(params.approach() == EclTwoPhaseApproach::OilWater)
281 return params.oilWaterParams().SnTrapped(maximumTrapping);
285 static Scalar trappedWaterSaturation(
const Params& params){
286 if(params.approach() == EclTwoPhaseApproach::GasWater)
287 return params.gasWaterParams().SwTrapped();
288 if(params.approach() == EclTwoPhaseApproach::OilWater)
289 return params.oilWaterParams().SwTrapped();
303 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
304 static Evaluation
pcgn(
const Params& ,
307 throw std::logic_error(
"Not implemented: pcgn()");
319 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
320 static Evaluation
pcnw(
const Params& ,
323 throw std::logic_error(
"Not implemented: pcnw()");
329 template <
class ContainerT,
class Flu
idState>
334 throw std::logic_error(
"Not implemented: saturations()");
340 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
341 static Evaluation
Sg(
const Params& ,
344 throw std::logic_error(
"Not implemented: Sg()");
350 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
351 static Evaluation
Sn(
const Params& ,
354 throw std::logic_error(
"Not implemented: Sn()");
360 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
361 static Evaluation
Sw(
const Params& ,
364 throw std::logic_error(
"Not implemented: Sw()");
382 template <
class ContainerT,
class FluidState,
class ...Args>
384 const Params& params,
385 const FluidState& fluidState)
387 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
388 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
390 switch (params.approach()) {
391 case EclTwoPhaseApproach::GasOil: {
392 const Evaluation& So =
393 decay<Evaluation>(fluidState.saturation(oilPhaseIdx));
395 values[oilPhaseIdx] = GasOilMaterialLaw::template twoPhaseSatKrw<Evaluation, Args...>(params.
gasOilParams(), So);
396 values[gasPhaseIdx] = GasOilMaterialLaw::template twoPhaseSatKrn<Evaluation, Args...>(params.
gasOilParams(), So);
400 case EclTwoPhaseApproach::OilWater: {
401 const Evaluation& sw =
402 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
404 values[waterPhaseIdx] = OilWaterMaterialLaw::template twoPhaseSatKrw<Evaluation, Args...>(params.
oilWaterParams(), sw);
405 values[oilPhaseIdx] = OilWaterMaterialLaw::template twoPhaseSatKrn<Evaluation, Args...>(params.
oilWaterParams(), sw);
409 case EclTwoPhaseApproach::GasWater: {
410 const Evaluation& sw =
411 decay<Evaluation>(fluidState.saturation(waterPhaseIdx));
413 values[waterPhaseIdx] = GasWaterMaterialLaw::template twoPhaseSatKrw<Evaluation, Args...>(params.
gasWaterParams(), sw);
414 values[gasPhaseIdx] = GasWaterMaterialLaw::template twoPhaseSatKrn<Evaluation, Args...>(params.
gasWaterParams(), sw);
424 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
425 static Evaluation
krg(
const Params& ,
428 throw std::logic_error(
"Not implemented: krg()");
434 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
435 static Evaluation
krw(
const Params& ,
438 throw std::logic_error(
"Not implemented: krw()");
444 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
445 static Evaluation
krn(
const Params& ,
448 throw std::logic_error(
"Not implemented: krn()");
459 template <
class Flu
idState>
462 if constexpr (Traits::enableHysteresis) {
463 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
464 switch (params.approach()) {
465 case EclTwoPhaseApproach::GasOil: {
466 Scalar So = scalarValue(fluidState.saturation(oilPhaseIdx));
469 case EclTwoPhaseApproach::OilWater: {
470 Scalar sw = scalarValue(fluidState.saturation(waterPhaseIdx));
473 case EclTwoPhaseApproach::GasWater: {
474 Scalar sw = scalarValue(fluidState.saturation(waterPhaseIdx));
Implementation for the parameters required by the material law for two-phase simulations.
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
Implementation for the parameters required by the material law for two-phase simulations.
Definition EclTwoPhaseMaterialParams.hpp:51
const GasWaterParams & gasWaterParams() const
The parameter object for the gas-water twophase law.
Definition EclTwoPhaseMaterialParams.hpp:113
const GasOilParams & gasOilParams() const
The parameter object for the gas-oil twophase law.
Definition EclTwoPhaseMaterialParams.hpp:77
const OilWaterParams & oilWaterParams() const
The parameter object for the oil-water twophase law.
Definition EclTwoPhaseMaterialParams.hpp:95
Implements a multiplexer class that provides ECL saturation functions for twophase simulations.
Definition EclTwoPhaseMaterial.hpp:57
static constexpr bool isTemperatureDependent
Definition EclTwoPhaseMaterial.hpp:108
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 implementsTwoPhaseApi
Definition EclTwoPhaseMaterial.hpp:92
static Evaluation Sw(const Params &, const FluidState &)
Definition EclTwoPhaseMaterial.hpp:361
static Evaluation pcgn(const Params &, const FluidState &)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition EclTwoPhaseMaterial.hpp:304
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition EclTwoPhaseMaterial.hpp:330
static Evaluation krn(const Params &, const FluidState &)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition EclTwoPhaseMaterial.hpp:445
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition EclTwoPhaseMaterial.hpp:351
static constexpr bool isSaturationDependent
Definition EclTwoPhaseMaterial.hpp:100
static constexpr bool isPressureDependent
Definition EclTwoPhaseMaterial.hpp:104
static Evaluation krg(const Params &, const FluidState &)
The relative permeability of the gas phase.
Definition EclTwoPhaseMaterial.hpp:425
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition EclTwoPhaseMaterial.hpp:341
static bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition EclTwoPhaseMaterial.hpp:460
static constexpr bool isCompositionDependent
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:320
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition EclTwoPhaseMaterial.hpp:383
static Evaluation krw(const Params &, const FluidState &)
The relative permeability of the wetting phase.
Definition EclTwoPhaseMaterial.hpp:435
static constexpr bool implementsTwoPhaseSatApi
Definition EclTwoPhaseMaterial.hpp:96
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30