GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/mass/1pnc/advectiveflux.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 11 12 91.7%
Functions: 8 14 57.1%
Branches: 4 4 100.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 NavierStokesModel
10 * \brief Helper struct defining the advective fluxes of the single-phase flow multicomponent
11 * Navier-Stokes mass model
12 */
13 #ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1PNC_ADVECTIVE_FLUX_HH
14 #define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1PNC_ADVECTIVE_FLUX_HH
15
16 namespace Dumux {
17
18 #ifndef DOXYGEN
19 // forward declare
20 template<int nComp, bool useM, int repCompEqIdx>
21 struct NavierStokesMassOnePNCModelTraits;
22
23 template<class IsothermalTraits>
24 struct NavierStokesEnergyModelTraits;
25
26 template<class ModelTraits>
27 struct AdvectiveFlux;
28 #endif
29
30
31 /*!
32 * \ingroup NavierStokesModel
33 * \brief Helper struct defining the advective fluxes of the single-phase flow multicomponent
34 * Navier-Stokes mass model
35 */
36 template<int nComp, bool useM, int repCompEqIdx>
37 struct AdvectiveFlux<NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>>
38 {
39 template<class NumEqVector, class UpwindFunction>
40 24947184 static void addAdvectiveFlux(NumEqVector& flux,
41 const UpwindFunction& upwind)
42 {
43 using ModelTraits = NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>;
44 static constexpr bool useMoles = ModelTraits::useMoles();
45 static constexpr auto numComponents = ModelTraits::numFluidComponents();
46 static constexpr auto replaceCompEqIdx = ModelTraits::replaceCompEqIdx();
47 static constexpr bool useTotalMassBalance = replaceCompEqIdx < numComponents;
48
49
2/2
✓ Branch 0 taken 31912288 times.
✓ Branch 1 taken 15482864 times.
75788112 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
50 {
51 // get equation index
52 50840928 const auto eqIdx = ModelTraits::Indices::conti0EqIdx + compIdx;
53
54
2/2
✓ Branch 0 taken 15482864 times.
✓ Branch 1 taken 16429424 times.
50840928 if (eqIdx == replaceCompEqIdx)
55 24871584 continue;
56
57 auto upwindTerm = [&]()
58 {
59 if constexpr (useMoles)
60 98349744 return [compIdx](const auto& volVars) { return volVars.molarDensity()*volVars.moleFraction(compIdx); };
61 else
62 return [compIdx](const auto& volVars) { return volVars.density()*volVars.massFraction(compIdx); };
63 25893744 }();
64
65 26044944 flux[eqIdx] += upwind(upwindTerm);
66 }
67
68 // in case one balance is substituted by the total mole balance
69 if constexpr(useTotalMassBalance)
70 {
71 auto upwindTerm = [&]()
72 {
73 62082656 return [](const auto& volVars) { return volVars.density(); };
74 }();
75
76 25098384 flux[replaceCompEqIdx] += upwind(upwindTerm);
77 }
78 24947184 }
79 };
80
81 // use the same mass flux for the non-isothermal model (heat fluxes are added separately)
82 template<int nComp, bool useM, int repCompEqIdx>
83 struct AdvectiveFlux<NavierStokesEnergyModelTraits<NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>>>
84 : public AdvectiveFlux<NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>>
85 {};
86
87 } // end namespace Dumux
88
89 #endif
90