3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
dumux/freeflow/rans/twoeq/komega/problem.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_PROBLEM_HH
25#define DUMUX_KOMEGA_PROBLEM_HH
26
34
35#include "model.hh"
36
37namespace Dumux {
38
45template<class TypeTag>
46class RANSProblemImpl<TypeTag, TurbulenceModel::komega> : public RANSProblemBase<TypeTag>
47{
48 using ParentType = RANSProblemBase<TypeTag>;
49 using Implementation = GetPropType<TypeTag, Properties::Problem>;
51
53 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
54
58 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
60
61 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
62 using DimVector = typename Element::Geometry::GlobalCoordinate;
63
64public:
65 RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
66 : ParentType(gridGeometry, paramGroup)
67 {
68 useStoredEddyViscosity_ = getParamFromGroup<bool>(this->paramGroup(), "RANS.UseStoredEddyViscosity", false);
69 }
70
75 {
76 ParentType::updateStaticWallProperties();
77
78 // update size and initial values of the global vectors
79 storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
80 storedDissipation_.resize(this->gridGeometry().elementMapper().size(), 0.0);
81 storedDissipationGradient_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
82 storedTurbulentKineticEnergy_.resize(this->gridGeometry().elementMapper().size(), 0.0);
83 storedTurbulentKineticEnergyGradient_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
84 }
85
91 void updateDynamicWallProperties(const SolutionVector& curSol)
92 {
93 ParentType::updateDynamicWallProperties(curSol);
94
95 for (const auto& element : elements(this->gridGeometry().gridView()))
96 {
97 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
98
99 auto fvGeometry = localView(this->gridGeometry());
100 fvGeometry.bindElement(element);
101 for (auto&& scv : scvs(fvGeometry))
102 {
103 const int dofIdx = scv.dofIndex();
104 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
105 PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
106 auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars));
107 // NOTE: first update the turbulence quantities
108 storedDissipation_[elementIdx] = elemSol[0][Indices::dissipationEqIdx];
109 storedTurbulentKineticEnergy_[elementIdx] = elemSol[0][Indices::turbulentKineticEnergyEqIdx];
110 // NOTE: then update the volVars
111 VolumeVariables volVars;
112 volVars.update(elemSol, asImp_(), element, scv);
113 storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity(*this);
114 }
115 }
116
117 // calculate cell-centered gradients
118 for (const auto& element : elements(this->gridGeometry().gridView()))
119 {
120 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
121
122 for (unsigned int dimIdx = 0; dimIdx < DimVector::dimension; ++dimIdx)
123 {
124 unsigned backwardNeighbor = ParentType::neighborIdx_[elementIdx][dimIdx][0];
125 unsigned forwardNeighbor = ParentType::neighborIdx_[elementIdx][dimIdx][1];
126 storedTurbulentKineticEnergyGradient_[elementIdx][dimIdx]
127 = (storedTurbulentKineticEnergy_[forwardNeighbor]
128 - storedTurbulentKineticEnergy_[backwardNeighbor])
129 / (ParentType::cellCenter_[forwardNeighbor][dimIdx]
130 - ParentType::cellCenter_[backwardNeighbor][dimIdx]);
131 storedDissipationGradient_[elementIdx][dimIdx]
132 = (storedDissipation_[forwardNeighbor]
133 - storedDissipation_[backwardNeighbor])
134 / (ParentType::cellCenter_[forwardNeighbor][dimIdx]
135 - ParentType::cellCenter_[backwardNeighbor][dimIdx]);
136 }
137 }
138 }
139
141 const Scalar betaOmega() const
142 {
143 return 0.0708;
144 }
145
146public:
147 std::vector<Scalar> storedDynamicEddyViscosity_;
148 std::vector<Scalar> storedDissipation_;
149 std::vector<DimVector> storedDissipationGradient_;
150 std::vector<Scalar> storedTurbulentKineticEnergy_;
153
154private:
156 Implementation &asImp_()
157 { return *static_cast<Implementation *>(this); }
158
160 const Implementation &asImp_() const
161 { return *static_cast<const Implementation *>(this); }
162};
163
164} // end namespace Dumux
165
166#endif
Base class for all staggered fv problems.
Free function to get the local view of a grid cache object.
The available discretization methods in Dumux.
The available free flow turbulence models in Dumux.
TurbulenceModel
The available free flow turbulence models in Dumux.
Definition: turbulencemodel.hh:37
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
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
forward declare
Definition: dumux/freeflow/rans/problem.hh:41
Reynolds-Averaged Navier-Stokes problem base class.
Definition: dumux/freeflow/rans/problem.hh:57
std::vector< Scalar > storedTurbulentKineticEnergy_
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:150
void updateDynamicWallProperties(const SolutionVector &curSol)
Update the dynamic (solution dependent) relations to the walls.
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:91
bool useStoredEddyViscosity_
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:152
std::vector< DimVector > storedTurbulentKineticEnergyGradient_
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:151
void updateStaticWallProperties()
Correct size of the static (solution independent) wall variables.
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:74
std::vector< DimVector > storedDissipationGradient_
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:149
RANSProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:65
std::vector< Scalar > storedDynamicEddyViscosity_
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:147
std::vector< Scalar > storedDissipation_
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:148
const Scalar betaOmega() const
Returns the constant.
Definition: dumux/freeflow/rans/twoeq/komega/problem.hh:141
Declares all properties used in Dumux.
Adaption of the fully implicit scheme to the tracer transport model.
The local element solution class for staggered methods.