GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/fluxstencil.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 14 100.0%
Functions: 34 47 72.3%
Branches: 16 20 80.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 Discretization
10 * \brief The flux stencil specialized for different discretization schemes
11 */
12 #ifndef DUMUX_DISCRETIZATION_FLUXSTENCIL_HH
13 #define DUMUX_DISCRETIZATION_FLUXSTENCIL_HH
14
15 #include <vector>
16
17 #include <dune/common/reservedvector.hh>
18 #include <dumux/common/indextraits.hh>
19 #include <dumux/discretization/method.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup Discretization
25 * \brief The flux stencil specialized for different discretization schemes
26 * \note There might be different stencils used for e.g. advection and diffusion for schemes
27 * where the stencil depends on variables. Also schemes might even have solution dependent
28 * stencil. However, we always reserve the stencil or all DOFs that are possibly involved
29 * since we use the flux stencil for matrix and assembly. This might lead to some zeros stored
30 * in the matrix.
31 */
32 template<class FVElementGeometry, class DiscretizationMethod = typename FVElementGeometry::GridGeometry::DiscretizationMethod>
33 class FluxStencil;
34
35 /*
36 * \ingroup Discretization
37 * \brief Flux stencil specialization for the cell-centered tpfa scheme
38 * \tparam FVElementGeometry The local view on the finite volume grid geometry
39 */
40 template<class FVElementGeometry>
41 class FluxStencil<FVElementGeometry, DiscretizationMethods::CCTpfa>
42 {
43 using GridGeometry = typename FVElementGeometry::GridGeometry;
44 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
45 using GridView = typename GridGeometry::GridView;
46 using Element = typename GridView::template Codim<0>::Entity;
47 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
48
49 public:
50 //! Each cell I couples to a cell J always only via one face
51 using ScvfStencilIForJ = Dune::ReservedVector<GridIndexType, 1>;
52
53 //! The flux stencil type
54 using Stencil = typename SubControlVolumeFace::Traits::GridIndexStorage;
55
56 //! Returns the flux stencil
57 10214543 static Stencil stencil(const Element& element,
58 const FVElementGeometry& fvGeometry,
59 const SubControlVolumeFace& scvf)
60 {
61
2/2
✓ Branch 0 taken 49849 times.
✓ Branch 1 taken 3066430 times.
10214543 if (scvf.boundary())
62 388004 return Stencil({scvf.insideScvIdx()});
63
4/4
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3065920 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 3065920 times.
20043516 else if (scvf.numOutsideScvs() > 1)
64 {
65 5680 Stencil stencil({scvf.insideScvIdx()});
66
4/4
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 1446 times.
✓ Branch 3 taken 510 times.
9056 for (unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
67
2/6
✓ Branch 1 taken 1446 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1446 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7636 stencil.push_back(scvf.outsideScvIdx(i));
68 2840 return stencil;
69 }
70 else
71 30141370 return Stencil({scvf.insideScvIdx(), scvf.outsideScvIdx()});
72 }
73 };
74
75 /*
76 * \ingroup Discretization
77 * \brief Flux stencil specialization for the cell-centered mpfa scheme
78 * \tparam FVElementGeometry The local view on the finite volume grid geometry
79 */
80 template<class FVElementGeometry>
81 class FluxStencil<FVElementGeometry, DiscretizationMethods::CCMpfa>
82 {
83 using GridGeometry = typename FVElementGeometry::GridGeometry;
84 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
85 using GridView = typename GridGeometry::GridView;
86 using Element = typename GridView::template Codim<0>::Entity;
87 using GridIndexType = typename IndexTraits<GridView>::GridIndex;
88
89 // Use the stencil type of the primary interaction volume
90 using NodalIndexSet = typename GridGeometry::GridIVIndexSets::DualGridIndexSet::NodalIndexSet;
91
92 public:
93 //! We don't know yet how many faces couple to a neighboring element
94 using ScvfStencilIForJ = std::vector<GridIndexType>;
95
96 //! The flux stencil type
97 using Stencil = typename NodalIndexSet::NodalGridStencilType;
98
99 //! Returns the indices of the elements required for flux calculation on an scvf.
100 6144 static const Stencil& stencil(const Element& element,
101 const FVElementGeometry& fvGeometry,
102 const SubControlVolumeFace& scvf)
103 {
104 630616 const auto& gridGeometry = fvGeometry.gridGeometry();
105
106 // return the scv (element) indices in the interaction region
107
4/4
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 5520 times.
✓ Branch 2 taken 624 times.
✓ Branch 3 taken 5520 times.
636760 if (gridGeometry.vertexUsesSecondaryInteractionVolume(scvf.vertexIndex()))
108 2496 return gridGeometry.gridInteractionVolumeIndexSets().secondaryIndexSet(scvf).gridScvIndices();
109 else
110 1895496 return gridGeometry.gridInteractionVolumeIndexSets().primaryIndexSet(scvf).gridScvIndices();
111 }
112 };
113
114 } // end namespace Dumux
115
116 #endif
117