12#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
13#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
20#include <dumux/common/concepts/variables_.hh>
33template<
class Problem>
35:
public std::false_type
42template<
class TypeTag>
48 using GridVariablesCache = Concept::GridVariablesCache_t<GridVariables>;
49 using ElementVariables =
typename GridVariablesCache::LocalView;
50 using Variables = Concept::Variables_t<GridVariables>;
55 using ElementDiscretization =
typename GridGeometry::LocalView;
56 using SubControlVolume =
typename ElementDiscretization::SubControlVolume;
57 using SubControlVolumeFace =
typename ElementDiscretization::SubControlVolumeFace;
58 using GridView =
typename GridGeometry::GridView;
59 using Element =
typename GridView::template Codim<0>::Entity;
68 using ParentType::ParentType;
73 template<
class ElementRes
idualVector>
75 const Problem& problem,
76 const Element& element,
77 const ElementDiscretization& elemDisc,
78 const ElementVariables& elemVars,
79 bool isPreviousTimeLevel)
const
87 template<
class ElementRes
idualVector>
89 const Problem& problem,
90 const Element& element,
91 const ElementDiscretization& elemDisc,
92 const ElementVariables& elemVars)
const
101 const SubControlVolume& scv,
102 const Variables& vars)
const
104 NumEqVector storage(0.0);
105 storage[ModelTraits::Indices::conti0EqIdx] = vars.density();
108 if constexpr (ModelTraits::enableEnergyBalance())
109 storage[ModelTraits::Indices::energyEqIdx] = vars.density() * vars.internalEnergy();
124 const ElementVariables& elemVars,
125 const SubControlVolume& scv,
126 bool isPreviousTimeLevel)
const
128 const auto& vars = elemVars[scv];
130 NumEqVector storage(0.0);
131 storage[ModelTraits::Indices::conti0EqIdx] = vars.density();
134 if constexpr (ModelTraits::enableEnergyBalance())
135 storage[ModelTraits::Indices::energyEqIdx] = vars.density() * vars.internalEnergy();
137 storage *= Extrusion::volume(elemDisc, scv) * vars.extrusionFactor();
152 template<
class ElementFluxVariablesCache>
154 const Element& element,
155 const ElementDiscretization& elemDisc,
156 const ElementVariables& elemVars,
157 const SubControlVolumeFace& scvf,
158 const ElementFluxVariablesCache& elemFluxVarsCache)
const
161 FluxVariables fluxVars;
162 fluxVars.init(problem, element, elemDisc, elemVars, scvf, elemFluxVarsCache);
163 auto flux = fluxVars.flux(0);
168 flux += problem.auxiliaryFlux(element, elemDisc, elemVars, elemFluxVarsCache, scvf);
182 const ElementVariables& elemVars,
183 const SubControlVolumeFace& scvf)
const
185 static_assert(!ModelTraits::enableEnergyBalance(),
186 "The flux integral does not include the energy balance");
188 const auto& problem = this->asImp().problem();
189 Scalar volumeFlux = 0.0;
192 const auto& faceIpData = qpData.ipData();
193 volumeFlux += qpData.weight() * (problem.velocity(elemDisc, faceIpData) * faceIpData.unitOuterNormal());
196 static const auto upwindWeight
199 const auto& insideVars = elemVars[elemDisc.scv(scvf.insideScvIdx())];
200 const auto& outsideVars = elemVars[elemDisc.scv(scvf.outsideScvIdx())];
201 const bool insideIsUpwind = volumeFlux > 0.0;
202 const auto& upwindVars = insideIsUpwind ? insideVars : outsideVars;
203 const auto& downwindVars = insideIsUpwind ? outsideVars : insideVars;
205 NumEqVector flux(0.0);
206 flux[ModelTraits::Indices::conti0EqIdx]
207 = volumeFlux * (upwindWeight * upwindVars.density() + (1.0 - upwindWeight) * downwindVars.density());
212 flux += problem.auxiliaryFlux(elemDisc.element(), elemDisc, elemVars, scvf);
214 return flux * insideVars.extrusionFactor();
Helper class for evaluating FE-based local residuals.
Definition mass/1p/felocalresidual.hh:35
static void addStorageTerms(ResidualVector &storage, const Problem &problem, const ElementDiscretization &elemDisc, const ElementVariables &elemVars, const bool isPreviousTimeLevel)
Definition mass/1p/felocalresidual.hh:47
static void addFluxAndSourceTerms(ResidualVector &residual, const Problem &problem, const ElementDiscretization &elemDisc, const ElementVariables &elemVars)
Definition mass/1p/felocalresidual.hh:89
Element-wise calculation of the Navier-Stokes residual for single-phase flow.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:45
NumEqVector fluxIntegral(const ElementDiscretization &elemDisc, const ElementVariables &elemVars, const SubControlVolumeFace &scvf) const
Calculates the flux integral over a face of a sub control volume.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:181
NumEqVector computeFlux(const Problem &problem, const Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluate the mass flux over a face of a sub control volume.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:153
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const Variables &vars) const
Calculate the storage term of the equation.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:100
void addToElementFluxAndSourceResidual(ElementResidualVector &residual, const Problem &problem, const Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars) const
Add flux and source residual contribution for non-CV local dofs.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:88
void addToElementStorage(ElementResidualVector &storage, const Problem &problem, const Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars, bool isPreviousTimeLevel) const
Add the storage of non-CV local dofs at one time level.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:74
NumEqVector storageIntegral(const ElementDiscretization &elemDisc, const ElementVariables &elemVars, const SubControlVolume &scv, bool isPreviousTimeLevel) const
Calculate the storage term of the equation.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:123
Defines all properties used in Dumux.
The default local operator than can be specialized for each discretization scheme.
Helper classes to compute the integration elements.
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
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:165
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
Element-wise calculation of the Navier-Stokes mass residual for single-phase flow when using fe discr...
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition quadraturerules.hh:160
typename Detail::DiscretizationDefaultLocalOperator< TypeTag >::type DiscretizationDefaultLocalOperator
Definition defaultlocaloperator.hh:26
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:257
A helper to deduce a vector with the same size as numbers of equations.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Quadrature rules over sub-control volumes and sub-control volume faces.
Traits class to be specialized for problems to add auxiliary fluxes.
Definition freeflow/navierstokes/mass/1p/localresidual.hh:36