GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/freeflow/rans/twoeq/lowrekepsilon/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 33 33 100.0%
Functions: 32 32 100.0%
Branches: 15 25 60.0%

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-FileCopyrightText: 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 12 RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
51
1/2
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
24 : ParentType(gridGeometry, paramGroup)
52 12 { }
53
54 /*!
55 * \brief Correct size of the static (solution independent) wall variables
56 */
57 12 void updateStaticWallProperties()
58 {
59 12 ParentType::updateStaticWallProperties();
60
61 // update size and initial values of the global vectors
62 12 storedDissipationTilde_.resize(this->gridGeometry().elementMapper().size(), 0.0);
63 12 storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
64 12 storedTurbulentKineticEnergy_.resize(this->gridGeometry().elementMapper().size(), 0.0);
65 12 }
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 160 void updateDynamicWallProperties(const SolutionVector& curSol)
74 {
75 160 ParentType::updateDynamicWallProperties(curSol);
76
77
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
160 auto fvGeometry = localView(this->gridGeometry());
78
3/5
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 34416 times.
✓ Branch 4 taken 104 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
103552 for (const auto& element : elements(this->gridGeometry().gridView()))
79 {
80
1/2
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
34464 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
81 34664 fvGeometry.bindElement(element);
82
83
2/2
✓ Branch 0 taken 34364 times.
✓ Branch 1 taken 34364 times.
68928 for (auto&& scv : scvs(fvGeometry))
84 {
85 const int dofIdx = scv.dofIndex();
86 34464 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
87 34464 PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
88
1/2
✓ Branch 1 taken 34364 times.
✗ Branch 2 not taken.
34464 auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars));
89 // NOTE: first update the turbulence quantities
90 34464 storedDissipationTilde_[elementIdx] = elemSol[0][Indices::dissipationEqIdx];
91 34464 storedTurbulentKineticEnergy_[elementIdx] = elemSol[0][Indices::turbulentKineticEnergyEqIdx];
92 // NOTE: then update the volVars
93 34464 VolumeVariables volVars;
94
1/2
✓ Branch 1 taken 34364 times.
✗ Branch 2 not taken.
34464 volVars.update(elemSol, asImp_(), element, scv);
95
1/2
✓ Branch 1 taken 34364 times.
✗ Branch 2 not taken.
34464 storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity();
96 }
97 }
98 160 }
99
100 14089028 bool useStoredEddyViscosity() const
101 {
102
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 14088320 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
14089028 static const bool useStoredEddyViscosity = getParamFromGroup<bool>(this->paramGroup(), "RANS.UseStoredEddyViscosity", true);
103 14089028 return useStoredEddyViscosity;
104 }
105
106 14088328 Scalar storedDissipationTilde(const int elementIdx) const
107 14088328 { return storedDissipationTilde_[elementIdx]; }
108
109 Scalar storedDynamicEddyViscosity(const int elementIdx) const
110 14088328 { return storedDynamicEddyViscosity_[elementIdx]; }
111
112 14088328 Scalar storedTurbulentKineticEnergy(const int elementIdx) const
113 14088328 { 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