27 #ifndef EWOMS_PVS_LOCAL_RESIDUAL_HH
28 #define EWOMS_PVS_LOCAL_RESIDUAL_HH
43 template <
class TypeTag>
46 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
47 typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
48 typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
49 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
50 typedef typename GET_PROP_TYPE(TypeTag, IntensiveQuantities) IntensiveQuantities;
51 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
56 enum { conti0EqIdx = Indices::conti0EqIdx };
58 enum { enableDiffusion =
GET_PROP_VALUE(TypeTag, EnableDiffusion) };
64 typedef Opm::MathToolbox<Evaluation> Toolbox;
70 template <
class LhsEval>
72 const ElementContext &elemCtx,
77 const IntensiveQuantities &intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx);
78 const auto &fs = intQuants.fluidState();
81 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
82 int eqIdx = conti0EqIdx + compIdx;
84 Toolbox::template toLhs<LhsEval>(fs.molarity(phaseIdx, compIdx))
85 * Toolbox::template toLhs<LhsEval>(fs.saturation(phaseIdx))
86 * Toolbox::template toLhs<LhsEval>(intQuants.porosity());
89 EnergyModule::addPhaseStorage(storage, elemCtx.intensiveQuantities(dofIdx, timeIdx), phaseIdx);
95 template <
class LhsEval>
97 const ElementContext& elemCtx,
102 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
105 EnergyModule::addSolidHeatStorage(storage, elemCtx.intensiveQuantities(dofIdx, timeIdx));
111 void computeFlux(RateVector &flux,
const ElementContext &elemCtx,
int scvfIdx,
int timeIdx)
const
113 flux = Toolbox::createConstant(0.0);
115 Valgrind::CheckDefined(flux);
118 Valgrind::CheckDefined(flux);
125 int scvfIdx,
int timeIdx)
const
127 const auto &extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
129 int interiorIdx = extQuants.interiorIndex();
130 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
133 int upIdx = extQuants.upstreamIndex(phaseIdx);
134 const IntensiveQuantities &up = elemCtx.intensiveQuantities(upIdx, timeIdx);
139 if (upIdx == interiorIdx) {
141 up.fluidState().molarDensity(phaseIdx)
142 * extQuants.volumeFlux(phaseIdx);
144 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
145 flux[conti0EqIdx + compIdx] +=
146 tmp*up.fluidState().moleFraction(phaseIdx, compIdx);
151 Toolbox::value(up.fluidState().molarDensity(phaseIdx))
152 * extQuants.volumeFlux(phaseIdx);
154 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
155 flux[conti0EqIdx + compIdx] +=
156 tmp*Toolbox::value(up.fluidState().moleFraction(phaseIdx, compIdx));
161 EnergyModule::addAdvectiveFlux(flux, elemCtx, scvfIdx, timeIdx);
168 int scvfIdx,
int timeIdx)
const
170 DiffusionModule::addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx);
171 EnergyModule::addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx);
178 const ElementContext &elemCtx,
182 Valgrind::SetUndefined(source);
183 elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx);
184 Valgrind::CheckDefined(source);
Classes required for molecular diffusion.
void addAdvectiveFlux(RateVector &flux, const ElementContext &elemCtx, int scvfIdx, int timeIdx) const
Add the advective mass flux at a given flux integration point.
Definition: pvslocalresidual.hh:124
Provides the auxiliary methods required for consideration of the diffusion equation.
Definition: diffusionmodule.hh:46
void computeStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, int dofIdx, int timeIdx) const
Evaluate the amount all conservation quantities (e.g. phase mass) within a finite sub-control volume...
Definition: pvslocalresidual.hh:96
void addDiffusiveFlux(RateVector &flux, const ElementContext &elemCtx, int scvfIdx, int timeIdx) const
Adds the diffusive flux at a given flux integration point.
Definition: pvslocalresidual.hh:167
void computeSource(RateVector &source, const ElementContext &elemCtx, int dofIdx, int timeIdx) const
Calculate the source term of the equation.
Definition: pvslocalresidual.hh:177
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:54
Definition: baseauxiliarymodule.hh:35
void computeFlux(RateVector &flux, const ElementContext &elemCtx, int scvfIdx, int timeIdx) const
Evaluates the total mass flux of all conservation quantities over a face of a sub-control volume...
Definition: pvslocalresidual.hh:111
Element-wise calculation of the local residual for the compositional multi-phase primary variable swi...
Definition: pvslocalresidual.hh:44
void addPhaseStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, int dofIdx, int timeIdx, int phaseIdx) const
Adds the amount all conservation quantities (e.g. phase mass) within a single fluid phase...
Definition: pvslocalresidual.hh:71
Declares the properties required for the compositional multi-phase primary variable switching model...
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...