3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/rans/twoeq/komega/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_KOMEGA_STAGGERED_FLUXVARIABLES_HH
25#define DUMUX_KOMEGA_STAGGERED_FLUXVARIABLES_HH
26
27#include <numeric>
34
35namespace Dumux {
36
42// forward declaration
43template<class TypeTag, class BaseFluxVariables, DiscretizationMethod discMethod>
44class KOmegaFluxVariablesImpl;
45
46template<class TypeTag, class BaseFluxVariables>
47class KOmegaFluxVariablesImpl<TypeTag, BaseFluxVariables, DiscretizationMethod::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 Extrusion = Extrusion_t<GridGeometry>;
71 using GridView = typename GridGeometry::GridView;
73 using Element = typename GridView::template Codim<0>::Entity;
75 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
77
78 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
79 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
80
81public:
82
86 CellCenterPrimaryVariables computeMassFlux(const Problem& problem,
87 const Element &element,
88 const FVElementGeometry& fvGeometry,
89 const ElementVolumeVariables& elemVolVars,
90 const ElementFaceVariables& elemFaceVars,
91 const SubControlVolumeFace &scvf,
92 const FluxVariablesCache& fluxVarsCache)
93 {
94 CellCenterPrimaryVariables flux = ParentType::computeMassFlux(problem, element, fvGeometry,
95 elemVolVars, elemFaceVars, scvf, fluxVarsCache);
96
97 // calculate advective flux
98 auto upwindTermK = [](const auto& volVars)
99 {
100 return volVars.turbulentKineticEnergy()*volVars.density();
101 };
102 auto upwindTermOmega = [](const auto& volVars)
103 {
104 return volVars.dissipation()*volVars.density();
105 };
106
107 flux[turbulentKineticEnergyEqIdx]
108 = ParentType::advectiveFluxForCellCenter(problem, elemVolVars, elemFaceVars, scvf, upwindTermK);
109 flux[dissipationEqIdx]
110 = ParentType::advectiveFluxForCellCenter(problem, elemVolVars, elemFaceVars, scvf, upwindTermOmega);
111
112 // calculate diffusive flux
113 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
114 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
115 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
116 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
117
118 // effective diffusion coefficients
119 Scalar insideCoeff_k = insideVolVars.viscosity()
120 + ( insideVolVars.sigmaK() * insideVolVars.density()* insideVolVars.turbulentKineticEnergy() / insideVolVars.dissipation() );
121 Scalar outsideCoeff_k = outsideVolVars.viscosity()
122 + ( outsideVolVars.sigmaK() * outsideVolVars.density()* outsideVolVars.turbulentKineticEnergy() / outsideVolVars.dissipation() );
123 Scalar insideCoeff_w = insideVolVars.viscosity()
124 + ( insideVolVars.sigmaOmega() * insideVolVars.density()* insideVolVars.turbulentKineticEnergy() / insideVolVars.dissipation() );
125 Scalar outsideCoeff_w = outsideVolVars.viscosity()
126 + ( outsideVolVars.sigmaOmega() * outsideVolVars.density()* outsideVolVars.turbulentKineticEnergy() / outsideVolVars.dissipation() );
127
128 // scale by extrusion factor
129 insideCoeff_k *= insideVolVars.extrusionFactor();
130 outsideCoeff_k *= outsideVolVars.extrusionFactor();
131 insideCoeff_w *= insideVolVars.extrusionFactor();
132 outsideCoeff_w *= outsideVolVars.extrusionFactor();
133
134 Scalar distance = 0.0;
135 Scalar coeff_k = 0.0;
136 Scalar coeff_w = 0.0;
137 if (scvf.boundary())
138 {
139 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
140 coeff_k = insideCoeff_k;
141 coeff_w = insideCoeff_w;
142 }
143 else
144 {
145 // average and distance
146 coeff_k = arithmeticMean(insideCoeff_k, outsideCoeff_k,
147 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
148 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
149 coeff_w = arithmeticMean(insideCoeff_w, outsideCoeff_w,
150 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
151 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
152 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
153 }
154
155 const auto bcTypes = problem.boundaryTypes(element, scvf);
156 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
157 || bcTypes.isSymmetry())))
158 {
159 flux[turbulentKineticEnergyEqIdx]
160 += coeff_k / distance
161 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
162 * Extrusion::area(scvf);
163 }
164 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx)
165 || bcTypes.isSymmetry())))
166 {
167 flux[dissipationEqIdx]
168 += coeff_w / distance
169 * (insideVolVars.dissipation() - outsideVolVars.dissipation())
170 * Extrusion::area(scvf);
171 }
172 return flux;
173 }
174
178 FacePrimaryVariables computeMomentumFlux(const Problem& problem,
179 const Element& element,
180 const SubControlVolumeFace& scvf,
181 const FVElementGeometry& fvGeometry,
182 const ElementVolumeVariables& elemVolVars,
183 const ElementFaceVariables& elemFaceVars,
184 const GridFluxVariablesCache& gridFluxVarsCache)
185 {
186 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
187
188 return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
189 + ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
190 + 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
191 * Extrusion::area(scvf) * scvf.directionSign() * insideVolVars.extrusionFactor();
192 }
193};
194
195} // end namespace
196
197#endif
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
Base class for the flux variables living on a sub control volume face.
ctype distance(const Dune::FieldVector< ctype, dimWorld > &a, const Dune::FieldVector< ctype, dimWorld > &b)
Compute the shortest distance between two points.
Definition: geometry/distance.hh:138
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
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:49
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 (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
The flux variables class for the k-omega model using the staggered grid discretization.
Definition: freeflow/rans/twoeq/komega/fluxvariables.hh:34
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/komega/staggered/fluxvariables.hh:178
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/komega/staggered/fluxvariables.hh:86
Declares all properties used in Dumux.