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::NavierStokesResidualImpl | ||
11 | */ | ||
12 | #ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH | ||
13 | #define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH | ||
14 | |||
15 | #include <type_traits> | ||
16 | |||
17 | #include <dumux/common/numeqvector.hh> | ||
18 | #include <dumux/common/properties.hh> | ||
19 | |||
20 | namespace Dumux { | ||
21 | |||
22 | /*! | ||
23 | * \ingroup NavierStokesModel | ||
24 | * \brief Traits class to be specialized for problems to add auxiliary fluxes | ||
25 | * \note This can be used, for example, to implement flux stabilization terms | ||
26 | */ | ||
27 | template<class Problem> | ||
28 | struct ImplementsAuxiliaryFluxNavierStokesMassOneP | ||
29 | : public std::false_type | ||
30 | {}; | ||
31 | |||
32 | /*! | ||
33 | * \ingroup NavierStokesModel | ||
34 | * \brief Element-wise calculation of the Navier-Stokes residual for single-phase flow. | ||
35 | */ | ||
36 | template<class TypeTag> | ||
37 | class NavierStokesMassOnePLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual> | ||
38 | { | ||
39 | using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>; | ||
40 | using GridVariables = GetPropType<TypeTag, Properties::GridVariables>; | ||
41 | using GridVolumeVariables = typename GridVariables::GridVolumeVariables; | ||
42 | using ElementVolumeVariables = typename GridVolumeVariables::LocalView; | ||
43 | using VolumeVariables = typename GridVolumeVariables::VolumeVariables; | ||
44 | |||
45 | using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache; | ||
46 | using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView; | ||
47 | |||
48 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
49 | using Problem = GetPropType<TypeTag, Properties::Problem>; | ||
50 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
51 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
52 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
53 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
54 | using GridView = typename GridGeometry::GridView; | ||
55 | using Element = typename GridView::template Codim<0>::Entity; | ||
56 | using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>; | ||
57 | using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; | ||
58 | using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; | ||
59 | |||
60 | public: | ||
61 | //! Use the parent type's constructor | ||
62 |
4/8✓ Branch 1 taken 2635464 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2635464 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
|
6240978 | using ParentType::ParentType; |
63 | |||
64 | /*! | ||
65 | * \brief Calculate the storage term of the equation | ||
66 | */ | ||
67 | ✗ | NumEqVector computeStorage(const Problem& problem, | |
68 | const SubControlVolume& scv, | ||
69 | const VolumeVariables& volVars) const | ||
70 | { | ||
71 | 14984080 | NumEqVector storage(0.0); | |
72 | 29968160 | storage[ModelTraits::Indices::conti0EqIdx] = volVars.density(); | |
73 | |||
74 | // consider energy storage for non-isothermal models | ||
75 | if constexpr (ModelTraits::enableEnergyBalance()) | ||
76 | 9240000 | storage[ModelTraits::Indices::energyEqIdx] = volVars.density() * volVars.internalEnergy(); | |
77 | |||
78 | ✗ | return storage; | |
79 | } | ||
80 | |||
81 | /*! | ||
82 | * \brief Evaluate the mass flux over a face of a sub control volume. | ||
83 | * | ||
84 | * \param problem The problem | ||
85 | * \param element The element | ||
86 | * \param fvGeometry The finite volume geometry context | ||
87 | * \param elemVolVars The volume variables for all flux stencil elements | ||
88 | * \param scvf The sub control volume face to compute the flux on | ||
89 | * \param elemFluxVarsCache The cache related to flux computation | ||
90 | */ | ||
91 | 249600 | NumEqVector computeFlux(const Problem& problem, | |
92 | const Element& element, | ||
93 | const FVElementGeometry& fvGeometry, | ||
94 | const ElementVolumeVariables& elemVolVars, | ||
95 | const SubControlVolumeFace& scvf, | ||
96 | const ElementFluxVariablesCache& elemFluxVarsCache) const | ||
97 | { | ||
98 | FluxVariables fluxVars; | ||
99 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
103595868 | fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); |
100 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
103595868 | auto flux = fluxVars.flux(0); |
101 | |||
102 | // the auxiliary flux is enabled if the trait is specialized for the problem | ||
103 | // this can be used, for example, to implement flux stabilization terms | ||
104 | if constexpr (ImplementsAuxiliaryFluxNavierStokesMassOneP<Problem>::value) | ||
105 |
1/2✓ Branch 0 taken 249600 times.
✗ Branch 1 not taken.
|
249600 | flux += problem.auxiliaryFlux(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf); |
106 | |||
107 | 6052950 | return flux; | |
108 | } | ||
109 | }; | ||
110 | |||
111 | } // end namespace Dumux | ||
112 | |||
113 | #endif | ||
114 |