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