25 #ifndef OPM_ECL_DEFAULT_MATERIAL_HPP
26 #define OPM_ECL_DEFAULT_MATERIAL_HPP
33 #include <opm/common/Exceptions.hpp>
34 #include <opm/common/ErrorMacros.hpp>
53 template <
class TraitsT,
54 class GasOilMaterialLawT,
55 class OilWaterMaterialLawT,
56 class ParamsT = EclDefaultMaterialParams<TraitsT,
57 typename GasOilMaterialLawT::Params,
58 typename OilWaterMaterialLawT::Params> >
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!");
87 typedef TraitsT Traits;
88 typedef ParamsT Params;
89 typedef typename Traits::Scalar Scalar;
91 static const int numPhases = 3;
92 static const int waterPhaseIdx = Traits::wettingPhaseIdx;
93 static const int oilPhaseIdx = Traits::nonWettingPhaseIdx;
94 static const int gasPhaseIdx = Traits::gasPhaseIdx;
98 static const bool implementsTwoPhaseApi =
false;
102 static const bool implementsTwoPhaseSatApi =
false;
106 static const bool isSaturationDependent =
true;
110 static const bool isPressureDependent =
false;
114 static const bool isTemperatureDependent =
false;
118 static const bool isCompositionDependent =
false;
134 template <
class ContainerT,
class Flu
idState>
135 static void capillaryPressures(ContainerT &values,
136 const Params ¶ms,
137 const FluidState &state)
139 typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
140 values[gasPhaseIdx] = pcgn<FluidState, Evaluation>(params, state);
141 values[oilPhaseIdx] = 0;
142 values[waterPhaseIdx] = - pcnw<FluidState, Evaluation>(params, state);
158 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
159 static Evaluation pcgn(
const Params ¶ms,
160 const FluidState &fs)
164 const auto& Sw = 1.0 - FsToolbox::template toLhs<Evaluation>(fs.saturation(gasPhaseIdx));
165 return GasOilMaterialLaw::twoPhaseSatPcnw(params.gasOilParams(), Sw);
177 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
178 static Evaluation pcnw(
const Params ¶ms,
179 const FluidState &fs)
181 typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
183 const auto& Sw = FsToolbox::template toLhs<Evaluation>(fs.saturation(waterPhaseIdx));
184 return OilWaterMaterialLaw::twoPhaseSatPcnw(params.oilWaterParams(), Sw);
190 template <
class ContainerT,
class Flu
idState>
191 static void saturations(ContainerT& ,
195 OPM_THROW(std::logic_error,
"Not implemented: saturations()");
201 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
202 static Evaluation Sg(
const Params& ,
205 OPM_THROW(std::logic_error,
"Not implemented: Sg()");
211 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
212 static Evaluation Sn(
const Params& ,
215 OPM_THROW(std::logic_error,
"Not implemented: Sn()");
221 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
222 static Evaluation Sw(
const Params& ,
225 OPM_THROW(std::logic_error,
"Not implemented: Sw()");
243 template <
class ContainerT,
class Flu
idState>
244 static void relativePermeabilities(ContainerT &values,
245 const Params ¶ms,
246 const FluidState &fluidState)
248 typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
250 values[waterPhaseIdx] = krw<FluidState, Evaluation>(params, fluidState);
251 values[oilPhaseIdx] = krn<FluidState, Evaluation>(params, fluidState);
252 values[gasPhaseIdx] = krg<FluidState, Evaluation>(params, fluidState);
258 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
259 static Evaluation krg(
const Params ¶ms,
260 const FluidState &fluidState)
262 typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
264 const Evaluation& Sw = 1 - FsToolbox::template toLhs<Evaluation>(fluidState.saturation(gasPhaseIdx));
265 return GasOilMaterialLaw::twoPhaseSatKrn(params.gasOilParams(), Sw);
271 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
272 static Evaluation krw(
const Params ¶ms,
273 const FluidState &fluidState)
275 typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
277 const Evaluation& Sw = FsToolbox::template toLhs<Evaluation>(fluidState.saturation(waterPhaseIdx));
278 return OilWaterMaterialLaw::twoPhaseSatKrw(params.oilWaterParams(), Sw);
284 template <
class Flu
idState,
class Evaluation =
typename Flu
idState::Scalar>
285 static Evaluation krn(
const Params ¶ms,
286 const FluidState &fluidState)
288 typedef MathToolbox<Evaluation> Toolbox;
289 typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
291 Scalar Swco = params.Swl();
295 FsToolbox::template toLhs<Evaluation>(fluidState.saturation(waterPhaseIdx)));
296 Evaluation Sg = FsToolbox::template toLhs<Evaluation>(fluidState.saturation(gasPhaseIdx));
298 Evaluation Sw_ow = Sg + Sw;
299 Evaluation So_go = 1.0 - Sw_ow;
300 const Evaluation& kro_ow = OilWaterMaterialLaw::twoPhaseSatKrn(params.oilWaterParams(), Sw_ow);
301 const Evaluation& kro_go = GasOilMaterialLaw::twoPhaseSatKrw(params.gasOilParams(), So_go);
306 const Scalar epsilon = 1e-5;
307 if (Toolbox::value(Sw_ow) - Swco < epsilon) {
308 Evaluation kro2 = (kro_ow + kro_go)/2;;
309 if (Toolbox::value(Sw_ow) - Swco > epsilon/2) {
310 Evaluation kro1 = (Sg*kro_go + (Sw - Swco)*kro_ow)/(Sw_ow - Swco);
311 Evaluation alpha = (epsilon - (Sw_ow - Swco))/(epsilon/2);
312 return kro2*alpha + kro1*(1 - alpha);
318 return (Sg*kro_go + (Sw - Swco)*kro_ow)/(Sw_ow - Swco);
328 template <
class Flu
idState>
329 static void updateHysteresis(Params ¶ms,
const FluidState &fluidState)
331 typedef MathToolbox<typename FluidState::Scalar> FsToolbox;
333 Scalar Sw = FsToolbox::value(fluidState.saturation(waterPhaseIdx));
334 Scalar So = FsToolbox::value(fluidState.saturation(oilPhaseIdx));
335 Scalar Sg = FsToolbox::value(fluidState.saturation(gasPhaseIdx));
337 if (params.inconsistentHysteresisUpdate()) {
348 params.oilWaterParams().update(1 - So, 1 - So, 1 - So);
349 params.gasOilParams().update(1 - Sg, 1 - Sg, 1 - Sg);
352 Scalar Swco = params.Swl();
356 Scalar Sw_ow = Sg +
std::max(Swco, Sw);
357 Scalar So_go = 1 + Sw_ow;
359 params.oilWaterParams().update(Sw, 1 - Sg, Sw_ow);
360 params.gasOilParams().update(1 - Sg, So_go, 1 - Sg);
GasOilMaterialLawT GasOilMaterialLaw
Definition: EclDefaultMaterial.hpp:62
bool CheckDefined(const T &value OPM_UNUSED)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
Definition: Air_Mesitylene.hpp:31
Default implementation for the parameters required by the default three-phase capillary pressure mode...
Some templates to wrap the valgrind client request macros.
Evaluation< Scalar, VarSetTag, numVars > max(const Evaluation< Scalar, VarSetTag, numVars > &x1, const Evaluation< Scalar, VarSetTag, numVars > &x2)
Definition: Math.hpp:114
Implements the default three phase capillary pressure law used by the ECLipse simulator.
Definition: EclDefaultMaterial.hpp:59
Evaluation< Scalar, VarSetTag, numVars > min(const Evaluation< Scalar, VarSetTag, numVars > &x1, const Evaluation< Scalar, VarSetTag, numVars > &x2)
Definition: Math.hpp:61
OilWaterMaterialLawT OilWaterMaterialLaw
Definition: EclDefaultMaterial.hpp:63