27 #ifndef OPM_ECL_MULTIPLEXER_MATERIAL_HPP 28 #define OPM_ECL_MULTIPLEXER_MATERIAL_HPP 36 #include <opm/common/TimingMacros.hpp> 37 #include <opm/common/ErrorMacros.hpp> 39 #include <opm/common/utility/gpuDecorators.hpp> 45 #if OPM_IS_INSIDE_DEVICE_FUNCTION 46 #define OPM_ECL_MULTIPLEXER_MATERIAL_CALL(codeToCall, onePhaseCode) \ 48 constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Default; \ 49 auto& realParams = params.template getRealParams<approach>(); \ 50 using ActualLaw = DefaultMaterial; \ 54 #define OPM_ECL_MULTIPLEXER_MATERIAL_CALL(codeToCall, onePhaseCode) \ 55 switch (params.approach()) { \ 56 case EclMultiplexerApproach::Stone1: { \ 57 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone1; \ 58 auto& realParams = params.template getRealParams<approach>(); \ 59 using ActualLaw = Stone1Material; \ 63 case EclMultiplexerApproach::Stone2: { \ 64 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone2; \ 65 auto& realParams = params.template getRealParams<approach>(); \ 66 using ActualLaw = Stone2Material; \ 70 case EclMultiplexerApproach::Default: { \ 71 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Default; \ 72 auto& realParams = params.template getRealParams<approach>(); \ 73 using ActualLaw = DefaultMaterial; \ 77 case EclMultiplexerApproach::TwoPhase: { \ 78 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::TwoPhase; \ 79 auto& realParams = params.template getRealParams<approach>(); \ 80 using ActualLaw = TwoPhaseMaterial; \ 84 case EclMultiplexerApproach::OnePhase: { \ 85 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::OnePhase; \ 93 #if (defined(__GNUC__) && (__GNUC__ < 13)) || defined(__CUDACC__) 94 #define STATIC_ASSERT_ECL_MULTIPLEXER_UNLESS_GCC_LT_13 throw std::logic_error("Unhandled EclMultiplexerApproach") 96 #define STATIC_ASSERT_ECL_MULTIPLEXER_UNLESS_GCC_LT_13 static_assert(false, "Unhandled EclMultiplexerApproach") 99 #if OPM_IS_INSIDE_DEVICE_FUNCTION 100 #define OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(codeToCall, onePhaseCode) \ 101 if constexpr (Head::approach == EclMultiplexerApproach::Default) { \ 102 constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Default; \ 103 auto& realParams = params.template getRealParams<approach>(); \ 104 using ActualLaw = DefaultMaterial; \ 109 #define OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(codeToCall, onePhaseCode) \ 110 if constexpr (Head::approach == EclMultiplexerApproach::Stone1) { \ 111 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone1; \ 112 auto& realParams = params.template getRealParams<approach>(); \ 113 using ActualLaw = Stone1Material; \ 115 } else if constexpr (Head::approach == EclMultiplexerApproach::Stone2) { \ 116 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone2; \ 117 auto& realParams = params.template getRealParams<approach>(); \ 118 using ActualLaw = Stone2Material; \ 120 } else if constexpr (Head::approach == EclMultiplexerApproach::Default) { \ 121 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Default; \ 122 auto& realParams = params.template getRealParams<approach>(); \ 123 using ActualLaw = DefaultMaterial; \ 125 } else if constexpr (Head::approach == EclMultiplexerApproach::TwoPhase) { \ 126 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::TwoPhase; \ 127 auto& realParams = params.template getRealParams<approach>(); \ 128 using ActualLaw = TwoPhaseMaterial; \ 130 } else if constexpr (Head::approach == EclMultiplexerApproach::OnePhase) { \ 131 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::OnePhase; \ 134 STATIC_ASSERT_ECL_MULTIPLEXER_UNLESS_GCC_LT_13; \ 138 inline void doNothing() { };
146 template <
class TraitsT,
147 class GasOilMaterialLawT,
148 class OilWaterMaterialLawT,
149 class GasWaterMaterialLawT,
150 class ParamsT = EclMultiplexerMaterialParams<TraitsT,
152 OilWaterMaterialLawT,
153 GasWaterMaterialLawT> >
157 using GasOilMaterialLaw = GasOilMaterialLawT;
158 using OilWaterMaterialLaw = OilWaterMaterialLawT;
159 using GasWaterMaterialLaw = GasWaterMaterialLawT;
167 static_assert(TraitsT::numPhases == 3,
168 "The number of phases considered by this capillary pressure " 169 "law is always three!");
170 static_assert(GasOilMaterialLaw::numPhases == 2,
171 "The number of phases considered by the gas-oil capillary " 172 "pressure law must be two!");
173 static_assert(OilWaterMaterialLaw::numPhases == 2,
174 "The number of phases considered by the oil-water capillary " 175 "pressure law must be two!");
176 static_assert(GasWaterMaterialLaw::numPhases == 2,
177 "The number of phases considered by the gas-water capillary " 178 "pressure law must be two!");
179 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
180 typename OilWaterMaterialLaw::Scalar>::
value,
181 "The two two-phase capillary pressure laws must use the same " 182 "type of floating point values.");
184 using Traits = TraitsT;
185 using Params = ParamsT;
186 using Scalar =
typename Traits::Scalar;
188 static constexpr
int numPhases = 3;
189 static constexpr
int waterPhaseIdx = Traits::wettingPhaseIdx;
190 static constexpr
int oilPhaseIdx = Traits::nonWettingPhaseIdx;
191 static constexpr
int gasPhaseIdx = Traits::gasPhaseIdx;
231 template <
class ContainerT,
class FluidState,
class ...Args>
233 const Params& params,
234 const FluidState& fluidState)
236 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
237 if constexpr (FrontIsEclMultiplexerDispatchV<Args...>) {
238 capillaryPressuresT<ContainerT, FluidState, Args...>(values, params, fluidState);
241 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::capillaryPressures(values, realParams, fluidState),
246 template <
class ContainerT,
class FluidState,
class Head,
class ...Args>
247 static void capillaryPressuresT(ContainerT& values,
248 const Params& params,
249 const FluidState& fluidState)
251 #define OPM_LOCAL_TEMPLATE_ARGS ContainerT, FluidState, Args... 252 OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(
253 ActualLaw::template capillaryPressures<OPM_LOCAL_TEMPLATE_ARGS>(values, realParams, fluidState),
256 #undef OPM_LOCAL_TEMPLATE_ARGS 266 static void oilWaterHysteresisParams(Scalar& soMax,
269 const Params& params)
271 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
272 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::oilWaterHysteresisParams(soMax, swMax, swMin, realParams),
283 static void setOilWaterHysteresisParams(
const Scalar& soMax,
288 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
289 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::setOilWaterHysteresisParams(soMax, swMax, swMin, realParams),
300 static void gasOilHysteresisParams(Scalar& sgmax,
303 const Params& params)
305 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
306 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::gasOilHysteresisParams(sgmax, shmax, somin, realParams),
310 static Scalar trappedGasSaturation(
const Params& params,
bool maximumTrapping)
312 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
313 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::trappedGasSaturation(realParams, maximumTrapping),
318 static Scalar strandedGasSaturation(
const Params& params, Scalar
Sg, Scalar Kg)
320 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
321 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::strandedGasSaturation(realParams,
Sg, Kg),
326 static Scalar trappedOilSaturation(
const Params& params,
bool maximumTrapping)
328 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
329 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::trappedOilSaturation(realParams, maximumTrapping),
334 static Scalar trappedWaterSaturation(
const Params& params)
336 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
337 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::trappedWaterSaturation(realParams),
348 static void setGasOilHysteresisParams(
const Scalar& sgmax,
353 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
354 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::setGasOilHysteresisParams(sgmax, shmax, somin, realParams),
367 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
368 static Evaluation
pcgn(
const Params& ,
371 throw std::logic_error(
"Not implemented: pcgn()");
383 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
384 static Evaluation
pcnw(
const Params& ,
387 throw std::logic_error(
"Not implemented: pcnw()");
393 template <
class ContainerT,
class Flu
idState>
398 throw std::logic_error(
"Not implemented: saturations()");
404 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
405 static Evaluation
Sg(
const Params& ,
408 throw std::logic_error(
"Not implemented: Sg()");
414 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
415 static Evaluation
Sn(
const Params& ,
418 throw std::logic_error(
"Not implemented: Sn()");
424 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
425 static Evaluation
Sw(
const Params& ,
428 throw std::logic_error(
"Not implemented: Sw()");
446 template <
class ContainerT,
class FluidState,
class ...Args>
448 const Params& params,
449 const FluidState& fluidState)
451 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
452 if constexpr (FrontIsEclMultiplexerDispatchV<Args...>) {
453 relativePermeabilitiesT<ContainerT, FluidState, Args...>(values, params, fluidState);
456 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::relativePermeabilities(values, realParams, fluidState),
460 template <
class ContainerT,
class FluidState,
class Head,
class ...Args>
461 static void relativePermeabilitiesT(ContainerT& values,
462 const Params& params,
463 const FluidState& fluidState)
465 #define OPM_LOCAL_TEMPLATE_ARGS ContainerT, FluidState, Args... 466 OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(
467 ActualLaw::template relativePermeabilities<OPM_LOCAL_TEMPLATE_ARGS>(values, realParams, fluidState),
470 #undef OPM_LOCAL_TEMPLATE_ARGS 479 template <
class Evaluation,
class Flu
idState>
481 const FluidState& fluidState)
483 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
484 switch (params.approach()) {
485 case EclMultiplexerApproach::Stone1:
486 return Stone1Material::template relpermOilInOilGasSystem<Evaluation>
487 (params.template getRealParams<EclMultiplexerApproach::Stone1>(),
490 case EclMultiplexerApproach::Stone2:
491 return Stone2Material::template relpermOilInOilGasSystem<Evaluation>
492 (params.template getRealParams<EclMultiplexerApproach::Stone2>(),
495 case EclMultiplexerApproach::Default:
496 return DefaultMaterial::template relpermOilInOilGasSystem<Evaluation>
497 (params.template getRealParams<EclMultiplexerApproach::Default>(),
501 throw std::logic_error {
502 "relpermOilInOilGasSystem() is specific to three phases" 510 template <
class Evaluation,
class Flu
idState>
512 const FluidState& fluidState)
514 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
515 switch (params.approach()) {
516 case EclMultiplexerApproach::Stone1:
517 return Stone1Material::template relpermOilInOilWaterSystem<Evaluation>
518 (params.template getRealParams<EclMultiplexerApproach::Stone1>(),
521 case EclMultiplexerApproach::Stone2:
522 return Stone2Material::template relpermOilInOilWaterSystem<Evaluation>
523 (params.template getRealParams<EclMultiplexerApproach::Stone2>(),
526 case EclMultiplexerApproach::Default:
527 return DefaultMaterial::template relpermOilInOilWaterSystem<Evaluation>
528 (params.template getRealParams<EclMultiplexerApproach::Default>(),
532 throw std::logic_error {
533 "relpermOilInOilWaterSystem() is specific to three phases" 541 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
542 static Evaluation
krg(
const Params& ,
545 throw std::logic_error(
"Not implemented: krg()");
551 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
552 static Evaluation
krw(
const Params& ,
555 throw std::logic_error(
"Not implemented: krw()");
561 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
562 static Evaluation
krn(
const Params& ,
565 throw std::logic_error(
"Not implemented: krn()");
576 template <
class Flu
idState>
579 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
580 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::updateHysteresis(realParams, fluidState),
static Evaluation krn(const Params &, const FluidState &)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition: EclMultiplexerMaterial.hpp:562
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
static OPM_HOST_DEVICE void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclMultiplexerMaterial.hpp:447
static Evaluation pcgn(const Params &, const FluidState &)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclMultiplexerMaterial.hpp:368
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: EclMultiplexerMaterial.hpp:232
static bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclMultiplexerMaterial.hpp:577
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
static constexpr bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition...
Definition: EclMultiplexerMaterial.hpp:215
static Evaluation relpermOilInOilGasSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/gas system.
Definition: EclMultiplexerMaterial.hpp:480
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static constexpr bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure...
Definition: EclMultiplexerMaterial.hpp:207
static constexpr bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: EclMultiplexerMaterial.hpp:195
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone2Material.hpp:60
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone1Material.hpp:60
static constexpr bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition: EclMultiplexerMaterial.hpp:211
Implements a multiplexer class that provides all three phase capillary pressure laws used by the ECLi...
Definition: EclMultiplexerMaterial.hpp:154
static Evaluation krw(const Params &, const FluidState &)
The relative permeability of the wetting phase.
Definition: EclMultiplexerMaterial.hpp:552
Multiplexer implementation for the parameters required by the multiplexed three-phase material law...
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition: EclMultiplexerMaterial.hpp:425
static Evaluation krg(const Params &, const FluidState &)
The relative permeability of the gas phase.
Definition: EclMultiplexerMaterial.hpp:542
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclMultiplexerMaterial.hpp:405
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclMultiplexerMaterial.hpp:394
static constexpr bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: EclMultiplexerMaterial.hpp:199
static Evaluation pcnw(const Params &, const FluidState &)
Capillary pressure between the non-wetting liquid (i.e., oil) and the wetting liquid (i...
Definition: EclMultiplexerMaterial.hpp:384
static constexpr bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: EclMultiplexerMaterial.hpp:203
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclDefaultMaterial.hpp:62
static Evaluation relpermOilInOilWaterSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/water system.
Definition: EclMultiplexerMaterial.hpp:511
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclTwoPhaseMaterial.hpp:57
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclMultiplexerMaterial.hpp:415
Implements the default three phase capillary pressure law used by the ECLipse simulator.