GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/porousmediumflow/richardsextended/localresidual.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 4 4 100.0%
Branches: 1 2 50.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-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 ExtendedRichardsModel
10 * \brief Element-wise calculation of the Jacobian matrix for problems
11 * using the extended Richards fully implicit models.
12 */
13
14 #ifndef DUMUX_RICHARDSEXTENDED_LOCAL_RESIDUAL_HH
15 #define DUMUX_RICHARDSEXTENDED_LOCAL_RESIDUAL_HH
16
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/typetraits/typetraits.hh>
19 #include <dumux/common/numeqvector.hh>
20 #include <dumux/discretization/method.hh>
21 #include <dumux/discretization/extrusion.hh>
22 #include <dumux/flux/referencesystemformulation.hh>
23 #include <dumux/porousmediumflow/richards/localresidual.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup ExtendedRichardsModel
29 * \brief Element-wise calculation of the Jacobian matrix for problems
30 * using the extended Richards fully implicit models.
31 */
32 template<class TypeTag>
33 class ExtendedRichardsLocalResidual : public RichardsLocalResidual<TypeTag>
34 {
35 using ParentType = RichardsLocalResidual<TypeTag>;
36 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
37 using Problem = GetPropType<TypeTag, Properties::Problem>;
38 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
39 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
40 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
41 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
42 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
43 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
44 using FVElementGeometry = typename GridGeometry::LocalView;
45 using SubControlVolume = typename GridGeometry::SubControlVolume;
46 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
47 using GridView = typename GridGeometry::GridView;
48 using Element = typename GridView::template Codim<0>::Entity;
49 using EnergyLocalResidual = GetPropType<TypeTag, Properties::EnergyLocalResidual>;
50 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
51 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
52 // first index for the mass balance
53 enum { conti0EqIdx = Indices::conti0EqIdx };
54
55 // phase & component indices
56 static constexpr auto liquidPhaseIdx = FluidSystem::phase0Idx;
57 static constexpr auto gasPhaseIdx = FluidSystem::phase1Idx;
58 static constexpr auto liquidCompIdx = FluidSystem::comp0Idx;
59
60 public:
61
1/2
✓ Branch 1 taken 32700 times.
✗ Branch 2 not taken.
32700 using ParentType::ParentType;
62
63 /*!
64 * \brief Evaluates the rate of change of all conservation
65 * quantites (e.g. phase mass) within a sub-control
66 * volume of a finite volume element for the immiscible models.
67 * \param problem The problem
68 * \param scv The sub control volume
69 * \param volVars The current or previous volVars
70 */
71 1225800 NumEqVector computeStorage(const Problem& problem,
72 const SubControlVolume& scv,
73 const VolumeVariables& volVars) const
74 {
75 1225800 NumEqVector storage = ParentType::computeStorage(problem, scv, volVars);
76 // for extended Richards we consider water in air
77 1225800 storage[conti0EqIdx] += volVars.porosity()
78 1225800 * volVars.molarDensity(gasPhaseIdx)
79 1225800 * volVars.moleFraction(gasPhaseIdx, liquidCompIdx)
80 1225800 * FluidSystem::molarMass(liquidCompIdx)
81 1225800 * volVars.saturation(gasPhaseIdx);
82
83 1225800 return storage;
84 }
85
86
87 /*!
88 * \brief Evaluates the mass flux over a face of a sub control volume.
89 *
90 * \param problem The problem
91 * \param element The current element.
92 * \param fvGeometry The finite-volume geometry
93 * \param elemVolVars The volume variables of the current element
94 * \param scvf The sub control volume face to compute the flux on
95 * \param elemFluxVarsCache The cache related to flux computation
96 */
97 925830 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 925830 FluxVariables fluxVars;
105 925830 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
106 925830 NumEqVector flux = ParentType::computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
107
108 // for extended Richards we consider water vapor diffusion in air
109 //check for the reference system and adapt units of the diffusive flux accordingly.
110 if (FluxVariables::MolecularDiffusionType::referenceSystemFormulation() == ReferenceSystemFormulation::massAveraged)
111 925830 flux[conti0EqIdx] += fluxVars.molecularDiffusionFlux(gasPhaseIdx)[liquidCompIdx];
112 else
113 flux[conti0EqIdx] += fluxVars.molecularDiffusionFlux(gasPhaseIdx)[liquidCompIdx]*FluidSystem::molarMass(liquidCompIdx);
114
115 925830 return flux;
116 }
117 };
118
119 } // end namespace Dumux
120
121 #endif
122