GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/lowrekepsilon/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 32 32 100.0%
Branches: 25 45 55.6%

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 12 RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
51
2/6
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 : 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 48 storedDissipationTilde_.resize(this->gridGeometry().elementMapper().size(), 0.0);
63 48 storedDynamicEddyViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
64 48 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
2/4
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
320 auto fvGeometry = localView(this->gridGeometry());
78
5/9
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34416 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 104 times.
✗ Branch 10 not taken.
69416 for (const auto& element : elements(this->gridGeometry().gridView()))
79 {
80 103392 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
81
1/2
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
34464 fvGeometry.bindElement(element);
82
83
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 34264 times.
✓ Branch 3 taken 34264 times.
✓ Branch 4 taken 34264 times.
✓ Branch 5 taken 34264 times.
137456 for (auto&& scv : scvs(fvGeometry))
84 {
85 68928 const int dofIdx = scv.dofIndex();
86 68928 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
87 34464 PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
88
1/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
68928 auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars));
89 // NOTE: first update the turbulence quantities
90 68928 storedDissipationTilde_[elementIdx] = elemSol[0][Indices::dissipationEqIdx];
91 68928 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
2/4
✓ Branch 1 taken 34364 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34364 times.
✗ Branch 4 not taken.
34464 storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity();
96 }
97 }
98 160 }
99
100 14089028 bool useStoredEddyViscosity() const
101 {
102
5/8
✓ 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.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
14089028 static const bool useStoredEddyViscosity = getParamFromGroup<bool>(this->paramGroup(), "RANS.UseStoredEddyViscosity", true);
103 14089028 return useStoredEddyViscosity;
104 }
105
106 Scalar storedDissipationTilde(const int elementIdx) const
107 28176656 { return storedDissipationTilde_[elementIdx]; }
108
109 Scalar storedDynamicEddyViscosity(const int elementIdx) const
110 28176656 { return storedDynamicEddyViscosity_[elementIdx]; }
111
112 Scalar storedTurbulentKineticEnergy(const int elementIdx) const
113 28176656 { 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