3.6-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>
34
35namespace Dumux {
36
42// forward declaration
43template<class TypeTag, class BaseFluxVariables, class DiscretizationMethod>
44class KEpsilonFluxVariablesImpl;
45
46template<class TypeTag, class BaseFluxVariables>
47class KEpsilonFluxVariablesImpl<TypeTag, BaseFluxVariables, DiscretizationMethods::Staggered>
48: public BaseFluxVariables
49{
50 using ParentType = BaseFluxVariables;
51
53
54 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
55 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
56 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
57
58 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
59 using FluxVariablesCache = typename GridFluxVariablesCache::FluxVariablesCache;
60
61 using GridFaceVariables = typename GridVariables::GridFaceVariables;
62 using ElementFaceVariables = typename GridFaceVariables::LocalView;
63 using FaceVariables = typename GridFaceVariables::FaceVariables;
64
68 using FVElementGeometry = typename GridGeometry::LocalView;
69 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
70 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
71 using Extrusion = Extrusion_t<GridGeometry>;
72 using GridView = typename GridGeometry::GridView;
74 using Element = typename GridView::template Codim<0>::Entity;
76 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
78
79 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
80 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
81
82public:
83
87 CellCenterPrimaryVariables computeMassFlux(const Problem& problem,
88 const Element &element,
89 const FVElementGeometry& fvGeometry,
90 const ElementVolumeVariables& elemVolVars,
91 const ElementFaceVariables& elemFaceVars,
92 const SubControlVolumeFace &scvf,
93 const FluxVariablesCache& fluxVarsCache)
94 {
95 CellCenterPrimaryVariables flux = ParentType::computeMassFlux(problem, element, fvGeometry,
96 elemVolVars, elemFaceVars, scvf, fluxVarsCache);
97
98 // calculate advective flux
99 auto upwindTermK = [](const auto& volVars)
100 {
101 return volVars.turbulentKineticEnergy() * volVars.density();
102 };
103 auto upwindTermEpsilon = [](const auto& volVars)
104 {
105 return volVars.dissipation() * volVars.density();
106 };
107
108 flux[turbulentKineticEnergyEqIdx]
109 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermK);
110 flux[dissipationEqIdx ]
111 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermEpsilon);
112
113 // calculate diffusive flux
114 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
115 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
116 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
117 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
118
119 // effective diffusion coefficients
120 Scalar insideCoeff_k = (insideVolVars.dynamicEddyViscosity() / insideVolVars.sigmaK()) + insideVolVars.viscosity();
121 Scalar outsideCoeff_k = (outsideVolVars.dynamicEddyViscosity() / outsideVolVars.sigmaK()) + outsideVolVars.viscosity();
122 Scalar insideCoeff_e = (insideVolVars.dynamicEddyViscosity() / insideVolVars.sigmaEpsilon()) + insideVolVars.viscosity();
123 Scalar outsideCoeff_e = (outsideVolVars.dynamicEddyViscosity() / outsideVolVars.sigmaEpsilon()) + outsideVolVars.viscosity();
124
125 // scale by extrusion factor
126 insideCoeff_k *= insideVolVars.extrusionFactor();
127 outsideCoeff_k *= outsideVolVars.extrusionFactor();
128 insideCoeff_e *= insideVolVars.extrusionFactor();
129 outsideCoeff_e *= outsideVolVars.extrusionFactor();
130
131 Scalar coeff_k = 0.0;
132 Scalar coeff_e = 0.0;
133 Scalar distance = 0.0;
134 if (scvf.boundary())
135 {
136 coeff_k = insideCoeff_k;
137 coeff_e = insideCoeff_e;
138 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
139 }
140 else
141 {
142 // average and distance
143 // is more stable with simple/unweighted arithmetic mean
144 coeff_k = arithmeticMean(insideCoeff_k, outsideCoeff_k);
145 coeff_e = arithmeticMean(insideCoeff_e, outsideCoeff_e);
146 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
147 }
148
149 const auto bcTypes = problem.boundaryTypes(element, scvf);
150
151 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
152 || bcTypes.isSymmetry()
153 || bcTypes.hasWall())))
154 {
155 if (!(insideVolVars.isMatchingPoint() && outsideVolVars.isMatchingPoint())
156 || !(insideVolVars.isMatchingPoint() && outsideVolVars.inNearWallRegion())
157 || !(insideVolVars.inNearWallRegion() && outsideVolVars.isMatchingPoint()))
158 {
159 flux[turbulentKineticEnergyEqIdx]
160 += coeff_k / distance
161 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
162 * Extrusion::area(fvGeometry, scvf);
163 }
164 }
165
166 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx)
167 || bcTypes.isSymmetry())))
168 {
169 flux[dissipationEqIdx]
170 += coeff_e / distance
171 * (insideVolVars.dissipation() - outsideVolVars.dissipation())
172 * Extrusion::area(fvGeometry, scvf);
173 }
174 return flux;
175 }
176
180 FacePrimaryVariables computeMomentumFlux(const Problem& problem,
181 const Element& element,
182 const SubControlVolumeFace& scvf,
183 const FVElementGeometry& fvGeometry,
184 const ElementVolumeVariables& elemVolVars,
185 const ElementFaceVariables& elemFaceVars,
186 const GridFluxVariablesCache& gridFluxVarsCache)
187 {
188 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
189
190 return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
191 + ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
192 + 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
193 * Extrusion::area(fvGeometry, scvf) * scvf.directionSign() * insideVolVars.extrusionFactor();
194 }
195
196};
197
198} // end namespace
199
200#endif
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:294
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
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 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:87
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:180
Declares all properties used in Dumux.