26 #ifndef EWOMS_FLASH_INTENSIVE_QUANTITIES_HH
27 #define EWOMS_FLASH_INTENSIVE_QUANTITIES_HH
34 #include <opm/material/fluidstates/CompositionalFluidState.hpp>
36 #include <dune/common/fvector.hh>
37 #include <dune/common/fmatrix.hh>
47 template <
class TypeTag>
52 ,
public GET_PROP_TYPE(TypeTag, FluxModule)::FluxIntensiveQuantities
54 typedef typename GET_PROP_TYPE(TypeTag, DiscIntensiveQuantities) ParentType;
56 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
57 typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
58 typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
59 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
60 typedef typename GET_PROP_TYPE(TypeTag, FluxModule) FluxModule;
61 typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
65 enum { cTot0Idx = Indices::cTot0Idx };
68 enum { enableDiffusion =
GET_PROP_VALUE(TypeTag, EnableDiffusion) };
70 enum { dimWorld = GridView::dimensionworld };
72 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
73 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
74 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
75 typedef typename GET_PROP_TYPE(TypeTag, FlashSolver) FlashSolver;
77 typedef Dune::FieldVector<Evaluation, numComponents> ComponentVector;
78 typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
80 typedef typename FluxModule::FluxIntensiveQuantities FluxIntensiveQuantities;
86 typedef Opm::CompositionalFluidState<Evaluation, FluidSystem, enableEnergy>
FluidState;
91 void update(
const ElementContext &elemCtx,
int dofIdx,
int timeIdx)
93 ParentType::update(elemCtx,
96 EnergyIntensiveQuantities::updateTemperatures_(fluidState_, elemCtx, dofIdx, timeIdx);
98 const auto &priVars = elemCtx.primaryVars(dofIdx, timeIdx);
99 const auto &problem = elemCtx.problem();
100 Scalar flashTolerance =
EWOMS_GET_PARAM(TypeTag, Scalar, FlashTolerance);
101 if (flashTolerance <= 0)
102 flashTolerance = std::numeric_limits<Scalar>::epsilon()*1e7;
105 ComponentVector cTotal;
106 for (
int compIdx = 0; compIdx < numComponents; ++compIdx)
107 cTotal[compIdx] = priVars.makeEvaluation(cTot0Idx + compIdx, timeIdx);
109 typename FluidSystem::ParameterCache paramCache;
110 const auto *hint = elemCtx.thermodynamicHint(dofIdx, timeIdx);
115 const Evaluation& T = fluidState_.temperature(0);
116 fluidState_.assign(hint->fluidState());
117 fluidState_.setTemperature(T);
120 FlashSolver::guessInitial(fluidState_, paramCache, cTotal);
123 const MaterialLawParams &materialParams =
124 problem.materialLawParams(elemCtx, dofIdx, timeIdx);
125 FlashSolver::template solve<MaterialLaw>(fluidState_,
132 MaterialLaw::relativePermeabilities(relativePermeability_,
133 materialParams, fluidState_);
134 Valgrind::CheckDefined(relativePermeability_);
137 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
138 const Evaluation& mu = FluidSystem::viscosity(fluidState_, paramCache, phaseIdx);
139 fluidState_.setViscosity(phaseIdx, mu);
141 mobility_[phaseIdx] = relativePermeability_[phaseIdx] / mu;
142 Valgrind::CheckDefined(mobility_[phaseIdx]);
150 porosity_ = problem.porosity(elemCtx, dofIdx, timeIdx);
151 Valgrind::CheckDefined(porosity_);
154 intrinsicPerm_ = problem.intrinsicPermeability(elemCtx, dofIdx, timeIdx);
157 FluxIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);
160 EnergyIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
163 DiffusionIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
170 {
return fluidState_; }
176 {
return intrinsicPerm_; }
182 {
return relativePermeability_[phaseIdx]; }
189 return mobility_[phaseIdx];
196 {
return porosity_; }
199 DimMatrix intrinsicPerm_;
200 FluidState fluidState_;
201 Evaluation porosity_;
202 Evaluation relativePermeability_[numPhases];
203 Evaluation mobility_[numPhases];
Provides the volumetric quantities required for the energy equation.
Definition: energymodule.hh:530
Classes required for molecular diffusion.
const Evaluation & porosity() const
Returns the average porosity within the control volume.
Definition: flashintensivequantities.hh:195
Opm::CompositionalFluidState< Evaluation, FluidSystem, enableEnergy > FluidState
The type of the object returned by the fluidState() method.
Definition: flashintensivequantities.hh:86
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
Contains the intensive quantities of the flash-based compositional multi-phase model.
Definition: flashintensivequantities.hh:48
const DimMatrix & intrinsicPermeability() const
Returns the intrinsic permeability tensor a degree of freedom.
Definition: flashintensivequantities.hh:175
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: flashintensivequantities.hh:169
void update(const ElementContext &elemCtx, int dofIdx, int timeIdx)
Definition: flashintensivequantities.hh:91
Simplifies multi-threaded capabilities.
Definition: threadmanager.hh:48
Definition: baseauxiliarymodule.hh:35
const Evaluation & mobility(int phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: flashintensivequantities.hh:187
Provides the volumetric quantities required for the calculation of molecular diffusive fluxes...
Definition: diffusionmodule.hh:138
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...
Declares the properties required by the compositional multi-phase model based on flash calculations...
const Evaluation & relativePermeability(int phaseIdx) const
Returns the relative permeability of a given phase within the control volume.
Definition: flashintensivequantities.hh:181
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95