GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/freeflow/rans/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 250 277 90.3%
Functions: 896 902 99.3%
Branches: 268 939 28.5%

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 RANSModel
10 * \copydoc Dumux::RANSProblem
11 */
12 #ifndef DUMUX_RANS_PROBLEM_HH
13 #define DUMUX_RANS_PROBLEM_HH
14
15 #include <algorithm>
16
17 #include <dune/common/fmatrix.hh>
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/staggeredfvproblem.hh>
20 #include <dumux/discretization/localview.hh>
21 #include <dumux/discretization/method.hh>
22 #include <dumux/discretization/walldistance.hh>
23 #include <dumux/discretization/staggered/elementsolution.hh>
24 #include <dumux/freeflow/navierstokes/staggered/problem.hh>
25 #include "model.hh"
26
27 namespace Dumux {
28
29 //! forward declare
30 template<class TypeTag, TurbulenceModel turbulenceModel>
31 class RANSProblemImpl;
32
33 //! the turbulence-model-specfic RANS problem
34 template<class TypeTag>
35 using RANSProblem = RANSProblemImpl<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::turbulenceModel()>;
36
37 /*!
38 * \ingroup RANSModel
39 * \brief Reynolds-Averaged Navier-Stokes problem base class.
40 *
41 * This implements some base functionality for RANS models.
42 * Especially vectors containing all wall-relevant properties, which are accessed
43 * by the volumevariables.
44 */
45 template<class TypeTag>
46 class RANSProblemBase : public NavierStokesStaggeredProblem<TypeTag>
47 {
48 using ParentType = NavierStokesStaggeredProblem<TypeTag>;
49 using Implementation = GetPropType<TypeTag, Properties::Problem>;
50
51 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
52
53 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
54 using FVElementGeometry = typename GridGeometry::LocalView;
55 using GridView = typename GridGeometry::GridView;
56 using Element = typename GridView::template Codim<0>::Entity;
57 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
58 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
59 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
60 using PrimaryVariables = typename VolumeVariables::PrimaryVariables;
61 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
62 using FacePrimaryVariables = GetPropType<TypeTag, Properties::FacePrimaryVariables>;
63 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
64
65 using GlobalPosition = typename SubControlVolumeFace::GlobalPosition;
66
67 static constexpr auto dim = GridView::dimension;
68 static constexpr int numCorners = SubControlVolumeFace::numCornersPerFace;
69 using DimVector = GlobalPosition;
70 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
71
72 struct WallElementInformation
73 {
74 // store the element indices for all elements with an intersection on the wall
75 unsigned int wallElementIdx;
76 // for each wall element, store the faces normal axis
77 unsigned int wallFaceNormalAxis;
78 // for each wall element, store the location of the face center and each corner.
79 GlobalPosition wallFaceCenter;
80 std::array<GlobalPosition, numCorners> wallFaceCorners;
81 };
82
83 public:
84
85 /*!
86 * \brief The constructor
87 * \param gridGeometry The finite volume grid geometry
88 * \param paramGroup The parameter group in which to look for runtime parameters first (default is "")
89 */
90 70 RANSProblemBase(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
91
4/8
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 50 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 50 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 50 times.
✗ Branch 12 not taken.
140 : ParentType(gridGeometry, paramGroup)
92 {
93
3/6
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 50 times.
140 if ( !(hasParamInGroup(this->paramGroup(), "RANS.IsFlatWallBounded")))
94 {
95 std::cout << "The parameter \"Rans.IsFlatWallBounded\" is not specified. \n"
96 << " -- Based on the grid and the boundary conditions specified by the user,"
97 << " this parameter is set to be "<< std::boolalpha << isFlatWallBounded() << "\n";
98 }
99
100 // update size and initial values of the global vectors
101
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 wallDistance_.resize(this->gridGeometry().elementMapper().size(), std::numeric_limits<Scalar>::max());
102
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 neighborIdx_.resize(this->gridGeometry().elementMapper().size());
103
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
140 velocity_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
104
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
140 velocityGradients_.resize(this->gridGeometry().elementMapper().size(), DimMatrix(0.0));
105
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 stressTensorScalarProduct_.resize(this->gridGeometry().elementMapper().size(), 0.0);
106
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 vorticityTensorScalarProduct_.resize(this->gridGeometry().elementMapper().size(), 0.0);
107
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 flowDirectionAxis_.resize(this->gridGeometry().elementMapper().size(), fixedFlowDirectionAxis_);
108
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 storedViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
109
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 storedDensity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
110 70 }
111
112 /*!
113 * \brief Update the static (solution independent) relations to the walls and neighbors
114 */
115 70 void updateStaticWallProperties()
116 {
117 70 std::cout << "Update static wall properties. ";
118 70 calledUpdateStaticWallProperties = true;
119
120 70 checkForWalls_();
121 70 findWallDistances_();
122 70 findNeighborIndices_();
123 70 }
124
125 /*!
126 * \brief Update the dynamic (solution dependent) turbulence parameters
127 *
128 * \param curSol The solution vector.
129 */
130 template<class SolutionVector>
131 1127 void updateDynamicWallProperties(const SolutionVector& curSol)
132 {
133 1127 std::cout << "Update dynamic wall properties." << std::endl;
134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1107 times.
1127 if (!calledUpdateStaticWallProperties)
135 DUNE_THROW(Dune::InvalidStateException,
136 "You have to call updateStaticWallProperties() once before you call updateDynamicWallProperties().");
137
138 1127 calculateCCVelocities_(curSol);
139 1127 calculateCCVelocityGradients_();
140 1127 calculateMaxMinVelocities_();
141 1127 calculateStressTensor_();
142 1127 calculateVorticityTensor_();
143 1127 storeViscosities_(curSol);
144 1127 }
145
146 /*!
147 * \brief Returns whether a wall function should be used at a given face
148 *
149 * \param element The element.
150 * \param scvf The sub control volume face.
151 * \param eqIdx The equation index.
152 */
153 bool useWallFunction(const Element& element,
154 const SubControlVolumeFace& scvf,
155 const int& eqIdx) const
156 { return false; }
157
158 /*!
159 * \brief Returns an additional wall function momentum flux
160 */
161 template<class ElementVolumeVariables, class ElementFaceVariables>
162 FacePrimaryVariables wallFunction(const Element& element,
163 const FVElementGeometry& fvGeometry,
164 const ElementVolumeVariables& elemVolVars,
165 const ElementFaceVariables& elemFaceVars,
166 const SubControlVolumeFace& scvf,
167 const SubControlVolumeFace& lateralBoundaryFace) const
168 { return FacePrimaryVariables(0.0); }
169
170 /*!
171 * \brief Returns an additional wall function flux for cell-centered quantities
172 */
173 template<class ElementVolumeVariables, class ElementFaceVariables>
174 CellCenterPrimaryVariables wallFunction(const Element& element,
175 const FVElementGeometry& fvGeometry,
176 const ElementVolumeVariables& elemVolVars,
177 const ElementFaceVariables& elemFaceVars,
178 const SubControlVolumeFace& scvf) const
179 { return CellCenterPrimaryVariables(0.0); }
180
181 /*!
182 * \brief Returns whether a given sub control volume face is on a wall
183 */
184 1005804617 bool isFlatWallBounded() const
185 {
186
4/6
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1005771615 times.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 50 times.
✗ Branch 7 not taken.
1005804617 static const bool hasAlignedWalls = hasAlignedWalls_();
187 1005804617 return hasAlignedWalls;
188 }
189
190 /*!
191 * \brief Returns the Karman constant
192 */
193 const Scalar karmanConstant() const
194 { return 0.41; }
195
196 //! \brief Returns the \f$ \beta_{\omega} \f$ constant
197 const Scalar betaOmega() const
198 { return 0.0708; }
199
200 /*!
201 * \brief Return the turbulent Prandtl number \f$ [-] \f$ which is used to convert
202 * the eddy viscosity to an eddy thermal conductivity
203 */
204 43055122 Scalar turbulentPrandtlNumber() const
205 {
206
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 43053397 times.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
43055157 static const Scalar turbulentPrandtlNumber
207
1/2
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
70 = getParamFromGroup<Scalar>(this->paramGroup(), "RANS.TurbulentPrandtlNumber", 1.0);
208 43055122 return turbulentPrandtlNumber;
209 }
210
211 /*!
212 * \brief Return the turbulent Schmidt number \f$ [-] \f$ which is used to convert
213 * the eddy viscosity to an eddy diffusivity
214 */
215 98533912 Scalar turbulentSchmidtNumber() const
216 {
217
3/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 98530462 times.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
98533982 static const Scalar turbulentSchmidtNumber
218
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
140 = getParamFromGroup<Scalar>(this->paramGroup(), "RANS.TurbulentSchmidtNumber", 1.0);
219 98533912 return turbulentSchmidtNumber;
220 }
221
222 139797016 int wallNormalAxis(const int elementIdx) const
223 {
224
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 139791884 times.
139797016 if (!isFlatWallBounded())
225 DUNE_THROW(Dune::NotImplemented, "\n Due to grid/geometric concerns, models requiring a wallNormalAxis "
226 << "can only be used for flat wall bounded flows. "
227 << "\n If your geometry is a flat channel, "
228 << "please set the runtime parameter RANS.IsFlatWallBounded to true. \n");
229 139797016 return wallNormalAxis_[elementIdx];
230 }
231
232 169490604 int flowDirectionAxis(const int elementIdx) const
233 {
234
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 169484872 times.
169490604 if (!isFlatWallBounded())
235 DUNE_THROW(Dune::NotImplemented, "\n Due to grid/geometric concerns, models requiring a flowDirectionAxis "
236 << "can only be used for flat wall bounded flows. "
237 << "\n If your geometry is a flat channel, "
238 << "please set the runtime parameter RANS.IsFlatWallBounded to true. \n");
239 169490604 return flowDirectionAxis_[elementIdx];
240 }
241
242 598219908 unsigned int wallElementIndex(const int elementIdx) const
243 {
244
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 598201268 times.
598219908 if (!isFlatWallBounded())
245 DUNE_THROW(Dune::NotImplemented, "\n Due to grid/geometric concerns, models requiring a wallElementIndex "
246 << "can only be used for flat wall bounded flows. "
247 << "\n If your geometry is a flat channel, "
248 << "please set the runtime parameter RANS.IsFlatWallBounded to true. \n");
249 598219908 return wallElementIdx_[elementIdx];
250
251 }
252
253 191446644 Scalar wallDistance(const int elementIdx) const
254
3/30
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 2 taken 16832 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 16832 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 16832 times.
✗ Branch 9 not taken.
184850556 { return wallDistance_[elementIdx]; }
255
256 5146204 GlobalPosition cellCenter(const int elementIdx) const
257 {
258 5146204 const auto& element = this->gridGeometry().element(elementIdx);
259 5146204 return element.geometry().center();
260 }
261
262 1446650 unsigned int neighborIndex(const int elementIdx, const int axisIdx, const int sideIdx) const
263
16/32
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 50 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 50 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 25 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 25 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 25 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 25 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 50 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 5 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 50 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 5 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 50 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 5 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 50 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 5 times.
✗ Branch 47 not taken.
603312 { return neighborIdx_[elementIdx][axisIdx][sideIdx];}
264
265 98292464 DimVector ccVelocityVector(const int elementIdx) const
266 98292464 { return velocity_[elementIdx]; }
267
268 87969050 Scalar ccVelocity(const int elementIdx, const int axisIdx) const
269 85352816 { return velocity_[elementIdx][axisIdx]; }
270
271 183712608 DimVector velocityMaximum(const int elementIdx) const
272
2/20
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 3 taken 33664 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 33664 times.
✗ Branch 7 not taken.
183678944 { return velocityMaximum_[elementIdx]; }
273
274 183712608 DimVector velocityMinimum(const int elementIdx) const
275
1/10
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✓ Branch 3 taken 33664 times.
✗ Branch 4 not taken.
183678944 { return velocityMinimum_[elementIdx]; }
276
277 98292464 DimMatrix velocityGradientTensor(const int elementIdx) const
278 98292464 { return velocityGradients_[elementIdx]; }
279
280 136445596 Scalar velocityGradient(const int elementIdx, const int i, const int j) const
281
22/56
✓ Branch 0 taken 136136 times.
✓ Branch 1 taken 85213430 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16982 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 150 times.
✓ Branch 6 taken 16832 times.
✓ Branch 7 taken 150 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 175 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 175 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 175 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 175 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 175 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 175 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 175 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 175 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 175 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 175 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 175 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 175 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 175 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 175 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 175 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 175 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
85386480 { return velocityGradients_[elementIdx][i][j]; }
282
283 93030316 Scalar stressTensorScalarProduct(const int elementIdx) const
284 93030316 { return stressTensorScalarProduct_[elementIdx]; }
285
286 26866480 Scalar vorticityTensorScalarProduct(const int elementIdx) const
287 26866480 { return vorticityTensorScalarProduct_[elementIdx]; }
288
289 336917404 Scalar storedViscosity(const int elementIdx) const
290 336917404 { return storedViscosity_[elementIdx]; }
291
292 337490968 Scalar storedDensity(const int elementIdx) const
293 337490968 { return storedDensity_[elementIdx]; }
294
295
1/10
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 2 taken 16832 times.
✗ Branch 3 not taken.
200480168 Scalar kinematicViscosity(const int elementIdx) const
296
2/20
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 2 taken 16832 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 16832 times.
✗ Branch 6 not taken.
216896296 { return storedViscosity(elementIdx) / storedDensity(elementIdx); }
297
298 bool calledUpdateStaticWallProperties = false;
299
300 private:
301
302 70 bool hasAlignedWalls_() const
303 {
304
2/4
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 50 times.
✗ Branch 6 not taken.
140 if ( hasParamInGroup(this->paramGroup(), "RANS.IsFlatWallBounded"))
305 {
306
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 50 times.
✗ Branch 7 not taken.
70 static const bool isFlatWallBounded = getParamFromGroup<bool>(this->paramGroup(), "RANS.IsFlatWallBounded");
307 70 return isFlatWallBounded;
308 }
309
310 std::vector<int> wallFaceAxis;
311 wallFaceAxis.reserve(this->gridGeometry().numBoundaryScvf());
312
313 const auto gridView = this->gridGeometry().gridView();
314 auto fvGeometry = localView(this->gridGeometry());
315 for (const auto& element : elements(gridView))
316 {
317 fvGeometry.bindElement(element);
318 for (const auto& scvf : scvfs(fvGeometry))
319 if (!scvf.boundary() && asImp_().boundaryTypes(element, scvf).hasWall()) // only search for walls at a global boundary
320 wallFaceAxis.push_back(scvf.directionIndex());
321 }
322
323 // Returns if all wall directions are the same
324 return std::all_of(wallFaceAxis.begin(), wallFaceAxis.end(), [firstDir=wallFaceAxis[0]](auto dir){ return (dir == firstDir);} ) ;
325 }
326
327 70 void checkForWalls_()
328 {
329
3/5
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 2 taken 30 times.
140 for (const auto& element : elements(this->gridGeometry().gridView()))
330 {
331
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
70 auto fvGeometry = localView(this->gridGeometry());
332 70 fvGeometry.bindElement(element);
333
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
130 for (auto&& scvf : scvfs(fvGeometry))
334
2/3
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
138 if (asImp_().boundaryTypes(element, scvf).hasWall())
335 70 return;
336 }
337 // If reached, no walls were found using the boundary types has wall function.
338
0/20
✗ 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.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
70 DUNE_THROW(Dune::InvalidStateException, "No walls are are specified with the setWall() function");
339 }
340
341 /*!
342 * \brief Use the boundary search algorithm to find the shortest distance to a wall for each element
343 *
344 * Also store the wall element's index, and its direction in the case of flat wall bounded problems
345 */
346 70 void findWallDistances_()
347 {
348 70 WallDistance wallInformation(this->gridGeometry(), WallDistance<GridGeometry>::atElementCenters,
349
1/2
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
470 [this] (const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvf)
350
32/32
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 15 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 15 times.
✓ Branch 12 taken 5 times.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 5 times.
✓ Branch 15 taken 15 times.
✓ Branch 16 taken 5 times.
✓ Branch 17 taken 15 times.
✓ Branch 18 taken 5 times.
✓ Branch 19 taken 15 times.
✓ Branch 20 taken 5 times.
✓ Branch 21 taken 15 times.
✓ Branch 22 taken 5 times.
✓ Branch 23 taken 15 times.
✓ Branch 24 taken 5 times.
✓ Branch 25 taken 15 times.
✓ Branch 26 taken 5 times.
✓ Branch 27 taken 15 times.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 15 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 15 times.
2270 { return asImp_().boundaryTypes(fvGeometry.element(), scvf).hasWall(); });
351
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 wallDistance_ = wallInformation.wallDistance();
352
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
70 storeWallElementAndDirectionIndex_(wallInformation.wallData());
353 70 }
354
355 template <class WallData>
356 70 void storeWallElementAndDirectionIndex_(const WallData& wallData)
357 {
358 // The wall Direction Index is used for flat quadrilateral channel problems only
359 if (!(GridGeometry::discMethod == DiscretizationMethods::staggered))
360 70 DUNE_THROW(Dune::NotImplemented, "The wall direction Index can only be calculated for quadrilateral structured grids");
361
362 // If isFlatWallBounded, the corresponding wall element is stored for each element
363
2/2
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 3 times.
70 if (isFlatWallBounded())
364 {
365 67 wallNormalAxis_.resize(wallData.size());
366 67 wallElementIdx_.resize(wallData.size());
367
368
1/2
✓ Branch 2 taken 6347 times.
✗ Branch 3 not taken.
20534 for (const auto& element : elements(this->gridGeometry().gridView()))
369 {
370 6800 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
371 6800 wallElementIdx_[elementIdx] = wallData[elementIdx].eIdx;
372
2/2
✓ Branch 1 taken 500 times.
✓ Branch 2 taken 5800 times.
13600 if ( ! (hasParam("RANS.WallNormalAxis")) )
373 {
374 1000 GlobalPosition wallOuterNormal = wallData[elementIdx].scvfOuterNormal;
375 if constexpr (dim == 2) // 2D
376 1000 wallNormalAxis_[elementIdx] = (wallOuterNormal[0] == 1) ? 0 : 1;
377 else // 3D
378 wallNormalAxis_[elementIdx] = (wallOuterNormal[0] == 1) ? 0 : ((wallOuterNormal[1] == 1) ? 1 : 2);
379 }
380 else
381 5800 wallNormalAxis_[elementIdx] = fixedWallNormalAxis_;
382 }
383 }
384 70 }
385
386 /*!
387 * \brief Store all direct neighbor indices for each element
388 */
389 70 void findNeighborIndices_()
390 {
391 // search for neighbor Idxs
392
1/2
✓ Branch 1 taken 7086 times.
✗ Branch 2 not taken.
15142 for (const auto& element : elements(this->gridGeometry().gridView()))
393 {
394 7536 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
395
2/2
✓ Branch 0 taken 14072 times.
✓ Branch 1 taken 7036 times.
22608 for (unsigned int axisIdx = 0; axisIdx < dim; ++axisIdx)
396 {
397 15072 neighborIdx_[elementIdx][axisIdx][0] = elementIdx;
398 15072 neighborIdx_[elementIdx][axisIdx][1] = elementIdx;
399 }
400
401
4/4
✓ Branch 1 taken 7036 times.
✓ Branch 2 taken 28144 times.
✓ Branch 4 taken 2270 times.
✓ Branch 5 taken 25874 times.
45216 for (const auto& intersection : intersections(this->gridGeometry().gridView(), element))
402 {
403
2/2
✓ Branch 0 taken 2270 times.
✓ Branch 1 taken 25874 times.
30144 if (intersection.boundary())
404 2670 continue;
405
406 27474 unsigned int neighborIdx = this->gridGeometry().elementMapper().index(intersection.outside());
407
2/2
✓ Branch 0 taken 51748 times.
✓ Branch 1 taken 25874 times.
82422 for (unsigned int axisIdx = 0; axisIdx < dim; ++axisIdx)
408 {
409
2/2
✓ Branch 2 taken 25874 times.
✓ Branch 3 taken 25874 times.
54948 if (abs(cellCenter(elementIdx)[axisIdx] - cellCenter(neighborIdx)[axisIdx]) > 1e-8)
410 {
411
2/2
✓ Branch 2 taken 12937 times.
✓ Branch 3 taken 12937 times.
27474 if (cellCenter(elementIdx)[axisIdx] > cellCenter(neighborIdx)[axisIdx])
412 13737 neighborIdx_[elementIdx][axisIdx][0] = neighborIdx;
413
414
2/2
✓ Branch 2 taken 12937 times.
✓ Branch 3 taken 12937 times.
27474 if (cellCenter(elementIdx)[axisIdx] < cellCenter(neighborIdx)[axisIdx])
415 13737 neighborIdx_[elementIdx][axisIdx][1] = neighborIdx;
416 }
417 }
418 }
419 }
420 70 }
421
422 template<class SolutionVector>
423 1127 void calculateCCVelocities_(const SolutionVector& curSol)
424 {
425
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
1127 auto fvGeometry = localView(this->gridGeometry());
426 // calculate cell-center-averaged velocities
427
4/7
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 246055 times.
✓ Branch 4 taken 520 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 500 times.
✗ Branch 8 not taken.
✗ Branch 3 not taken.
739031 for (const auto& element : elements(this->gridGeometry().gridView()))
428 {
429 245968 fvGeometry.bindElement(element);
430 245968 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
431
432 // calculate velocities
433 245968 DimVector velocityTemp(0.0);
434
2/2
✓ Branch 0 taken 981872 times.
✓ Branch 1 taken 245468 times.
1229840 for (auto&& scvf : scvfs(fvGeometry))
435 {
436 983872 const int dofIdxFace = scvf.dofIndex();
437 983872 const auto numericalSolutionFace = curSol[GridGeometry::faceIdx()][dofIdxFace][0];
438 983872 velocityTemp[scvf.directionIndex()] += numericalSolutionFace;
439 }
440
2/2
✓ Branch 0 taken 490936 times.
✓ Branch 1 taken 245468 times.
737904 for (unsigned int axisIdx = 0; axisIdx < dim; ++axisIdx)
441 491936 velocity_[elementIdx][axisIdx] = velocityTemp[axisIdx] * 0.5; // faces are equidistant to cell center
442 }
443 1127 }
444
445
446 1127 void calculateCCVelocityGradients_()
447 {
448 using std::abs;
449
450 // calculate cell-center-averaged velocity gradients, maximum, and minimum values
451
1/2
✓ Branch 1 taken 1107 times.
✗ Branch 2 not taken.
1127 auto fvGeometry = localView(this->gridGeometry());
452
2/4
✓ Branch 1 taken 1107 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 246575 times.
✗ Branch 5 not taken.
739031 for (const auto& element : elements(this->gridGeometry().gridView()))
453 {
454 245968 const unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
455
456
2/2
✓ Branch 0 taken 490936 times.
✓ Branch 1 taken 245468 times.
737904 for (unsigned int j = 0; j < dim; ++j)
457 {
458
2/2
✓ Branch 0 taken 981872 times.
✓ Branch 1 taken 490936 times.
1475808 for (unsigned int i = 0; i < dim; ++i)
459 {
460
1/2
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
983872 const unsigned int neighborIndex0 = neighborIndex(elementIdx, j, 0);
461 983872 const unsigned int neighborIndex1 = neighborIndex(elementIdx, j, 1);
462
463
1/2
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
983872 velocityGradients_[elementIdx][i][j]
464
1/2
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
983872 = (ccVelocity(neighborIndex1, i) - ccVelocity(neighborIndex0, i))
465
3/6
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 981872 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 981872 times.
✗ Branch 8 not taken.
983872 / (cellCenter(neighborIndex1)[j] - cellCenter(neighborIndex0)[j]);
466
467
3/6
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 981872 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 981872 times.
983872 if (abs(cellCenter(neighborIndex1)[j] - cellCenter(neighborIndex0)[j]) < 1e-8)
468 velocityGradients_[elementIdx][i][j] = 0.0;
469 }
470 }
471
472 245968 fvGeometry.bindElement(element);
473
6/6
✓ Branch 0 taken 69090 times.
✓ Branch 1 taken 912782 times.
✓ Branch 3 taken 2000 times.
✓ Branch 4 taken 979872 times.
✓ Branch 5 taken 246968 times.
✓ Branch 6 taken 500 times.
1233840 for (auto&& scvf : scvfs(fvGeometry))
474 {
475 // adapt calculations for Dirichlet condition
476
2/2
✓ Branch 0 taken 69090 times.
✓ Branch 1 taken 912782 times.
983872 unsigned int axisIdx = scvf.directionIndex();
477
2/2
✓ Branch 0 taken 69090 times.
✓ Branch 1 taken 912782 times.
983872 if (scvf.boundary())
478 {
479
2/2
✓ Branch 0 taken 138180 times.
✓ Branch 1 taken 69090 times.
208470 for (unsigned int velIdx = 0; velIdx < dim; ++velIdx)
480 {
481
4/5
✓ Branch 0 taken 86040 times.
✓ Branch 1 taken 52020 times.
✓ Branch 2 taken 52100 times.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
139300 if (!asImp_().boundaryTypes(element, scvf).isDirichlet(Indices::velocity(velIdx)))
482 52700 continue;
483
484
1/2
✓ Branch 1 taken 86080 times.
✗ Branch 2 not taken.
86680 Scalar dirichletVelocity = asImp_().dirichlet(element, scvf)[Indices::velocity(velIdx)];
485
486
1/2
✓ Branch 1 taken 86080 times.
✗ Branch 2 not taken.
86280 unsigned int neighborIdx = neighborIndex(elementIdx, axisIdx, 0);
487
3/4
✓ Branch 1 taken 86080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68890 times.
✓ Branch 4 taken 17190 times.
86280 if (scvf.center()[axisIdx] < cellCenter(elementIdx)[axisIdx])
488 69090 neighborIdx = neighborIndex(elementIdx, axisIdx, 1);
489
490 86280 velocityGradients_[elementIdx][velIdx][axisIdx]
491
1/2
✓ Branch 1 taken 86080 times.
✗ Branch 2 not taken.
86280 = (ccVelocity(neighborIdx, velIdx) - dirichletVelocity)
492
1/2
✓ Branch 1 taken 86080 times.
✗ Branch 2 not taken.
86280 / (cellCenter(neighborIdx)[axisIdx] - scvf.center()[axisIdx]);
493 }
494 }
495
496 // Calculate the BJS-velocity by accounting for all sub faces.
497
2/4
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 981872 times.
✗ Branch 5 not taken.
983872 std::vector<int> bjsNumFaces(dim, 0);
498
1/4
✓ Branch 1 taken 981872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
983872 std::vector<unsigned int> bjsNeighbor(dim, 0);
499 983872 DimVector bjsVelocityAverage(0.0);
500 983872 DimVector normalNormCoordinate(0.0);
501 983872 unsigned int velCompIdx = Indices::velocity(scvf.directionIndex());
502 983872 const int numSubFaces = scvf.pairData().size();
503
2/2
✓ Branch 0 taken 1963744 times.
✓ Branch 1 taken 981872 times.
2951616 for(int localSubFaceIdx = 0; localSubFaceIdx < numSubFaces; ++localSubFaceIdx)
504 {
505
3/3
✓ Branch 1 taken 1823164 times.
✓ Branch 2 taken 3200 times.
✓ Branch 0 taken 137380 times.
1967744 const auto& lateralFace = fvGeometry.scvf(scvf.insideScvIdx(), scvf.pairData()[localSubFaceIdx].localLateralFaceIdx);
506
507 // adapt calculations for Beavers-Joseph-Saffman condition
508
2/2
✓ Branch 0 taken 138180 times.
✓ Branch 1 taken 1825564 times.
1967744 unsigned int lateralAxisIdx = lateralFace.directionIndex();
509
4/5
✓ Branch 0 taken 138180 times.
✓ Branch 1 taken 1825564 times.
✓ Branch 2 taken 138020 times.
✓ Branch 3 taken 160 times.
✗ Branch 4 not taken.
1968064 if (lateralFace.boundary() && (asImp_().boundaryTypes(element, lateralFace).isBeaversJoseph(Indices::velocity(velCompIdx))))
510 {
511 unsigned int neighborIdx = neighborIndex(elementIdx, lateralAxisIdx, 0);
512 if (lateralFace.center()[lateralAxisIdx] < cellCenter(elementIdx)[lateralAxisIdx])
513 neighborIdx = neighborIndex(elementIdx, lateralAxisIdx, 1);
514
515 const SubControlVolume& scv = fvGeometry.scv(scvf.insideScvIdx());
516 bjsVelocityAverage[lateralAxisIdx] += ParentType::beaversJosephVelocity(element, scv, scvf, lateralFace, ccVelocity(elementIdx, velCompIdx), 0.0);
517 if (bjsNumFaces[lateralAxisIdx] > 0 && neighborIdx != bjsNeighbor[lateralAxisIdx])
518 DUNE_THROW(Dune::InvalidStateException, "Two different neighborIdx should not occur");
519 bjsNeighbor[lateralAxisIdx] = neighborIdx;
520 normalNormCoordinate[lateralAxisIdx] = lateralFace.center()[lateralAxisIdx];
521 bjsNumFaces[lateralAxisIdx]++;
522 }
523 }
524
2/2
✓ Branch 0 taken 1963744 times.
✓ Branch 1 taken 981872 times.
2951616 for (unsigned axisIdx = 0; axisIdx < dim; ++axisIdx)
525 {
526
1/2
✓ Branch 0 taken 1963744 times.
✗ Branch 1 not taken.
1967744 if (bjsNumFaces[axisIdx] == 0)
527 1967744 continue;
528
529 unsigned int neighborIdx = bjsNeighbor[axisIdx];
530 bjsVelocityAverage[axisIdx] /= bjsNumFaces[axisIdx];
531
532 velocityGradients_[elementIdx][velCompIdx][axisIdx]
533 = (ccVelocity(neighborIdx, velCompIdx) - bjsVelocityAverage[axisIdx])
534 / (cellCenter(neighborIdx)[axisIdx] - normalNormCoordinate[axisIdx]);
535 }
536 }
537 }
538 1127 }
539
540 1127 void calculateMaxMinVelocities_()
541 {
542 using std::abs;
543
2/2
✓ Branch 1 taken 970 times.
✓ Branch 2 taken 137 times.
1127 if (isFlatWallBounded())
544 {
545 // If the parameter isFlatWallBounded is set to true,
546 // the maximum/minimum velocities are calculated along a profile perpendicular to the corresponding wall face.
547
548 // re-initialize min and max values
549 1980 velocityMaximum_.assign(this->gridGeometry().elementMapper().size(), DimVector(1e-16));
550 1980 velocityMinimum_.assign(this->gridGeometry().elementMapper().size(), DimVector(std::numeric_limits<Scalar>::max()));
551
552 // For each profile perpendicular to the channel wall, find the max and minimum velocities
553
1/2
✓ Branch 2 taken 212486 times.
✗ Branch 3 not taken.
638028 for (const auto& element : elements(this->gridGeometry().gridView()))
554 {
555 212016 const unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
556 212016 Scalar maxVelocity = 0.0;
557 212016 const unsigned int wallElementIdx = wallElementIndex(elementIdx);
558
559
2/2
✓ Branch 0 taken 423032 times.
✓ Branch 1 taken 211516 times.
636048 for (unsigned int axisIdx = 0; axisIdx < dim; ++axisIdx)
560 {
561
2/2
✓ Branch 0 taken 255466 times.
✓ Branch 1 taken 167566 times.
424032 if (abs(ccVelocity(elementIdx, axisIdx)) > abs(velocityMaximum_[wallElementIdx][axisIdx]))
562 256466 velocityMaximum_[wallElementIdx][axisIdx] = ccVelocity(elementIdx, axisIdx);
563
564
2/2
✓ Branch 0 taken 108034 times.
✓ Branch 1 taken 314998 times.
424032 if (abs(ccVelocity(elementIdx, axisIdx)) < abs(velocityMinimum_[wallElementIdx][axisIdx]))
565 108234 velocityMinimum_[wallElementIdx][axisIdx] = ccVelocity(elementIdx, axisIdx);
566
567 // Set the flow direction axis as the direction of the max velocity
568
7/12
✓ Branch 1 taken 423032 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 423032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 423032 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 211750 times.
✓ Branch 9 taken 211282 times.
✓ Branch 10 taken 211282 times.
✓ Branch 11 taken 211750 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1272096 if ((hasParam("RANS.FlowDirectionAxis") != 1) && (maxVelocity) < abs(ccVelocity(elementIdx, axisIdx)))
569 {
570 211782 maxVelocity = abs(ccVelocity(elementIdx, axisIdx));
571 211782 flowDirectionAxis_[elementIdx] = axisIdx;
572 }
573 }
574 }
575 }
576 else
577 {
578 // If the parameter isFlatWallBounded is set to false, or not set,
579 // the maximum/minimum velocities are calculated as a global max/min throughout the domain.
580
581 137 DimVector maxVelocity(0.0);
582 137 DimVector minVelocity(std::numeric_limits<Scalar>::max());
583 // Find the max and minimum velocities in the full domain
584
1/2
✓ Branch 2 taken 34089 times.
✗ Branch 3 not taken.
101993 for (const auto& element : elements(this->gridGeometry().gridView()))
585 {
586 33952 const unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
587
588
2/2
✓ Branch 0 taken 67904 times.
✓ Branch 1 taken 33952 times.
101856 for (unsigned int axisIdx = 0; axisIdx < dim; ++axisIdx)
589 {
590
2/2
✓ Branch 0 taken 3543 times.
✓ Branch 1 taken 64361 times.
67904 if (abs(ccVelocity(elementIdx, axisIdx)) > abs(maxVelocity[axisIdx]))
591 3543 maxVelocity[axisIdx] = ccVelocity(elementIdx, axisIdx);
592
593
2/2
✓ Branch 0 taken 2744 times.
✓ Branch 1 taken 65160 times.
67904 if (abs(ccVelocity(elementIdx, axisIdx)) < abs(minVelocity[axisIdx]))
594 2744 minVelocity[axisIdx] = ccVelocity(elementIdx, axisIdx);
595 }
596 }
597 137 velocityMaximum_.assign(this->gridGeometry().elementMapper().size(), maxVelocity);
598 137 velocityMinimum_.assign(this->gridGeometry().elementMapper().size(), minVelocity);
599 }
600 1127 }
601
602 1127 void calculateStressTensor_()
603 {
604
1/2
✓ Branch 2 taken 246575 times.
✗ Branch 3 not taken.
739031 for (const auto& element : elements(this->gridGeometry().gridView()))
605 {
606 245968 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
607 983872 Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension> stressTensor(0.0);
608
2/2
✓ Branch 0 taken 490936 times.
✓ Branch 1 taken 245468 times.
737904 for (unsigned int j = 0; j < dim; ++j)
609 {
610
2/2
✓ Branch 0 taken 981872 times.
✓ Branch 1 taken 490936 times.
1475808 for (unsigned int i = 0; i < dim; ++i)
611 {
612 983872 stressTensor[j][i] = 0.5 * velocityGradient(elementIdx, j, i)
613 983872 + 0.5 * velocityGradient(elementIdx, i, j);
614 }
615 }
616 245968 stressTensorScalarProduct_[elementIdx] = 0.0;
617
2/2
✓ Branch 0 taken 490936 times.
✓ Branch 1 taken 245468 times.
737904 for (unsigned int j = 0; j < dim; ++j)
618 {
619
2/2
✓ Branch 0 taken 981872 times.
✓ Branch 1 taken 490936 times.
1475808 for (unsigned int i = 0; i < dim; ++i)
620 {
621 983872 stressTensorScalarProduct_[elementIdx] += stressTensor[j][i] * stressTensor[j][i];
622 }
623 }
624 }
625 1127 }
626
627 1127 void calculateVorticityTensor_()
628 {
629
1/2
✓ Branch 2 taken 246575 times.
✗ Branch 3 not taken.
739031 for (const auto& element : elements(this->gridGeometry().gridView()))
630 {
631 245968 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
632 983872 Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension> vorticityTensor(0.0);
633
2/2
✓ Branch 0 taken 490936 times.
✓ Branch 1 taken 245468 times.
737904 for (unsigned int j = 0; j < dim; ++j)
634 {
635
2/2
✓ Branch 0 taken 981872 times.
✓ Branch 1 taken 490936 times.
1475808 for (unsigned int i = 0; i < dim; ++i)
636 {
637 983872 vorticityTensor[j][i] = 0.5 * velocityGradient(elementIdx, j, i)
638 983872 - 0.5 * velocityGradient(elementIdx, i, j);
639 }
640 }
641 245968 vorticityTensorScalarProduct_[elementIdx] = 0.0;
642
2/2
✓ Branch 0 taken 490936 times.
✓ Branch 1 taken 245468 times.
737904 for (unsigned int j = 0; j < dim; ++j)
643 {
644
2/2
✓ Branch 0 taken 981872 times.
✓ Branch 1 taken 490936 times.
1475808 for (unsigned int i = 0; i < dim; ++i)
645 {
646 983872 vorticityTensorScalarProduct_[elementIdx] += vorticityTensor[j][i] * vorticityTensor[j][i];
647 }
648 }
649 }
650 1127 }
651
652 template<class SolutionVector>
653 1127 void storeViscosities_(const SolutionVector& curSol)
654 {
655 // calculate or call all secondary variables
656
1/2
✓ Branch 1 taken 1107 times.
✗ Branch 2 not taken.
1127 auto fvGeometry = localView(this->gridGeometry());
657
2/4
✓ Branch 1 taken 1107 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 246575 times.
✗ Branch 5 not taken.
739031 for (const auto& element : elements(this->gridGeometry().gridView()))
658 {
659
1/2
✓ Branch 2 taken 500 times.
✗ Branch 3 not taken.
245968 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
660 246968 fvGeometry.bindElement(element);
661
4/5
✓ Branch 0 taken 236227 times.
✓ Branch 1 taken 245468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9241 times.
✓ Branch 4 taken 9241 times.
491936 for (auto&& scv : scvs(fvGeometry))
662 {
663
1/2
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
245968 const int dofIdx = scv.dofIndex();
664 // construct a privars object from the cell center solution vector
665
1/2
✓ Branch 1 taken 9241 times.
✗ Branch 2 not taken.
245968 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
666 245968 PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
667
1/2
✓ Branch 1 taken 245468 times.
✗ Branch 2 not taken.
245968 auto elemSol = elementSolution<typename GridGeometry::LocalView>(std::move(priVars));
668
669 245968 VolumeVariables volVars;
670
1/2
✓ Branch 1 taken 245468 times.
✗ Branch 2 not taken.
245968 volVars.update(elemSol, asImp_(), element, scv);
671
1/2
✓ Branch 0 taken 245468 times.
✗ Branch 1 not taken.
245968 storedDensity_[elementIdx] = volVars.density();
672
1/2
✓ Branch 0 taken 245468 times.
✗ Branch 1 not taken.
245968 storedViscosity_[elementIdx] = volVars.viscosity();
673 }
674 }
675 1127 }
676
677 const int fixedFlowDirectionAxis_ = getParam<int>("RANS.FlowDirectionAxis", 0);
678 const int fixedWallNormalAxis_ = getParam<int>("RANS.WallNormalAxis", 1);
679
680 std::vector<unsigned int> wallNormalAxis_;
681 std::vector<unsigned int> flowDirectionAxis_;
682 std::vector<Scalar> wallDistance_;
683 std::vector<unsigned int> wallElementIdx_;
684 std::vector<std::array<std::array<unsigned int, 2>, dim>> neighborIdx_;
685
686 std::vector<DimVector> velocity_;
687 std::vector<DimVector> velocityMaximum_;
688 std::vector<DimVector> velocityMinimum_;
689 std::vector<DimMatrix> velocityGradients_;
690
691 std::vector<Scalar> stressTensorScalarProduct_;
692 std::vector<Scalar> vorticityTensorScalarProduct_;
693
694 std::vector<Scalar> storedDensity_;
695 std::vector<Scalar> storedViscosity_;
696
697 //! Returns the implementation of the problem (i.e. static polymorphism)
698 Implementation &asImp_()
699 { return *static_cast<Implementation *>(this); }
700
701 //! \copydoc asImp_()
702 const Implementation &asImp_() const
703 { return *static_cast<const Implementation *>(this); }
704 };
705
706 } // end namespace Dumux
707
708 #endif
709