28#ifndef EWOMS_PVS_PRIMARY_VARIABLES_HH
29#define EWOMS_PVS_PRIMARY_VARIABLES_HH
31#include <dune/common/fvector.hh>
33#include <opm/common/Exceptions.hpp>
39#include <opm/material/constraintsolvers/NcpFlash.hpp>
40#include <opm/material/fluidstates/CompositionalFluidState.hpp>
41#include <opm/material/common/Valgrind.hpp>
56template <
class TypeTag>
71 enum { pressure0Idx = Indices::pressure0Idx };
72 enum { switch0Idx = Indices::switch0Idx };
79 using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
85 { Valgrind::SetDefined(*
this); }
93 Valgrind::SetDefined(*
this);
95 phasePresence_ = value.phasePresence_;
101 template <
class Flu
idState>
109 assert(std::abs(fluidState.temperature(0) - fluidState.temperature(
phaseIdx)) < 1
e-30);
156 {
return phasePresence_; }
165 { phasePresence_ = value; }
207 {
return phasePresence_& (1 <<
phaseIdx); }
213 {
return static_cast<unsigned>(
ffs(phasePresence_) - 1); }
221 phasePresence_ = value.phasePresence_;
251 if (std::is_same<Evaluation, Scalar>::value)
256 Toolbox::createConstant((*
this)[
varIdx]);
257 return Toolbox::createVariable((*
this)[
varIdx],
varIdx);
264 template <
class Flu
idState>
271 EnergyModule::setPriVarTemperatures(*
this, fluidState);
274 (*this)[pressure0Idx] = FsToolbox::value(fluidState.pressure(0));
275 Valgrind::CheckDefined((*
this)[pressure0Idx]);
286 Scalar
b = FsToolbox::value(fluidState.saturation(
phaseIdx));
293 if (phasePresence_ == 0)
306 (*this)[switch0Idx +
switchIdx] = FsToolbox::value(fluidState.saturation(
phaseIdx));
307 Valgrind::CheckDefined((*
this)[switch0Idx +
switchIdx]);
312 Valgrind::CheckDefined((*
this)[switch0Idx +
switchIdx]);
319 (*this)[switch0Idx +
compIdx] =
321 Valgrind::CheckDefined((*
this)[switch0Idx +
compIdx]);
328 void print(std::ostream&
os = std::cout)
const
330 os <<
"(p_" << FluidSystem::phaseName(0) <<
" = "
331 << this->operator[](pressure0Idx);
341 os <<
", S_" << FluidSystem::phaseName(
phaseIdx) <<
" = "
346 << FluidSystem::componentName(
compIdx) <<
" = "
350 for (
unsigned compIdx = numPhases - 1;
compIdx < numComponents - 1;
353 << FluidSystem::componentName(
compIdx + 1) <<
" = "
354 << (*this)[switch0Idx +
compIdx];
357 os <<
", phase presence: " <<
static_cast<int>(phasePresence_) << std::flush;
361 short phasePresence_;
Provides the auxiliary methods required for consideration of the energy equation.
Definition energymodule.hh:50
Represents the primary variables used by the a model.
Definition fvbaseprimaryvariables.hh:52
FvBasePrimaryVariables & operator=(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
Represents the primary variables used in the primary variable switching compositional model.
Definition pvsprimaryvariables.hh:58
void print(std::ostream &os=std::cout) const
Prints the names of the primary variables and their values.
Definition pvsprimaryvariables.hh:328
unsigned implicitSaturationIdx() const
Returns the index of the phase with's its saturation is determined by the closure condition of satura...
Definition pvsprimaryvariables.hh:186
void setPhasePresence(short value)
Set which fluid phases are present in a given control volume.
Definition pvsprimaryvariables.hh:164
static bool phaseIsPresent(unsigned phaseIdx, short phasePresence)
Returns true iff a phase is present for a given phase presence.
Definition pvsprimaryvariables.hh:197
void setPhasePresent(unsigned phaseIdx, bool yesno=true)
Set whether a given indivividual phase should be present or not.
Definition pvsprimaryvariables.hh:174
ThisType & operator=(const Implementation &value)
Assignment operator from an other primary variables object.
Definition pvsprimaryvariables.hh:218
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition pvsprimaryvariables.hh:265
PvsPrimaryVariables(const PvsPrimaryVariables &value)
Definition pvsprimaryvariables.hh:91
unsigned lowestPresentPhaseIdx() const
Returns the phase with the lowest index that is present.
Definition pvsprimaryvariables.hh:212
ThisType & operator=(Scalar value)
Assignment operator from a scalar value.
Definition pvsprimaryvariables.hh:229
Evaluation explicitSaturationValue(unsigned phaseIdx, unsigned timeIdx) const
Returns an explcitly stored saturation for a given phase.
Definition pvsprimaryvariables.hh:244
bool phaseIsPresent(unsigned phaseIdx) const
Returns true iff a phase is present for the current phase presence.
Definition pvsprimaryvariables.hh:206
short phasePresence() const
Return the fluid phases which are present in a given control volume.
Definition pvsprimaryvariables.hh:155
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams, bool isInEquilibrium=false)
< Import base class assignment operators.
Definition pvsprimaryvariables.hh:102
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
Represents the primary variables used by the a model.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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
Declares the properties required for the compositional multi-phase primary variable switching model.