3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/rans/oneeq/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_ONEEQ_PROBLEM_HH
25#define DUMUX_ONEEQ_PROBLEM_HH
26
34
35#include "model.hh"
36
37namespace Dumux {
38
45template<class TypeTag>
46class RANSProblemImpl<TypeTag, TurbulenceModel::oneeq> : public RANSProblemBase<TypeTag>
47{
48
49 using ParentType = RANSProblemBase<TypeTag>;
50 using Implementation = GetPropType<TypeTag, Properties::Problem>;
52 using Grid = typename GridView::Grid;
53
55 using DimVector = Dune::FieldVector<Scalar, Grid::dimension>;
56
58 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
59 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
60
64 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
66
67public:
69 RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
70 : ParentType(gridGeometry, paramGroup)
71 {
72 useStoredEddyViscosity_ = getParamFromGroup<bool>(this->paramGroup(),
73 "RANS.UseStoredEddyViscosity", false);
74 }
75
80 {
81 ParentType::updateStaticWallProperties();
82
83 // update size and initial values of the global vectors
84 storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
85 storedViscosityTilde_.resize(this->gridGeometry().elementMapper().size(), 0.0);
86 storedViscosityTildeGradient_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
87 }
88
94 void updateDynamicWallProperties(const SolutionVector& curSol)
95 {
96 ParentType::updateDynamicWallProperties(curSol);
97
98 for (const auto& element : elements(this->gridGeometry().gridView()))
99 {
100 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
101
102 auto fvGeometry = localView(this->gridGeometry());
103 fvGeometry.bindElement(element);
104 for (auto&& scv : scvs(fvGeometry))
105 {
106 const int dofIdx = scv.dofIndex();
107 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
108 PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
109 auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars));
110 // NOTE: first update the turbulence quantities
111 storedViscosityTilde_[elementIdx] = elemSol[0][Indices::viscosityTildeIdx];
112 // NOTE: then update the volVars
113 VolumeVariables volVars;
114 volVars.update(elemSol, asImp_(), element, scv);
115 storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity();
116 }
117 }
118
119 // calculate cell-center-averaged velocity gradients, maximum, and minimum values
120 for (const auto& element : elements(this->gridGeometry().gridView()))
121 {
122 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
123
124 for (unsigned int dimIdx = 0; dimIdx < Grid::dimension; ++dimIdx)
125 {
126 storedViscosityTildeGradient_[elementIdx][dimIdx]
127 = (storedViscosityTilde_[ParentType::neighborIdx_[elementIdx][dimIdx][1]]
128 - storedViscosityTilde_[ParentType::neighborIdx_[elementIdx][dimIdx][0]])
129 / (ParentType::cellCenter_[ParentType::neighborIdx_[elementIdx][dimIdx][1]][dimIdx]
130 - ParentType::cellCenter_[ParentType::neighborIdx_[elementIdx][dimIdx][0]][dimIdx]);
131 }
132
133 auto fvGeometry = localView(this->gridGeometry());
134 fvGeometry.bindElement(element);
135 for (auto&& scvf : scvfs(fvGeometry))
136 {
137 unsigned int normDim = scvf.directionIndex();
138 if (scvf.boundary() && asImp_().boundaryTypes(element, scvf).isDirichlet(Indices::viscosityTildeIdx))
139 {
140 // face Value
141 Scalar dirichletViscosityTilde = asImp_().dirichlet(element, scvf)[Indices::viscosityTildeIdx];
142
143 unsigned int neighborIdx = ParentType::neighborIdx_[elementIdx][normDim][0];
144 if (scvf.center()[normDim] < ParentType::cellCenter_[elementIdx][normDim])
145 neighborIdx = ParentType::neighborIdx_[elementIdx][normDim][1];
146
147 storedViscosityTildeGradient_[elementIdx][normDim]
148 = (storedViscosityTilde_[neighborIdx] - dirichletViscosityTilde)
149 / (ParentType::cellCenter_[neighborIdx][normDim] - scvf.center()[normDim]);
150 }
151 }
152 }
153 }
154
155public:
156 std::vector<Scalar> storedDynamicEddyViscosity_;
157 std::vector<Scalar> storedViscosityTilde_;
158 std::vector<DimVector> storedViscosityTildeGradient_;
160
161private:
163 Implementation &asImp_()
164 { return *static_cast<Implementation *>(this); }
165
167 const Implementation &asImp_() const
168 { return *static_cast<const Implementation *>(this); }
169};
170
171} // end namespace Dumux
172
173#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
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
void updateStaticWallProperties()
Correct size of the static (solution independent) wall variables.
Definition: freeflow/rans/oneeq/problem.hh:79
void updateDynamicWallProperties(const SolutionVector &curSol)
Update the dynamic (solution dependent) relations to the walls.
Definition: freeflow/rans/oneeq/problem.hh:94
std::vector< Scalar > storedDynamicEddyViscosity_
Definition: freeflow/rans/oneeq/problem.hh:156
RANSProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor sets the gravity, if desired by the user.
Definition: freeflow/rans/oneeq/problem.hh:69
bool useStoredEddyViscosity_
Definition: freeflow/rans/oneeq/problem.hh:159
std::vector< DimVector > storedViscosityTildeGradient_
Definition: freeflow/rans/oneeq/problem.hh:158
std::vector< Scalar > storedViscosityTilde_
Definition: freeflow/rans/oneeq/problem.hh:157
forward declare
Definition: freeflow/rans/problem.hh:41
Reynolds-Averaged Navier-Stokes problem base class.
Definition: freeflow/rans/problem.hh:57
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.