GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/immiscible/localresidual.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 35 313 11.2%
Branches: 22 38 57.9%

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 PorousmediumflowModels
10 * \brief Element-wise calculation of the residual for problems
11 * using the n-phase immiscible fully implicit models.
12 */
13 #ifndef DUMUX_IMMISCIBLE_LOCAL_RESIDUAL_HH
14 #define DUMUX_IMMISCIBLE_LOCAL_RESIDUAL_HH
15
16 #include <dumux/common/properties.hh>
17 #include <dumux/common/numeqvector.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup PorousmediumflowModels
23 * \brief Element-wise calculation of the residual for problems
24 * using the n-phase immiscible fully implicit models.
25 */
26 template<class TypeTag>
27 class ImmiscibleLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual>
28 {
29 using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>;
30 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
31 using Problem = GetPropType<TypeTag, Properties::Problem>;
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 FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
36 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
37 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
38 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
39 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
40 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
41 using Element = typename GridView::template Codim<0>::Entity;
42 using EnergyLocalResidual = GetPropType<TypeTag, Properties::EnergyLocalResidual>;
43
44 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
45 static constexpr int numPhases = ModelTraits::numFluidPhases();
46 static constexpr int conti0EqIdx = ModelTraits::Indices::conti0EqIdx; //!< first index for the mass balance
47
48 public:
49
14/28
✓ Branch 1 taken 10334131 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10334131 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1049093 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1048757 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 209436 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 311728 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 104488 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 104488 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 6233 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 6233 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 452 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 7708 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 7708 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 7708 times.
✗ Branch 41 not taken.
26851424 using ParentType::ParentType;
50
51 /*!
52 * \brief Evaluate the rate of change of all conservation
53 * quantites (e.g. phase mass) within a sub-control
54 * volume of a finite volume element for the immiscible models.
55 *
56 * \param problem the problem
57 * \param scv The sub control volume
58 * \param volVars The current or previous volVars
59 * \note This function should not include the source and sink terms.
60 * \note The volVars can be different to allow computing
61 * the implicit euler time derivative here
62 */
63 9513392 NumEqVector computeStorage(const Problem& problem,
64 const SubControlVolume& scv,
65 const VolumeVariables& volVars) const
66 {
67 // partial time derivative of the phase mass
68 238128858 NumEqVector storage;
69
6/6
✓ Branch 0 taken 20896480 times.
✓ Branch 1 taken 9648200 times.
✓ Branch 2 taken 229435818 times.
✓ Branch 3 taken 114493909 times.
✓ Branch 4 taken 228421498 times.
✓ Branch 5 taken 113986749 times.
602767529 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
70 {
71 487660784 auto eqIdx = conti0EqIdx + phaseIdx;
72 966414580 storage[eqIdx] = volVars.porosity()
73 975321568 * volVars.density(phaseIdx)
74 964292612 * volVars.saturation(phaseIdx);
75
76 //! The energy storage in the fluid phase with index phaseIdx
77 499383876 EnergyLocalResidual::fluidPhaseStorage(storage, problem, scv, volVars, phaseIdx);
78 }
79
80 //! The energy storage in the solid matrix
81 256279622 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
82
83 237232858 return storage;
84 }
85
86
87 /*!
88 * \brief Evaluate the mass flux over a face of a sub control volume.
89 *
90 * \param problem The problem
91 * \param element The element
92 * \param fvGeometry The finite volume geometry context
93 * \param elemVolVars The volume variables for all flux stencil elements
94 * \param scvf The sub control volume face to compute the flux on
95 * \param elemFluxVarsCache The cache related to flux computation
96 */
97 7028169 NumEqVector computeFlux(const Problem& problem,
98 const Element& element,
99 const FVElementGeometry& fvGeometry,
100 const ElementVolumeVariables& elemVolVars,
101 const SubControlVolumeFace& scvf,
102 const ElementFluxVariablesCache& elemFluxVarsCache) const
103 {
104 7028169 FluxVariables fluxVars;
105 7028169 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
106
107 7028169 NumEqVector flux;
108
2/2
✓ Branch 0 taken 13488225 times.
✓ Branch 1 taken 7028169 times.
20516394 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
109 {
110 // the physical quantities for which we perform upwinding
111 2521034582 auto upwindTerm = [phaseIdx](const auto& volVars)
112 3964581189 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
113
114 13488225 auto eqIdx = conti0EqIdx + phaseIdx;
115
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
13488225 flux[eqIdx] = fluxVars.advectiveFlux(phaseIdx, upwindTerm);
116
117 //! Add advective phase energy fluxes. For isothermal model the contribution is zero.
118 13488225 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
119 }
120
121 //! Add diffusive energy fluxes. For isothermal model the contribution is zero.
122 7581101 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
123
124 7028169 return flux;
125 }
126 };
127
128 } // end namespace Dumux
129
130 #endif
131