3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/navierstokes/momentum/diamond/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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_NAVIERSTOKES_MOMENTUM_DIAMOND_LOCAL_RESIDUAL_HH
25#define DUMUX_NAVIERSTOKES_MOMENTUM_DIAMOND_LOCAL_RESIDUAL_HH
26
27#include <dune/common/hybridutilities.hh>
28
31
35
37
38namespace Dumux {
39
44template<class TypeTag>
46: public CVFELocalResidual<TypeTag>
47{
49
51
52 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
53 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
54 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
55
56 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
57 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
58
63 using FVElementGeometry = typename GridGeometry::LocalView;
64 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
65 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
66 using GridView = typename GridGeometry::GridView;
67 using Element = typename GridView::template Codim<0>::Entity;
71 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
72
73 using Extrusion = Extrusion_t<GridGeometry>;
74
76
77 static constexpr auto dim = GridView::dimension;
78
81
82public:
84 using ParentType::ParentType;
85
95 NumEqVector computeStorage(const Problem& problem,
96 const FVElementGeometry& fvGeometry,
97 const SubControlVolume& scv,
98 const VolumeVariables& volVars,
99 const bool isPreviousStorage) const
100 {
101 return problem.density(fvGeometry.element(), fvGeometry, scv, isPreviousStorage) * volVars.velocity();
102 }
103
115 NumEqVector computeSource(const Problem& problem,
116 const Element& element,
117 const FVElementGeometry& fvGeometry,
118 const ElementVolumeVariables& elemVolVars,
119 const SubControlVolume& scv) const
120 {
121 NumEqVector source = ParentType::computeSource(problem, element, fvGeometry, elemVolVars, scv);
122
123 // add rho*g (note that gravity might be zero in case it's disabled in the problem)
124 source += problem.density(element, fvGeometry, scv) * problem.gravity();
125
126 // Axisymmetric problems in 2D feature an extra source terms arising from the transformation to cylindrical coordinates.
127 // See Ferziger/Peric: Computational methods for Fluid Dynamics (2020)
128 // https://doi.org/10.1007/978-3-319-99693-6
129 // Chapter 9.9 and Eq. (9.81) and comment on finite volume methods
130 if constexpr (dim == 2 && isRotationalExtrusion<Extrusion>)
131 {
132 // the radius with respect to the rotation axis
133 const auto r = scv.center()[Extrusion::radialAxis] - fvGeometry.gridGeometry().bBoxMin()[Extrusion::radialAxis];
134
135 // The velocity term is new with respect to Cartesian coordinates and handled below as a source term
136 // it only enters the balance of the momentum balance in radial direction
137 source[Extrusion::radialAxis] += -2.0*problem.effectiveViscosity(element, fvGeometry, scv)
138 * elemVolVars[scv].velocity(Extrusion::radialAxis) / (r*r);
139
140 // Pressure term (needed because we incorporate pressure in terms of a surface integral).
141 // grad(p) becomes div(pI) + (p/r)*n_r in cylindrical coordinates. The second term
142 // is new with respect to Cartesian coordinates and handled below as a source term.
143 source[Extrusion::radialAxis] += problem.pressure(element, fvGeometry, scv)/r;
144 }
145
146 return source;
147 }
148
159 NumEqVector computeFlux(const Problem& problem,
160 const Element& element,
161 const FVElementGeometry& fvGeometry,
162 const ElementVolumeVariables& elemVolVars,
163 const SubControlVolumeFace& scvf,
164 const ElementFluxVariablesCache& elemFluxVarsCache) const
165 {
166 FluxContext context(problem, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
167 FluxHelper fluxHelper;
168
169 NumEqVector flux(0.0);
170 flux += fluxHelper.advectiveMomentumFlux(context);
171 flux += fluxHelper.diffusiveMomentumFlux(context);
172 flux += fluxHelper.pressureContribution(context);
173 return flux;
174 }
175};
176
177} // end namespace Dumux
178
179#endif
Calculates the element-wise residual for control-volume finite element schemes.
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
The element-wise residual for control-volume finite element schemes.
Definition: cvfelocalresidual.hh:72
The element-wise residual for finite volume schemes.
Definition: fvlocalresidual.hh:47
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: fvlocalresidual.hh:220
const Problem & problem() const
the problem
Definition: fvlocalresidual.hh:484
Context for computing fluxes.
Definition: flux.hh:51
The flux variables class for the Navier-Stokes model using control-volume finite element schemes.
Definition: flux.hh:103
NumEqVector advectiveMomentumFlux(const Context &context) const
Returns the diffusive momentum flux due to viscous forces.
Definition: flux.hh:121
NumEqVector diffusiveMomentumFlux(const Context &context) const
Returns the diffusive momentum flux due to viscous forces.
Definition: flux.hh:155
NumEqVector pressureContribution(const Context &context) const
Definition: flux.hh:194
Element-wise calculation of the Navier-Stokes residual for models using the diamond discretization.
Definition: freeflow/navierstokes/momentum/diamond/localresidual.hh:47
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the mass flux over a face of a sub control volume.
Definition: freeflow/navierstokes/momentum/diamond/localresidual.hh:159
NumEqVector computeStorage(const Problem &problem, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, const VolumeVariables &volVars, const bool isPreviousStorage) const
Calculate the source term of the equation.
Definition: freeflow/navierstokes/momentum/diamond/localresidual.hh:95
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/diamond/localresidual.hh:115
Declares all properties used in Dumux.