27#ifndef OPM_ECL_STONE1_MATERIAL_HPP
28#define OPM_ECL_STONE1_MATERIAL_HPP
55template <
class TraitsT,
56 class GasOilMaterialLawT,
57 class OilWaterMaterialLawT,
58 class ParamsT = EclStone1MaterialParams<TraitsT, GasOilMaterialLawT, OilWaterMaterialLawT> >
66 static_assert(TraitsT::numPhases == 3,
67 "The number of phases considered by this capillary pressure "
68 "law is always three!");
69 static_assert(GasOilMaterialLaw::numPhases == 2,
70 "The number of phases considered by the gas-oil capillary "
71 "pressure law must be two!");
72 static_assert(OilWaterMaterialLaw::numPhases == 2,
73 "The number of phases considered by the oil-water capillary "
74 "pressure law must be two!");
75 static_assert(std::is_same<
typename GasOilMaterialLaw::Scalar,
76 typename OilWaterMaterialLaw::Scalar>::value,
77 "The two two-phase capillary pressure laws must use the same "
78 "type of floating point values.");
80 static_assert(GasOilMaterialLaw::implementsTwoPhaseSatApi,
81 "The gas-oil material law must implement the two-phase saturation "
82 "only API to for the default Ecl capillary pressure law!");
83 static_assert(OilWaterMaterialLaw::implementsTwoPhaseSatApi,
84 "The oil-water material law must implement the two-phase saturation "
85 "only API to for the default Ecl capillary pressure law!");
89 using Scalar =
typename Traits::Scalar;
93 static constexpr int oilPhaseIdx = Traits::nonWettingPhaseIdx;
134 template <
class ContainerT,
class Flu
idState>
137 const FluidState& state)
139 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
140 values[
gasPhaseIdx] = pcgn<FluidState, Evaluation>(params, state);
142 values[
waterPhaseIdx] = - pcnw<FluidState, Evaluation>(params, state);
158 pcSwMdc = params.oilWaterParams().pcSwMdc();
159 krnSwMdc = params.oilWaterParams().krnSwMdc();
175 constexpr const double krwSw = 2.0;
176 params.oilWaterParams().update(pcSwMdc, krwSw, krnSwMdc);
189 const auto Swco = params.Swl();
193 pcSwMdc =
std::min(params.gasOilParams().pcSwMdc() + Swco,
Scalar{2.0});
194 krnSwMdc =
std::min(params.gasOilParams().krnSwMdc() + Swco,
Scalar{2.0});
211 const auto Swco = params.Swl();
212 constexpr const double krwSw = 2.0;
213 params.gasOilParams().update(pcSwMdc - Swco, krwSw, krnSwMdc - Swco);
225 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
227 const FluidState& fs)
230 const auto Sw = 1.0 - params.Swl() - decay<Evaluation>(fs.saturation(
gasPhaseIdx));
231 return GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(),
Sw);
243 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
245 const FluidState& fs)
250 const auto result = OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(),
Sw);
259 template <
class ContainerT,
class Flu
idState>
264 throw std::logic_error(
"Not implemented: saturations()");
270 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
274 throw std::logic_error(
"Not implemented: Sg()");
280 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
284 throw std::logic_error(
"Not implemented: Sn()");
290 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
294 throw std::logic_error(
"Not implemented: Sw()");
312 template <
class ContainerT,
class Flu
idState>
315 const FluidState& fluidState)
317 using Evaluation =
typename std::remove_reference<
decltype(values[0])>::type;
319 values[
waterPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
320 values[
oilPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
321 values[
gasPhaseIdx] = krg<FluidState, Evaluation>(params, fluidState);
327 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
329 const FluidState& fluidState)
332 const Evaluation
Sw = 1 - params.Swl() - decay<Evaluation>(fluidState.saturation(
gasPhaseIdx));
333 return GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(),
Sw);
339 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
341 const FluidState& fluidState)
343 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(
waterPhaseIdx));
344 return OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(),
Sw);
350 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
352 const FluidState& fluidState)
357 const Scalar Swco = params.Swl();
360 const Scalar krocw = params.krocw();
362 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(
waterPhaseIdx));
363 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(
gasPhaseIdx));
365 const Evaluation kro_ow = relpermOilInOilWaterSystem<Evaluation>(params, fluidState);
366 const Evaluation kro_go = relpermOilInOilGasSystem<Evaluation>(params, fluidState);
375 const Evaluation SSw = (
Sw - Swco)/(1.0 - Swco);
376 const Evaluation SSg =
Sg/(1.0 - Swco);
377 const Evaluation SSo = 1.0 - SSw - SSg;
379 if (SSw >= 1.0 || SSg >= 1.0)
382 beta =
pow( SSo/((1 - SSw)*(1 - SSg)), params.eta());
385 return max(0.0,
min(1.0, beta*kro_ow*kro_go/krocw));
391 template <
class Evaluation,
class Flu
idState>
393 const FluidState& fluidState)
395 const Evaluation
Sg = decay<Evaluation>(fluidState.saturation(
gasPhaseIdx));
397 return GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), 1 -
Sg - params.Swl());
403 template <
class Evaluation,
class Flu
idState>
405 const FluidState& fluidState)
407 const Evaluation
Sw = decay<Evaluation>(fluidState.saturation(
waterPhaseIdx));
409 return OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(),
Sw);
419 template <
class Flu
idState>
422 const Scalar Swco = params.Swl();
426 params.oilWaterParams().update(
Sw,
Sw,
Sw);
427 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: EclStone1Material.hpp:60
static constexpr bool isSaturationDependent
Definition: EclStone1Material.hpp:106
static void setGasOilHysteresisParams(const Scalar &pcSwMdc, const Scalar &krnSwMdc, Params ¶ms)
Definition: EclStone1Material.hpp:206
static constexpr bool implementsTwoPhaseSatApi
Definition: EclStone1Material.hpp:102
static constexpr bool isCompositionDependent
Definition: EclStone1Material.hpp:118
static constexpr int waterPhaseIdx
Definition: EclStone1Material.hpp:92
static Evaluation krw(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the wetting phase.
Definition: EclStone1Material.hpp:340
static constexpr int gasPhaseIdx
Definition: EclStone1Material.hpp:94
static Evaluation krn(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the non-wetting (i.e., oil) phase.
Definition: EclStone1Material.hpp:351
static void relativePermeabilities(ContainerT &values, const Params ¶ms, const FluidState &fluidState)
The relative permeability of all phases.
Definition: EclStone1Material.hpp:313
static void setOilWaterHysteresisParams(const Scalar &pcSwMdc, const Scalar &krnSwMdc, Params ¶ms)
Definition: EclStone1Material.hpp:171
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: EclStone1Material.hpp:135
static void gasOilHysteresisParams(Scalar &pcSwMdc, Scalar &krnSwMdc, const Params ¶ms)
Definition: EclStone1Material.hpp:185
OilWaterMaterialLawT OilWaterMaterialLaw
Definition: EclStone1Material.hpp:63
typename Traits::Scalar Scalar
Definition: EclStone1Material.hpp:89
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: EclStone1Material.hpp:260
static constexpr bool isTemperatureDependent
Definition: EclStone1Material.hpp:114
static Evaluation Sg(const Params &, const FluidState &)
The saturation of the gas phase.
Definition: EclStone1Material.hpp:271
static void oilWaterHysteresisParams(Scalar &pcSwMdc, Scalar &krnSwMdc, const Params ¶ms)
Definition: EclStone1Material.hpp:154
static Evaluation krg(const Params ¶ms, const FluidState &fluidState)
The relative permeability of the gas phase.
Definition: EclStone1Material.hpp:328
static constexpr bool implementsTwoPhaseApi
Definition: EclStone1Material.hpp:98
static Evaluation Sw(const Params &, const FluidState &)
The saturation of the wetting (i.e., water) phase.
Definition: EclStone1Material.hpp:291
static Evaluation pcgn(const Params ¶ms, const FluidState &fs)
Capillary pressure between the gas and the non-wetting liquid (i.e., oil) phase.
Definition: EclStone1Material.hpp:226
TraitsT Traits
Definition: EclStone1Material.hpp:87
static constexpr bool isPressureDependent
Definition: EclStone1Material.hpp:110
static constexpr int oilPhaseIdx
Definition: EclStone1Material.hpp:93
static Evaluation relpermOilInOilWaterSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/water system.
Definition: EclStone1Material.hpp:404
GasOilMaterialLawT GasOilMaterialLaw
Definition: EclStone1Material.hpp:62
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: EclStone1Material.hpp:244
static Evaluation relpermOilInOilGasSystem(const Params ¶ms, const FluidState &fluidState)
The relative permeability of oil in oil/gas system.
Definition: EclStone1Material.hpp:392
static void updateHysteresis(Params ¶ms, const FluidState &fluidState)
Update the hysteresis parameters after a time step.
Definition: EclStone1Material.hpp:420
static Evaluation Sn(const Params &, const FluidState &)
The saturation of the non-wetting (i.e., oil) phase.
Definition: EclStone1Material.hpp:281
static constexpr int numPhases
Definition: EclStone1Material.hpp:91
ParamsT Params
Definition: EclStone1Material.hpp:88
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
ReturnEval_< Evaluation1, Evaluation2 >::type pow(const Evaluation1 &base, const Evaluation2 &exp)
Definition: MathToolbox.hpp:416