27 #ifndef OPM_ECL_MULTIPLEXER_MATERIAL_HPP 28 #define OPM_ECL_MULTIPLEXER_MATERIAL_HPP 36 #include <opm/common/TimingMacros.hpp> 43 #define OPM_ECL_MULTIPLEXER_MATERIAL_CALL(codeToCall, onePhaseCode) \ 44 switch (params.approach()) { \ 45 case EclMultiplexerApproach::Stone1: { \ 46 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone1; \ 47 auto& realParams = params.template getRealParams<approach>(); \ 48 using ActualLaw = Stone1Material; \ 52 case EclMultiplexerApproach::Stone2: { \ 53 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone2; \ 54 auto& realParams = params.template getRealParams<approach>(); \ 55 using ActualLaw = Stone2Material; \ 59 case EclMultiplexerApproach::Default: { \ 60 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Default; \ 61 auto& realParams = params.template getRealParams<approach>(); \ 62 using ActualLaw = DefaultMaterial; \ 66 case EclMultiplexerApproach::TwoPhase: { \ 67 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::TwoPhase; \ 68 auto& realParams = params.template getRealParams<approach>(); \ 69 using ActualLaw = TwoPhaseMaterial; \ 73 case EclMultiplexerApproach::OnePhase: { \ 74 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::OnePhase; \ 81 #if (defined(__GNUC__) && (__GNUC__ < 13)) || defined(__CUDACC__) 82 #define STATIC_ASSERT_ECL_MULTIPLEXER_UNLESS_GCC_LT_13 throw std::logic_error("Unhandled EclMultiplexerApproach") 84 #define STATIC_ASSERT_ECL_MULTIPLEXER_UNLESS_GCC_LT_13 static_assert(false, "Unhandled EclMultiplexerApproach") 87 #define OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(codeToCall, onePhaseCode) \ 88 if constexpr (Head::approach == EclMultiplexerApproach::Stone1) { \ 89 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone1; \ 90 auto& realParams = params.template getRealParams<approach>(); \ 91 using ActualLaw = Stone1Material; \ 93 } else if constexpr (Head::approach == EclMultiplexerApproach::Stone2) { \ 94 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Stone2; \ 95 auto& realParams = params.template getRealParams<approach>(); \ 96 using ActualLaw = Stone2Material; \ 98 } else if constexpr (Head::approach == EclMultiplexerApproach::Default) { \ 99 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::Default; \ 100 auto& realParams = params.template getRealParams<approach>(); \ 101 using ActualLaw = DefaultMaterial; \ 103 } else if constexpr (Head::approach == EclMultiplexerApproach::TwoPhase) { \ 104 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::TwoPhase; \ 105 auto& realParams = params.template getRealParams<approach>(); \ 106 using ActualLaw = TwoPhaseMaterial; \ 108 } else if constexpr (Head::approach == EclMultiplexerApproach::OnePhase) { \ 109 [[maybe_unused]] constexpr EclMultiplexerApproach approach = EclMultiplexerApproach::OnePhase; \ 112 STATIC_ASSERT_ECL_MULTIPLEXER_UNLESS_GCC_LT_13; \ 116 inline void doNothing() { };
124 template <
class TraitsT,
125 class GasOilMaterialLawT,
126 class OilWaterMaterialLawT,
127 class GasWaterMaterialLawT,
128 class ParamsT = EclMultiplexerMaterialParams<TraitsT,
130 OilWaterMaterialLawT,
131 GasWaterMaterialLawT> >
135 using GasOilMaterialLaw = GasOilMaterialLawT;
136 using OilWaterMaterialLaw = OilWaterMaterialLawT;
137 using GasWaterMaterialLaw = GasWaterMaterialLawT;
145 static_assert(TraitsT::numPhases == 3,
146 "The number of phases considered by this capillary pressure " 147 "law is always three!");
148 static_assert(GasOilMaterialLaw::numPhases == 2,
149 "The number of phases considered by the gas-oil capillary " 150 "pressure law must be two!");
151 static_assert(OilWaterMaterialLaw::numPhases == 2,
152 "The number of phases considered by the oil-water capillary " 153 "pressure law must be two!");
154 static_assert(GasWaterMaterialLaw::numPhases == 2,
155 "The number of phases considered by the gas-water capillary " 156 "pressure law must be two!");
157 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
158 typename OilWaterMaterialLaw::Scalar>::
value,
159 "The two two-phase capillary pressure laws must use the same " 160 "type of floating point values.");
162 using Traits = TraitsT;
163 using Params = ParamsT;
164 using Scalar =
typename Traits::Scalar;
166 static constexpr
int numPhases = 3;
167 static constexpr
int waterPhaseIdx = Traits::wettingPhaseIdx;
168 static constexpr
int oilPhaseIdx = Traits::nonWettingPhaseIdx;
169 static constexpr
int gasPhaseIdx = Traits::gasPhaseIdx;
209 template <
class ContainerT,
class FluidState,
class ...Args>
211 const Params& params,
212 const FluidState& fluidState)
214 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
215 if constexpr (FrontIsEclMultiplexerDispatchV<Args...>) {
216 capillaryPressuresT<ContainerT, FluidState, Args...>(values, params, fluidState);
219 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::capillaryPressures(values, realParams, fluidState),
224 template <
class ContainerT,
class FluidState,
class Head,
class ...Args>
225 static void capillaryPressuresT(ContainerT& values,
226 const Params& params,
227 const FluidState& fluidState)
229 #define OPM_LOCAL_TEMPLATE_ARGS ContainerT, FluidState, Args... 230 OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(
231 ActualLaw::template capillaryPressures<OPM_LOCAL_TEMPLATE_ARGS>(values, realParams, fluidState),
234 #undef OPM_LOCAL_TEMPLATE_ARGS 244 static void oilWaterHysteresisParams(Scalar& soMax,
247 const Params& params)
249 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
250 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::oilWaterHysteresisParams(soMax, swMax, swMin, realParams),
261 static void setOilWaterHysteresisParams(
const Scalar& soMax,
266 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
267 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::setOilWaterHysteresisParams(soMax, swMax, swMin, realParams),
278 static void gasOilHysteresisParams(Scalar& sgmax,
281 const Params& params)
283 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
284 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::gasOilHysteresisParams(sgmax, shmax, somin, realParams),
288 static Scalar trappedGasSaturation(
const Params& params,
bool maximumTrapping)
290 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
291 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::trappedGasSaturation(realParams, maximumTrapping),
296 static Scalar strandedGasSaturation(
const Params& params, Scalar
Sg, Scalar Kg)
298 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
299 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::strandedGasSaturation(realParams,
Sg, Kg),
304 static Scalar trappedOilSaturation(
const Params& params,
bool maximumTrapping)
306 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
307 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::trappedOilSaturation(realParams, maximumTrapping),
312 static Scalar trappedWaterSaturation(
const Params& params)
314 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
315 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(
return ActualLaw::trappedWaterSaturation(realParams),
326 static void setGasOilHysteresisParams(
const Scalar& sgmax,
331 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
332 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::setGasOilHysteresisParams(sgmax, shmax, somin, realParams),
345 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
346 static Evaluation
pcgn(
const Params& ,
349 throw std::logic_error(
"Not implemented: pcgn()");
361 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
362 static Evaluation
pcnw(
const Params& ,
365 throw std::logic_error(
"Not implemented: pcnw()");
371 template <
class ContainerT,
class Flu
idState>
376 throw std::logic_error(
"Not implemented: saturations()");
382 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
383 static Evaluation
Sg(
const Params& ,
386 throw std::logic_error(
"Not implemented: Sg()");
392 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
393 static Evaluation
Sn(
const Params& ,
396 throw std::logic_error(
"Not implemented: Sn()");
402 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
403 static Evaluation
Sw(
const Params& ,
406 throw std::logic_error(
"Not implemented: Sw()");
424 template <
class ContainerT,
class FluidState,
class ...Args>
426 const Params& params,
427 const FluidState& fluidState)
429 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
430 if constexpr (FrontIsEclMultiplexerDispatchV<Args...>) {
431 relativePermeabilitiesT<ContainerT, FluidState, Args...>(values, params, fluidState);
434 OPM_ECL_MULTIPLEXER_MATERIAL_CALL(ActualLaw::relativePermeabilities(values, realParams, fluidState),
438 template <
class ContainerT,
class FluidState,
class Head,
class ...Args>
439 static void relativePermeabilitiesT(ContainerT& values,
440 const Params& params,
441 const FluidState& fluidState)
443 #define OPM_LOCAL_TEMPLATE_ARGS ContainerT, FluidState, Args... 444 OPM_ECL_MULTIPLEXER_MATERIAL_CALL_COMPILETIME(
445 ActualLaw::template relativePermeabilities<OPM_LOCAL_TEMPLATE_ARGS>(values, realParams, fluidState),
448 #undef OPM_LOCAL_TEMPLATE_ARGS 457 template <
class Evaluation,
class Flu
idState>
459 const FluidState& fluidState)
461 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
462 switch (params.approach()) {
463 case EclMultiplexerApproach::Stone1:
464 return Stone1Material::template relpermOilInOilGasSystem<Evaluation>
465 (params.template getRealParams<EclMultiplexerApproach::Stone1>(),
468 case EclMultiplexerApproach::Stone2:
469 return Stone2Material::template relpermOilInOilGasSystem<Evaluation>
470 (params.template getRealParams<EclMultiplexerApproach::Stone2>(),
473 case EclMultiplexerApproach::Default:
474 return DefaultMaterial::template relpermOilInOilGasSystem<Evaluation>
475 (params.template getRealParams<EclMultiplexerApproach::Default>(),
479 throw std::logic_error {
480 "relpermOilInOilGasSystem() is specific to three phases" 488 template <
class Evaluation,
class Flu
idState>
490 const FluidState& fluidState)
492 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
493 switch (params.approach()) {
494 case EclMultiplexerApproach::Stone1:
495 return Stone1Material::template relpermOilInOilWaterSystem<Evaluation>
496 (params.template getRealParams<EclMultiplexerApproach::Stone1>(),
499 case EclMultiplexerApproach::Stone2:
500 return Stone2Material::template relpermOilInOilWaterSystem<Evaluation>
501 (params.template getRealParams<EclMultiplexerApproach::Stone2>(),
504 case EclMultiplexerApproach::Default:
505 return DefaultMaterial::template relpermOilInOilWaterSystem<Evaluation>
506 (params.template getRealParams<EclMultiplexerApproach::Default>(),
510 throw std::logic_error {
511 "relpermOilInOilWaterSystem() is specific to three phases" 519 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
520 static Evaluation
krg(
const Params& ,
523 throw std::logic_error(
"Not implemented: krg()");
529 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
530 static Evaluation
krw(
const Params& ,
533 throw std::logic_error(
"Not implemented: krw()");
539 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::ValueType>
540 static Evaluation
krn(
const Params& ,
543 throw std::logic_error(
"Not implemented: krn()");
554 template <
class Flu
idState>
557 OPM_TIMEFUNCTION_LOCAL(Subsystem::SatProps);
558 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:540
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
static Evaluation pcgn(const Params &, const FluidState &)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclMultiplexerMaterial.hpp:346
static bool updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclMultiplexerMaterial.hpp:555
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:193
static Evaluation relpermOilInOilGasSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/gas system.
Definition: EclMultiplexerMaterial.hpp:458
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:185
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: EclMultiplexerMaterial.hpp:210
static constexpr bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: EclMultiplexerMaterial.hpp:173
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:189
Implements a multiplexer class that provides all three phase capillary pressure laws used by the ECLi...
Definition: EclMultiplexerMaterial.hpp:132
static Evaluation krw(const Params &, const FluidState &)
The relative permeability of the wetting phase.
Definition: EclMultiplexerMaterial.hpp:530
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:403
static Evaluation krg(const Params &, const FluidState &)
The relative permeability of the gas phase.
Definition: EclMultiplexerMaterial.hpp:520
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclMultiplexerMaterial.hpp:383
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclMultiplexerMaterial.hpp:372
static constexpr bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: EclMultiplexerMaterial.hpp:177
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:362
static constexpr bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: EclMultiplexerMaterial.hpp:181
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclMultiplexerMaterial.hpp:425
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclDefaultMaterial.hpp:61
static Evaluation relpermOilInOilWaterSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/water system.
Definition: EclMultiplexerMaterial.hpp:489
Implements a multiplexer class that provides ECL saturation functions for twophase simulations...
Definition: EclTwoPhaseMaterial.hpp:56
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclMultiplexerMaterial.hpp:393
Implements the default three phase capillary pressure law used by the ECLipse simulator.