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 LowReKEpsilonModel | ||
10 | * \brief Low-Re k-epsilon turbulence problem base class. | ||
11 | */ | ||
12 | #ifndef DUMUX_LOWREKEPSILON_PROBLEM_HH | ||
13 | #define DUMUX_LOWREKEPSILON_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 LowReKEpsilonModel | ||
29 | * \brief Low-Re k-epsilon turbulence problem base class. | ||
30 | * | ||
31 | * This implements some base functionality for low-Re k-epsilon models. | ||
32 | */ | ||
33 | template<class TypeTag> | ||
34 | class RANSProblemImpl<TypeTag, TurbulenceModel::lowrekepsilon> : 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 | public: | ||
49 | //! The constructor sets the gravity, if desired by the user. | ||
50 | 4 | RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "") | |
51 |
2/6✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
16 | : ParentType(gridGeometry, paramGroup) |
52 | 4 | { } | |
53 | |||
54 | /*! | ||
55 | * \brief Correct size of the static (solution independent) wall variables | ||
56 | */ | ||
57 | 4 | void updateStaticWallProperties() | |
58 | { | ||
59 | 4 | ParentType::updateStaticWallProperties(); | |
60 | |||
61 | // update size and initial values of the global vectors | ||
62 | 16 | storedDissipationTilde_.resize(this->gridGeometry().elementMapper().size(), 0.0); | |
63 | 16 | storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0); | |
64 | 16 | storedTurbulentKineticEnergy_.resize(this->gridGeometry().elementMapper().size(), 0.0); | |
65 | 4 | } | |
66 | |||
67 | /*! | ||
68 | * \brief Update the dynamic (solution dependent) relations to the walls | ||
69 | * | ||
70 | * \param curSol The solution vector. | ||
71 | */ | ||
72 | template<class SolutionVector> | ||
73 | 152 | void updateDynamicWallProperties(const SolutionVector& curSol) | |
74 | { | ||
75 | 152 | ParentType::updateDynamicWallProperties(curSol); | |
76 | |||
77 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
304 | auto fvGeometry = localView(this->gridGeometry()); |
78 |
1/9✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34416 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.
|
68984 | for (const auto& element : elements(this->gridGeometry().gridView())) |
79 | { | ||
80 | 102792 | unsigned int elementIdx = this->gridGeometry().elementMapper().index(element); | |
81 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
34264 | fvGeometry.bindElement(element); |
82 | |||
83 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 34264 times.
✓ Branch 3 taken 34264 times.
✓ Branch 4 taken 34264 times.
✓ Branch 5 taken 34264 times.
|
137056 | for (auto&& scv : scvs(fvGeometry)) |
84 | { | ||
85 | 68528 | const int dofIdx = scv.dofIndex(); | |
86 | 68528 | const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx]; | |
87 | 34264 | PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars); | |
88 |
0/4✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
68528 | auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars)); |
89 | // NOTE: first update the turbulence quantities | ||
90 | 68528 | storedDissipationTilde_[elementIdx] = elemSol[0][Indices::dissipationEqIdx]; | |
91 | 68528 | storedTurbulentKineticEnergy_[elementIdx] = elemSol[0][Indices::turbulentKineticEnergyEqIdx]; | |
92 | // NOTE: then update the volVars | ||
93 | 34264 | VolumeVariables volVars; | |
94 |
1/2✓ Branch 1 taken 34264 times.
✗ Branch 2 not taken.
|
34264 | volVars.update(elemSol, asImp_(), element, scv); |
95 |
2/4✓ Branch 1 taken 34264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34264 times.
✗ Branch 4 not taken.
|
34264 | storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity(); |
96 | } | ||
97 | } | ||
98 | 152 | } | |
99 | |||
100 | 14087628 | bool useStoredEddyViscosity() const | |
101 | { | ||
102 |
5/8✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14087624 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
|
14087628 | static const bool useStoredEddyViscosity = getParamFromGroup<bool>(this->paramGroup(), "RANS.UseStoredEddyViscosity", true); |
103 | 14087628 | return useStoredEddyViscosity; | |
104 | } | ||
105 | |||
106 | Scalar storedDissipationTilde(const int elementIdx) const | ||
107 | 28175256 | { return storedDissipationTilde_[elementIdx]; } | |
108 | |||
109 | Scalar storedDynamicEddyViscosity(const int elementIdx) const | ||
110 | 28175256 | { return storedDynamicEddyViscosity_[elementIdx]; } | |
111 | |||
112 | Scalar storedTurbulentKineticEnergy(const int elementIdx) const | ||
113 | 28175256 | { return storedTurbulentKineticEnergy_[elementIdx]; } | |
114 | |||
115 | private: | ||
116 | std::vector<Scalar> storedDissipationTilde_; | ||
117 | std::vector<Scalar> storedDynamicEddyViscosity_; | ||
118 | std::vector<Scalar> storedTurbulentKineticEnergy_; | ||
119 | |||
120 | //! Returns the implementation of the problem (i.e. static polymorphism) | ||
121 | Implementation &asImp_() | ||
122 | { return *static_cast<Implementation *>(this); } | ||
123 | |||
124 | //! \copydoc asImp_() | ||
125 | const Implementation &asImp_() const | ||
126 | { return *static_cast<const Implementation *>(this); } | ||
127 | }; | ||
128 | |||
129 | } | ||
130 | |||
131 | #endif | ||
132 |