GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/lowrekepsilon/staggered/fluxvariables.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 58 60 96.7%
Functions: 8 16 50.0%
Branches: 44 50 88.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 LowReKEpsilonModel
10 * \copydoc Dumux::LowReKEpsilonFluxVariablesImpl
11 */
12 #ifndef DUMUX_LOWREKEPSILON_STAGGERED_FLUXVARIABLES_HH
13 #define DUMUX_LOWREKEPSILON_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/lowrekepsilon/fluxvariables.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup LowReKEpsilonModel
27 * \brief The flux variables class for the low-Reynolds k-epsilon model using the staggered grid discretization.
28 */
29
30 // forward declaration
31 template<class TypeTag, class BaseFluxVariables, class DiscretizationMethod>
32 class LowReKEpsilonFluxVariablesImpl;
33
34 template<class TypeTag, class BaseFluxVariables>
35 class LowReKEpsilonFluxVariablesImpl<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 20190354 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 20190354 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 80761416 return volVars.turbulentKineticEnergy() * volVars.density();
89 };
90 auto upwindTermEpsilon = [](const auto& volVars)
91 {
92 80761416 return volVars.dissipationTilde() * volVars.density();
93 };
94
95 40380708 flux[turbulentKineticEnergyEqIdx]
96 20190354 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermK);
97 40380708 flux[dissipationEqIdx]
98 20190354 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermEpsilon);
99
100 // calculate diffusive flux
101 40380708 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
102 40380708 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
103 40380708 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
104 40380708 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
105
106 // effective diffusion coefficients
107
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 Scalar insideCoeff_k = insideVolVars.viscosity() + insideVolVars.kinematicEddyViscosity()
108
4/4
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
✓ Branch 2 taken 1173870 times.
✓ Branch 3 taken 19016484 times.
40380708 * insideVolVars.density() / insideVolVars.sigmaK();
109
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 Scalar outsideCoeff_k = outsideVolVars.viscosity() + outsideVolVars.kinematicEddyViscosity()
110
4/4
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
✓ Branch 2 taken 1173870 times.
✓ Branch 3 taken 19016484 times.
40380708 * outsideVolVars.density() / outsideVolVars.sigmaK();
111
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 Scalar insideCoeff_e = insideVolVars.viscosity() + insideVolVars.kinematicEddyViscosity()
112
4/4
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
✓ Branch 2 taken 1173870 times.
✓ Branch 3 taken 19016484 times.
40380708 * insideVolVars.density() / insideVolVars.sigmaEpsilon();
113
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 Scalar outsideCoeff_e = outsideVolVars.viscosity() + outsideVolVars.kinematicEddyViscosity()
114
4/4
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
✓ Branch 2 taken 1173870 times.
✓ Branch 3 taken 19016484 times.
40380708 * outsideVolVars.density() / outsideVolVars.sigmaEpsilon();
115
116 // scale by extrusion factor
117 20190354 insideCoeff_k *= insideVolVars.extrusionFactor();
118 20190354 outsideCoeff_k *= outsideVolVars.extrusionFactor();
119 20190354 insideCoeff_e *= insideVolVars.extrusionFactor();
120 20190354 outsideCoeff_e *= outsideVolVars.extrusionFactor();
121
122 20190354 Scalar coeff_k = 0.0;
123 20190354 Scalar coeff_e = 0.0;
124 20190354 Scalar distance = 0.0;
125
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 if (scvf.boundary())
126 {
127 1173870 coeff_k = insideCoeff_k;
128 1173870 coeff_e = insideCoeff_e;
129 5869350 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
130 }
131 else
132 {
133 // average and distance
134
1/2
✓ Branch 0 taken 19016484 times.
✗ Branch 1 not taken.
19016484 coeff_k = arithmeticMean(insideCoeff_k, outsideCoeff_k,
135 76065936 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
136 76065936 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
137
1/2
✓ Branch 0 taken 19016484 times.
✗ Branch 1 not taken.
19016484 coeff_e = arithmeticMean(insideCoeff_e, outsideCoeff_e,
138 76065936 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
139 76065936 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
140 95082420 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
141 }
142
143 20190354 const auto bcTypes = problem.boundaryTypes(element, scvf);
144
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
145
6/8
✓ Branch 0 taken 766806 times.
✓ Branch 1 taken 407064 times.
✓ Branch 2 taken 766806 times.
✓ Branch 3 taken 407064 times.
✓ Branch 4 taken 766806 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 766806 times.
✗ Branch 7 not taken.
2347740 || bcTypes.isSymmetry())))
146 {
147 59349870 flux[turbulentKineticEnergyEqIdx]
148 19783290 += coeff_k / distance
149 19783290 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
150 39566580 * Extrusion::area(fvGeometry, scvf);
151 }
152
2/2
✓ Branch 0 taken 1173870 times.
✓ Branch 1 taken 19016484 times.
20190354 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx)
153
6/8
✓ Branch 0 taken 766806 times.
✓ Branch 1 taken 407064 times.
✓ Branch 2 taken 766806 times.
✓ Branch 3 taken 407064 times.
✓ Branch 4 taken 766806 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 766806 times.
✗ Branch 7 not taken.
2347740 || bcTypes.isSymmetry())))
154 {
155 59349870 flux[dissipationEqIdx]
156 19783290 += coeff_e / distance
157 19783290 * (insideVolVars.dissipationTilde() - outsideVolVars.dissipationTilde())
158 39566580 * Extrusion::area(fvGeometry, scvf);
159 }
160 20190354 return flux;
161 }
162
163 /*!
164 * \brief Returns the momentum flux over all staggered faces.
165 */
166 16592064 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 33184128 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
175
176 16592064 return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
177 66368256 + ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
178 16592064 + 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
179 33184128 * Extrusion::area(fvGeometry, scvf) * scvf.directionSign() * insideVolVars.extrusionFactor();
180 }
181 };
182
183 } // end namespace
184
185 #endif
186