28#ifndef EWOMS_IMMISCIBLE_LOCAL_RESIDUAL_BASE_HH
29#define EWOMS_IMMISCIBLE_LOCAL_RESIDUAL_BASE_HH
35#include <opm/material/common/Valgrind.hpp>
44template <
class TypeTag>
58 enum { conti0EqIdx = Indices::conti0EqIdx };
59 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
60 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
61 enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
64 using Toolbox = Opm::MathToolbox<Evaluation>;
75 template <
class LhsEval>
77 const ElementContext& elemCtx,
80 unsigned phaseIdx)
const
84 const IntensiveQuantities& intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx);
85 const auto& fs = intQuants.fluidState();
87 storage[conti0EqIdx + phaseIdx] =
88 Toolbox::template decay<LhsEval>(intQuants.porosity())
89 * Toolbox::template decay<LhsEval>(fs.saturation(phaseIdx))
90 * Toolbox::template decay<LhsEval>(fs.density(phaseIdx));
92 EnergyModule::addPhaseStorage(storage, intQuants, phaseIdx);
98 template <
class LhsEval>
100 const ElementContext& elemCtx,
102 unsigned timeIdx)
const
105 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
106 asImp_().addPhaseStorage(storage, elemCtx, dofIdx, timeIdx, phaseIdx);
108 EnergyModule::addSolidEnergyStorage(storage, elemCtx.intensiveQuantities(dofIdx, timeIdx));
115 const ElementContext& elemCtx,
117 unsigned timeIdx)
const
120 asImp_().addAdvectiveFlux(flux, elemCtx, scvfIdx, timeIdx);
121 asImp_().addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx);
130 const ElementContext& elemCtx,
132 unsigned timeIdx)
const
134 const ExtensiveQuantities& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
139 unsigned focusDofIdx = elemCtx.focusDofIndex();
140 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
142 unsigned upIdx =
static_cast<unsigned>(extQuants.upstreamIndex(phaseIdx));
144 const IntensiveQuantities& up = elemCtx.intensiveQuantities(upIdx, 0);
147 const Evaluation& rho = up.fluidState().density(phaseIdx);
148 if (focusDofIdx == upIdx)
149 flux[conti0EqIdx + phaseIdx] += extQuants.volumeFlux(phaseIdx)*rho;
151 flux[conti0EqIdx + phaseIdx] += extQuants.volumeFlux(phaseIdx)*Toolbox::value(rho);
154 EnergyModule::addAdvectiveFlux(flux, elemCtx, scvfIdx, timeIdx);
166 const ElementContext& elemCtx,
168 unsigned timeIdx)
const
173 EnergyModule::addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx);
183 const ElementContext& elemCtx,
185 unsigned timeIdx)
const
187 Opm::Valgrind::SetUndefined(source);
188 elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx);
189 Opm::Valgrind::CheckDefined(source);
193 const Implementation& asImp_()
const
194 {
return *
static_cast<const Implementation *
>(
this); }
Provides the auxiliary methods required for consideration of the energy equation.
Definition: energymodule.hh:50
Calculates the local residual of the immiscible multi-phase model.
Definition: immisciblelocalresidual.hh:46
void computeStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx) const
Evaluate the amount all conservation quantities (e.g. phase mass) within a finite sub-control volume.
Definition: immisciblelocalresidual.hh:99
void addAdvectiveFlux(RateVector &flux, const ElementContext &elemCtx, unsigned scvfIdx, unsigned timeIdx) const
Add the advective mass flux at a given flux integration point.
Definition: immisciblelocalresidual.hh:129
void computeSource(RateVector &source, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx) const
Calculate the source term of the equation.
Definition: immisciblelocalresidual.hh:182
void addDiffusiveFlux(RateVector &flux, const ElementContext &elemCtx, unsigned scvfIdx, unsigned timeIdx) const
Adds the diffusive flux at a given flux integration point.
Definition: immisciblelocalresidual.hh:165
void addPhaseStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx, unsigned phaseIdx) const
Adds the amount all conservation quantities (e.g. phase mass) within a single fluid phase.
Definition: immisciblelocalresidual.hh:76
void computeFlux(RateVector &flux, const ElementContext &elemCtx, unsigned scvfIdx, unsigned timeIdx) const
Evaluates the total mass flux of all conservation quantities over a face of a sub-control volume.
Definition: immisciblelocalresidual.hh:114
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
Defines the properties required for the immiscible multi-phase model.
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