GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/assembly/cclocalresidual.hh
Date: 2025-07-12 19:18:49
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 296 299 99.0%
Branches: 35 68 51.5%

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 Assembly
10 * \ingroup CCDiscretization
11 * \brief Calculates the element-wise residual for cell-centered discretization schemes
12 */
13 #ifndef DUMUX_CC_LOCAL_RESIDUAL_HH
14 #define DUMUX_CC_LOCAL_RESIDUAL_HH
15
16 #include <dumux/common/reservedblockvector.hh>
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/numeqvector.hh>
19 #include <dumux/assembly/fvlocalresidual.hh>
20 #include <dumux/discretization/extrusion.hh>
21
22 namespace Dumux {
23
24 /*!
25 * \ingroup Assembly
26 * \ingroup CCDiscretization
27 * \brief Calculates the element-wise residual for the cell-centered discretization schemes
28 */
29 template<class TypeTag>
30 class CCLocalResidual : public FVLocalResidual<TypeTag>
31 {
32 using ParentType = FVLocalResidual<TypeTag>;
33 using Problem = GetPropType<TypeTag, Properties::Problem>;
34 using Element = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView::template Codim<0>::Entity;
35 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
36 using ElementBoundaryTypes = GetPropType<TypeTag, Properties::ElementBoundaryTypes>;
37 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
38 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
39 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
40 using FVElementGeometry = typename GridGeometry::LocalView;
41 using Extrusion = Extrusion_t<GridGeometry>;
42 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
43
44 public:
45 using ElementResidualVector = typename ParentType::ElementResidualVector;
46
7/14
✓ Branch 1 taken 44127057 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20215383 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1360056 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 100264 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 105781 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1928000 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 200 times.
✗ Branch 20 not taken.
67836741 using ParentType::ParentType;
47
48 //! evaluate the flux residual for a sub control volume face and add to residual
49
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108077375 times.
657225332 void evalFlux(ElementResidualVector& residual,
50 const Problem& problem,
51 const Element& element,
52 const FVElementGeometry& fvGeometry,
53 const ElementVolumeVariables& elemVolVars,
54 const ElementBoundaryTypes& elemBcTypes,
55 const ElementFluxVariablesCache& elemFluxVarsCache,
56 const SubControlVolumeFace& scvf) const
57 {
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108077375 times.
641737972 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
59 657225332 const auto localScvIdx = scv.localDofIndex();
60
2/2
✓ Branch 1 taken 596894149 times.
✓ Branch 2 taken 251101161 times.
1258977945 residual[localScvIdx] += this->asImp().evalFlux(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
61 384720904 }
62
63 //! evaluate the flux residual for a sub control volume face
64 1162805732 NumEqVector evalFlux(const Problem& problem,
65 const Element& element,
66 const FVElementGeometry& fvGeometry,
67 const ElementVolumeVariables& elemVolVars,
68 const ElementFluxVariablesCache& elemFluxVarsCache,
69 const SubControlVolumeFace& scvf) const
70 {
71
2/2
✓ Branch 0 taken 752528591 times.
✓ Branch 1 taken 21521947 times.
1162805732 NumEqVector flux(0.0);
72
73 // inner faces
74
2/2
✓ Branch 0 taken 752528591 times.
✓ Branch 1 taken 21521947 times.
1162805732 if (!scvf.boundary())
75 {
76 1799587750 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
77 }
78
79 // boundary faces
80 else
81 {
82
5/5
✓ Branch 0 taken 1534620 times.
✓ Branch 1 taken 18529443 times.
✓ Branch 2 taken 1491164 times.
✓ Branch 3 taken 102738 times.
✓ Branch 4 taken 38094 times.
32267158 const auto& bcTypes = problem.boundaryTypes(element, scvf);
83
84 // Dirichlet boundaries
85
4/4
✓ Branch 0 taken 1789038 times.
✓ Branch 1 taken 19732909 times.
✓ Branch 2 taken 1643606 times.
✓ Branch 3 taken 145432 times.
32035381 if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann())
86
1/2
✓ Branch 1 taken 145432 times.
✗ Branch 2 not taken.
4151930 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
87
88 // Neumann and Robin ("solution dependent Neumann") boundary conditions
89
2/4
✓ Branch 0 taken 19732909 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19732909 times.
29794073 else if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet())
90 {
91
4/5
✓ Branch 0 taken 7796336 times.
✓ Branch 1 taken 4242315 times.
✓ Branch 2 taken 592054 times.
✓ Branch 3 taken 24896 times.
✗ Branch 4 not taken.
35126841 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
92
93 // multiply neumann fluxes with the area and the extrusion factor
94
2/2
✓ Branch 0 taken 9186832 times.
✓ Branch 1 taken 792739 times.
40333944 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
95
2/2
✓ Branch 1 taken 33418282 times.
✓ Branch 2 taken 12729795 times.
93966996 neumannFluxes *= Extrusion::area(fvGeometry, scvf)*elemVolVars[scv].extrusionFactor();
96
97 29794073 flux += neumannFluxes;
98 }
99
100 else
101
0/20
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
32035381 DUNE_THROW(Dune::NotImplemented, "Mixed boundary conditions. Use pure boundary conditions by converting Dirichlet BCs to Robin BCs");
102 }
103
104 1162805732 return flux;
105 }
106 };
107
108 } // end namespace Dumux
109
110 #endif
111