version 3.11-dev
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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-FileCopyrightText: 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
19
20namespace Dumux {
21
26template<class TypeTag>
29{
32
33 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
34 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
35 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
36
37 using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
38 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
39
43 using FVElementGeometry = typename GridGeometry::LocalView;
44 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
45 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
46 using GridView = typename GridGeometry::GridView;
47 using Element = typename GridView::template Codim<0>::Entity;
51
52 static_assert(GridGeometry::discMethod == DiscretizationMethods::cctpfa, "");
53 static constexpr bool useMoles = ModelTraits::useMoles();
54 static constexpr auto numComponents = ModelTraits::numFluidComponents();
55
56 static constexpr int replaceCompEqIdx = ModelTraits::replaceCompEqIdx();
57 static constexpr bool useTotalMassBalance = replaceCompEqIdx < numComponents;
58
59public:
61 using ParentType::ParentType;
62
66 NumEqVector computeStorage(const Problem& problem,
67 const SubControlVolume& scv,
68 const VolumeVariables& volVars) const
69 {
70 NumEqVector storage(0.0);
71
72 const Scalar density = useMoles ? volVars.molarDensity() : volVars.density();
73
74 // compute storage term of all components
75 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
76 {
77 const int eqIdx = compIdx;
78
79 const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
80 const Scalar s = density * massOrMoleFraction;
81
82 if (eqIdx != ModelTraits::replaceCompEqIdx())
83 storage[eqIdx] += s;
84 }
85
86 // in case one balance is substituted by the total mass balance
87 if constexpr (useTotalMassBalance)
88 storage[ModelTraits::replaceCompEqIdx()] = volVars.density();
89
90 // consider energy storage for non-isothermal models
91 if constexpr (ModelTraits::enableEnergyBalance())
92 storage[ModelTraits::Indices::energyEqIdx] = volVars.density() * volVars.internalEnergy();
93
94 return storage;
95 }
96
107 NumEqVector computeFlux(const Problem& problem,
108 const Element& element,
109 const FVElementGeometry& fvGeometry,
110 const ElementVolumeVariables& elemVolVars,
111 const SubControlVolumeFace& scvf,
112 const ElementFluxVariablesCache& elemFluxVarsCache) const
113 {
114 FluxVariables fluxVars;
115 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
116 return fluxVars.flux(0);
117 }
118};
119
120} // end namespace Dumux
121
122#endif
Element-wise calculation of the Navier-Stokes residual for multicomponent single-phase flow.
Definition: freeflow/navierstokes/mass/1pnc/localresidual.hh:29
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:66
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:107
Defines all properties used in Dumux.
The default local operator than can be specialized for each discretization scheme.
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
typename Detail::DiscretizationDefaultLocalOperator< TypeTag >::type DiscretizationDefaultLocalOperator
Definition: defaultlocaloperator.hh:27
A helper to deduce a vector with the same size as numbers of equations.