3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Loading...
Searching...
No Matches
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
77 {
79
80 // update size and initial values of the global vectors
81 storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
82 storedViscosityTilde_.resize(this->gridGeometry().elementMapper().size(), 0.0);
83 storedViscosityTildeGradient_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
84 }
85
91 void updateDynamicWallProperties(const SolutionVector& curSol)
92 {
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 storedViscosityTilde_[elementIdx] = elemSol[0][Indices::viscosityTildeIdx];
109 // NOTE: then update the volVars
110 VolumeVariables volVars;
111 volVars.update(elemSol, asImp_(), element, scv);
112 storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity();
113 }
114 }
115
116 // calculate cell-center-averaged gradient
117 for (const auto& element : elements(this->gridGeometry().gridView()))
118 {
119 const unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
120
121 for (unsigned int dimIdx = 0; dimIdx < Grid::dimension; ++dimIdx)
122 {
123 const unsigned int neighborIndex0 = ParentType::neighborIndex(elementIdx, dimIdx, 0);
124 const unsigned int neighborIndex1 = ParentType::neighborIndex(elementIdx, dimIdx, 1);
125
126 // calculate cell-centered turbulentEddyViscosity (viscosityTilde) gradient
127 storedViscosityTildeGradient_[elementIdx][dimIdx]
128 = (storedViscosityTilde(neighborIndex1) - storedViscosityTilde(neighborIndex0))
129 / (ParentType::cellCenter(neighborIndex1)[dimIdx] - ParentType::cellCenter(neighborIndex0)[dimIdx]);
130 }
131
132 // Adjust for dirichlet boundary conditions
133 auto fvGeometry = localView(this->gridGeometry());
134 fvGeometry.bindElement(element);
135 for (auto&& scvf : scvfs(fvGeometry))
136 {
137 const 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 neighborIndex = ParentType::neighborIndex(elementIdx, normDim, 0);
144 if (scvf.center()[normDim] < ParentType::cellCenter(elementIdx)[normDim])
145 neighborIndex = ParentType::neighborIndex(elementIdx, normDim, 1);
146
147 storedViscosityTildeGradient_[elementIdx][normDim]
148 = (storedViscosityTilde(neighborIndex) - dirichletViscosityTilde)
149 / (ParentType::cellCenter(neighborIndex)[normDim] - scvf.center()[normDim]);
150 }
151 }
152 }
153 }
154
156 {
157 static const bool useStoredEddyViscosity = getParamFromGroup<bool>(this->paramGroup(), "RANS.UseStoredEddyViscosity", false);
159 }
160
161 Scalar storedDynamicEddyViscosity(const int elementIdx) const
162 { return storedDynamicEddyViscosity_[elementIdx]; }
163
164 Scalar storedViscosityTilde(const int elementIdx) const
165 { return storedViscosityTilde_[elementIdx]; }
166
167 DimVector storedViscosityTildeGradient(const int elementIdx) const
168 { return storedViscosityTildeGradient_[elementIdx]; }
169
170private:
171 std::vector<Scalar> storedDynamicEddyViscosity_;
172 std::vector<Scalar> storedViscosityTilde_;
173 std::vector<DimVector> storedViscosityTildeGradient_;
174
176 Implementation &asImp_()
177 { return *static_cast<Implementation *>(this); }
178
180 const Implementation &asImp_() const
181 { return *static_cast<const Implementation *>(this); }
182};
183
184} // end namespace Dumux
185
186#endif
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.
Base class for all staggered fv problems.
TurbulenceModel
The available free flow turbulence models in Dumux.
Definition turbulencemodel.hh:37
@ oneeq
Definition turbulencemodel.hh:38
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition box/elementsolution.hh:118
PrimaryVariables makePriVarsFromCellCenterPriVars(const CellCenterPrimaryVariables &cellCenterPriVars)
Helper function to create a PrimaryVariables object from CellCenterPrimaryVariables.
Definition staggered/elementsolution.hh:41
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:358
Definition adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:150
void updateStaticWallProperties()
Correct size of the static (solution independent) wall variables.
Definition freeflow/rans/oneeq/problem.hh:76
bool useStoredEddyViscosity() const
Definition freeflow/rans/oneeq/problem.hh:155
void updateDynamicWallProperties(const SolutionVector &curSol)
Update the dynamic (solution dependent) relations to the walls.
Definition freeflow/rans/oneeq/problem.hh:91
Scalar storedViscosityTilde(const int elementIdx) const
Definition freeflow/rans/oneeq/problem.hh:164
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
DimVector storedViscosityTildeGradient(const int elementIdx) const
Definition freeflow/rans/oneeq/problem.hh:167
Scalar storedDynamicEddyViscosity(const int elementIdx) const
Definition freeflow/rans/oneeq/problem.hh:161
void updateDynamicWallProperties(const SolutionVector &curSol)
Update the dynamic (solution dependent) relations to the walls.
Definition freeflow/rans/problem.hh:246
void updateStaticWallProperties()
Update the static (solution independent) relations to the walls.
Definition freeflow/rans/problem.hh:112
GlobalPosition cellCenter(const int elementIdx) const
Definition freeflow/rans/problem.hh:386
unsigned int neighborIndex(const int elementIdx, const int dimIdx, const int sideIdx) const
Definition freeflow/rans/problem.hh:389
RANSProblemBase(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
The constructor.
Definition freeflow/rans/problem.hh:102
The local element solution class for staggered methods.
Declares all properties used in Dumux.
the turbulence-model-specfic RANS problem
A single-phase, isothermal one-equation turbulence model by Spalart-Allmaras.