3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.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_KEPSILON_STAGGERED_FLUXVARIABLES_HH
25#define DUMUX_KEPSILON_STAGGERED_FLUXVARIABLES_HH
26
27#include <numeric>
35
36namespace Dumux {
37
43// forward declaration
44template<class TypeTag, class BaseFluxVariables, class DiscretizationMethod>
45class KEpsilonFluxVariablesImpl;
46
47template<class TypeTag, class BaseFluxVariables>
48class KEpsilonFluxVariablesImpl<TypeTag, BaseFluxVariables, DiscretizationMethods::Staggered>
49: public BaseFluxVariables
50{
51 using ParentType = BaseFluxVariables;
52
54
55 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
56 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
57 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
58
59 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
60 using FluxVariablesCache = typename GridFluxVariablesCache::FluxVariablesCache;
61
62 using GridFaceVariables = typename GridVariables::GridFaceVariables;
63 using ElementFaceVariables = typename GridFaceVariables::LocalView;
64 using FaceVariables = typename GridFaceVariables::FaceVariables;
65
69 using FVElementGeometry = typename GridGeometry::LocalView;
70 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
71 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
72 using Extrusion = Extrusion_t<GridGeometry>;
73 using GridView = typename GridGeometry::GridView;
75 using Element = typename GridView::template Codim<0>::Entity;
77 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
79
80 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
81 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
82
83public:
84
88 CellCenterPrimaryVariables computeMassFlux(const Problem& problem,
89 const Element &element,
90 const FVElementGeometry& fvGeometry,
91 const ElementVolumeVariables& elemVolVars,
92 const ElementFaceVariables& elemFaceVars,
93 const SubControlVolumeFace &scvf,
94 const FluxVariablesCache& fluxVarsCache)
95 {
96 CellCenterPrimaryVariables flux = ParentType::computeMassFlux(problem, element, fvGeometry,
97 elemVolVars, elemFaceVars, scvf, fluxVarsCache);
98
99 // calculate advective flux
100 auto upwindTermK = [](const auto& volVars)
101 {
102 return volVars.turbulentKineticEnergy() * volVars.density();
103 };
104 auto upwindTermEpsilon = [](const auto& volVars)
105 {
106 return volVars.dissipation() * volVars.density();
107 };
108
109 flux[turbulentKineticEnergyEqIdx]
110 = ParentType::advectiveFluxForCellCenter(problem, elemVolVars, elemFaceVars, scvf, upwindTermK);
111 flux[dissipationEqIdx ]
112 = ParentType::advectiveFluxForCellCenter(problem, elemVolVars, elemFaceVars, scvf, upwindTermEpsilon);
113
114 // calculate diffusive flux
115 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
116 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
117 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
118 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
119
120 // effective diffusion coefficients
121 Scalar insideCoeff_k = (insideVolVars.dynamicEddyViscosity() / insideVolVars.sigmaK()) + insideVolVars.viscosity();
122 Scalar outsideCoeff_k = (outsideVolVars.dynamicEddyViscosity() / outsideVolVars.sigmaK()) + outsideVolVars.viscosity();
123 Scalar insideCoeff_e = (insideVolVars.dynamicEddyViscosity() / insideVolVars.sigmaEpsilon()) + insideVolVars.viscosity();
124 Scalar outsideCoeff_e = (outsideVolVars.dynamicEddyViscosity() / outsideVolVars.sigmaEpsilon()) + outsideVolVars.viscosity();
125
126 // scale by extrusion factor
127 insideCoeff_k *= insideVolVars.extrusionFactor();
128 outsideCoeff_k *= outsideVolVars.extrusionFactor();
129 insideCoeff_e *= insideVolVars.extrusionFactor();
130 outsideCoeff_e *= outsideVolVars.extrusionFactor();
131
132 Scalar coeff_k = 0.0;
133 Scalar coeff_e = 0.0;
134 Scalar distance = 0.0;
135 if (scvf.boundary())
136 {
137 coeff_k = insideCoeff_k;
138 coeff_e = insideCoeff_e;
139 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
140 }
141 else
142 {
143 // average and distance
144 // is more stable with simple/unweighted arithmetic mean
145 coeff_k = arithmeticMean(insideCoeff_k, outsideCoeff_k);
146 coeff_e = arithmeticMean(insideCoeff_e, outsideCoeff_e);
147 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
148 }
149
150 const auto bcTypes = problem.boundaryTypes(element, scvf);
151
152 // Remove this check after release 3.5. IsOnWall Interface is deprecated
153 if constexpr (Deprecated::hasIsOnWall<Problem, GlobalPosition>())
154 {
155 // Remove this part
156 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
157 || bcTypes.isSymmetry()
158 || problem.isOnWall(scvf))))
159 {
160 if (!(insideVolVars.isMatchingPoint() && outsideVolVars.isMatchingPoint())
161 || !(insideVolVars.isMatchingPoint() && outsideVolVars.inNearWallRegion())
162 || !(insideVolVars.inNearWallRegion() && outsideVolVars.isMatchingPoint()))
163 {
164 flux[turbulentKineticEnergyEqIdx]
165 += coeff_k / distance
166 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
167 * Extrusion::area(scvf);
168 }
169 }
170 }
171 else
172 {
173 // Keep this part
174 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
175 || bcTypes.isSymmetry()
176 || bcTypes.hasWall())))
177 {
178 if (!(insideVolVars.isMatchingPoint() && outsideVolVars.isMatchingPoint())
179 || !(insideVolVars.isMatchingPoint() && outsideVolVars.inNearWallRegion())
180 || !(insideVolVars.inNearWallRegion() && outsideVolVars.isMatchingPoint()))
181 {
182 flux[turbulentKineticEnergyEqIdx]
183 += coeff_k / distance
184 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
185 * Extrusion::area(scvf);
186 }
187 }
188 }
189
190 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx)
191 || bcTypes.isSymmetry())))
192 {
193 flux[dissipationEqIdx]
194 += coeff_e / distance
195 * (insideVolVars.dissipation() - outsideVolVars.dissipation())
196 * Extrusion::area(scvf);
197 }
198 return flux;
199 }
200
204 FacePrimaryVariables computeMomentumFlux(const Problem& problem,
205 const Element& element,
206 const SubControlVolumeFace& scvf,
207 const FVElementGeometry& fvGeometry,
208 const ElementVolumeVariables& elemVolVars,
209 const ElementFaceVariables& elemFaceVars,
210 const GridFluxVariablesCache& gridFluxVarsCache)
211 {
212 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
213
214 return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
215 + ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
216 + 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
217 * Extrusion::area(scvf) * scvf.directionSign() * insideVolVars.extrusionFactor();
218 }
219
220};
221
222} // end namespace
223
224#endif
Helpers for deprecation.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
Base class for the flux variables living on a sub control volume face.
static ctype distance(const Dune::FieldVector< ctype, dimWorld > &a, const Dune::FieldVector< ctype, dimWorld > &b)
Compute the shortest distance between two points.
Definition: distance.hh:292
constexpr Scalar arithmeticMean(Scalar x, Scalar y, Scalar wx=1.0, Scalar wy=1.0) noexcept
Calculate the (weighted) arithmetic mean of two scalar values.
Definition: math.hh:50
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
The flux variables class for the k-epsilon model using the staggered grid discretization.
Definition: freeflow/rans/twoeq/kepsilon/fluxvariables.hh:34
CellCenterPrimaryVariables computeMassFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf, const FluxVariablesCache &fluxVarsCache)
Computes the flux for the cell center residual.
Definition: freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh:88
FacePrimaryVariables computeMomentumFlux(const Problem &problem, const Element &element, const SubControlVolumeFace &scvf, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const GridFluxVariablesCache &gridFluxVarsCache)
Returns the momentum flux over all staggered faces.
Definition: freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh:204
Declares all properties used in Dumux.