Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup NavierStokesModel | ||
10 | * \copydoc Dumux::NavierStokesMassOnePNCLocalResidual | ||
11 | */ | ||
12 | #ifndef DUMUX_NAVIERSTOKES_MASS_1PNC_LOCAL_RESIDUAL_HH | ||
13 | #define DUMUX_NAVIERSTOKES_MASS_1PNC_LOCAL_RESIDUAL_HH | ||
14 | |||
15 | #include <dumux/common/numeqvector.hh> | ||
16 | #include <dumux/common/properties.hh> | ||
17 | #include <dumux/discretization/method.hh> | ||
18 | |||
19 | namespace Dumux { | ||
20 | |||
21 | /*! | ||
22 | * \ingroup NavierStokesModel | ||
23 | * \brief Element-wise calculation of the Navier-Stokes residual for multicomponent single-phase flow. | ||
24 | */ | ||
25 | template<class TypeTag> | ||
26 | class NavierStokesMassOnePNCLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual> | ||
27 | { | ||
28 | using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>; | ||
29 | using GridVariables = GetPropType<TypeTag, Properties::GridVariables>; | ||
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 | |||
38 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
39 | using Problem = GetPropType<TypeTag, Properties::Problem>; | ||
40 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
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; | ||
46 | using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>; | ||
47 | using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; | ||
48 | using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; | ||
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 | |||
57 | public: | ||
58 | //! Use the parent type's constructor | ||
59 |
2/4✓ Branch 1 taken 274100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 274100 times.
✗ Branch 5 not taken.
|
548200 | using ParentType::ParentType; |
60 | |||
61 | /*! | ||
62 | * \brief Calculate the storage term of the equation | ||
63 | */ | ||
64 | ✗ | NumEqVector computeStorage(const Problem& problem, | |
65 | const SubControlVolume& scv, | ||
66 | const VolumeVariables& volVars) const | ||
67 | { | ||
68 | 367200 | NumEqVector storage(0.0); | |
69 | |||
70 | 367200 | const Scalar density = useMoles ? volVars.molarDensity() : volVars.density(); | |
71 | |||
72 | // compute storage term of all components | ||
73 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 550800 times.
✓ Branch 3 taken 183600 times.
✓ Branch 4 taken 550800 times.
✓ Branch 5 taken 183600 times.
|
1468800 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
74 | { | ||
75 | 1101600 | const int eqIdx = compIdx; | |
76 | |||
77 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 367200 times.
✓ Branch 3 taken 183600 times.
✓ Branch 4 taken 367200 times.
✓ Branch 5 taken 183600 times.
|
1101600 | const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx); |
78 | 1101600 | const Scalar s = density * massOrMoleFraction; | |
79 | |||
80 |
4/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 367200 times.
✓ Branch 3 taken 183600 times.
✓ Branch 4 taken 367200 times.
✓ Branch 5 taken 183600 times.
|
1101600 | if (eqIdx != ModelTraits::replaceCompEqIdx()) |
81 | 1468800 | storage[eqIdx] += s; | |
82 | } | ||
83 | |||
84 | // in case one balance is substituted by the total mass balance | ||
85 | if constexpr (useTotalMassBalance) | ||
86 | 1101600 | 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 | |||
95 | /*! | ||
96 | * \brief Evaluates the mass or mole flux over a face of a sub control volume. | ||
97 | * | ||
98 | * \param problem The problem | ||
99 | * \param element The element | ||
100 | * \param fvGeometry The finite volume geometry context | ||
101 | * \param elemVolVars The volume variables for all flux stencil elements | ||
102 | * \param scvf The sub control volume face to compute the flux on | ||
103 | * \param elemFluxVarsCache The cache related to flux computation | ||
104 | */ | ||
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 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
15445064 | fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); |
114 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
15445064 | return fluxVars.flux(0); |
115 | } | ||
116 | }; | ||
117 | |||
118 | } // end namespace Dumux | ||
119 | |||
120 | #endif | ||
121 |