version 3.8
1pnc/advectiveflux.hh
Go to the documentation of this file.
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//
13#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1PNC_ADVECTIVE_FLUX_HH
14#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1PNC_ADVECTIVE_FLUX_HH
15
16namespace Dumux {
17
18#ifndef DOXYGEN
19// forward declare
20template<int nComp, bool useM, int repCompEqIdx>
21struct NavierStokesMassOnePNCModelTraits;
22
23template<class IsothermalTraits>
24struct NavierStokesEnergyModelTraits;
25
26template<class ModelTraits>
27struct AdvectiveFlux;
28#endif
29
30
36template<int nComp, bool useM, int repCompEqIdx>
37struct AdvectiveFlux<NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>>
38{
39 template<class NumEqVector, class UpwindFunction>
40 static void addAdvectiveFlux(NumEqVector& flux,
41 const UpwindFunction& upwind)
42 {
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 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
50 {
51 // get equation index
52 const auto eqIdx = ModelTraits::Indices::conti0EqIdx + compIdx;
53
54 if (eqIdx == replaceCompEqIdx)
55 continue;
56
57 auto upwindTerm = [&]()
58 {
59 if constexpr (useMoles)
60 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 }();
64
65 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 return [](const auto& volVars) { return volVars.density(); };
74 }();
75
76 flux[replaceCompEqIdx] += upwind(upwindTerm);
77 }
78 }
79};
80
81// use the same mass flux for the non-isothermal model (heat fluxes are added separately)
82template<int nComp, bool useM, int repCompEqIdx>
83struct AdvectiveFlux<NavierStokesEnergyModelTraits<NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>>>
84: public AdvectiveFlux<NavierStokesMassOnePNCModelTraits<nComp, useM, repCompEqIdx>>
85{};
86
87} // end namespace Dumux
88
89#endif
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:34
Definition: adapt.hh:17
static void addAdvectiveFlux(NumEqVector &flux, const UpwindFunction &upwind)
Definition: 1pnc/advectiveflux.hh:40
Specifies a number properties of non-isothermal free-flow flow models based on the specifics of a giv...
Definition: freeflow/navierstokes/energy/model.hh:47
Traits for the Navier-Stokes model.
Definition: freeflow/navierstokes/mass/1pnc/model.hh:68