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 KOmegaModel | ||
10 | * \copydoc Dumux::KOmegaResidualImpl | ||
11 | */ | ||
12 | #ifndef DUMUX_STAGGERED_KOMEGA_LOCAL_RESIDUAL_HH | ||
13 | #define DUMUX_STAGGERED_KOMEGA_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 KOmegaModel | ||
24 | * \brief Element-wise calculation of the residual for k-omega models using the staggered discretization | ||
25 | */ | ||
26 | |||
27 | // forward declaration | ||
28 | template<class TypeTag, class BaseLocalResidual, class DiscretizationMethod> | ||
29 | class KOmegaResidualImpl; | ||
30 | |||
31 | template<class TypeTag, class BaseLocalResidual> | ||
32 | class KOmegaResidualImpl<TypeTag, BaseLocalResidual, DiscretizationMethods::Staggered> | ||
33 | : public BaseLocalResidual | ||
34 | { | ||
35 | using ParentType = BaseLocalResidual; | ||
36 | |||
37 | using GridVariables = GetPropType<TypeTag, Properties::GridVariables>; | ||
38 | |||
39 | using GridVolumeVariables = typename GridVariables::GridVolumeVariables; | ||
40 | using ElementVolumeVariables = typename GridVolumeVariables::LocalView; | ||
41 | using VolumeVariables = typename GridVolumeVariables::VolumeVariables; | ||
42 | |||
43 | using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache; | ||
44 | using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView; | ||
45 | using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>; | ||
46 | |||
47 | using GridFaceVariables = typename GridVariables::GridFaceVariables; | ||
48 | using ElementFaceVariables = typename GridFaceVariables::LocalView; | ||
49 | |||
50 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
51 | using Problem = GetPropType<TypeTag, Properties::Problem>; | ||
52 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
53 | using Element = typename GridView::template Codim<0>::Entity; | ||
54 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
55 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
56 | using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>; | ||
57 | using CellCenterResidual = CellCenterPrimaryVariables; | ||
58 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
59 | using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; | ||
60 | |||
61 | static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim(); | ||
62 | static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim(); | ||
63 | |||
64 | public: | ||
65 |
4/8✓ Branch 1 taken 177320 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 177320 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 177320 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 177320 times.
✗ Branch 11 not taken.
|
709280 | using ParentType::ParentType; |
66 | |||
67 | //! Evaluate fluxes entering or leaving the cell center control volume. | ||
68 | ✗ | CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem, | |
69 | const SubControlVolume& scv, | ||
70 | const VolumeVariables& volVars) const | ||
71 | { | ||
72 | 11195200 | CellCenterPrimaryVariables storage = ParentType::computeStorageForCellCenter(problem, scv, volVars); | |
73 | |||
74 | 22390400 | storage[turbulentKineticEnergyEqIdx] = volVars.turbulentKineticEnergy()*volVars.density(); | |
75 | 33585600 | storage[dissipationEqIdx] = volVars.dissipation()*volVars.density(); | |
76 | |||
77 | ✗ | return storage; | |
78 | } | ||
79 | |||
80 | 7747800 | CellCenterPrimaryVariables computeSourceForCellCenter(const Problem& problem, | |
81 | const Element &element, | ||
82 | const FVElementGeometry& fvGeometry, | ||
83 | const ElementVolumeVariables& elemVolVars, | ||
84 | const ElementFaceVariables& elemFaceVars, | ||
85 | const SubControlVolume &scv) const | ||
86 | { | ||
87 | 7747800 | CellCenterPrimaryVariables source = ParentType::computeSourceForCellCenter(problem, element, fvGeometry, | |
88 | elemVolVars, elemFaceVars, scv); | ||
89 | |||
90 | using std::min; | ||
91 | 7747800 | const auto& volVars = elemVolVars[scv]; | |
92 | |||
93 | // production | ||
94 |
3/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7747795 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
|
7747805 | static const auto enableKOmegaProductionLimiter |
95 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
15 | = getParamFromGroup<bool>(problem.paramGroup(), "KOmega.EnableProductionLimiter", false); |
96 | 7747800 | Scalar productionTerm = 2.0 * volVars.dynamicEddyViscosity() * volVars.stressTensorScalarProduct(); | |
97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7747800 times.
|
7747800 | if (enableKOmegaProductionLimiter) |
98 | { | ||
99 | ✗ | Scalar productionAlternative = 20.0 * volVars.density() * volVars.betaK() * volVars.turbulentKineticEnergy() * volVars.dissipation(); | |
100 | ✗ | productionTerm = min(productionTerm, productionAlternative); | |
101 | } | ||
102 | 7747800 | source[turbulentKineticEnergyEqIdx] += productionTerm; | |
103 | 7747800 | source[dissipationEqIdx] += volVars.alpha() * volVars.dissipation() / volVars.turbulentKineticEnergy() * productionTerm; | |
104 | |||
105 | // destruction | ||
106 | 15495600 | source[turbulentKineticEnergyEqIdx] -= volVars.betaK() * volVars.density() * volVars.turbulentKineticEnergy() * volVars.dissipation(); | |
107 | 15495600 | source[dissipationEqIdx] -= volVars.betaOmega() * volVars.density() * volVars.dissipation() * volVars.dissipation(); | |
108 | |||
109 | // cross-diffusion term | ||
110 | 7747800 | Scalar gradientProduct = 0.0; | |
111 |
2/2✓ Branch 0 taken 15495600 times.
✓ Branch 1 taken 7747800 times.
|
23243400 | for (unsigned int i = 0; i < ModelTraits::dim(); ++i) |
112 | 15495600 | gradientProduct += volVars.storedTurbulentKineticEnergyGradient()[i] | |
113 | 30991200 | * volVars.storedDissipationGradient()[i]; | |
114 |
2/2✓ Branch 0 taken 3625465 times.
✓ Branch 1 taken 4122335 times.
|
7747800 | if (gradientProduct > 0.0) |
115 | 10876395 | source[dissipationEqIdx] += 0.125 *volVars.density() / volVars.dissipation() * gradientProduct; | |
116 | |||
117 | 7747800 | return source; | |
118 | } | ||
119 | }; | ||
120 | } // end namespace Dumux | ||
121 | |||
122 | #endif | ||
123 |