3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_FREEFLOW_NC_STAGGERED_LOCAL_RESIDUAL_HH
25#define DUMUX_FREEFLOW_NC_STAGGERED_LOCAL_RESIDUAL_HH
26
30
31namespace Dumux {
32
33// forward declaration
34template<class TypeTag, DiscretizationMethod discMethod>
35class FreeflowNCResidualImpl;
36
41template<class TypeTag>
43: public NavierStokesResidual<TypeTag>
44{
46
50 using GridView = typename GridGeometry::GridView;
51 using Element = typename GridView::template Codim<0>::Entity;
52 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
53 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
54 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
56
57 static constexpr int numComponents = ModelTraits::numFluidComponents();
58 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
59
60 using EnergyLocalResidual = typename ParentType::EnergyLocalResidual;
61
62public:
63 using ParentType::ParentType;
64
66 template<class VolumeVariables>
67 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
68 const SubControlVolume& scv,
69 const VolumeVariables& volVars) const
70 {
71 CellCenterPrimaryVariables storage(0.0);
72
73 const Scalar density = useMoles ? volVars.molarDensity() : volVars.density();
74
75 // compute storage term of all components
76 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
77 {
78 const int eqIdx = compIdx;
79
80 const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
81 const Scalar s = density * massOrMoleFraction;
82
83 if (eqIdx != ModelTraits::replaceCompEqIdx())
84 storage[eqIdx] += s;
85 }
86
87 // in case one balance is substituted by the total mass balance
88 if(ModelTraits::replaceCompEqIdx() < numComponents)
89 storage[ModelTraits::replaceCompEqIdx()] = density;
90
91 EnergyLocalResidual::fluidPhaseStorage(storage, volVars);
92
93 return storage;
94 }
95};
96} // end namespace Dumux
97
98#endif
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
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:66
Definition: adapt.hh:29
EnergyLocalResidualImplementation< TypeTag, GetPropType< TypeTag, Properties::ModelTraits >::enableEnergyBalance()> EnergyLocalResidual
Definition: porousmediumflow/nonisothermal/localresidual.hh:38
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Definition: freeflow/compositional/localresidual.hh:36
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:67
Definition: freeflow/navierstokes/localresidual.hh:35
Declares all properties used in Dumux.