version 3.11-dev
freeflow/navierstokes/mass/1p/localresidual.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
13#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
14
15#include <type_traits>
16
23
24namespace Dumux {
25
31template<class Problem>
33: public std::false_type
34{};
35
40template<class TypeTag>
43{
46 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
47 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
48 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
49
50 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
51 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
52
56 using FVElementGeometry = typename GridGeometry::LocalView;
57 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
58 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
59 using GridView = typename GridGeometry::GridView;
60 using Element = typename GridView::template Codim<0>::Entity;
64
65 using Extrusion = Extrusion_t<GridGeometry>;
66
67public:
69 using ParentType::ParentType;
70
74 NumEqVector computeStorage(const Problem& problem,
75 const SubControlVolume& scv,
76 const VolumeVariables& volVars) const
77 {
78 NumEqVector storage(0.0);
79 storage[ModelTraits::Indices::conti0EqIdx] = volVars.density();
80
81 // consider energy storage for non-isothermal models
82 if constexpr (ModelTraits::enableEnergyBalance())
83 storage[ModelTraits::Indices::energyEqIdx] = volVars.density() * volVars.internalEnergy();
84
85 return storage;
86 }
87
97 NumEqVector storageIntegral(const FVElementGeometry& fvGeometry,
98 const ElementVolumeVariables& elemVars,
99 const SubControlVolume& scv,
100 bool isPreviousTimeLevel) const
101 {
102 const auto& volVars = elemVars[scv];
103 // We apply mass lumping here
104 NumEqVector storage(0.0);
105 storage[ModelTraits::Indices::conti0EqIdx] = volVars.density();
106
107 // consider energy storage for non-isothermal models
108 if constexpr (ModelTraits::enableEnergyBalance())
109 storage[ModelTraits::Indices::energyEqIdx] = volVars.density() * volVars.internalEnergy();
110
111 storage *= Extrusion::volume(fvGeometry, scv) * volVars.extrusionFactor();
112
113 return storage;
114 }
115
124 NumEqVector sourceIntegral(const FVElementGeometry& fvGeometry,
125 const ElementVolumeVariables& elemVars,
126 const SubControlVolume& scv) const
127 {
128 const auto& problem = this->asImp().problem();
129
130 NumEqVector source(0.0);
131 for (const auto& qpData : CVFE::quadratureRule(fvGeometry, scv))
132 source += qpData.weight() * problem.source(fvGeometry, elemVars, qpData.ipData());
133
134 // ToDo: point source data with ipData
135 // add contribution from possible point sources
136 if (!problem.pointSourceMap().empty())
137 source += Extrusion::volume(fvGeometry, scv) * problem.scvPointSources(fvGeometry.element(), fvGeometry, elemVars, scv);
138
139 return source * elemVars[scv].extrusionFactor();
140 }
141
152 NumEqVector computeFlux(const Problem& problem,
153 const Element& element,
154 const FVElementGeometry& fvGeometry,
155 const ElementVolumeVariables& elemVolVars,
156 const SubControlVolumeFace& scvf,
157 const ElementFluxVariablesCache& elemFluxVarsCache) const
158 {
159 FluxVariables fluxVars;
160 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
161 auto flux = fluxVars.flux(0);
162
163 // the auxiliary flux is enabled if the trait is specialized for the problem
164 // this can be used, for example, to implement flux stabilization terms
166 flux += problem.auxiliaryFlux(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
167
168 return flux;
169 }
170
180 NumEqVector fluxIntegral(const FVElementGeometry& fvGeometry,
181 const ElementVolumeVariables& elemVars,
182 const ElementFluxVariablesCache& elemFluxVarsCache,
183 const SubControlVolumeFace& scvf) const
184 {
185 const auto& problem = this->asImp().problem();
186 NumEqVector flux(0.0);
187 for (const auto& qpData : CVFE::quadratureRule(fvGeometry, scvf))
188 {
189 const auto& faceIpData = qpData.ipData();
190 flux += qpData.weight() * (problem.velocity(fvGeometry, faceIpData) * faceIpData.unitOuterNormal());
191 }
192
193 static const auto upwindWeight
194 = getParamFromGroup<Scalar>(this->problem().paramGroup(), "Flux.UpwindWeight", 1.0);
195
196 const auto& insideVars = elemVars[fvGeometry.scv(scvf.insideScvIdx())];
197 const auto& outsideVars = elemVars[fvGeometry.scv(scvf.outsideScvIdx())];
198
199 flux *= (upwindWeight * insideVars.density() + (1.0 - upwindWeight) * outsideVars.density());
200
201 // the auxiliary flux is enabled if the trait is specialized for the problem
202 // this can be used, for example, to implement flux stabilization terms
204 flux += problem.auxiliaryFlux(fvGeometry.element(), fvGeometry, elemVars, elemFluxVarsCache, scvf);
205
206 return flux * insideVars.extrusionFactor();
207 }
208
209};
210
211} // end namespace Dumux
212
213#endif
Element-wise calculation of the Navier-Stokes residual for single-phase flow.
Definition: freeflow/navierstokes/mass/1p/localresidual.hh:43
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, 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:152
NumEqVector storageIntegral(const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVars, const SubControlVolume &scv, bool isPreviousTimeLevel) const
Calculate the storage term of the equation.
Definition: freeflow/navierstokes/mass/1p/localresidual.hh:97
NumEqVector sourceIntegral(const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVars, const SubControlVolume &scv) const
Calculate the source integral.
Definition: freeflow/navierstokes/mass/1p/localresidual.hh:124
NumEqVector fluxIntegral(const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Calculates the flux integral over a face of a sub control volume.
Definition: freeflow/navierstokes/mass/1p/localresidual.hh:180
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Calculate the storage term of the equation.
Definition: freeflow/navierstokes/mass/1p/localresidual.hh:74
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
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:159
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition: quadraturerules.hh:148
Definition: adapt.hh:17
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
typename Detail::DiscretizationDefaultLocalOperator< TypeTag >::type DiscretizationDefaultLocalOperator
Definition: defaultlocaloperator.hh:27
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:34