version 3.10-dev
freeflow/navierstokes/mass/1pnc/localresidual.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//
12#ifndef DUMUX_NAVIERSTOKES_MASS_1PNC_LOCAL_RESIDUAL_HH
13#define DUMUX_NAVIERSTOKES_MASS_1PNC_LOCAL_RESIDUAL_HH
14
18
19namespace Dumux {
20
25template<class TypeTag>
26class NavierStokesMassOnePNCLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual>
27{
30
31 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
32 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
33 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
34
35 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
36 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
37
41 using FVElementGeometry = typename GridGeometry::LocalView;
42 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
43 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
44 using GridView = typename GridGeometry::GridView;
45 using Element = typename GridView::template Codim<0>::Entity;
49
50 static_assert(GridGeometry::discMethod == DiscretizationMethods::cctpfa, "");
51 static constexpr bool useMoles = ModelTraits::useMoles();
52 static constexpr auto numComponents = ModelTraits::numFluidComponents();
53
54 static constexpr int replaceCompEqIdx = ModelTraits::replaceCompEqIdx();
55 static constexpr bool useTotalMassBalance = replaceCompEqIdx < numComponents;
56
57public:
59 using ParentType::ParentType;
60
64 NumEqVector computeStorage(const Problem& problem,
65 const SubControlVolume& scv,
66 const VolumeVariables& volVars) const
67 {
68 NumEqVector storage(0.0);
69
70 const Scalar density = useMoles ? volVars.molarDensity() : volVars.density();
71
72 // compute storage term of all components
73 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
74 {
75 const int eqIdx = compIdx;
76
77 const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
78 const Scalar s = density * massOrMoleFraction;
79
80 if (eqIdx != ModelTraits::replaceCompEqIdx())
81 storage[eqIdx] += s;
82 }
83
84 // in case one balance is substituted by the total mass balance
85 if constexpr (useTotalMassBalance)
86 storage[ModelTraits::replaceCompEqIdx()] = volVars.density();
87
88 // consider energy storage for non-isothermal models
89 if constexpr (ModelTraits::enableEnergyBalance())
90 storage[ModelTraits::Indices::energyEqIdx] = volVars.density() * volVars.internalEnergy();
91
92 return storage;
93 }
94
105 NumEqVector computeFlux(const Problem& problem,
106 const Element& element,
107 const FVElementGeometry& fvGeometry,
108 const ElementVolumeVariables& elemVolVars,
109 const SubControlVolumeFace& scvf,
110 const ElementFluxVariablesCache& elemFluxVarsCache) const
111 {
112 FluxVariables fluxVars;
113 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
114 return fluxVars.flux(0);
115 }
116};
117
118} // end namespace Dumux
119
120#endif
Element-wise calculation of the Navier-Stokes residual for multicomponent single-phase flow.
Definition: freeflow/navierstokes/mass/1pnc/localresidual.hh:27
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Calculate the storage term of the equation.
Definition: freeflow/navierstokes/mass/1pnc/localresidual.hh:64
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the mass or mole flux over a face of a sub control volume.
Definition: freeflow/navierstokes/mass/1pnc/localresidual.hh:105
Defines all properties used in Dumux.
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
VolumeVariables::PrimaryVariables::value_type massOrMoleFraction(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx, const int compIdx)
returns the mass or mole fraction to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:54
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
constexpr CCTpfa cctpfa
Definition: method.hh:145
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17
A helper to deduce a vector with the same size as numbers of equations.