28 #ifndef EWOMS_IMMISCIBLE_LOCAL_RESIDUAL_BASE_HH
29 #define EWOMS_IMMISCIBLE_LOCAL_RESIDUAL_BASE_HH
35 #include <opm/common/Valgrind.hpp>
44 template <
class TypeTag>
47 typedef typename GET_PROP_TYPE(TypeTag, LocalResidual) Implementation;
49 typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
50 typedef typename GET_PROP_TYPE(TypeTag, IntensiveQuantities) IntensiveQuantities;
51 typedef typename GET_PROP_TYPE(TypeTag, ExtensiveQuantities) ExtensiveQuantities;
52 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
53 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
54 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
55 typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
56 typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
58 enum { conti0EqIdx = Indices::conti0EqIdx };
64 typedef Opm::MathToolbox<Evaluation> Toolbox;
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::addSolidHeatStorage(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);
167 const ElementContext& elemCtx,
169 unsigned timeIdx)
const
174 EnergyModule::addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx);
184 const ElementContext& elemCtx,
186 unsigned timeIdx)
const
188 Opm::Valgrind::SetUndefined(source);
189 elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx);
190 Opm::Valgrind::CheckDefined(source);
194 const Implementation& asImp_()
const
195 {
return *
static_cast<const Implementation *
>(
this); }
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:166
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
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:59
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
void computeStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx) const
Evaluate the amount all conservation quantities (e.g.
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:183
Defines the properties required for the immiscible multi-phase model.
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.
Definition: immisciblelocalresidual.hh:76
Calculates the local residual of the immiscible multi-phase model.
Definition: immisciblelocalresidual.hh:45