GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/freeflow/navierstokes/mass/1p/localresidual.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 10 10 100.0%
Functions: 3 3 100.0%
Branches: 6 10 60.0%

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