GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/immiscible/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 33 307 10.7%
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 11673181 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11673181 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.
29529524 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 9646512 NumEqVector computeStorage(const Problem& problem,
64 const SubControlVolume& scv,
65 const VolumeVariables& volVars) const
66 {
67 // partial time derivative of the phase mass
68 238368634 NumEqVector storage;
69
6/6
✓ Branch 0 taken 21007840 times.
✓ Branch 1 taken 9781320 times.
✓ Branch 2 taken 229542474 times.
✓ Branch 3 taken 114547237 times.
✓ Branch 4 taken 228528154 times.
✓ Branch 5 taken 114040077 times.
603278649 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
70 {
71 491991536 auto eqIdx = conti0EqIdx + phaseIdx;
72 971070004 storage[eqIdx] = volVars.porosity()
73 983983072 * volVars.density(phaseIdx)
74 968804036 * volVars.saturation(phaseIdx);
75
76 //! The energy storage in the fluid phase with index phaseIdx
77 499819908 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
78 }
79
80 //! The energy storage in the solid matrix
81 260658598 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
82
83 237472634 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 5791961 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 5791961 FluxVariables fluxVars;
105 5791961 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
106
107 5791961 NumEqVector flux;
108
2/2
✓ Branch 0 taken 12241137 times.
✓ Branch 1 taken 5791961 times.
18033098 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
109 {
110 // the physical quantities for which we perform upwinding
111 2533557355 auto upwindTerm = [phaseIdx](const auto& volVars)
112 4001337744 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
113
114 12241137 auto eqIdx = conti0EqIdx + phaseIdx;
115
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12241137 flux[eqIdx] = fluxVars.advectiveFlux(phaseIdx, upwindTerm);
116
117 //! Add advective phase energy fluxes. For isothermal model the contribution is zero.
118 12241137 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
119 }
120
121 //! Add diffusive energy fluxes. For isothermal model the contribution is zero.
122 6344893 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
123
124 5791961 return flux;
125 }
126 };
127
128 } // end namespace Dumux
129
130 #endif
131