GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/twoeq/komega/staggered/fluxvariables.hh
Date: 2024-09-21 20:52:54
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 30870910 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 30870910 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 123483640 return volVars.turbulentKineticEnergy()*volVars.density();
89 };
90 auto upwindTermOmega = [](const auto& volVars)
91 {
92 123483640 return volVars.dissipation()*volVars.density();
93 };
94
95 61741820 flux[turbulentKineticEnergyEqIdx]
96 30870910 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermK);
97 61741820 flux[dissipationEqIdx]
98 30870910 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermOmega);
99
100 // calculate diffusive flux
101 61741820 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
102 61741820 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
103 61741820 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
104 61741820 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
105
106 // effective diffusion coefficients
107 30870910 Scalar insideCoeff_k = insideVolVars.viscosity()
108
4/4
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
✓ Branch 2 taken 1777330 times.
✓ Branch 3 taken 29093580 times.
61741820 + ( insideVolVars.sigmaK() * insideVolVars.density()* insideVolVars.turbulentKineticEnergy() / insideVolVars.dissipation() );
109 30870910 Scalar outsideCoeff_k = outsideVolVars.viscosity()
110
4/4
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
✓ Branch 2 taken 1777330 times.
✓ Branch 3 taken 29093580 times.
61741820 + ( outsideVolVars.sigmaK() * outsideVolVars.density()* outsideVolVars.turbulentKineticEnergy() / outsideVolVars.dissipation() );
111 30870910 Scalar insideCoeff_w = insideVolVars.viscosity()
112
4/4
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
✓ Branch 2 taken 1777330 times.
✓ Branch 3 taken 29093580 times.
61741820 + ( insideVolVars.sigmaOmega() * insideVolVars.density()* insideVolVars.turbulentKineticEnergy() / insideVolVars.dissipation() );
113 30870910 Scalar outsideCoeff_w = outsideVolVars.viscosity()
114
4/4
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
✓ Branch 2 taken 1777330 times.
✓ Branch 3 taken 29093580 times.
61741820 + ( outsideVolVars.sigmaOmega() * outsideVolVars.density()* outsideVolVars.turbulentKineticEnergy() / outsideVolVars.dissipation() );
115
116 // scale by extrusion factor
117 30870910 insideCoeff_k *= insideVolVars.extrusionFactor();
118 30870910 outsideCoeff_k *= outsideVolVars.extrusionFactor();
119 30870910 insideCoeff_w *= insideVolVars.extrusionFactor();
120 30870910 outsideCoeff_w *= outsideVolVars.extrusionFactor();
121
122 30870910 Scalar distance = 0.0;
123 30870910 Scalar coeff_k = 0.0;
124 30870910 Scalar coeff_w = 0.0;
125
2/2
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
30870910 if (scvf.boundary())
126 {
127 7109320 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
128 1777330 coeff_k = insideCoeff_k;
129 1777330 coeff_w = insideCoeff_w;
130 }
131 else
132 {
133 // average and distance
134
2/2
✓ Branch 0 taken 29084382 times.
✓ Branch 1 taken 9198 times.
29093580 coeff_k = arithmeticMean(insideCoeff_k, outsideCoeff_k,
135 116374320 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
136 116374320 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
137
2/2
✓ Branch 0 taken 29084254 times.
✓ Branch 1 taken 9326 times.
29093580 coeff_w = arithmeticMean(insideCoeff_w, outsideCoeff_w,
138 116374320 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
139 116374320 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
140 145467900 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
141 }
142
143 30870910 const auto bcTypes = problem.boundaryTypes(element, scvf);
144
2/2
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
30870910 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx)
145
6/8
✓ Branch 0 taken 1168530 times.
✓ Branch 1 taken 608800 times.
✓ Branch 2 taken 1168530 times.
✓ Branch 3 taken 608800 times.
✓ Branch 4 taken 1168530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1168530 times.
✗ Branch 7 not taken.
3554660 || bcTypes.isSymmetry())))
146 {
147 90786330 flux[turbulentKineticEnergyEqIdx]
148 30262110 += coeff_k / distance
149 30262110 * (insideVolVars.turbulentKineticEnergy() - outsideVolVars.turbulentKineticEnergy())
150 60524220 * Extrusion::area(fvGeometry, scvf);
151 }
152
2/2
✓ Branch 0 taken 1777330 times.
✓ Branch 1 taken 29093580 times.
30870910 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx)
153
6/8
✓ Branch 0 taken 1168530 times.
✓ Branch 1 taken 608800 times.
✓ Branch 2 taken 1168530 times.
✓ Branch 3 taken 608800 times.
✓ Branch 4 taken 1168530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1168530 times.
✗ Branch 7 not taken.
3554660 || bcTypes.isSymmetry())))
154 {
155 90786330 flux[dissipationEqIdx]
156 30262110 += coeff_w / distance
157 30262110 * (insideVolVars.dissipation() - outsideVolVars.dissipation())
158 60524220 * Extrusion::area(fvGeometry, scvf);
159 }
160 30870910 return flux;
161 }
162
163 /*!
164 * \brief Returns the momentum flux over all staggered faces.
165 */
166 25409372 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 50818744 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
175
176 25409372 return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
177 101637488 + ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
178 25409372 + 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
179 50818744 * Extrusion::area(fvGeometry, scvf) * scvf.directionSign() * insideVolVars.extrusionFactor();
180 }
181 };
182
183 } // end namespace
184
185 #endif
186