12#ifndef DUMUX_NAVIERSTOKES_MASS_1PNC_FLUXVARIABLES_HH
13#define DUMUX_NAVIERSTOKES_MASS_1PNC_FLUXVARIABLES_HH
29template<
class Problem,
32 class ElementVolumeVariables,
33 class ElementFluxVariablesCache,
34 class UpwindScheme = UpwindScheme<typename ProblemTraits<Problem>::GridGeometry>>
39 ElementVolumeVariables,
40 ElementFluxVariablesCache,
43 using VolumeVariables =
typename ElementVolumeVariables::VolumeVariables;
44 using NumEqVector =
typename VolumeVariables::PrimaryVariables;
45 using Scalar =
typename VolumeVariables::PrimaryVariables::value_type;
46 using Indices =
typename ModelTraits::Indices;
48 static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion();
49 static constexpr auto replaceCompEqIdx = ModelTraits::replaceCompEqIdx();
50 static constexpr bool useTotalMassBalance = replaceCompEqIdx < ModelTraits::numFluidComponents();
52 using FluidSystem =
typename VolumeVariables::FluidSystem;
57 ElementVolumeVariables,
58 ElementFluxVariablesCache,
63 static constexpr auto numComponents = ModelTraits::numFluidComponents();
64 static constexpr bool useMoles = ModelTraits::useMoles();
72 NumEqVector result(0.0);
73 if constexpr (enableMolecularDiffusion)
75 const auto diffusiveFluxes = MolecularDiffusionType::flux(this->
problem(),
83 static constexpr auto referenceSystemFormulation = MolecularDiffusionType::referenceSystemFormulation();
88 const auto eqIdx = Indices::conti0EqIdx + compIdx;
89 if (eqIdx == replaceCompEqIdx)
94 result[eqIdx] +=
useMoles ? diffusiveFluxes[compIdx]/FluidSystem::molarMass(compIdx)
95 : diffusiveFluxes[compIdx];
97 result[eqIdx] +=
useMoles ? diffusiveFluxes[compIdx]
98 : diffusiveFluxes[compIdx]*FluidSystem::molarMass(compIdx);
100 DUNE_THROW(Dune::NotImplemented,
"other reference systems than mass and molar averaged are not implemented");
104 if constexpr(useTotalMassBalance)
110 result[replaceCompEqIdx] += diffusiveFluxes[compIdx];
112 result[replaceCompEqIdx] += diffusiveFluxes[compIdx]*FluidSystem::molarMass(compIdx);
114 DUNE_THROW(Dune::NotImplemented,
"other reference systems than mass and molar averaged are not implemented");
127 const auto diffusiveFlux = MolecularDiffusionType::flux(this->
problem(),
134 static constexpr auto referenceSystemFormulation = MolecularDiffusionType::referenceSystemFormulation();
136 const auto& scvf = this->
scvFace();
139 const auto componentEnthalpy = [](
const auto& volVars,
int compIdx)
140 {
return FluidSystem::componentEnthalpy(volVars.fluidState(), 0, compIdx); };
146 const bool insideIsUpstream = !signbit(diffusiveFlux[compIdx]);
147 const auto& upstreamVolVars = insideIsUpstream ?
elemVolVars[scvf.insideScvIdx()] :
elemVolVars[scvf.outsideScvIdx()];
150 flux += diffusiveFlux[compIdx] * componentEnthalpy(upstreamVolVars, compIdx);
152 flux += diffusiveFlux[compIdx] * componentEnthalpy(upstreamVolVars, compIdx)*
elemVolVars[scvf.insideScvIdx()].molarMass(compIdx);
164 NumEqVector result(0.0);
166 const auto upwinding = [
this](
const auto& term) {
return this->
getAdvectiveFlux(term); };
167 AdvectiveFlux<ModelTraits>::addAdvectiveFlux(result, upwinding);
177 NumEqVector
flux(
int phaseIdx = 0)
const
180 NumEqVector
flux = diffusiveFlux;
182 const auto upwinding = [
this](
const auto& term) {
return this->
getAdvectiveFlux(term); };
183 AdvectiveFlux<ModelTraits>::addAdvectiveFlux(
flux, upwinding);
185 if constexpr (ModelTraits::enableEnergyBalance())
Helper struct defining the advective fluxes of the single-phase flow multicomponent Navier-Stokes mas...
const ElementVolumeVariables & elemVolVars() const
Definition: fluxvariablesbase.hh:69
const SubControlVolumeFace & scvFace() const
Definition: fluxvariablesbase.hh:63
const ElementFluxVariablesCache & elemFluxVarsCache() const
Definition: fluxvariablesbase.hh:72
const ProblemTraits< Problem >::GridGeometry::LocalView & fvGeometry() const
Definition: fluxvariablesbase.hh:66
const Element & element() const
Definition: fluxvariablesbase.hh:60
const Problem & problem() const
Definition: fluxvariablesbase.hh:57
The flux variables class for the single-phase flow, multi-component Navier-Stokes model.
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:42
static constexpr auto numComponents
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:63
NumEqVector molecularDiffusionFlux(int phaseIdx=0) const
Returns the diffusive fluxes computed by the respective law.
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:70
NumEqVector advectiveFlux(int phaseIdx=0) const
Returns the advective mass flux in kg/s or the advective mole flux in mole/s.
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:162
typename FluxTs::MolecularDiffusionType MolecularDiffusionType
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:65
static constexpr bool useMoles
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:64
NumEqVector flux(int phaseIdx=0) const
Returns all fluxes for the single-phase flow, multi-component Navier-Stokes model: the advective mass...
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:177
Scalar diffusiveEnthalpyFlux(int phaseIdx=0) const
Returns the flux of enthalpy in J/s carried by diffusing molecules.
Definition: freeflow/navierstokes/mass/1pnc/fluxvariables.hh:125
The flux variables base class for scalar quantities balanced in the Navier-Stokes model.
Definition: scalarfluxvariables.hh:39
void addHeatFlux(NumEqVector &flux) const
Adds the energy flux to a given flux vector.
Definition: scalarfluxvariables.hh:127
Scalar getAdvectiveFlux(const FunctionType &upwindTerm) const
Returns the advective flux computed by the respective law.
Definition: scalarfluxvariables.hh:69
Forward declaration of the upwind scheme implementation.
Definition: flux/upwindscheme.hh:22
Type traits for problem classes.
Base class for the upwind scheme.
UpwindSchemeImpl< GridGeometry, typename GridGeometry::DiscretizationMethod > UpwindScheme
The upwind scheme used for the advective fluxes. This depends on the chosen discretization method.
Definition: flux/upwindscheme.hh:30