27#ifndef OPM_ECL_STONE2_MATERIAL_HPP
28#define OPM_ECL_STONE2_MATERIAL_HPP
54template <
class TraitsT,
55 class GasOilMaterialLawT,
56 class OilWaterMaterialLawT,
57 class ParamsT = EclStone2MaterialParams<TraitsT,
58 typename GasOilMaterialLawT::Params,
59 typename OilWaterMaterialLawT::Params> >
67 static_assert(TraitsT::numPhases == 3,
68 "The number of phases considered by this capillary pressure "
69 "law is always three!");
70 static_assert(GasOilMaterialLaw::numPhases == 2,
71 "The number of phases considered by the gas-oil capillary "
72 "pressure law must be two!");
73 static_assert(OilWaterMaterialLaw::numPhases == 2,
74 "The number of phases considered by the oil-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 static_assert(GasOilMaterialLaw::implementsTwoPhaseSatApi,
82 "The gas-oil material law must implement the two-phase saturation "
83 "only API to for the default Ecl capillary pressure law!");
84 static_assert(OilWaterMaterialLaw::implementsTwoPhaseSatApi,
85 "The oil-water material law must implement the two-phase saturation "
86 "only API to for the default Ecl capillary pressure law!");
90 using Scalar =
typename Traits::Scalar;
94 static constexpr int oilPhaseIdx = Traits::nonWettingPhaseIdx;
135 template <
class ContainerT,
class Flu
idState>
138 const FluidState& state)
140 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
141 values[
gasPhaseIdx] = pcgn<FluidState, Evaluation>(params, state);
143 values[
waterPhaseIdx] = - pcnw<FluidState, Evaluation>(params, state);
159 pcSwMdc = params.oilWaterParams().pcSwMdc();
160 krnSwMdc = params.oilWaterParams().krnSwMdc();
176 constexpr const double krwSw = 2.0;
177 params.oilWaterParams().update(pcSwMdc, krwSw, krnSwMdc);
190 const auto Swco = params.Swl();
194 pcSwMdc =
std::min(params.gasOilParams().pcSwMdc() + Swco,
Scalar{2.0});
195 krnSwMdc =
std::min(params.gasOilParams().krnSwMdc() + Swco,
Scalar{2.0});
212 const auto Swco = params.Swl();
213 constexpr const double krwSw = 2.0;
214 params.gasOilParams().update(pcSwMdc - Swco, krwSw, krnSwMdc - Swco);
226 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
228 const FluidState& fs)
231 const auto Sw = 1.0 - params.Swl() - decay<Evaluation>(fs.saturation(
gasPhaseIdx));
232 return GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(),
Sw);
244 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
246 const FluidState& fs)
251 const auto result = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(),
Sw);
260 template <
class ContainerT,
class Flu
idState>
265 throw std::logic_error(
"Not implemented: saturations()");
271 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
275 throw std::logic_error(
"Not implemented: Sg()");
281 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
285 throw std::logic_error(
"Not implemented: Sn()");
291 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
295 throw std::logic_error(
"Not implemented: Sw()");
313 template <
class ContainerT,
class Flu
idState>
316 const FluidState& fluidState)
318 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
320 values[
waterPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
321 values[
oilPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
322 values[
gasPhaseIdx] = krg<FluidState, Evaluation>(params, fluidState);
328 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
330 const FluidState& fluidState)
333 const Evaluation
Sw = 1 - params.Swl() - decay<Evaluation>(fluidState.saturation(
gasPhaseIdx));
334 return GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(),
Sw);
340 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
342 const FluidState& fluidState)
344 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(
waterPhaseIdx));
345 return OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
351 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
353 const FluidState& fluidState)
355 const Scalar Swco = params.Swl();
357 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(
waterPhaseIdx));
358 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(
gasPhaseIdx));
360 const Scalar krocw = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), Swco);
361 const Evaluation krow = relpermOilInOilWaterSystem<Evaluation>(params, fluidState);
362 const Evaluation
krw = OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
363 const Evaluation
krg = GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), 1 - Swco -
Sg);
364 const Evaluation krog = relpermOilInOilGasSystem<Evaluation>(params, fluidState);
366 return max(krocw * ((krow/krocw +
krw) * (krog/krocw +
krg) -
krw -
krg), Evaluation{0});
373 template <
class Evaluation,
class Flu
idState>
375 const FluidState& fluidState)
377 const Scalar Swco = params.Swl();
378 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(
gasPhaseIdx));
380 return GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), 1 - Swco -
Sg);
387 template <
class Evaluation,
class Flu
idState>
389 const FluidState& fluidState)
391 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(
waterPhaseIdx));
393 return OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(),
Sw);
403 template <
class Flu
idState>
406 const Scalar Swco = params.Swl();
410 params.oilWaterParams().update(
Sw,
Sw,
Sw);
411 params.gasOilParams().update( 1.0 - Swco -
Sg,
Some templates to wrap the valgrind client request macros.
Implements the second phase capillary pressure/relperm law suggested by Stone as used by the ECLipse ...
Definition: EclStone2Material.hpp:61
static constexpr bool isPressureDependent
Definition: EclStone2Material.hpp:111
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition: EclStone2Material.hpp:292
TraitsT Traits
Definition: EclStone2Material.hpp:88
static Evaluation pcgn(const Params ¶ms, const FluidState &fs)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclStone2Material.hpp:227
static Evaluation pcnw(const Params ¶ms, const FluidState &fs)
Capillary pressure between the non-wetting liquid (i.e., oil) and the wetting liquid (i....
Definition: EclStone2Material.hpp:245
static void updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclStone2Material.hpp:404
static void capillaryPressures(ContainerT &values, const Params ¶ms, const FluidState &state)
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclStone2Material.hpp:136
static void setOilWaterHysteresisParams(const Scalar &pcSwMdc, const Scalar &krnSwMdc, Params ¶ms)
Definition: EclStone2Material.hpp:172
static Evaluation relpermOilInOilWaterSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/water system.
Definition: EclStone2Material.hpp:388
static constexpr bool implementsTwoPhaseSatApi
Definition: EclStone2Material.hpp:103
static constexpr bool isTemperatureDependent
Definition: EclStone2Material.hpp:115
GasOilMaterialLawT GasOilMaterialLaw
Definition: EclStone2Material.hpp:63
typename Traits::Scalar Scalar
Definition: EclStone2Material.hpp:90
static void setGasOilHysteresisParams(const Scalar &pcSwMdc, const Scalar &krnSwMdc, Params ¶ms)
Definition: EclStone2Material.hpp:207
static constexpr bool isCompositionDependent
Definition: EclStone2Material.hpp:119
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclStone2Material.hpp:272
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclStone2Material.hpp:261
static constexpr bool implementsTwoPhaseApi
Definition: EclStone2Material.hpp:99
static Evaluation relpermOilInOilGasSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/gas system.
Definition: EclStone2Material.hpp:374
static constexpr int waterPhaseIdx
Definition: EclStone2Material.hpp:93
static constexpr int oilPhaseIdx
Definition: EclStone2Material.hpp:94
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclStone2Material.hpp:282
static Evaluation krn(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition: EclStone2Material.hpp:352
OilWaterMaterialLawT OilWaterMaterialLaw
Definition: EclStone2Material.hpp:64
static void oilWaterHysteresisParams(Scalar &pcSwMdc, Scalar &krnSwMdc, const Params ¶ms)
Definition: EclStone2Material.hpp:155
ParamsT Params
Definition: EclStone2Material.hpp:89
static void gasOilHysteresisParams(Scalar &pcSwMdc, Scalar &krnSwMdc, const Params ¶ms)
Definition: EclStone2Material.hpp:186
static constexpr int gasPhaseIdx
Definition: EclStone2Material.hpp:95
static constexpr bool isSaturationDependent
Definition: EclStone2Material.hpp:107
static Evaluation krw(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the wetting phase.
Definition: EclStone2Material.hpp:341
static Evaluation krg(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the gas phase.
Definition: EclStone2Material.hpp:329
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclStone2Material.hpp:314
static constexpr int numPhases
Definition: EclStone2Material.hpp:92
bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
Definition: Air_Mesitylene.hpp:34
ReturnEval_< Evaluation1, Evaluation2 >::type min(const Evaluation1 &arg1, const Evaluation2 &arg2)
Definition: MathToolbox.hpp:346
ReturnEval_< Evaluation1, Evaluation2 >::type max(const Evaluation1 &arg1, const Evaluation2 &arg2)
Definition: MathToolbox.hpp:341
auto scalarValue(const Evaluation &val) -> decltype(MathToolbox< Evaluation >::scalarValue(val))
Definition: MathToolbox.hpp:335