version 3.8
freeflow/compositional/staggered/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_FREEFLOW_NC_STAGGERED_LOCAL_RESIDUAL_HH
13#define DUMUX_FREEFLOW_NC_STAGGERED_LOCAL_RESIDUAL_HH
14
18
19namespace Dumux {
20
26// forward declaration
27template<class TypeTag, class DiscretizationMethod>
28class FreeflowNCResidualImpl;
29
30template<class TypeTag>
31class FreeflowNCResidualImpl<TypeTag, DiscretizationMethods::Staggered>
32: public NavierStokesResidual<TypeTag>
33{
35
39 using GridView = typename GridGeometry::GridView;
40 using Element = typename GridView::template Codim<0>::Entity;
41 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
42 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
43 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
45
46 static constexpr int numComponents = ModelTraits::numFluidComponents();
47 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
48
49 using EnergyLocalResidual = typename ParentType::EnergyLocalResidual;
50
51public:
52 using ParentType::ParentType;
53
55 template<class VolumeVariables>
56 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
57 const SubControlVolume& scv,
58 const VolumeVariables& volVars) const
59 {
60 CellCenterPrimaryVariables storage(0.0);
61
62 const Scalar density = useMoles ? volVars.molarDensity() : volVars.density();
63
64 // compute storage term of all components
65 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
66 {
67 const int eqIdx = compIdx;
68
69 const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
70 const Scalar s = density * massOrMoleFraction;
71
72 if (eqIdx != ModelTraits::replaceCompEqIdx())
73 storage[eqIdx] += s;
74 }
75
76 // in case one balance is substituted by the total mass balance (use the mass density)
77 if(ModelTraits::replaceCompEqIdx() < numComponents)
78 storage[ModelTraits::replaceCompEqIdx()] = volVars.density();
79
80 EnergyLocalResidual::fluidPhaseStorage(storage, volVars);
81
82 return storage;
83 }
84};
85} // end namespace Dumux
86
87#endif
CellCenterPrimaryVariables computeStorageForCellCenter(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluate fluxes entering or leaving the cell center control volume.
Definition: freeflow/compositional/staggered/localresidual.hh:56
Element-wise calculation of the multi-component free-flow residual for models using the staggered dis...
Definition: freeflow/compositional/localresidual.hh:24
Element-wise calculation of the Navier-Stokes residual for models using the staggered discretization.
Definition: freeflow/navierstokes/localresidual.hh:23
Defines all properties used in Dumux.
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.
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17
EnergyLocalResidualImplementation< TypeTag, GetPropType< TypeTag, Properties::ModelTraits >::enableEnergyBalance()> EnergyLocalResidual
Definition: porousmediumflow/nonisothermal/localresidual.hh:27