3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/rans/twoeq/komega/staggered/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_STAGGERED_KOMEGA_LOCAL_RESIDUAL_HH
25#define DUMUX_STAGGERED_KOMEGA_LOCAL_RESIDUAL_HH
26
27#include <dune/common/hybridutilities.hh>
31
32namespace Dumux {
33
34// forward declaration
35template<class TypeTag, class BaseLocalResidual, DiscretizationMethod discMethod>
36class KOmegaResidualImpl;
37
42template<class TypeTag, class BaseLocalResidual>
43class KOmegaResidualImpl<TypeTag, BaseLocalResidual, DiscretizationMethod::staggered>
44: public BaseLocalResidual
45{
46 using ParentType = BaseLocalResidual;
47
49
50 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
51 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
52 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
53
54 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
55 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
57
58 using GridFaceVariables = typename GridVariables::GridFaceVariables;
59 using ElementFaceVariables = typename GridFaceVariables::LocalView;
60
64 using Element = typename GridView::template Codim<0>::Entity;
65 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
66 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
67 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
68 using CellCenterResidual = CellCenterPrimaryVariables;
72
73 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
74 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
75
76public:
77 using ParentType::ParentType;
78
80 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
81 const SubControlVolume& scv,
82 const VolumeVariables& volVars) const
83 {
84 CellCenterPrimaryVariables storage = ParentType::computeStorageForCellCenter(problem, scv, volVars);
85
86 storage[turbulentKineticEnergyEqIdx] = volVars.turbulentKineticEnergy();
87 storage[dissipationEqIdx] = volVars.dissipation();
88
89 return storage;
90 }
91
92 CellCenterPrimaryVariables computeSourceForCellCenter(const Problem& problem,
93 const Element &element,
94 const FVElementGeometry& fvGeometry,
95 const ElementVolumeVariables& elemVolVars,
96 const ElementFaceVariables& elemFaceVars,
97 const SubControlVolume &scv) const
98 {
99 CellCenterPrimaryVariables source = ParentType::computeSourceForCellCenter(problem, element, fvGeometry,
100 elemVolVars, elemFaceVars, scv);
101
102 using std::min;
103 const auto& volVars = elemVolVars[scv];
104
105 // production
106 static const auto enableKOmegaProductionLimiter
107 = getParamFromGroup<bool>(problem.paramGroup(), "KOmega.EnableProductionLimiter", false);
108 Scalar productionTerm = 2.0 * volVars.kinematicEddyViscosity() * volVars.stressTensorScalarProduct();
109 if (enableKOmegaProductionLimiter)
110 {
111 Scalar productionAlternative = 20.0 * volVars.betaK() * volVars.turbulentKineticEnergy() * volVars.dissipation();
112 productionTerm = min(productionTerm, productionAlternative);
113 }
114 source[turbulentKineticEnergyEqIdx] += productionTerm;
115 source[dissipationEqIdx] += volVars.alpha() * volVars.dissipation() / volVars.turbulentKineticEnergy() * productionTerm;
116
117 // destruction
118 source[turbulentKineticEnergyEqIdx] -= volVars.betaK() * volVars.turbulentKineticEnergy() * volVars.dissipation();
119 source[dissipationEqIdx] -= volVars.betaOmega() * volVars.dissipation() * volVars.dissipation();
120
121 // cross-diffusion term
122 Scalar gradientProduct = 0.0;
123 for (unsigned int i = 0; i < ModelTraits::dim(); ++i)
124 gradientProduct += volVars.storedTurbulentKineticEnergyGradient()[i]
125 * volVars.storedDissipationGradient()[i];
126 if (gradientProduct > 0.0)
127 source[dissipationEqIdx] += 0.125 / volVars.dissipation() * gradientProduct;
128
129 return source;
130 }
131};
132} // end namespace Dumux
133
134#endif
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
Definition: adapt.hh:29
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
Definition: freeflow/rans/twoeq/komega/localresidual.hh:36
CellCenterPrimaryVariables computeSourceForCellCenter(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const SubControlVolume &scv) const
Definition: freeflow/rans/twoeq/komega/staggered/localresidual.hh:92
CellCenterPrimaryVariables computeStorageForCellCenter(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluate fluxes entering or leaving the cell center control volume.
Definition: freeflow/rans/twoeq/komega/staggered/localresidual.hh:80
Declares all properties used in Dumux.