28#ifndef EWOMS_RICHARDS_PRIMARY_VARIABLES_HH
29#define EWOMS_RICHARDS_PRIMARY_VARIABLES_HH
35#include <opm/material/constraintsolvers/ImmiscibleFlash.hpp>
36#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
37#include <opm/material/common/Valgrind.hpp>
39#include <dune/common/fvector.hh>
51template <
class TypeTag>
64 enum { pressureWIdx = Indices::pressureWIdx };
66 enum { liquidPhaseIdx = getPropValue<TypeTag, Properties::LiquidPhaseIndex>() };
67 enum { gasPhaseIdx = getPropValue<TypeTag, Properties::GasPhaseIndex>() };
69 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
70 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
72 using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
73 using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
74 using Toolbox =
typename Opm::MathToolbox<Evaluation>;
75 using ImmiscibleFlash = Opm::ImmiscibleFlash<Scalar, FluidSystem>;
79 { Opm::Valgrind::SetUndefined(*
this); }
104 const MaterialLawParams& matParams)
106 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
108 fs.setTemperature(T);
109 fs.setSaturation(liquidPhaseIdx, Sw);
110 fs.setSaturation(gasPhaseIdx, 1 - Sw);
114 MaterialLaw::capillaryPressures(pC, matParams, fs);
116 fs.setPressure(liquidPhaseIdx, pw);
117 fs.setPressure(gasPhaseIdx, pw + (pC[gasPhaseIdx] - pC[liquidPhaseIdx]));
132 const MaterialLawParams& matParams)
134 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
136 fs.setTemperature(T);
137 fs.setSaturation(liquidPhaseIdx, 1 - Sn);
138 fs.setSaturation(gasPhaseIdx, Sn);
142 MaterialLaw::capillaryPressures(pC, matParams, fs);
144 fs.setPressure(gasPhaseIdx, pn);
145 fs.setPressure(gasPhaseIdx, pn + (pC[liquidPhaseIdx] - pC[gasPhaseIdx]));
153 template <
class Flu
idState>
155 const MaterialLawParams& matParams,
158 ComponentVector globalMolarities(0.0);
159 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
160 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
161 globalMolarities[compIdx] +=
162 fluidState.molarity(phaseIdx, compIdx) * fluidState.saturation(phaseIdx);
166 Opm::ImmiscibleFluidState<Scalar, FluidSystem> fsFlash;
167 fsFlash.assign(fluidState);
168 typename FluidSystem::ParameterCache paramCache;
169 ImmiscibleFlash::template solve<MaterialLaw>(fsFlash, paramCache,
179 template <
class Flu
idState>
184 EnergyModule::setPriVarTemperatures(*
this, fluidState);
186 (*this)[pressureWIdx] = fluidState.pressure(liquidPhaseIdx);
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:52
Represents the primary variables used in the Richards model.
Definition: richardsprimaryvariables.hh:53
RichardsPrimaryVariables & operator=(const RichardsPrimaryVariables &value)=default
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams, bool=false)
Set the primary variables from an arbitrary fluid state in a mass conservative way.
Definition: richardsprimaryvariables.hh:154
RichardsPrimaryVariables(const RichardsPrimaryVariables &value)=default
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition: richardsprimaryvariables.hh:180
RichardsPrimaryVariables()
Definition: richardsprimaryvariables.hh:78
void assignImmiscibleFromWetting(Scalar T, Scalar pw, Scalar Sw, const MaterialLawParams &matParams)
Set the primary variables with the wetting phase pressure, saturation and temperature.
Definition: richardsprimaryvariables.hh:103
void assignImmiscibleFromNonWetting(Scalar T, Scalar pn, Scalar Sn, const MaterialLawParams &matParams)
Set the primary variables with the non-wetting phase pressure, saturation and temperature.
Definition: richardsprimaryvariables.hh:131
RichardsPrimaryVariables(Scalar value)
Constructor with assignment from scalar.
Definition: richardsprimaryvariables.hh:84
Definition: blackoilboundaryratevector.hh:37
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:235
Contains the property declarations for the Richards model.