Line | Branch | Exec | Source |
---|---|---|---|
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 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup KOmegaModel | ||
10 | * \brief K-Omega turbulence model problem base class. | ||
11 | */ | ||
12 | #ifndef DUMUX_KOMEGA_PROBLEM_HH | ||
13 | #define DUMUX_KOMEGA_PROBLEM_HH | ||
14 | |||
15 | #include <dumux/common/properties.hh> | ||
16 | #include <dumux/common/staggeredfvproblem.hh> | ||
17 | #include <dumux/discretization/localview.hh> | ||
18 | #include <dumux/discretization/staggered/elementsolution.hh> | ||
19 | #include <dumux/discretization/method.hh> | ||
20 | #include <dumux/freeflow/rans/problem.hh> | ||
21 | #include <dumux/freeflow/turbulencemodel.hh> | ||
22 | |||
23 | #include "model.hh" | ||
24 | |||
25 | namespace Dumux { | ||
26 | |||
27 | /*! | ||
28 | * \ingroup KOmegaModel | ||
29 | * \brief K-Omega turbulence model problem base class. | ||
30 | * | ||
31 | * This implements the 2-equation k-omega turbulence model developed in Wilcox08 and Wilcox88 | ||
32 | */ | ||
33 | template<class TypeTag> | ||
34 | class RANSProblemImpl<TypeTag, TurbulenceModel::komega> : public RANSProblemBase<TypeTag> | ||
35 | { | ||
36 | using ParentType = RANSProblemBase<TypeTag>; | ||
37 | using Implementation = GetPropType<TypeTag, Properties::Problem>; | ||
38 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
39 | |||
40 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
41 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
42 | |||
43 | using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>; | ||
44 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
45 | using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>; | ||
46 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
47 | |||
48 | using Element = typename GridGeometry::GridView::template Codim<0>::Entity; | ||
49 | using DimVector = typename Element::Geometry::GlobalCoordinate; | ||
50 | |||
51 | public: | ||
52 | 5 | RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "") | |
53 |
2/6✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
30 | : ParentType(gridGeometry, paramGroup) |
54 | 5 | { } | |
55 | |||
56 | /*! | ||
57 | * \brief Correct size of the static (solution independent) wall variables | ||
58 | */ | ||
59 | 5 | void updateStaticWallProperties() | |
60 | { | ||
61 | 5 | ParentType::updateStaticWallProperties(); | |
62 | |||
63 | // update size and initial values of the global vectors | ||
64 | 20 | storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0); | |
65 | 20 | storedDissipation_.resize(this->gridGeometry().elementMapper().size(), 0.0); | |
66 | 25 | storedDissipationGradient_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0)); | |
67 | 20 | storedTurbulentKineticEnergy_.resize(this->gridGeometry().elementMapper().size(), 0.0); | |
68 | 25 | storedTurbulentKineticEnergyGradient_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0)); | |
69 | 5 | } | |
70 | |||
71 | /*! | ||
72 | * \brief Update the dynamic (solution dependent) relations to the walls | ||
73 | * | ||
74 | * \param curSol The solution vector. | ||
75 | */ | ||
76 | template<class SolutionVector> | ||
77 | 205 | void updateDynamicWallProperties(const SolutionVector& curSol) | |
78 | { | ||
79 | 205 | ParentType::updateDynamicWallProperties(curSol); | |
80 | |||
81 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
410 | auto fvGeometry = localView(this->gridGeometry()); |
82 |
1/9✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47565 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
95335 | for (const auto& element : elements(this->gridGeometry().gridView())) |
83 | { | ||
84 | 142080 | unsigned int elementIdx = this->gridGeometry().elementMapper().index(element); | |
85 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
47360 | fvGeometry.bindElement(element); |
86 | |||
87 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 47360 times.
✓ Branch 3 taken 47360 times.
✓ Branch 4 taken 47360 times.
✓ Branch 5 taken 47360 times.
|
189440 | for (auto&& scv : scvs(fvGeometry)) |
88 | { | ||
89 | 47360 | const int dofIdx = scv.dofIndex(); | |
90 | 94720 | const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx]; | |
91 | 47360 | PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars); | |
92 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
94720 | auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars)); |
93 | // NOTE: first update the turbulence quantities | ||
94 | 94720 | storedDissipation_[elementIdx] = elemSol[0][Indices::dissipationEqIdx]; | |
95 | 94720 | storedTurbulentKineticEnergy_[elementIdx] = elemSol[0][Indices::turbulentKineticEnergyEqIdx]; | |
96 | // NOTE: then update the volVars | ||
97 | 47360 | VolumeVariables volVars; | |
98 |
1/2✓ Branch 1 taken 47360 times.
✗ Branch 2 not taken.
|
47360 | volVars.update(elemSol, asImp_(), element, scv); |
99 |
3/6✓ Branch 1 taken 47360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47360 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47360 times.
✗ Branch 6 not taken.
|
47360 | storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity(*this); |
100 | } | ||
101 | } | ||
102 | |||
103 | // calculate cell-centered gradients | ||
104 |
1/9✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47565 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
95335 | for (const auto& element : elements(this->gridGeometry().gridView())) |
105 | { | ||
106 | 94720 | const unsigned int elementIdx = this->gridGeometry().elementMapper().index(element); | |
107 | |||
108 |
2/2✓ Branch 1 taken 94720 times.
✓ Branch 2 taken 47360 times.
|
142080 | for (unsigned int axisIdx = 0; axisIdx < DimVector::dimension; ++axisIdx) |
109 | { | ||
110 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
94720 | const unsigned neighborIdx0 = ParentType::neighborIndex(elementIdx, axisIdx, 0); |
111 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
94720 | const unsigned neighborIdx1 = ParentType::neighborIndex(elementIdx, axisIdx, 1); |
112 | |||
113 | // Cell centered TKE Gradient | ||
114 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
94720 | storedTurbulentKineticEnergyGradient_[elementIdx][axisIdx] |
115 | 284160 | = (storedTurbulentKineticEnergy(neighborIdx1) - storedTurbulentKineticEnergy(neighborIdx0)) | |
116 |
0/8✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
189440 | / (ParentType::cellCenter(neighborIdx1)[axisIdx] - ParentType::cellCenter(neighborIdx0)[axisIdx]); |
117 | // Cell centered Omega Gradient | ||
118 | 94720 | storedDissipationGradient_[elementIdx][axisIdx] | |
119 | 284160 | = (storedDissipation(neighborIdx1) - storedDissipation(neighborIdx0)) | |
120 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
189440 | / (ParentType::cellCenter(neighborIdx1)[axisIdx] - ParentType::cellCenter(neighborIdx0)[axisIdx]); |
121 | } | ||
122 | } | ||
123 | 205 | } | |
124 | |||
125 | //! \brief Returns the \f$ \beta_{\omega} \f$ constant | ||
126 | ✗ | const Scalar betaOmega() const | |
127 | ✗ | { return 0.0708; } | |
128 | |||
129 | 21498104 | bool useStoredEddyViscosity() const | |
130 | { | ||
131 |
5/8✓ Branch 0 taken 5 times.
✓ Branch 1 taken 21498099 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
|
21498104 | static const bool useStoredEddyViscosity = getParamFromGroup<bool>(this->paramGroup(), "RANS.UseStoredEddyViscosity", false); |
132 | 21498104 | return useStoredEddyViscosity; | |
133 | } | ||
134 | |||
135 | Scalar storedDynamicEddyViscosity(const int elementIdx) const | ||
136 | ✗ | { return storedDynamicEddyViscosity_[elementIdx]; } | |
137 | |||
138 | Scalar storedTurbulentKineticEnergy(const int elementIdx) const | ||
139 |
0/24✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
|
43280368 | { return storedTurbulentKineticEnergy_[elementIdx]; } |
140 | |||
141 | Scalar storedDissipation(const int elementIdx) const | ||
142 |
0/24✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
|
43280368 | { return storedDissipation_[elementIdx]; } |
143 | |||
144 | DimVector storedTurbulentKineticEnergyGradient(const int elementIdx) const | ||
145 | 42996208 | { return storedTurbulentKineticEnergyGradient_[elementIdx]; } | |
146 | |||
147 | DimVector storedDissipationGradient(const int elementIdx) const | ||
148 | 42996208 | { return storedDissipationGradient_[elementIdx]; } | |
149 | |||
150 | private: | ||
151 | std::vector<Scalar> storedDynamicEddyViscosity_; | ||
152 | std::vector<Scalar> storedTurbulentKineticEnergy_; | ||
153 | std::vector<Scalar> storedDissipation_; | ||
154 | std::vector<DimVector> storedDissipationGradient_; | ||
155 | std::vector<DimVector> storedTurbulentKineticEnergyGradient_; | ||
156 | |||
157 | //! Returns the implementation of the problem (i.e. static polymorphism) | ||
158 | Implementation &asImp_() | ||
159 | { return *static_cast<Implementation *>(this); } | ||
160 | |||
161 | //! \copydoc asImp_() | ||
162 | const Implementation &asImp_() const | ||
163 | { return *static_cast<const Implementation *>(this); } | ||
164 | }; | ||
165 | |||
166 | } // end namespace Dumux | ||
167 | |||
168 | #endif | ||
169 |