GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/multidomain/facet/box/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 16 16 100.0%
Branches: 20 22 90.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 FacetCoupling
10 * \brief Calculates the element-wise residual for the box scheme with
11 * coupling to a lower-dimensional domain occurring across the element facets.
12 */
13 #ifndef DUMUX_FACETCOUPLING_BOX_LOCAL_RESIDUAL_HH
14 #define DUMUX_FACETCOUPLING_BOX_LOCAL_RESIDUAL_HH
15
16 #include <dune/geometry/type.hh>
17
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/numeqvector.hh>
20 #include <dumux/assembly/fvlocalresidual.hh>
21 #include <dumux/discretization/extrusion.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup FacetCoupling
27 * \brief The element-wise residual for the box scheme
28 * \tparam TypeTag the TypeTag
29 */
30 template<class TypeTag>
31 class BoxFacetCouplingLocalResidual : public FVLocalResidual<TypeTag>
32 {
33 using ParentType = FVLocalResidual<TypeTag>;
34 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
35 using Problem = GetPropType<TypeTag, Properties::Problem>;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using FVElementGeometry = typename GridGeometry::LocalView;
38 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
39 using Extrusion = Extrusion_t<GridGeometry>;
40 using GridView = typename GridGeometry::GridView;
41 using Element = typename GridView::template Codim<0>::Entity;
42 using ElementBoundaryTypes = GetPropType<TypeTag, Properties::ElementBoundaryTypes>;
43 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
44 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
45 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
46
47 public:
48 using ElementResidualVector = typename ParentType::ElementResidualVector;
49
2/4
✓ Branch 1 taken 53150 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1127800 times.
✗ Branch 5 not taken.
1180950 using ParentType::ParentType;
50
51 //! evaluate flux residuals for one sub control volume face and add to residual
52 16830896 void evalFlux(ElementResidualVector& residual,
53 const Problem& problem,
54 const Element& element,
55 const FVElementGeometry& fvGeometry,
56 const ElementVolumeVariables& elemVolVars,
57 const ElementBoundaryTypes& elemBcTypes,
58 const ElementFluxVariablesCache& elemFluxVarsCache,
59 const SubControlVolumeFace& scvf) const
60 {
61 16830896 const auto flux = evalFlux(problem, element, fvGeometry, elemVolVars, elemBcTypes, elemFluxVarsCache, scvf);
62
63 // inner faces
64
4/4
✓ Branch 0 taken 12572048 times.
✓ Branch 1 taken 705528 times.
✓ Branch 2 taken 12192936 times.
✓ Branch 3 taken 379112 times.
16830896 if (!scvf.boundary() && !scvf.interiorBoundary())
65 {
66 30825888 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
67 15412944 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
68 30825888 residual[insideScv.localDofIndex()] += flux;
69 30825888 residual[outsideScv.localDofIndex()] -= flux;
70 }
71
72 // interior/domain boundary faces
73 else
74 {
75 2835904 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
76 2835904 residual[insideScv.localDofIndex()] += flux;
77 }
78 16830896 }
79
80 //! evaluate flux residuals for one sub control volume face
81 14182664 NumEqVector evalFlux(const Problem& problem,
82 const Element& element,
83 const FVElementGeometry& fvGeometry,
84 const ElementVolumeVariables& elemVolVars,
85 const ElementBoundaryTypes& elemBcTypes,
86 const ElementFluxVariablesCache& elemFluxVarsCache,
87 const SubControlVolumeFace& scvf) const
88 {
89
2/2
✓ Branch 0 taken 59264 times.
✓ Branch 1 taken 1901376 times.
14182664 NumEqVector flux(0.0);
90
91 // inner or interior boundary faces
92
4/4
✓ Branch 0 taken 593432 times.
✓ Branch 1 taken 9751208 times.
✓ Branch 2 taken 4896 times.
✓ Branch 3 taken 588536 times.
14182664 if (!scvf.boundary() || scvf.interiorBoundary())
93 21328120 flux += this->asImp().computeFlux(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
94
95 // boundary faces
96 else
97 {
98 1408752 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
99 704376 const auto& bcTypes = elemBcTypes.get(fvGeometry, scv);
100
101 // Neumann and Robin ("solution dependent Neumann") boundary conditions
102
4/4
✓ Branch 0 taken 275872 times.
✓ Branch 1 taken 312664 times.
✓ Branch 2 taken 275872 times.
✓ Branch 3 taken 312664 times.
1408752 if (bcTypes.hasNeumann())
103 {
104 372768 auto neumannFluxes = problem.neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
105
106 // multiply neumann fluxes with the area and the extrusion factor
107 1118304 neumannFluxes *= Extrusion::area(fvGeometry, scvf)*elemVolVars[scv].extrusionFactor();
108
109 // only add fluxes to equations for which Neumann is set
110
2/2
✓ Branch 0 taken 689652 times.
✓ Branch 1 taken 275872 times.
1159316 for (int eqIdx = 0; eqIdx < NumEqVector::dimension; ++eqIdx)
111
2/2
✓ Branch 0 taken 20880 times.
✓ Branch 1 taken 668772 times.
786548 if (bcTypes.isNeumann(eqIdx))
112 2087828 flux[eqIdx] += neumannFluxes[eqIdx];
113 }
114 }
115
116 14182664 return flux;
117 }
118 };
119
120 } // end namespace Dumux
121
122 #endif
123