GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/2p1c/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 4 6 66.7%
Branches: 6 8 75.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-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 TwoPOneCModel
10 *
11 * \copydoc Dumux::TwoPOneCLocalResidual
12 */
13
14 #ifndef DUMUX_2P1C_LOCAL_RESIDUAL_HH
15 #define DUMUX_2P1C_LOCAL_RESIDUAL_HH
16
17 #include <dumux/common/numeqvector.hh>
18 #include <dumux/porousmediumflow/immiscible/localresidual.hh>
19
20 namespace Dumux {
21 /*!
22 * \ingroup TwoPOneCModel
23 * \brief Element-wise calculation of the residual for the fully implicit two-phase one-component flow model.
24 */
25 template<class TypeTag>
26 class TwoPOneCLocalResidual : public ImmiscibleLocalResidual<TypeTag>
27 {
28 using ParentType = ImmiscibleLocalResidual<TypeTag>;
29 using Problem = GetPropType<TypeTag, Properties::Problem>;
30 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
31 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
32 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
33 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
34 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
35 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
36 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
37 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
38 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
39 using Element = typename GridView::template Codim<0>::Entity;
40 using EnergyLocalResidual = GetPropType<TypeTag, Properties::EnergyLocalResidual>;
41 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
42
43 static const auto numPhases = GetPropType<TypeTag, Properties::ModelTraits>::numFluidPhases();
44
45 public:
46 //! Use the parent type's constructor
47
2/4
✓ Branch 1 taken 101000 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 101000 times.
✗ Branch 5 not taken.
202000 using ParentType::ParentType;
48
49 //! Evaluate the storage term within a given scv
50 1728000 NumEqVector computeStorage(const Problem& problem,
51 const SubControlVolume& scv,
52 const VolumeVariables& volVars) const
53 {
54 1728000 NumEqVector storage(0.0);
55 // Compute storage term of all components within all phases
56
2/2
✓ Branch 0 taken 3456000 times.
✓ Branch 1 taken 1728000 times.
5184000 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
57 {
58 6912000 storage[Indices::conti0EqIdx] +=
59 volVars.porosity()
60 13824000 * volVars.saturation(phaseIdx) * volVars.density(phaseIdx);
61
62 6912000 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
63 }
64
65 // The energy storage in the solid matrix
66 3456000 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
67
68 1728000 return storage;
69 }
70
71 //! Evaluate the fluxes over a face of a sub control volume
72 2571300 NumEqVector computeFlux(const Problem& problem,
73 const Element& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars,
76 const SubControlVolumeFace& scvf,
77 const ElementFluxVariablesCache& elemFluxVarsCache) const
78 {
79 2571300 FluxVariables fluxVars;
80 2571300 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
81
82 2571300 NumEqVector flux;
83
2/2
✓ Branch 0 taken 5142600 times.
✓ Branch 1 taken 2571300 times.
7713900 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
84 {
85 // The physical quantities for which we perform upwinding
86 25713000 auto upwindTerm = [phaseIdx](const auto& volVars)
87 30855600 { return volVars.density(phaseIdx)*volVars.mobility(phaseIdx); };
88
89 5142600 flux[Indices::conti0EqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
90
91 // Add advective phase energy fluxes. For isothermal model the contribution is zero.
92 5142600 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
93 }
94
95 // Add diffusive energy fluxes. For isothermal model the contribution is zero.
96 2571300 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
97
98 2571300 return flux;
99 }
100 };
101
102 } // end namespace Dumux
103
104 #endif
105