GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/assembly/cclocalresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 17 20 85.0%
Functions: 129 316 40.8%
Branches: 39 71 54.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 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 43932740 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20198584 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1277064 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.
67542633 using ParentType::ParentType;
47
48 //! evaluate the flux residual for a sub control volume face and add to residual
49 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
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
938256858 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
59 515214533 const auto localScvIdx = scv.localDofIndex();
60
9/9
✓ Branch 1 taken 709104 times.
✓ Branch 2 taken 354552 times.
✓ Branch 3 taken 584828253 times.
✓ Branch 4 taken 245644617 times.
✓ Branch 5 taken 584119149 times.
✓ Branch 6 taken 249439425 times.
✓ Branch 7 taken 2074680 times.
✓ Branch 8 taken 4149360 times.
✓ Branch 9 taken 2074680 times.
1693169759 residual[localScvIdx] += this->asImp().evalFlux(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
61 }
62
63 //! evaluate the flux residual for a sub control volume face
64 1145691070 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 113295716 times.
✓ Branch 1 taken 6861508 times.
1145691070 NumEqVector flux(0.0);
72
73 // inner faces
74
2/2
✓ Branch 0 taken 743268750 times.
✓ Branch 1 taken 20919430 times.
1145691070 if (!scvf.boundary())
75 {
76 1772686922 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
77 }
78
79 // boundary faces
80 else
81 {
82
2/2
✓ Branch 0 taken 5914384 times.
✓ Branch 1 taken 904362 times.
31271688 const auto& bcTypes = problem.boundaryTypes(element, scvf);
83
84 // Dirichlet boundaries
85
8/8
✓ Branch 0 taken 1754133 times.
✓ Branch 1 taken 19165297 times.
✓ Branch 2 taken 1754133 times.
✓ Branch 3 taken 19165297 times.
✓ Branch 4 taken 1620421 times.
✓ Branch 5 taken 133712 times.
✓ Branch 6 taken 1620421 times.
✓ Branch 7 taken 133712 times.
62543376 if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann())
86 3970608 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
87
88 // Neumann and Robin ("solution dependent Neumann") boundary conditions
89
4/8
✓ Branch 0 taken 19165297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19165297 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 19165297 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 19165297 times.
58253802 else if (bcTypes.hasNeumann() && !bcTypes.hasDirichlet())
90 {
91
2/2
✓ Branch 0 taken 5770926 times.
✓ Branch 1 taken 29942 times.
29126901 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
92
93 // multiply neumann fluxes with the area and the extrusion factor
94
3/4
✓ Branch 0 taken 9180861 times.
✓ Branch 1 taken 753555 times.
✓ Branch 2 taken 8411797 times.
✗ Branch 3 not taken.
52483153 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
95 60668406 neumannFluxes *= Extrusion::area(fvGeometry, scvf)*elemVolVars[scv].extrusionFactor();
96
97 29126961 flux += neumannFluxes;
98 }
99
100 else
101 DUNE_THROW(Dune::NotImplemented, "Mixed boundary conditions. Use pure boundary conditions by converting Dirichlet BCs to Robin BCs");
102 }
103
104 1145691070 return flux;
105 }
106 };
107
108 } // end namespace Dumux
109
110 #endif
111