GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/sst/staggered/localresidual.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 20 33 60.6%
Functions: 4 8 50.0%
Branches: 8 32 25.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-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 SSTModel
10 * \copydoc Dumux::SSTResidualImpl
11 */
12 #ifndef DUMUX_SST_STAGGERED_KOMEGA_LOCAL_RESIDUAL_HH
13 #define DUMUX_SST_STAGGERED_KOMEGA_LOCAL_RESIDUAL_HH
14
15 #include <dune/common/hybridutilities.hh>
16 #include <dune/common/exceptions.hh>
17 #include <dumux/common/properties.hh>
18 #include <dumux/discretization/method.hh>
19 #include <dumux/freeflow/turbulencemodel.hh>
20 #include <dumux/freeflow/navierstokes/localresidual.hh>
21
22 namespace Dumux {
23
24 /*!
25 * \ingroup SSTModel
26 * \brief Element-wise calculation of the residual for SST models using the staggered discretization
27 */
28
29 // forward declaration
30 template<class TypeTag, class BaseLocalResidual, class DiscretizationMethod>
31 class SSTResidualImpl;
32
33 template<class TypeTag, class BaseLocalResidual>
34 class SSTResidualImpl<TypeTag, BaseLocalResidual, DiscretizationMethods::Staggered>
35 : public BaseLocalResidual
36 {
37 using ParentType = BaseLocalResidual;
38
39 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
40
41 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
42 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
43 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
44
45 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
46 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
47 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
48
49 using GridFaceVariables = typename GridVariables::GridFaceVariables;
50 using ElementFaceVariables = typename GridFaceVariables::LocalView;
51
52 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
53 using Problem = GetPropType<TypeTag, Properties::Problem>;
54 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
55 using Element = typename GridView::template Codim<0>::Entity;
56 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
57 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
58 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
59 using CellCenterResidual = CellCenterPrimaryVariables;
60 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
61 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
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 131104 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 131104 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 131104 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 131104 times.
✗ Branch 11 not taken.
524416 using ParentType::ParentType;
68
69 //! Evaluate fluxes entering or leaving the cell center control volume.
70 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
71 const SubControlVolume& scv,
72 const VolumeVariables& volVars) const
73 {
74 7776000 CellCenterPrimaryVariables storage = ParentType::computeStorageForCellCenter(problem, scv, volVars);
75
76 15552000 storage[turbulentKineticEnergyEqIdx] = volVars.turbulentKineticEnergy()*volVars.density();
77 23328000 storage[dissipationEqIdx] = volVars.dissipation()*volVars.density();
78
79 return storage;
80 }
81
82 5879680 CellCenterPrimaryVariables computeSourceForCellCenter(const Problem& problem,
83 const Element &element,
84 const FVElementGeometry& fvGeometry,
85 const ElementVolumeVariables& elemVolVars,
86 const ElementFaceVariables& elemFaceVars,
87 const SubControlVolume &scv) const
88 {
89 5879680 CellCenterPrimaryVariables source = ParentType::computeSourceForCellCenter(problem, element, fvGeometry,
90 elemVolVars, elemFaceVars, scv);
91
92 using std::min;
93 5879680 const auto& volVars = elemVolVars[scv];
94
95
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5879680 times.
5879680 if(problem.sstModelVersion() == SSTModel::BSL)
96 {
97 // production
98 Scalar productionTerm = 2.0 * volVars.dynamicEddyViscosity() * volVars.stressTensorScalarProduct();
99 source[turbulentKineticEnergyEqIdx] += productionTerm;
100 source[dissipationEqIdx] += volVars.gammaBSL() / volVars.kinematicEddyViscosity() * productionTerm;
101
102 // destruction
103 source[turbulentKineticEnergyEqIdx] -= volVars.betaStarBSL() * volVars.density() * volVars.turbulentKineticEnergy() * volVars.dissipation();
104 source[dissipationEqIdx] -= volVars.betaBSL() * volVars.density() * volVars.dissipation() * volVars.dissipation();
105
106 // cross-diffusion term
107 Scalar gradientProduct = 0.0;
108 for (unsigned int i = 0; i < ModelTraits::dim(); ++i)
109 gradientProduct += volVars.storedTurbulentKineticEnergyGradient()[i]
110 * volVars.storedDissipationGradient()[i];
111
112 source[dissipationEqIdx] += 2.0 * volVars.density() * (1.0-volVars.F1()) * volVars.sigmaOmega2() / volVars.dissipation() * gradientProduct;
113 }
114
1/2
✓ Branch 0 taken 5879680 times.
✗ Branch 1 not taken.
5879680 else if(problem.sstModelVersion() == SSTModel::SST)
115 {
116 // production
117 5879680 Scalar productionTerm = 2.0 * volVars.dynamicEddyViscosity() * volVars.stressTensorScalarProduct();
118 5879680 source[turbulentKineticEnergyEqIdx] += productionTerm;
119 5879680 source[dissipationEqIdx] += volVars.gammaSST() / volVars.kinematicEddyViscosity() * productionTerm;
120
121 // destruction
122 5879680 source[turbulentKineticEnergyEqIdx] -= volVars.betaStarSST() * volVars.density() * volVars.turbulentKineticEnergy() * volVars.dissipation();
123 5879680 source[dissipationEqIdx] -= volVars.betaSST() * volVars.density() * volVars.dissipation() * volVars.dissipation();
124
125 // cross-diffusion term
126 5879680 Scalar gradientProduct = 0.0;
127
2/2
✓ Branch 0 taken 11759360 times.
✓ Branch 1 taken 5879680 times.
17639040 for (unsigned int i = 0; i < ModelTraits::dim(); ++i)
128 11759360 gradientProduct += volVars.storedTurbulentKineticEnergyGradient()[i]
129 23518720 * volVars.storedDissipationGradient()[i];
130 11759360 source[dissipationEqIdx] += 2.0 * volVars.density() * (1.0-volVars.F1()) * volVars.sigmaOmega2() / volVars.dissipation() * gradientProduct;
131 }
132 else
133 DUNE_THROW(Dune::NotImplemented, "\nThis SST Model is not implemented.\n");
134
135 5879680 return source;
136 }
137 };
138 } // end namespace Dumux
139
140 #endif
141