GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/kepsilon/staggered/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 22 24 91.7%
Functions: 4 8 50.0%
Branches: 10 14 71.4%

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 KEpsilonModel
10 * \copydoc Dumux::KEpsilonResidualImpl
11 */
12 #ifndef DUMUX_STAGGERED_KEPSILON_LOCAL_RESIDUAL_HH
13 #define DUMUX_STAGGERED_KEPSILON_LOCAL_RESIDUAL_HH
14
15 #include <dune/common/hybridutilities.hh>
16 #include <dumux/common/properties.hh>
17 #include <dumux/discretization/method.hh>
18 #include <dumux/freeflow/navierstokes/localresidual.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup KEpsilonModel
24 * \brief Element-wise calculation of the residual for k-epsilon models using the staggered discretization
25 */
26
27 // forward declaration
28 template<class TypeTag, class BaseLocalResidual, class DiscretizationMethod>
29 class KEpsilonResidualImpl;
30
31 template<class TypeTag, class BaseLocalResidual>
32 class KEpsilonResidualImpl<TypeTag, BaseLocalResidual, DiscretizationMethods::Staggered>
33 : public BaseLocalResidual
34 {
35 using ParentType = BaseLocalResidual;
36 friend class StaggeredLocalResidual<TypeTag>;
37
38 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
39
40 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
41 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
42 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
43
44 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
45 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
46 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
47
48 using GridFaceVariables = typename GridVariables::GridFaceVariables;
49 using ElementFaceVariables = typename GridFaceVariables::LocalView;
50
51 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
52 using Problem = GetPropType<TypeTag, Properties::Problem>;
53 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
54 using Element = typename GridView::template Codim<0>::Entity;
55 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
56 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
57 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
58 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
59 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
60
61 using CellCenterResidual = CellCenterPrimaryVariables;
62
63 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
64 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
65
66 public:
67
4/8
✓ Branch 1 taken 261912 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 261912 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 261912 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 261912 times.
✗ Branch 11 not taken.
1047648 using ParentType::ParentType;
68
69 // account for the offset of the cell center privars within the PrimaryVariables container
70 static constexpr auto cellCenterOffset = ModelTraits::numEq() - CellCenterPrimaryVariables::dimension;
71 static_assert(cellCenterOffset == ModelTraits::dim(), "cellCenterOffset must equal dim for staggered NavierStokes");
72
73 //! Evaluate fluxes entering or leaving the cell center control volume.
74 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
75 const SubControlVolume& scv,
76 const VolumeVariables& volVars) const
77 {
78 18405720 CellCenterPrimaryVariables storage = ParentType::computeStorageForCellCenter(problem, scv, volVars);
79
80 36811440 storage[turbulentKineticEnergyEqIdx] = volVars.turbulentKineticEnergy() * volVars.density();
81 55217160 storage[dissipationEqIdx] = volVars.dissipation() * volVars.density();
82
83 return storage;
84 }
85
86 10875020 CellCenterPrimaryVariables computeSourceForCellCenter(const Problem& problem,
87 const Element &element,
88 const FVElementGeometry& fvGeometry,
89 const ElementVolumeVariables& elemVolVars,
90 const ElementFaceVariables& elemFaceVars,
91 const SubControlVolume &scv) const
92 {
93 10875020 CellCenterPrimaryVariables source = ParentType::computeSourceForCellCenter(problem, element, fvGeometry,
94 elemVolVars, elemFaceVars, scv);
95
96 10875020 const auto& volVars = elemVolVars[scv];
97 10875020 Scalar turbulentKineticEnergy = volVars.turbulentKineticEnergy();
98 10875020 Scalar dissipation = volVars.dissipation();
99
100 // production
101 // turbulence production is equal to dissipation -> exclude both terms (according to local equilibrium hypothesis, see FLUENT)
102
2/2
✓ Branch 0 taken 9856414 times.
✓ Branch 1 taken 1018606 times.
10875020 if (!volVars.isMatchingPoint())
103 {
104 9856414 source[turbulentKineticEnergyEqIdx] += 2.0 * volVars.dynamicEddyViscosity()
105 9856414 * volVars.stressTensorScalarProduct();
106 }
107 21750040 source[dissipationEqIdx] += volVars.cOneEpsilon()
108 10875020 * dissipation / turbulentKineticEnergy
109 10875020 * 2.0 * volVars.dynamicEddyViscosity()
110
2/2
✓ Branch 0 taken 9856414 times.
✓ Branch 1 taken 1018606 times.
10875020 * volVars.stressTensorScalarProduct();
111
112 // destruction
113 // turbulence production is equal to dissipation -> exclude both terms (according to local equilibrium hypothesis, see FLUENT)
114
2/2
✓ Branch 0 taken 9856414 times.
✓ Branch 1 taken 1018606 times.
10875020 if (!volVars.isMatchingPoint())
115 {
116 29569242 source[turbulentKineticEnergyEqIdx] -= dissipation * volVars.density();
117 }
118 21750040 source[dissipationEqIdx] -= volVars.cTwoEpsilon()
119 10875020 * dissipation * dissipation
120 21750040 / turbulentKineticEnergy * volVars.density();
121
122 10875020 return source;
123 }
124 };
125 } // end namespace Dumux
126
127 #endif
128