GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/rans/oneeq/staggered/fluxvariables.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 32 33 97.0%
Functions: 4 8 50.0%
Branches: 20 22 90.9%

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 OneEqModel
10 * \copydoc Dumux::OneEqFluxVariablesImpl
11 */
12 #ifndef DUMUX_ONEEQ_STAGGERED_FLUXVARIABLES_HH
13 #define DUMUX_ONEEQ_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/oneeq/fluxvariables.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup OneEqModel
27 * \brief The flux variables class for the one-equation model by Spalart-Allmaras
28 * using the staggered grid discretization.
29 */
30
31 // forward declaration
32 template<class TypeTag, class BaseFluxVariables, class DiscretizationMethod>
33 class OneEqFluxVariablesImpl;
34
35 template<class TypeTag, class BaseFluxVariables>
36 class OneEqFluxVariablesImpl<TypeTag, BaseFluxVariables, DiscretizationMethods::Staggered>
37 : public BaseFluxVariables
38 {
39 using ParentType = BaseFluxVariables;
40
41 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
42
43 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
44 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
45 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
46
47 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
48 using FluxVariablesCache = typename GridFluxVariablesCache::FluxVariablesCache;
49
50 using GridFaceVariables = typename GridVariables::GridFaceVariables;
51 using ElementFaceVariables = typename GridFaceVariables::LocalView;
52 using FaceVariables = typename GridFaceVariables::FaceVariables;
53
54 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
55 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
56 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
57 using FVElementGeometry = typename GridGeometry::LocalView;
58 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
59 using Extrusion = Extrusion_t<GridGeometry>;
60 using GridView = typename GridGeometry::GridView;
61 using Problem = GetPropType<TypeTag, Properties::Problem>;
62 using Element = typename GridView::template Codim<0>::Entity;
63 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
64 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
65
66 static constexpr int viscosityTildeEqIdx = Indices::viscosityTildeEqIdx - ModelTraits::dim();
67
68 public:
69
70 /*!
71 * \brief Computes the flux for the cell center residual.
72 */
73 15822030 CellCenterPrimaryVariables computeMassFlux(const Problem& problem,
74 const Element &element,
75 const FVElementGeometry& fvGeometry,
76 const ElementVolumeVariables& elemVolVars,
77 const ElementFaceVariables& elemFaceVars,
78 const SubControlVolumeFace &scvf,
79 const FluxVariablesCache& fluxVarsCache)
80 {
81 15822030 CellCenterPrimaryVariables flux = ParentType::computeMassFlux(problem, element, fvGeometry,
82 elemVolVars, elemFaceVars, scvf, fluxVarsCache);
83
84 // calculate advective flux
85 auto upwindTermK = [](const auto& volVars)
86 {
87 63288120 return volVars.viscosityTilde() * volVars.density();
88 };
89
90 31644060 flux[viscosityTildeEqIdx]
91 15822030 = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTermK);
92
93 // calculate diffusive flux
94 31644060 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
95 31644060 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
96 31644060 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
97 31644060 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
98
99 // effective diffusion coefficients
100
4/4
✓ Branch 0 taken 944770 times.
✓ Branch 1 taken 14877260 times.
✓ Branch 2 taken 944770 times.
✓ Branch 3 taken 14877260 times.
31644060 Scalar insideCoeff = (insideVolVars.viscosity() + insideVolVars.viscosityTilde() * insideVolVars.density())
101 15822030 / insideVolVars.sigma();
102
4/4
✓ Branch 0 taken 944770 times.
✓ Branch 1 taken 14877260 times.
✓ Branch 2 taken 944770 times.
✓ Branch 3 taken 14877260 times.
31644060 Scalar outsideCoeff = (outsideVolVars.viscosity() + outsideVolVars.viscosityTilde() * outsideVolVars.density())
103 15822030 / outsideVolVars.sigma();
104
105 // scale by extrusion factor
106 15822030 insideCoeff *= insideVolVars.extrusionFactor();
107 15822030 outsideCoeff *= outsideVolVars.extrusionFactor();
108
109
110 15822030 Scalar coeff = 0.0;
111 15822030 Scalar distance = 0.0;
112
2/2
✓ Branch 0 taken 944770 times.
✓ Branch 1 taken 14877260 times.
15822030 if (scvf.boundary())
113 {
114 944770 coeff = insideCoeff;
115 4723850 distance = (insideScv.dofPosition() - scvf.ipGlobal()).two_norm();
116 }
117 else
118 {
119 // average and distance
120
2/2
✓ Branch 0 taken 14834278 times.
✓ Branch 1 taken 42982 times.
14877260 coeff = arithmeticMean(insideCoeff, outsideCoeff,
121 59509040 (outsideScv.dofPosition() - scvf.ipGlobal()).two_norm(),
122 59509040 (insideScv.dofPosition() - scvf.ipGlobal()).two_norm());
123 74386300 distance = (outsideScv.dofPosition() - insideScv.dofPosition()).two_norm();
124 }
125
126 15822030 const auto bcTypes = problem.boundaryTypes(element, scvf);
127
2/2
✓ Branch 0 taken 944770 times.
✓ Branch 1 taken 14877260 times.
15822030 if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::viscosityTildeEqIdx)
128
6/8
✓ Branch 0 taken 602726 times.
✓ Branch 1 taken 342044 times.
✓ Branch 2 taken 602726 times.
✓ Branch 3 taken 342044 times.
✓ Branch 4 taken 602726 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 602726 times.
✗ Branch 7 not taken.
1889540 || bcTypes.isSymmetry())))
129 {
130 46439958 flux[viscosityTildeEqIdx]
131 15479986 += coeff / distance
132 15479986 * (insideVolVars.viscosityTilde() - outsideVolVars.viscosityTilde())
133 30959972 * Extrusion::area(fvGeometry, scvf);
134 }
135 15822030 return flux;
136 }
137 };
138
139 } // end namespace
140
141 #endif
142