3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/rans/twoeq/kepsilon/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_KEPSILON_LOCAL_RESIDUAL_HH
25#define DUMUX_STAGGERED_KEPSILON_LOCAL_RESIDUAL_HH
26
27#include <dune/common/hybridutilities.hh>
31
32namespace Dumux {
33
39// forward declaration
40template<class TypeTag, class BaseLocalResidual, class DiscretizationMethod>
42
43template<class TypeTag, class BaseLocalResidual>
44class KEpsilonResidualImpl<TypeTag, BaseLocalResidual, DiscretizationMethods::Staggered>
45: public BaseLocalResidual
46{
47 using ParentType = BaseLocalResidual;
48 friend class StaggeredLocalResidual<TypeTag>;
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;
59
60 using GridFaceVariables = typename GridVariables::GridFaceVariables;
61 using ElementFaceVariables = typename GridFaceVariables::LocalView;
62
66 using Element = typename GridView::template Codim<0>::Entity;
67 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
68 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
69 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
72
73 using CellCenterResidual = CellCenterPrimaryVariables;
74
75 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
76 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
77
78public:
79 using ParentType::ParentType;
80
81 // account for the offset of the cell center privars within the PrimaryVariables container
82 static constexpr auto cellCenterOffset = ModelTraits::numEq() - CellCenterPrimaryVariables::dimension;
83 static_assert(cellCenterOffset == ModelTraits::dim(), "cellCenterOffset must equal dim for staggered NavierStokes");
84
86 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
87 const SubControlVolume& scv,
88 const VolumeVariables& volVars) const
89 {
90 CellCenterPrimaryVariables storage = ParentType::computeStorageForCellCenter(problem, scv, volVars);
91
92 storage[turbulentKineticEnergyEqIdx] = volVars.turbulentKineticEnergy() * volVars.density();
93 storage[dissipationEqIdx] = volVars.dissipation() * volVars.density();
94
95 return storage;
96 }
97
98 CellCenterPrimaryVariables computeSourceForCellCenter(const Problem& problem,
99 const Element &element,
100 const FVElementGeometry& fvGeometry,
101 const ElementVolumeVariables& elemVolVars,
102 const ElementFaceVariables& elemFaceVars,
103 const SubControlVolume &scv) const
104 {
105 CellCenterPrimaryVariables source = ParentType::computeSourceForCellCenter(problem, element, fvGeometry,
106 elemVolVars, elemFaceVars, scv);
107
108 const auto& volVars = elemVolVars[scv];
109 Scalar turbulentKineticEnergy = volVars.turbulentKineticEnergy();
110 Scalar dissipation = volVars.dissipation();
111
112 // production
113 // turbulence production is equal to dissipation -> exclude both terms (according to local equilibrium hypothesis, see FLUENT)
114 if (!volVars.isMatchingPoint())
115 {
116 source[turbulentKineticEnergyEqIdx] += 2.0 * volVars.dynamicEddyViscosity()
117 * volVars.stressTensorScalarProduct();
118 }
119 source[dissipationEqIdx] += volVars.cOneEpsilon()
120 * dissipation / turbulentKineticEnergy
121 * 2.0 * volVars.dynamicEddyViscosity()
122 * volVars.stressTensorScalarProduct();
123
124 // destruction
125 // turbulence production is equal to dissipation -> exclude both terms (according to local equilibrium hypothesis, see FLUENT)
126 if (!volVars.isMatchingPoint())
127 {
128 source[turbulentKineticEnergyEqIdx] -= dissipation * volVars.density();
129 }
130 source[dissipationEqIdx] -= volVars.cTwoEpsilon()
131 * dissipation * dissipation
132 / turbulentKineticEnergy * volVars.density();
133
134 return source;
135 }
136};
137} // end namespace Dumux
138
139#endif
The available discretization methods in Dumux.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
Calculates the element-wise residual for the staggered FV scheme.
Definition: staggeredlocalresidual.hh:41
Element-wise calculation of the residual for k-epsilon models using the staggered discretization.
Definition: freeflow/rans/twoeq/kepsilon/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/kepsilon/staggered/localresidual.hh:98
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/kepsilon/staggered/localresidual.hh:86
Declares all properties used in Dumux.