GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/shallowwater/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 12 14 85.7%
Functions: 6 12 50.0%
Branches: 9 14 64.3%

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 ShallowWaterModels
10 * \copydoc Dumux::ShallowWaterResidual
11 */
12 #ifndef DUMUX_FREEFLOW_SHALLOW_WATER_LOCAL_RESIDUAL_HH
13 #define DUMUX_FREEFLOW_SHALLOW_WATER_LOCAL_RESIDUAL_HH
14
15 #include <dumux/common/parameters.hh>
16 #include <dumux/common/properties.hh>
17 #include <dumux/common/numeqvector.hh>
18
19 namespace Dumux{
20
21 /*!
22 * \ingroup ShallowWaterModels
23 * \brief Element-wise calculation of the residual for the shallow water equations
24 */
25 template<class TypeTag>
26 class ShallowWaterResidual
27 : public GetPropType<TypeTag, Properties::BaseLocalResidual>
28 {
29 using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>;
30 using Problem = GetPropType<TypeTag, Properties::Problem>;
31 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
32 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
33 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
34 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
35 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
36 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
37 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
38 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
39 using Element = typename GridView::template Codim<0>::Entity;
40 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
41 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
42
43 public:
44
45
2/4
✓ Branch 1 taken 6648890 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6648890 times.
✗ Branch 5 not taken.
13297780 using ParentType::ParentType;
46
47 /*!
48 * \brief Evaluate the rate of change of all conservation
49 * quantites (e.g. mass, momentum) within a sub-control
50 * volume of a finite volume element.
51 * \param problem The problem
52 * \param scv The sub control volume
53 * \param volVars The current or previous volVars
54 * \note This function should not include the source and sink terms.
55 * \note The volVars can be different to allow computing
56 * the implicit euler time derivative here
57 */
58 NumEqVector computeStorage(const Problem& problem,
59 const SubControlVolume& scv,
60 const VolumeVariables& volVars) const
61 {
62 // partial time derivative of the phase mass
63 42658590 NumEqVector storage(0.0);
64 85317180 storage[Indices::massBalanceIdx] = volVars.waterDepth();
65 127975770 storage[Indices::momentumXBalanceIdx] = volVars.waterDepth() * volVars.velocity(0);
66 170634360 storage[Indices::momentumYBalanceIdx] = volVars.waterDepth() * volVars.velocity(1);
67 return storage;
68 }
69
70 /*!
71 * \brief Evaluate the mass/momentum flux over a face of a sub control volume
72 *
73 * \param problem The problem
74 * \param element The current element.
75 * \param fvGeometry The finite-volume geometry
76 * \param elemVolVars The volume variables of the current element
77 * \param scvf The sub control volume face to compute the flux on
78 * \param elemFluxVarsCache the flux variable cache for the element stencil
79 */
80 156514916 NumEqVector computeFlux(const Problem& problem,
81 const Element& element,
82 const FVElementGeometry& fvGeometry,
83 const ElementVolumeVariables& elemVolVars,
84 const SubControlVolumeFace& scvf,
85 const ElementFluxVariablesCache& elemFluxVarsCache) const
86 {
87 156514916 NumEqVector flux(0.0);
88 FluxVariables fluxVars;
89 156514916 flux += fluxVars.advectiveFlux(problem, element, fvGeometry, elemVolVars, scvf);
90
91 // Compute viscous momentum flux contribution if required
92
5/8
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 156514900 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 16 times.
✗ Branch 10 not taken.
156514916 static const bool enableViscousFlux = getParamFromGroup<bool>(problem.paramGroup(), "ShallowWater.EnableViscousFlux", false);
93
2/2
✓ Branch 0 taken 4583245 times.
✓ Branch 1 taken 151931671 times.
156514916 if (enableViscousFlux)
94 9166490 flux += fluxVars.viscousFlux(problem, element, fvGeometry, elemVolVars, scvf);
95 156514916 return flux;
96 }
97 };
98 } // end namespace Dumux
99
100 #endif
101