12#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_LOCAL_RESIDUAL_HH
13#define DUMUX_NAVIERSTOKES_MOMENTUM_LOCAL_RESIDUAL_HH
20#include <dune/common/hybridutilities.hh>
28template<
class TypeTag>
37 using GridVolumeVariables =
typename GridVariables::GridVolumeVariables;
38 using ElementVolumeVariables =
typename GridVolumeVariables::LocalView;
39 using VolumeVariables =
typename GridVolumeVariables::VolumeVariables;
41 using GridFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache;
42 using ElementFluxVariablesCache =
typename GridFluxVariablesCache::LocalView;
48 using FVElementGeometry =
typename GridGeometry::LocalView;
49 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
50 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
51 using GridView =
typename GridGeometry::GridView;
52 using Element =
typename GridView::template Codim<0>::Entity;
62 static constexpr auto dim = GridView::dimension;
66 using ParentType::ParentType;
79 const SubControlVolume& scv,
80 const VolumeVariables& volVars,
81 const bool isPreviousStorage =
false)
const
83 const auto& element =
problem.gridGeometry().element(scv.elementIndex());
84 return problem.density(element, scv, isPreviousStorage) * volVars.velocity();
101 const Element& element,
102 const FVElementGeometry& fvGeometry,
103 const ElementVolumeVariables& elemVolVars,
104 const SubControlVolume& scv)
const
107 source +=
problem.gravity()[scv.dofAxis()] *
problem.density(element, scv);
112 if constexpr (dim == 2 && isRotationalExtrusion<Extrusion>)
114 if (scv.dofAxis() == Extrusion::radialAxis)
116 const auto r = scv.center()[scv.dofAxis()] - fvGeometry.gridGeometry().bBoxMin()[scv.dofAxis()];
117 const auto& scvf = (*scvfs(fvGeometry, scv).begin());
120 source -= -2.0*
problem.effectiveViscosity(element, fvGeometry, scvf) * elemVolVars[scv].velocity() / (r*r);
125 source +=
problem.pressure(element, fvGeometry, scvf)/r;
144 const Element& element,
145 const FVElementGeometry& fvGeometry,
146 const ElementVolumeVariables& elemVolVars,
147 const SubControlVolumeFace& scvf,
148 const ElementFluxVariablesCache& elemFluxVarsCache,
149 const ElementBoundaryTypes& elemBcTypes)
const
151 FluxVariables fluxVars(
problem, element, fvGeometry, scvf, elemVolVars, elemFluxVarsCache, elemBcTypes);
153 NumEqVector flux(0.0);
154 flux += fluxVars.advectiveMomentumFlux();
155 flux += fluxVars.diffusiveMomentumFlux();
156 flux += fluxVars.pressureContribution();
163 const Element& element,
164 const FVElementGeometry& fvGeometry,
165 const ElementVolumeVariables& elemVolVars,
166 const ElementBoundaryTypes& elemBcTypes,
167 const ElementFluxVariablesCache& elemFluxVarsCache,
168 const SubControlVolumeFace& scvf)
const
170 if (
const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); scv.boundary())
172 const auto& frontalScvfOnBoundary = fvGeometry.frontalScvfOnBoundary(scv);
173 const auto& bcTypes = elemBcTypes[frontalScvfOnBoundary.localIndex()];
174 if (bcTypes.isDirichlet(scv.dofAxis()))
180 if (elemBcTypes.hasNeumann())
181 return this->
asImp().maybeHandleNeumannBoundary(problem, element, fvGeometry, elemVolVars, elemBcTypes, elemFluxVarsCache, scvf);
183 return this->
asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache, elemBcTypes);
189 const Element& element,
190 const FVElementGeometry& fvGeometry,
191 const ElementVolumeVariables& elemVolVars,
192 const ElementBoundaryTypes& elemBcTypes,
193 const ElementFluxVariablesCache& elemFluxVarsCache,
194 const SubControlVolumeFace& scvf)
const
198 std::decay_t<
decltype(
199 problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf)
200 )>::size() == ModelTraits::dim(),
201 "The momentum model expects problem.neumann to return a vector of size dim. "
202 "When in doubt you should be able to use 'using NumEqVector = typename ParentType::NumEqVector;'."
204 assert(elemBcTypes.hasNeumann());
206 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
225 if (scvf.boundary() && scvf.isFrontal())
227 const auto& bcTypes = elemBcTypes[scvf.localIndex()];
228 if (bcTypes.hasNeumann() && bcTypes.isNeumann(scv.dofAxis()))
230 const auto neumannFluxes =
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
231 return neumannFluxes[scv.dofAxis()] * Extrusion::area(fvGeometry, scvf) * elemVolVars[scv].extrusionFactor();
234 else if (scvf.isLateral())
258 const auto& frontalScvfOnBoundary = fvGeometry.frontalScvfOnBoundary(scv);
259 assert(frontalScvfOnBoundary.isFrontal() && frontalScvfOnBoundary.boundary());
260 const auto& bcTypes = elemBcTypes[frontalScvfOnBoundary.localIndex()];
261 if (bcTypes.hasNeumann() && bcTypes.isNeumann(scvf.normalAxis()))
263 const auto neumannFluxes =
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
264 return neumannFluxes[scv.dofAxis()] * Extrusion::area(fvGeometry, scvf) * elemVolVars[scv].extrusionFactor();
268 else if (scvf.boundary())
289 assert(scvf.isLateral());
290 const auto& bcTypes = elemBcTypes[scvf.localIndex()];
291 if (bcTypes.hasNeumann() && bcTypes.isNeumann(scv.dofAxis()))
293 const auto neumannFluxes =
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
294 return neumannFluxes[scv.dofAxis()] * Extrusion::area(fvGeometry, scvf) * elemVolVars[scv].extrusionFactor();
299 return this->
asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache, elemBcTypes);
304 {
return *
static_cast<Implementation *
>(
this); }
308 {
return *
static_cast<const Implementation *
>(
this); }
The element-wise residual for finite volume schemes.
Definition: fvlocalresidual.hh:35
Implementation & asImp()
Definition: fvlocalresidual.hh:487
const Problem & problem() const
the problem
Definition: fvlocalresidual.hh:472
The element-wise residual for the box scheme.
Definition: fclocalresidual.hh:34
NumEqVector computeSource(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Calculate the source term of the equation.
Definition: fclocalresidual.hh:100
Element-wise calculation of the Navier-Stokes residual for models using the staggered discretization.
Definition: freeflow/navierstokes/momentum/localresidual.hh:31
NumEqVector maybeHandleNeumannBoundary(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementBoundaryTypes &elemBcTypes, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Definition: freeflow/navierstokes/momentum/localresidual.hh:188
NumEqVector computeSource(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Calculate the source term of the equation.
Definition: freeflow/navierstokes/momentum/localresidual.hh:100
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache, const ElementBoundaryTypes &elemBcTypes) const
Evaluates the mass flux over a face of a sub control volume.
Definition: freeflow/navierstokes/momentum/localresidual.hh:143
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: freeflow/navierstokes/momentum/localresidual.hh:303
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: freeflow/navierstokes/momentum/localresidual.hh:307
NumEqVector maybeHandleDirichletBoundary(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementBoundaryTypes &elemBcTypes, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Definition: freeflow/navierstokes/momentum/localresidual.hh:162
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars, const bool isPreviousStorage=false) const
Calculate the source term of the equation.
Definition: freeflow/navierstokes/momentum/localresidual.hh:78
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
Calculates the element-wise residual for the box scheme.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:34
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
constexpr FCStaggered fcstaggered
Definition: method.hh:151
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
A helper to deduce a vector with the same size as numbers of equations.