GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/komega/staggered/fluxvariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 58 60 96.7%
Functions: 8 16 50.0%
Branches: 38 42 90.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-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::KOmegaFluxVariablesImpl
11 */
12 #ifndef DUMUX_KOMEGA_STAGGERED_FLUXVARIABLES_HH
13 #define DUMUX_KOMEGA_STAGGERED_FLUXVARIABLES_HH
14
15 #include <numeric>
16 #include <dumux/common/properties.hh>
17 #include <dumux/flux/fluxvariablesbase.hh>
18 #include <dumux/discretization/method.hh>
19 #include <dumux/discretization/extrusion.hh>
20 #include <dumux/freeflow/navierstokes/fluxvariables.hh>
21 #include <dumux/freeflow/rans/twoeq/komega/fluxvariables.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup KOmegaModel
27 * \brief The flux variables class for the k-omega model using the staggered grid discretization.
28 */
29
30 // forward declaration
31 template<class TypeTag, class BaseFluxVariables, class DiscretizationMethod>
32 class KOmegaFluxVariablesImpl;
33
34 template<class TypeTag, class BaseFluxVariables>
35 class KOmegaFluxVariablesImpl<TypeTag, BaseFluxVariables, DiscretizationMethods::Staggered>
36 : public BaseFluxVariables
37 {
38 using ParentType = BaseFluxVariables;
39
40 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
41
42 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
43 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
44 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
45
46 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
47 using FluxVariablesCache = typename GridFluxVariablesCache::FluxVariablesCache;
48
49 using GridFaceVariables = typename GridVariables::GridFaceVariables;
50 using ElementFaceVariables = typename GridFaceVariables::LocalView;
51 using FaceVariables = typename GridFaceVariables::FaceVariables;
52
53 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
54 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
55 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
56 using FVElementGeometry = typename GridGeometry::LocalView;
57 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
58 using Extrusion = Extrusion_t<GridGeometry>;
59 using GridView = typename GridGeometry::GridView;
60 using Problem = GetPropType<TypeTag, Properties::Problem>;
61 using Element = typename GridView::template Codim<0>::Entity;
62 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
63 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
64 using FacePrimaryVariables = GetPropType<TypeTag, Properties::FacePrimaryVariables>;
65
66 static constexpr int turbulentKineticEnergyEqIdx = Indices::turbulentKineticEnergyEqIdx - ModelTraits::dim();
67 static constexpr int dissipationEqIdx = Indices::dissipationEqIdx - ModelTraits::dim();
68
69 public:
70
71 /*!
72 * \brief Computes the flux for the cell center residual.
73 */
74 31979160 CellCenterPrimaryVariables computeMassFlux(const Problem& problem,
75 const Element &element,
76 const FVElementGeometry& fvGeometry,
77 const ElementVolumeVariables& elemVolVars,
78 const ElementFaceVariables& elemFaceVars,
79 const SubControlVolumeFace &scvf,
80 const FluxVariablesCache& fluxVarsCache)
81 {
82 31979160 CellCenterPrimaryVariables flux = ParentType::computeMassFlux(problem, element, fvGeometry,
83 elemVolVars, elemFaceVars, scvf, fluxVarsCache);
84
85 // calculate advective flux
86 auto upwindTermK = [](const auto& volVars)
87 {
88 127916640 return volVars.turbulentKineticEnergy()*volVars.density();
89 };
90 auto upwindTermOmega = [](const auto& volVars)
91 {
92 127916640 return volVars.dissipation()*volVars.density();
93 };
94
95 63958320 flux[turbulentKineticEnergyEqIdx]
96 31979160 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermK);
97 63958320 flux[dissipationEqIdx]
98 31979160 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermOmega);
99
100 // calculate diffusive flux
101 63958320 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
102 63958320 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
103 63958320 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
104 63958320 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
105
106 // effective diffusion coefficients
107 31979160 Scalar insideCoeff_k = insideVolVars.viscosity()
108
4/4
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
✓ Branch 2 taken 1837080 times.
✓ Branch 3 taken 30142080 times.
63958320 + ( insideVolVars.sigmaK() * insideVolVars.density()* insideVolVars.turbulentKineticEnergy() / insideVolVars.dissipation() );
109 31979160 Scalar outsideCoeff_k = outsideVolVars.viscosity()
110
4/4
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
✓ Branch 2 taken 1837080 times.
✓ Branch 3 taken 30142080 times.
63958320 + ( outsideVolVars.sigmaK() * outsideVolVars.density()* outsideVolVars.turbulentKineticEnergy() / outsideVolVars.dissipation() );
111 31979160 Scalar insideCoeff_w = insideVolVars.viscosity()
112
4/4
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
✓ Branch 2 taken 1837080 times.
✓ Branch 3 taken 30142080 times.
63958320 + ( insideVolVars.sigmaOmega() * insideVolVars.density()* insideVolVars.turbulentKineticEnergy() / insideVolVars.dissipation() );
113 31979160 Scalar outsideCoeff_w = outsideVolVars.viscosity()
114
4/4
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
✓ Branch 2 taken 1837080 times.
✓ Branch 3 taken 30142080 times.
63958320 + ( outsideVolVars.sigmaOmega() * outsideVolVars.density()* outsideVolVars.turbulentKineticEnergy() / outsideVolVars.dissipation() );
115
116 // scale by extrusion factor
117 31979160 insideCoeff_k *= insideVolVars.extrusionFactor();
118 31979160 outsideCoeff_k *= outsideVolVars.extrusionFactor();
119 31979160 insideCoeff_w *= insideVolVars.extrusionFactor();
120 31979160 outsideCoeff_w *= outsideVolVars.extrusionFactor();
121
122 31979160 Scalar distance = 0.0;
123 31979160 Scalar coeff_k = 0.0;
124 31979160 Scalar coeff_w = 0.0;
125
2/2
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
31979160 if (scvf.boundary())
126 {
127 7348320 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
128 1837080 coeff_k = insideCoeff_k;
129 1837080 coeff_w = insideCoeff_w;
130 }
131 else
132 {
133 // average and distance
134
2/2
✓ Branch 0 taken 30132882 times.
✓ Branch 1 taken 9198 times.
30142080 coeff_k = arithmeticMean(insideCoeff_k, outsideCoeff_k,
135 120568320 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
136 120568320 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
137
2/2
✓ Branch 0 taken 30132754 times.
✓ Branch 1 taken 9326 times.
30142080 coeff_w = arithmeticMean(insideCoeff_w, outsideCoeff_w,
138 120568320 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
139 120568320 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
140 150710400 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
141 }
142
143 31979160 const auto bcTypes = problem.boundaryTypes(element, scvf);
144
2/2
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
31979160 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
145
6/8
✓ Branch 0 taken 1204280 times.
✓ Branch 1 taken 632800 times.
✓ Branch 2 taken 1204280 times.
✓ Branch 3 taken 632800 times.
✓ Branch 4 taken 1204280 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1204280 times.
✗ Branch 7 not taken.
3674160 || bcTypes.isSymmetry())))
146 {
147 94039080 flux[turbulentKineticEnergyEqIdx]
148 31346360 += coeff_k / distance
149 31346360 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
150 62692720 * Extrusion::area(fvGeometry, scvf);
151 }
152
2/2
✓ Branch 0 taken 1837080 times.
✓ Branch 1 taken 30142080 times.
31979160 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx)
153
6/8
✓ Branch 0 taken 1204280 times.
✓ Branch 1 taken 632800 times.
✓ Branch 2 taken 1204280 times.
✓ Branch 3 taken 632800 times.
✓ Branch 4 taken 1204280 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1204280 times.
✗ Branch 7 not taken.
3674160 || bcTypes.isSymmetry())))
154 {
155 94039080 flux[dissipationEqIdx]
156 31346360 += coeff_w / distance
157 31346360 * (insideVolVars.dissipation() - outsideVolVars.dissipation())
158 62692720 * Extrusion::area(fvGeometry, scvf);
159 }
160 31979160 return flux;
161 }
162
163 /*!
164 * \brief Returns the momentum flux over all staggered faces.
165 */
166 26266172 FacePrimaryVariables computeMomentumFlux(const Problem& problem,
167 const Element& element,
168 const SubControlVolumeFace& scvf,
169 const FVElementGeometry& fvGeometry,
170 const ElementVolumeVariables& elemVolVars,
171 const ElementFaceVariables& elemFaceVars,
172 const GridFluxVariablesCache& gridFluxVarsCache)
173 {
174 52532344 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
175
176 26266172 return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
177 105064688 + ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
178 26266172 + 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
179 52532344 * Extrusion::area(fvGeometry, scvf) * scvf.directionSign() * insideVolVars.extrusionFactor();
180 }
181 };
182
183 } // end namespace
184
185 #endif
186