24#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_LOCAL_RESIDUAL_HH
25#define DUMUX_NAVIERSTOKES_MOMENTUM_LOCAL_RESIDUAL_HH
32#include <dune/common/hybridutilities.hh>
40template<
class TypeTag>
49 using GridVolumeVariables =
typename GridVariables::GridVolumeVariables;
50 using ElementVolumeVariables =
typename GridVolumeVariables::LocalView;
51 using VolumeVariables =
typename GridVolumeVariables::VolumeVariables;
53 using GridFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache;
54 using ElementFluxVariablesCache =
typename GridFluxVariablesCache::LocalView;
60 using FVElementGeometry =
typename GridGeometry::LocalView;
61 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
62 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
63 using GridView =
typename GridGeometry::GridView;
64 using Element =
typename GridView::template Codim<0>::Entity;
74 static constexpr auto dim = GridView::dimension;
78 using ParentType::ParentType;
91 const SubControlVolume& scv,
92 const VolumeVariables& volVars,
93 const bool isPreviousStorage =
false)
const
95 const auto& element =
problem.gridGeometry().element(scv.elementIndex());
96 return problem.density(element, scv, isPreviousStorage) * volVars.velocity();
113 const Element& element,
114 const FVElementGeometry& fvGeometry,
115 const ElementVolumeVariables& elemVolVars,
116 const SubControlVolume& scv)
const
119 source +=
problem.gravity()[scv.dofAxis()] *
problem.density(element, scv);
124 if constexpr (dim == 2 && isRotationalExtrusion<Extrusion>)
126 if (scv.dofAxis() == Extrusion::radialAxis)
128 const auto r = scv.center()[scv.dofAxis()] - fvGeometry.gridGeometry().bBoxMin()[scv.dofAxis()];
129 const auto& scvf = (*scvfs(fvGeometry, scv).begin());
132 source -= -2.0*
problem.effectiveViscosity(element, fvGeometry, scvf) * elemVolVars[scv].velocity() / (r*r);
137 source +=
problem.pressure(element, fvGeometry, scvf)/r;
156 const Element& element,
157 const FVElementGeometry& fvGeometry,
158 const ElementVolumeVariables& elemVolVars,
159 const SubControlVolumeFace& scvf,
160 const ElementFluxVariablesCache& elemFluxVarsCache,
161 const ElementBoundaryTypes& elemBcTypes)
const
163 FluxVariables fluxVars(
problem, element, fvGeometry, scvf, elemVolVars, elemFluxVarsCache, elemBcTypes);
165 NumEqVector flux(0.0);
166 flux += fluxVars.advectiveMomentumFlux();
167 flux += fluxVars.diffusiveMomentumFlux();
168 flux += fluxVars.pressureContribution();
175 const Element& element,
176 const FVElementGeometry& fvGeometry,
177 const ElementVolumeVariables& elemVolVars,
178 const ElementBoundaryTypes& elemBcTypes,
179 const ElementFluxVariablesCache& elemFluxVarsCache,
180 const SubControlVolumeFace& scvf)
const
182 if (
const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); scv.boundary())
184 const auto& frontalScvfOnBoundary = fvGeometry.frontalScvfOnBoundary(scv);
185 const auto& bcTypes = elemBcTypes[frontalScvfOnBoundary.localIndex()];
186 if (bcTypes.isDirichlet(scv.dofAxis()))
192 if (elemBcTypes.hasNeumann())
193 return this->
asImp().maybeHandleNeumannBoundary(problem, element, fvGeometry, elemVolVars, elemBcTypes, elemFluxVarsCache, scvf);
195 return this->
asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache, elemBcTypes);
201 const Element& element,
202 const FVElementGeometry& fvGeometry,
203 const ElementVolumeVariables& elemVolVars,
204 const ElementBoundaryTypes& elemBcTypes,
205 const ElementFluxVariablesCache& elemFluxVarsCache,
206 const SubControlVolumeFace& scvf)
const
210 std::decay_t<
decltype(
211 problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf)
212 )>::size() == ModelTraits::dim(),
213 "The momentum model expects problem.neumann to return a vector of size dim. "
214 "When in doubt you should be able to use 'using NumEqVector = typename ParentType::NumEqVector;'."
216 assert(elemBcTypes.hasNeumann());
218 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
237 if (scvf.boundary() && scvf.isFrontal())
239 const auto& bcTypes = elemBcTypes[scvf.localIndex()];
240 if (bcTypes.hasNeumann() && bcTypes.isNeumann(scv.dofAxis()))
242 const auto neumannFluxes =
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
243 return neumannFluxes[scv.dofAxis()] * Extrusion::area(fvGeometry, scvf) * elemVolVars[scv].extrusionFactor();
246 else if (scvf.isLateral())
270 const auto& frontalScvfOnBoundary = fvGeometry.frontalScvfOnBoundary(scv);
271 assert(frontalScvfOnBoundary.isFrontal() && frontalScvfOnBoundary.boundary());
272 const auto& bcTypes = elemBcTypes[frontalScvfOnBoundary.localIndex()];
273 if (bcTypes.hasNeumann() && bcTypes.isNeumann(scvf.normalAxis()))
275 const auto neumannFluxes =
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
276 return neumannFluxes[scv.dofAxis()] * Extrusion::area(fvGeometry, scvf) * elemVolVars[scv].extrusionFactor();
280 else if (scvf.boundary())
301 assert(scvf.isLateral());
302 const auto& bcTypes = elemBcTypes[scvf.localIndex()];
303 if (bcTypes.hasNeumann() && bcTypes.isNeumann(scv.dofAxis()))
305 const auto neumannFluxes =
problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
306 return neumannFluxes[scv.dofAxis()] * Extrusion::area(fvGeometry, scvf) * elemVolVars[scv].extrusionFactor();
311 return this->
asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache, elemBcTypes);
316 {
return *
static_cast<Implementation *
>(
this); }
320 {
return *
static_cast<const Implementation *
>(
this); }
Calculates the element-wise residual for the box scheme.
A helper to deduce a vector with the same size as numbers of equations.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
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:46
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
constexpr FCStaggered fcstaggered
Definition: method.hh:140
The element-wise residual for the box scheme.
Definition: fclocalresidual.hh:46
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:112
The element-wise residual for finite volume schemes.
Definition: fvlocalresidual.hh:47
Implementation & asImp()
Definition: fvlocalresidual.hh:499
const Problem & problem() const
the problem
Definition: fvlocalresidual.hh:484
Element-wise calculation of the Navier-Stokes residual for models using the staggered discretization.
Definition: freeflow/navierstokes/momentum/localresidual.hh:43
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:200
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:112
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:155
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: freeflow/navierstokes/momentum/localresidual.hh:315
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: freeflow/navierstokes/momentum/localresidual.hh:319
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:174
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:90
Declares all properties used in Dumux.