12#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_CVFE_LOCAL_RESIDUAL_HH
13#define DUMUX_NAVIERSTOKES_MOMENTUM_CVFE_LOCAL_RESIDUAL_HH
15#include <dune/common/hybridutilities.hh>
16#include <dune/geometry/quadraturerules.hh>
20#include <dumux/common/concepts/variables_.hh>
21#include <dumux/common/typetraits/localdofs_.hh>
39template<
class P,
class FVG,
class EV,
class IPD>
41 std::declval<P>().source(std::declval<FVG>(), std::declval<EV>(), std::declval<IPD>())
44template<
class P,
class FVG,
class EV,
class IPD>
46{
return Dune::Std::is_detected<SourceWithIpDataInterface, P, FVG, EV, IPD>::value; }
54template<
class TypeTag>
62 using GridVariablesCache = Concept::GridVariablesCache_t<GridVariables>;
63 using ElementVariables =
typename GridVariablesCache::LocalView;
64 using Variables = Concept::Variables_t<GridVariables>;
69 using FVElementGeometry =
typename GridGeometry::LocalView;
70 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
71 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
72 using GridView =
typename GridGeometry::GridView;
73 using Element =
typename GridView::template Codim<0>::Entity;
83 static constexpr auto dim = GridView::dimension;
85 using LocalBasis =
typename GridGeometry::FeCache::FiniteElementType::Traits::LocalBasisType;
86 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
96 using ParentType::ParentType;
109 const FVElementGeometry& fvGeometry,
110 const SubControlVolume& scv,
111 const Variables& vars,
112 const bool isPreviousStorage)
const
114 return problem.density(fvGeometry.element(), fvGeometry, ipData(fvGeometry, scv), isPreviousStorage) * vars.velocity();
127 const ElementVariables& elemVars,
128 const SubControlVolume& scv,
129 bool isPreviousTimeLevel)
const
131 const auto& vars = elemVars[scv];
133 NumEqVector storage = this->asImp().problem().density(fvGeometry.element(), fvGeometry, ipData(fvGeometry, scv), isPreviousTimeLevel)
136 storage *= Extrusion::volume(fvGeometry, scv) * vars.extrusionFactor();
153 const Element& element,
154 const FVElementGeometry& fvGeometry,
155 const ElementVariables& elemVars,
156 const SubControlVolume& scv)
const
162 source = problem.source(fvGeometry, elemVars, ipData(fvGeometry, scv.center()));
166 if (!problem.pointSourceMap().empty())
167 source += problem.scvPointSources(element, fvGeometry, elemVars, scv);
170 source = ParentType::computeSource(problem, element, fvGeometry, elemVars, scv);
174 const auto& data = ipData(fvGeometry, scv);
175 source += problem.density(element, fvGeometry, data) * problem.gravity();
184 const auto r = scv.center()[Extrusion::radialAxis] - fvGeometry.gridGeometry().bBoxMin()[Extrusion::radialAxis];
188 source[Extrusion::radialAxis] += -2.0*problem.effectiveViscosity(element, fvGeometry, data)
189 * elemVars[scv].velocity(Extrusion::radialAxis) / (r*r);
194 source[Extrusion::radialAxis] += problem.pressure(element, fvGeometry, data)/r;
209 const ElementVariables& elemVars,
210 const SubControlVolume& scv)
const
214 const auto& problem = this->asImp().problem();
216 NumEqVector source(0.0);
219 source += qpData.weight() * (problem.source(fvGeometry, elemVars, qpData.ipData())
220 + problem.density(fvGeometry.element(), fvGeometry, qpData.ipData()) * problem.gravity());
223 source *= elemVars[scv].extrusionFactor();
226 const auto& pointSources = problem.pointSources();
227 if (!pointSources.empty())
228 for (
const auto& context : pointSources.contexts(fvGeometry, scv))
230 auto psValues = pointSources.eval(fvGeometry, elemVars, context);
247 template<
class ElementFluxVariablesCache>
249 const Element& element,
250 const FVElementGeometry& fvGeometry,
251 const ElementVariables& elemVars,
252 const SubControlVolumeFace& scvf,
253 const ElementFluxVariablesCache& elemFluxVarsCache)
const
256 FluxContext context(problem, fvGeometry, elemVars, elemFluxVarsCache, scvf);
257 FluxHelper fluxHelper;
259 NumEqVector flux(0.0);
275 const ElementVariables& elemVars,
276 const SubControlVolumeFace& scvf)
const
278 const auto& problem = this->asImp().problem();
280 NumEqVector flux(0.0);
281 GlobalPosition velIntegral(0.0);
282 FluxFunctionHelper fluxFunctionHelper;
287 const auto& ipCache = cache(elemVars, qpData.ipData());
288 FluxFunctionContext context(this->problem(), fvGeometry, elemVars, ipCache);
290 velIntegral += context.velocity() * qpData.weight();
296 flux *= elemVars[fvGeometry.scv(scvf.insideScvIdx())].extrusionFactor();
302 const Problem& problem,
303 const Element& element,
304 const FVElementGeometry& fvGeometry,
305 const ElementVariables& prevElemVolVars,
306 const ElementVariables& curElemVolVars)
const
309 residual, problem, fvGeometry, prevElemVolVars, curElemVolVars, this->timeLoop().timeStepSize()
314 const Problem& problem,
315 const Element& element,
316 const FVElementGeometry& fvGeometry,
317 const ElementVariables& elemVars)
const
320 residual, problem, fvGeometry, elemVars
Boundary flag to store e.g. in sub control volume faces.
An interpolation point related to an element that includes global and local positions.
Definition cvfe/interpolationpointdata.hh:31
Element-wise calculation of the Navier-Stokes residual for models using CVFE discretizations.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:57
NumEqVector sourceIntegral(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolume &scv) const
Calculate the source integral.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:208
NumEqVector computeSource(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolume &scv) const
Calculate the source term of the equation.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:152
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the mass flux over a face of a sub control volume.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:248
NumEqVector fluxIntegral(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolumeFace &scvf) const
Calculates the flux integral over a sub control volume face.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:274
NumEqVector computeStorage(const Problem &problem, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, const Variables &vars, const bool isPreviousStorage) const
Calculate the storage term of the equation.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:108
void addToElementStorageResidual(ElementResidualVector &residual, const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVariables &prevElemVolVars, const ElementVariables &curElemVolVars) const
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:301
typename ParentType::ElementResidualVector ElementResidualVector
Use the parent type's constructor.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:95
NumEqVector storageIntegral(const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolume &scv, bool isPreviousTimeLevel) const
Calculate the storage integral.
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:126
void addToElementFluxAndSourceResidual(ElementResidualVector &residual, const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars) const
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:313
Helper class for evaluating FE-based local residuals.
Definition felocalresidual.hh:31
static void addFluxAndSourceTerms(ResidualVector &residual, const Problem &problem, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars)
Add flux and source residual contribution for non-CV local dofs.
Definition felocalresidual.hh:106
static void addStorageTerms(ResidualVector &residual, const Problem &problem, const FVElementGeometry &fvGeometry, const ElementVariables &prevElemVars, const ElementVariables &curElemVars, const Scalar timeStepSize)
Add storage residual contribution for non-CV local dofs.
Definition felocalresidual.hh:46
The flux variables class for the Navier-Stokes model using control-volume finite element schemes.
Definition flux.hh:178
NumEqVector advectiveMomentumFlux(const Context &context) const
Returns the advective momentum flux.
Definition flux.hh:196
NumEqVector diffusiveMomentumFlux(const Context &context) const
Returns the diffusive momentum flux due to viscous forces.
Definition flux.hh:230
NumEqVector pressureContribution(const Context &context) const
Definition flux.hh:269
Context for computing fluxes.
Definition flux.hh:39
The flux function class for the Navier-Stokes model using control-volume finite element schemes.
Definition flux.hh:299
NumEqVector pressureFluxIntegrand(const Context &context, const IpData &ipData) const
Definition flux.hh:372
NumEqVector diffusiveMomentumFluxIntegrand(const Context &context, const IpData &ipData) const
Returns the diffusive momentum flux due to viscous forces.
Definition flux.hh:345
NumEqVector advectiveMomentumFluxIntegral(const Problem &problem, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, const SubControlVolumeFace &scvf, const VelocityVector &integratedVelocity) const
Returns the advective momentum flux contribution for a given integrated velocity at the face.
Definition flux.hh:318
Context for interpolating data on interpolation points.
Definition flux.hh:99
Defines all properties used in Dumux.
Classes representing interpolation point data for control-volume finite element schemes.
The default local operator than can be specialized for each discretization scheme.
Helper classes to compute the integration elements.
Helper functions for assembling FE-based local residuals.
Shape functions and gradients at an interpolation point.
The flux variables class for the Navier-Stokes model using control-volume finite element schemes.
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.
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition quadraturerules.hh:159
Definition cvfelocalresidual.hh:25
decltype( std::declval< P >().source(std::declval< FVG >(), std::declval< EV >(), std::declval< IPD >())) SourceWithIpDataInterface
helper struct detecting if a problem has new source interface
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:40
constexpr bool hasProblemSourceWithIpDataInterface()
Definition freeflow/navierstokes/momentum/cvfe/localresidual.hh:45
constexpr bool isRotationalExtrusion
Convenience trait to check whether the extrusion is rotational.
Definition extrusion.hh:242
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:236
A helper to deduce a vector with the same size as numbers of equations.
Quadrature rules over sub-control volumes and sub-control volume faces.