GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/freeflow/navierstokes/mass/1pnc/advectiveflux.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 12 12 100.0%
Functions: 12 12 100.0%
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-FileCopyrightText: 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 31902460 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 38867564 times.
✓ Branch 1 taken 18960502 times.
96653940 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
50 {
51 // get equation index
52 64751480 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 24947184 continue;
56
57 39804296 auto upwindTerm = [&]()
58 {
59 if constexpr (useMoles)
60 23304100 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 39804296 }();
64
65 39804296 flux[eqIdx] += upwind(upwindTerm);
66 }
67
68 // in case one balance is substituted by the total mass balance
69 if constexpr(useTotalMassBalance)
70 {
71 auto upwindTerm = [&]()
72 {
73 15520664 return [](const auto& volVars) { return volVars.density(); };
74 }();
75
76 24947184 flux[replaceCompEqIdx] += upwind(upwindTerm);
77 }
78 31902460 }
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