GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/freeflow/ransnc/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 104 115 90.4%
Functions: 56 102 54.9%
Branches: 223 298 74.8%

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 RANSNCTests
10 * \brief Flat plate test for the multi-component staggered grid Reynolds-averaged Navier-Stokes model.
11 */
12 #ifndef DUMUX_RANS_NC_TEST_PROBLEM_HH
13 #define DUMUX_RANS_NC_TEST_PROBLEM_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/common/parameters.hh>
17 #include <dumux/common/timeloop.hh>
18 #include <dumux/common/numeqvector.hh>
19
20 #include <dumux/freeflow/rans/boundarytypes.hh>
21 #include <dumux/freeflow/turbulencemodel.hh>
22 #include <dumux/freeflow/turbulenceproperties.hh>
23 #include <dumux/freeflow/rans/zeroeq/problem.hh>
24 #include <dumux/freeflow/rans/oneeq/problem.hh>
25 #include <dumux/freeflow/rans/twoeq/komega/problem.hh>
26 #include <dumux/freeflow/rans/twoeq/sst/problem.hh>
27 #include <dumux/freeflow/rans/twoeq/lowrekepsilon/problem.hh>
28 #include <dumux/freeflow/rans/twoeq/kepsilon/problem.hh>
29
30 namespace Dumux {
31
32 /*!
33 * \ingroup RANSNCTests
34 * \brief Test problem for the one-phase model.
35 *
36 * Dry air is entering from the left side and flows above a 1-D a flat plate.
37 * In the middle of the inlet, water vapor is injected, which spreads by turbulent diffusion.
38 * For the non-isothermal model the bottom has a constant temperature
39 * which is higher than the initial and inlet temperature.
40 */
41 template <class TypeTag>
42 class FlatPlateNCTestProblem : public RANSProblem<TypeTag>
43 {
44 using ParentType = RANSProblem<TypeTag>;
45
46 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
47 using FluidState = GetPropType<TypeTag, Properties::FluidState>;
48 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
49 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
50 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
51 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
52
53 static constexpr auto dimWorld = GridGeometry::GridView::dimensionworld;
54 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
55 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
56 using BoundaryTypes = Dumux::RANSBoundaryTypes<ModelTraits, ModelTraits::numEq()>;
57 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
58 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
59 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
60 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
61 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
62
63 using TimeLoopPtr = std::shared_ptr<CheckPointTimeLoop<Scalar>>;
64
65 static constexpr auto transportEqIdx = Indices::conti0EqIdx + 1;
66 static constexpr auto transportCompIdx = Indices::conti0EqIdx + 1;
67
68 public:
69 15 FlatPlateNCTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
70
8/22
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 15 taken 15 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 15 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 15 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
45 : ParentType(gridGeometry), eps_(1e-6)
71 {
72
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 inletVelocity_ = getParam<Scalar>("Problem.InletVelocity", 0.1);
73
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 inletTemperature_ = getParam<Scalar>("Problem.InletTemperature", 283.15);
74
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 wallTemperature_ = getParam<Scalar>("Problem.WallTemperature", 313.15);
75
1/4
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
15 inletMoleFraction_ = getParam<Scalar>("Problem.InletMoleFraction", 1e-3);
76
77
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 FluidSystem::init();
78 Dumux::TurbulenceProperties<Scalar, dimWorld, true> turbulenceProperties;
79 15 FluidState fluidState;
80 15 const auto phaseIdx = 0;
81
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 fluidState.setPressure(phaseIdx, 1e5);
82
2/4
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
30 fluidState.setTemperature(this->spatialParams().temperatureAtPos({}));
83
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 fluidState.setMassFraction(phaseIdx, phaseIdx, 1.0);
84
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 Scalar density = FluidSystem::density(fluidState, phaseIdx);
85
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 Scalar kinematicViscosity = FluidSystem::viscosity(fluidState, phaseIdx) / density;
86
6/12
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 15 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 15 times.
✗ Branch 17 not taken.
90 Scalar diameter = this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1];
87
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 viscosityTilde_ = 1e-3 * turbulenceProperties.viscosityTilde(inletVelocity_, diameter, kinematicViscosity);
88
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 turbulentKineticEnergy_ = turbulenceProperties.turbulentKineticEnergy(inletVelocity_, diameter, kinematicViscosity);
89 15 if (ModelTraits::turbulenceModel() == TurbulenceModel::komega || ModelTraits::turbulenceModel() == TurbulenceModel::sst)
90
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 dissipation_ = turbulenceProperties.dissipationRate(inletVelocity_, diameter, kinematicViscosity);
91 else
92
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 dissipation_ = turbulenceProperties.dissipation(inletVelocity_, diameter, kinematicViscosity);
93
2/4
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
15 turbulenceModelName_ = turbulenceModelToString(ModelTraits::turbulenceModel());
94
2/4
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
30 std::cout << "Using the "<< turbulenceModelName_ << " Turbulence Model. \n";
95
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 std::cout << std::endl;
96 15 }
97
98 /*!
99 * \name Boundary conditions
100 */
101 // \{
102
103 /*!
104 * \brief Specifies which kind of boundary condition should be
105 * used for which equation on a given boundary control volume.
106 *
107 * \param globalPos The position of the center of the finite volume
108 */
109 176974608 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
110 {
111 176974608 BoundaryTypes values;
112
113 // turbulence model-specific boundary types
114 186496017 setBcTypes_(values, globalPos);
115
116 353949216 if(isInlet_(globalPos))
117 {
118 11206829 values.setDirichlet(Indices::velocityXIdx);
119 11206829 values.setDirichlet(Indices::velocityYIdx);
120 11206829 values.setDirichlet(transportCompIdx);
121 #if NONISOTHERMAL
122 6263609 values.setDirichlet(Indices::temperatureIdx);
123 #endif
124 }
125 331535558 else if(isOutlet_(globalPos))
126 {
127 14050302 values.setDirichlet(Indices::pressureIdx);
128 14050302 values.setOutflow(transportEqIdx);
129 #if NONISOTHERMAL
130 7658378 values.setOutflow(Indices::energyEqIdx);
131 #endif
132 }
133 303434954 else if(isLowerWall_(globalPos))
134 {
135 5981400 values.setWall();
136 5981400 values.setNeumann(transportEqIdx);
137 #if NONISOTHERMAL
138 3346255 values.setDirichlet(Indices::temperatureIdx);
139 #endif
140 }
141 else
142 values.setAllSymmetry();
143
144 176974608 return values;
145 }
146
147 /*!
148 * \brief Returns whether a fixed Dirichlet value shall be used at a given cell.
149 *
150 * \param element The finite element
151 * \param fvGeometry The finite-volume geometry
152 * \param scv The sub control volume
153 * \param pvIdx The primary variable index in the solution vector
154 */
155 template<class Element, class FVElementGeometry, class SubControlVolume>
156 bool isDirichletCell(const Element& element,
157 const FVElementGeometry& fvGeometry,
158 const SubControlVolume& scv,
159 int pvIdx) const
160 36655960 { return isDirichletCell_(element, fvGeometry, scv, pvIdx); }
161
162 /*!
163 * \brief Evaluate the boundary conditions for a dirichlet values at the boundary.
164 *
165 * \param element The finite element
166 * \param scvf the sub control volume face
167 * \note used for cell-centered discretization schemes
168 */
169 7625060 PrimaryVariables dirichlet(const Element& element, const SubControlVolumeFace& scvf) const
170 {
171 7625060 const auto globalPos = scvf.ipGlobal();
172 15250120 PrimaryVariables values(initialAtPos(globalPos));
173
174 if (isInlet_(globalPos)
175
10/10
✓ Branch 0 taken 530302 times.
✓ Branch 1 taken 3773106 times.
✓ Branch 2 taken 530302 times.
✓ Branch 3 taken 3773106 times.
✓ Branch 4 taken 530302 times.
✓ Branch 5 taken 3773106 times.
✓ Branch 6 taken 530302 times.
✓ Branch 7 taken 3773106 times.
✓ Branch 8 taken 530302 times.
✓ Branch 9 taken 3773106 times.
21517040 && globalPos[1] > 0.4 * this->gridGeometry().bBoxMax()[1]
176
10/10
✓ Branch 0 taken 225894 times.
✓ Branch 1 taken 304408 times.
✓ Branch 2 taken 225894 times.
✓ Branch 3 taken 304408 times.
✓ Branch 4 taken 225894 times.
✓ Branch 5 taken 304408 times.
✓ Branch 6 taken 225894 times.
✓ Branch 7 taken 304408 times.
✓ Branch 8 taken 225894 times.
✓ Branch 9 taken 304408 times.
2651510 && globalPos[1] < 0.6 * this->gridGeometry().bBoxMax()[1])
177 {
178 370546 values[transportCompIdx] = (time() > 10.0) ? inletMoleFraction_ : 0.0;
179 }
180
181 #if NONISOTHERMAL
182 3769476 values[Indices::temperatureIdx] = (isLowerWall_(globalPos) && time() > 10.0) ? wallTemperature_ : inletTemperature_;
183 #endif
184
185 7625060 return values;
186 }
187
188 /*!
189 * \brief Evaluate the boundary conditions for fixed values at cell centers
190 *
191 * \param element The finite element
192 * \param scv the sub control volume
193 * \note used for cell-centered discretization schemes
194 */
195 PrimaryVariables dirichlet([[maybe_unused]] const Element& element, const SubControlVolume& scv) const
196 {
197 if constexpr (ModelTraits::turbulenceModel() == TurbulenceModel::kepsilon
198 || ModelTraits::turbulenceModel() == TurbulenceModel::komega
199 || ModelTraits::turbulenceModel() == TurbulenceModel::sst)
200 2764866 return dirichletTurbulentTwoEq_(element, scv);
201 else
202 {
203 const auto globalPos = scv.center();
204 PrimaryVariables values(initialAtPos(globalPos));
205 return values;
206 }
207 }
208
209 /*!
210 * \brief Evaluates the initial value for a control volume.
211 *
212 * \param globalPos The global position
213 */
214 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
215 {
216 48524944 PrimaryVariables values(0.0);
217
9/12
✓ Branch 0 taken 36212550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1370522 times.
✓ Branch 3 taken 194404 times.
✓ Branch 4 taken 2765266 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4832974 times.
✓ Branch 7 taken 2104070 times.
✓ Branch 8 taken 2300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9070 times.
✓ Branch 11 taken 130 times.
51203402 values[Indices::pressureIdx] = 1.0e+5;
218
9/12
✓ Branch 0 taken 36212550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1370522 times.
✓ Branch 3 taken 194404 times.
✓ Branch 4 taken 2765266 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4832974 times.
✓ Branch 7 taken 2104070 times.
✓ Branch 8 taken 2300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9070 times.
✓ Branch 11 taken 130 times.
51203402 values[transportCompIdx] = 0.0;
219 #if NONISOTHERMAL
220
9/12
✓ Branch 0 taken 17477856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 685868 times.
✓ Branch 3 taken 102172 times.
✓ Branch 4 taken 1320340 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2336214 times.
✓ Branch 7 taken 1071850 times.
✓ Branch 8 taken 1250 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4930 times.
✓ Branch 11 taken 70 times.
24946758 values[Indices::temperatureIdx] = inletTemperature_;
221 #endif
222 // block velocity profile
223
9/12
✓ Branch 0 taken 36212550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1370522 times.
✓ Branch 3 taken 194404 times.
✓ Branch 4 taken 2765266 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4832974 times.
✓ Branch 7 taken 2104070 times.
✓ Branch 8 taken 2300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9070 times.
✓ Branch 11 taken 130 times.
51203402 values[Indices::velocityXIdx] = 0.0;
224 102579620 if (!isLowerWall_(globalPos))
225 90385364 values[Indices::velocityXIdx] = inletVelocity_;
226
7/8
✓ Branch 0 taken 401184 times.
✓ Branch 1 taken 3053298 times.
✓ Branch 2 taken 2104050 times.
✓ Branch 3 taken 4831394 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2300 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 9070 times.
46615976 values[Indices::velocityYIdx] = 0.0;
227
228 // turbulence model-specific initial conditions
229 3725616 setInitialAtPos_(values, globalPos);
230 return values;
231 }
232
233 // \}
234
235 void setTimeLoop(TimeLoopPtr timeLoop)
236
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 { timeLoop_ = timeLoop; }
237
238 Scalar time() const
239
12/12
✓ Branch 0 taken 81242 times.
✓ Branch 1 taken 144652 times.
✓ Branch 2 taken 81242 times.
✓ Branch 3 taken 144652 times.
✓ Branch 4 taken 81242 times.
✓ Branch 5 taken 144652 times.
✓ Branch 6 taken 452758 times.
✓ Branch 7 taken 721254 times.
✓ Branch 8 taken 452758 times.
✓ Branch 9 taken 721254 times.
✓ Branch 10 taken 452758 times.
✓ Branch 11 taken 721254 times.
4199718 { return timeLoop_->time(); }
240
241 private:
242 bool isInlet_(const GlobalPosition& globalPos) const
243
8/8
✓ Branch 0 taken 4303408 times.
✓ Branch 1 taken 3321652 times.
✓ Branch 2 taken 4303408 times.
✓ Branch 3 taken 3321652 times.
✓ Branch 4 taken 11206829 times.
✓ Branch 5 taken 165767779 times.
✓ Branch 6 taken 11206829 times.
✓ Branch 7 taken 165767779 times.
369199336 { return globalPos[0] < eps_; }
244
245 bool isOutlet_(const GlobalPosition& globalPos) const
246
16/16
✓ Branch 0 taken 14050302 times.
✓ Branch 1 taken 162309766 times.
✓ Branch 2 taken 14050302 times.
✓ Branch 3 taken 162309766 times.
✓ Branch 4 taken 14050302 times.
✓ Branch 5 taken 162309766 times.
✓ Branch 6 taken 14050302 times.
✓ Branch 7 taken 151717477 times.
✓ Branch 8 taken 14050302 times.
✓ Branch 9 taken 151717477 times.
✓ Branch 10 taken 13179865 times.
✓ Branch 11 taken 151206197 times.
✓ Branch 12 taken 13179865 times.
✓ Branch 13 taken 151206197 times.
✓ Branch 14 taken 13179865 times.
✓ Branch 15 taken 151206197 times.
1353773948 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
247
248 bool isLowerWall_(const GlobalPosition& globalPos) const
249
30/32
✓ Branch 0 taken 36212550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36212550 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1370522 times.
✓ Branch 5 taken 194404 times.
✓ Branch 6 taken 1370522 times.
✓ Branch 7 taken 194404 times.
✓ Branch 8 taken 2965752 times.
✓ Branch 9 taken 378840 times.
✓ Branch 10 taken 2965752 times.
✓ Branch 11 taken 378840 times.
✓ Branch 12 taken 4942225 times.
✓ Branch 13 taken 2287185 times.
✓ Branch 14 taken 4942225 times.
✓ Branch 15 taken 2287185 times.
✓ Branch 16 taken 66778992 times.
✓ Branch 17 taken 4851779 times.
✓ Branch 18 taken 66778992 times.
✓ Branch 19 taken 4851779 times.
✓ Branch 20 taken 79822410 times.
✓ Branch 21 taken 3163130 times.
✓ Branch 22 taken 79822410 times.
✓ Branch 23 taken 3163130 times.
✓ Branch 24 taken 5390 times.
✓ Branch 25 taken 60 times.
✓ Branch 26 taken 5390 times.
✓ Branch 27 taken 60 times.
✓ Branch 28 taken 4930 times.
✓ Branch 29 taken 70 times.
✓ Branch 30 taken 4930 times.
✓ Branch 31 taken 70 times.
413380710 { return globalPos[1] < eps_; }
250
251 //! Initial conditions for the komega, kepsilon and lowrekepsilon turbulence models
252 void setInitialAtPos_([[maybe_unused]] PrimaryVariables& values,
253 [[maybe_unused]] const GlobalPosition &globalPos) const
254 {
255 if constexpr (numTurbulenceEq(ModelTraits::turbulenceModel()) == 0) // zero equation models
256 return;
257 else if constexpr (numTurbulenceEq(ModelTraits::turbulenceModel()) == 1) // one equation models
258 {
259
5/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 289606 times.
✓ Branch 3 taken 735768 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 400 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 1580 times.
6534138 values[Indices::viscosityTildeIdx] = viscosityTilde_;
260
10/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 289606 times.
✓ Branch 5 taken 735768 times.
✓ Branch 6 taken 289606 times.
✓ Branch 7 taken 735768 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 400 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 400 times.
✓ Branch 12 taken 20 times.
✓ Branch 13 taken 1580 times.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 1580 times.
13068276 if (isLowerWall_(globalPos))
261 579252 values[Indices::viscosityTildeIdx] = 0.0;
262 }
263 else // two equation models
264 {
265 static_assert(numTurbulenceEq(ModelTraits::turbulenceModel()) == 2, "Only reached by 2eq models");
266
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2764866 times.
✓ Branch 2 taken 1814444 times.
✓ Branch 3 taken 4095626 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1900 times.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 7490 times.
39390222 values[Indices::turbulentKineticEnergyIdx] = turbulentKineticEnergy_;
267
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2764866 times.
✓ Branch 2 taken 1814444 times.
✓ Branch 3 taken 4095626 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1900 times.
✓ Branch 6 taken 110 times.
✓ Branch 7 taken 7490 times.
39390222 values[Indices::dissipationIdx] = dissipation_;
268
12/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2764866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2764866 times.
✓ Branch 4 taken 1814444 times.
✓ Branch 5 taken 4095626 times.
✓ Branch 6 taken 1814444 times.
✓ Branch 7 taken 4095626 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1900 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1900 times.
✓ Branch 12 taken 110 times.
✓ Branch 13 taken 7490 times.
✓ Branch 14 taken 110 times.
✓ Branch 15 taken 7490 times.
78780444 if (isLowerWall_(globalPos))
269 {
270 1814554 values[Indices::turbulentKineticEnergyIdx] = 0.0;
271 3629108 values[Indices::dissipationIdx] = 0.0;
272 }
273 }
274 }
275
276 //! Boundary condition types for the one-eq turbulence model
277 165456942 void setBcTypes_([[maybe_unused]] BoundaryTypes& values,
278 [[maybe_unused]] const GlobalPosition& pos) const
279 {
280 if constexpr (numTurbulenceEq(ModelTraits::turbulenceModel()) == 0) // zero equation models
281 return;
282 else if constexpr (numTurbulenceEq(ModelTraits::turbulenceModel()) == 1) // one equation models
283 {
284
4/4
✓ Branch 0 taken 1448019 times.
✓ Branch 1 taken 8073390 times.
✓ Branch 2 taken 1448019 times.
✓ Branch 3 taken 8073390 times.
19042818 if(isOutlet_(pos))
285 1448019 values.setOutflow(Indices::viscosityTildeIdx);
286 else // walls and inflow
287 8073390 values.setDirichlet(Indices::viscosityTildeIdx);
288 }
289 else // two equation models
290 {
291 static_assert(numTurbulenceEq(ModelTraits::turbulenceModel()) == 2, "Only reached by 2eq models");
292
4/4
✓ Branch 0 taken 11731846 times.
✓ Branch 1 taken 153725096 times.
✓ Branch 2 taken 11731846 times.
✓ Branch 3 taken 153725096 times.
330913884 if(isOutlet_(pos))
293 {
294 11731846 values.setOutflow(Indices::turbulentKineticEnergyEqIdx);
295 11731846 values.setOutflow(Indices::dissipationEqIdx);
296 }
297 else
298 {
299 // walls and inflow
300 153725096 values.setDirichlet(Indices::turbulentKineticEnergyIdx);
301 153725096 values.setDirichlet(Indices::dissipationIdx);
302 }
303 }
304 165456942 }
305
306 template<class Element, class FVElementGeometry, class SubControlVolume>
307 36655960 bool isDirichletCell_([[maybe_unused]] const Element& element,
308 const FVElementGeometry& fvGeometry,
309 [[maybe_unused]] const SubControlVolume& scv,
310 const int& pvIdx) const
311 {
312 if constexpr (ModelTraits::turbulenceModel() == TurbulenceModel::kepsilon)
313 {
314 20102080 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
315 // For the kepsilon model we set fixed values within the matching point and at the wall
316
2/2
✓ Branch 1 taken 5421184 times.
✓ Branch 2 taken 4629856 times.
10051040 if (this->inNearWallRegion(eIdx))
317 5421184 return pvIdx == Indices::turbulentKineticEnergyEqIdx || pvIdx == Indices::dissipationEqIdx;
318
2/2
✓ Branch 1 taken 658302 times.
✓ Branch 2 taken 3971554 times.
4629856 if (this->isMatchingPoint(eIdx))
319 658302 return pvIdx == Indices::dissipationEqIdx;
320 return false;
321 }
322 else if constexpr (ModelTraits::turbulenceModel() == TurbulenceModel::komega ||
323 ModelTraits::turbulenceModel() == TurbulenceModel::sst )
324 {
325 // For the komega model we set a fixed dissipation (omega) for all cells at the wall
326
4/4
✓ Branch 0 taken 106170724 times.
✓ Branch 1 taken 26355964 times.
✓ Branch 2 taken 106170724 times.
✓ Branch 3 taken 26355964 times.
265053376 for (const auto& scvf : scvfs(fvGeometry))
327
4/4
✓ Branch 1 taken 1123984 times.
✓ Branch 2 taken 105046740 times.
✓ Branch 3 taken 248956 times.
✓ Branch 4 taken 875028 times.
106170724 if (this->boundaryTypes(element, scvf).hasWall() && pvIdx == Indices::dissipationIdx)
328 248956 return true;
329 26355964 return false;
330 }
331 else
332 return ParentType::isDirichletCell(element, fvGeometry, scv, pvIdx);
333 }
334
335 //! Specialization for the kepsilon and komega
336 template<class Element, class SubControlVolume>
337 2764866 PrimaryVariables dirichletTurbulentTwoEq_(const Element& element,
338 const SubControlVolume& scv) const
339 {
340 2764866 const auto globalPos = scv.center();
341 2764866 PrimaryVariables values(initialAtPos(globalPos));
342 8294598 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
343
344 if constexpr (ModelTraits::turbulenceModel() == TurbulenceModel::kepsilon)
345 {
346 // For the kepsilon model we set a fixed value for the turbulent kinetic energy and the dissipation
347 2521570 values[Indices::turbulentKineticEnergyEqIdx] = this->turbulentKineticEnergyWallFunction(elementIdx);
348 2521570 values[Indices::dissipationEqIdx] = this->dissipationWallFunction(elementIdx);
349 2521570 return values;
350 }
351 else
352 {
353 static_assert(ModelTraits::turbulenceModel() == TurbulenceModel::komega ||
354 ModelTraits::turbulenceModel() == TurbulenceModel::sst, "Only valid for SST and KOmega Models");
355 // For the komega model we set a fixed value for the dissipation
356 486592 const auto wallDistance = ParentType::wallDistance(elementIdx);
357 using std::pow;
358 973184 values[Indices::dissipationEqIdx] = 6.0 * ParentType::kinematicViscosity(elementIdx)
359 243296 / (ParentType::betaOmega() * wallDistance * wallDistance);
360 243296 return values;
361 }
362 }
363
364 const Scalar eps_;
365 Scalar inletVelocity_;
366 Scalar inletMoleFraction_;
367 Scalar inletTemperature_;
368 Scalar wallTemperature_;
369 Scalar viscosityTilde_;
370 Scalar turbulentKineticEnergy_;
371 Scalar dissipation_;
372 TimeLoopPtr timeLoop_;
373 std::string turbulenceModelName_;
374 };
375 } // end namespace Dumux
376
377 #endif
378