27 #ifndef EWOMS_STOKES_LOCAL_RESIDUAL_HH
28 #define EWOMS_STOKES_LOCAL_RESIDUAL_HH
34 #include <opm/material/common/Valgrind.hpp>
36 #include <dune/grid/common/grid.hh>
37 #include <dune/common/fvector.hh>
46 template<
class TypeTag>
50 typedef typename GET_PROP_TYPE(TypeTag, DiscLocalResidual) ParentType;
51 typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
52 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
53 typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
54 typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
55 typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
56 typedef typename GET_PROP_TYPE(TypeTag, IntensiveQuantities) IntensiveQuantities;
57 typedef typename GET_PROP_TYPE(TypeTag, ExtensiveQuantities) ExtensiveQuantities;
58 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
59 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
61 enum { dimWorld = GridView::dimensionworld };
63 enum { numComponents = FluidSystem::numComponents };
64 enum { conti0EqIdx = Indices::conti0EqIdx };
65 enum { momentum0EqIdx = Indices::momentum0EqIdx };
69 typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
77 ParentType::registerParameters();
80 "Enable the Navier term (convective flux term).");
87 const ElementContext &elemCtx,
91 const auto &intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx);
92 const auto &fs = intQuants.fluidState();
95 for (
int compIdx = 0; compIdx < numComponents; ++compIdx) {
96 storage[conti0EqIdx + compIdx] = fs.molarity(phaseIdx, compIdx);
98 Valgrind::CheckDefined(storage);
101 for (
int axisIdx = 0; axisIdx < dimWorld; ++ axisIdx) {
102 storage[momentum0EqIdx + axisIdx] =
103 fs.density(phaseIdx) * intQuants.velocity()[axisIdx];
105 Valgrind::CheckDefined(storage);
107 EnergyModule::addPhaseStorage(storage, elemCtx.intensiveQuantities(dofIdx, timeIdx), phaseIdx);
108 Valgrind::CheckDefined(storage);
115 int scvfIdx,
int timeIdx)
const
119 Valgrind::CheckDefined(flux);
121 Valgrind::CheckDefined(flux);
128 int scvfIdx,
int timeIdx)
const
130 const ExtensiveQuantities &extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
133 const IntensiveQuantities &up =
134 elemCtx.intensiveQuantities(extQuants.upstreamIndex(phaseIdx), timeIdx);
136 auto normal = extQuants.normal();
139 Scalar vTimesN = extQuants.velocity() * normal;
140 for (
int compIdx = 0; compIdx < numComponents; ++compIdx)
141 flux[conti0EqIdx + compIdx] = up.fluidState().molarity(phaseIdx, compIdx) * vTimesN;
145 up.fluidState().viscosity(phaseIdx)
146 + extQuants.eddyViscosity();
147 for (
int axisIdx = 0; axisIdx < dimWorld; ++axisIdx) {
152 for (
int j = 0; j < dimWorld; ++j) {
153 tmp[j] = extQuants.velocityGrad(axisIdx)[j];
154 tmp[j] += extQuants.velocityGrad(j)[axisIdx];
157 flux[momentum0EqIdx + axisIdx] = -mu * (tmp * normal);
162 if (enableNavierTerm_()) {
163 flux[momentum0EqIdx + axisIdx] +=
164 up.velocity()[axisIdx] * (up.velocity() * normal);
168 EnergyModule::addAdvectiveFlux(flux, elemCtx, scvfIdx, timeIdx);
175 int scvfIdx,
int timeIdx)
const
178 EnergyModule::addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx);
185 const ElementContext &elemCtx,
189 assert(timeIdx == 0);
190 const auto &intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx);
193 Valgrind::SetUndefined(source);
194 elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx);
195 Valgrind::CheckDefined(source);
197 const auto &gravity = intQuants.gravity();
198 const auto &gradp = intQuants.pressureGradient();
199 Scalar density = intQuants.fluidState().density(phaseIdx);
201 assert(std::isfinite(gradp.two_norm()));
202 assert(std::isfinite(density));
203 assert(std::isfinite(source.two_norm()));
205 Valgrind::CheckDefined(gravity);
206 Valgrind::CheckDefined(gradp);
207 Valgrind::CheckDefined(density);
210 for (
int axisIdx = 0; axisIdx < dimWorld; ++axisIdx)
211 source[momentum0EqIdx + axisIdx] +=
212 gradp[axisIdx] - density * gravity[axisIdx];
216 static bool enableNavierTerm_()
Declares the properties required by the Stokes model.
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
The local residual function for problems using the Stokes model.
Definition: stokeslocalresidual.hh:47
void computeStorage(EqVector &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: stokeslocalresidual.hh:86
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
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: stokeslocalresidual.hh:114
static void registerParameters()
Register all run-time parameters for the local residual.
Definition: stokeslocalresidual.hh:75
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:54
Definition: baseauxiliarymodule.hh:35
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:64
Contains the intensive quantities of the Stokes model.
Contains the data which is required to calculate the mass and momentum fluxes over the face of a sub-...
void addAdvectiveFlux(RateVector &flux, const ElementContext &elemCtx, int scvfIdx, int timeIdx) const
Add the advective mass flux at a given flux integration point.
Definition: stokeslocalresidual.hh:127
void addDiffusiveFlux(RateVector &flux, const ElementContext &elemCtx, int scvfIdx, int timeIdx) const
Adds the diffusive flux at a given flux integration point.
Definition: stokeslocalresidual.hh:174
void computeSource(RateVector &source, const ElementContext &elemCtx, int dofIdx, int timeIdx) const
Calculate the source term of the equation.
Definition: stokeslocalresidual.hh:184
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95