GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/box/scvftoscvboundarytypes.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 20 21 95.2%
Functions: 5 5 100.0%
Branches: 49 68 72.1%

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 BoxDiscretization
10 * \brief Convert intersection boundary types to vertex boundary types
11 */
12 #ifndef DUMUX_SCVF_TO_SCV_BCTYPES_HH
13 #define DUMUX_SCVF_TO_SCV_BCTYPES_HH
14
15 #include <vector>
16 #include <dune/common/exceptions.hh>
17 #include <dumux/discretization/method.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup BoxDiscretization
23 * \brief Convert intersection boundary types to vertex boundary types
24 */
25 template<class BoundaryTypes, class DiscretizationMethod>
26 class ScvfToScvBoundaryTypes
27 {
28 public:
29
2/4
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
28 ScvfToScvBoundaryTypes() = default;
30
31 template<class Problem>
32 14 void computeBoundaryTypes(const Problem& problem)
33 {
34 // only do something for box
35 if (DiscretizationMethod{} == DiscretizationMethods::box)
36 {
37 14 const auto& gridGeometry = problem.gridGeometry();
38 28 scvBoundaryTypes.resize(gridGeometry.vertexMapper().size());
39 // set all equations to Neumann by default
40
4/4
✓ Branch 0 taken 39924 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 39924 times.
✓ Branch 3 taken 14 times.
79876 for (std::size_t vIdx = 0; vIdx < scvBoundaryTypes.size(); vIdx++)
41 119772 scvBoundaryTypes[vIdx].setAllNeumann();
42
43
1/4
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
14 auto fvGeometry = localView(gridGeometry);
44
11/18
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 14 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 37462 times.
✓ Branch 13 taken 14 times.
✓ Branch 14 taken 37462 times.
✓ Branch 15 taken 14 times.
✓ Branch 17 taken 37462 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 37462 times.
✗ Branch 21 not taken.
✓ Branch 25 taken 8 times.
✗ Branch 26 not taken.
37504 for (const auto& element : elements(gridGeometry.gridView()))
45 {
46 // iterate over the scvfs
47
1/2
✓ Branch 1 taken 37462 times.
✗ Branch 2 not taken.
37462 fvGeometry.bindElement(element);
48
49
6/6
✓ Branch 0 taken 180012 times.
✓ Branch 1 taken 37462 times.
✓ Branch 2 taken 180012 times.
✓ Branch 3 taken 37462 times.
✓ Branch 4 taken 1512 times.
✓ Branch 5 taken 86694 times.
254936 for (const auto& scvf : scvfs(fvGeometry))
50 {
51
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 175980 times.
180012 if (!scvf.boundary())
52 179372 continue;
53
54
1/2
✓ Branch 1 taken 4032 times.
✗ Branch 2 not taken.
4032 const auto bcTypes = problem.boundaryTypes(element, scvf);
55
4/4
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 3392 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 3392 times.
8064 if (!bcTypes.hasDirichlet())
56 continue;
57
58 // get the inside scv belonging to this scvf and set possible Dirichlet boundary conditions
59
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
1120 const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
60
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 640 times.
2160 for (int pvIdx = 0; pvIdx < bcTypes.size(); ++pvIdx)
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1520 times.
1520 if (bcTypes.isDirichlet(pvIdx))
62 3760 scvBoundaryTypes[scv.dofIndex()].setDirichlet(pvIdx);
63 }
64 }
65 }
66 14 }
67
68 //! get the boundary types of the scv
69 template<class SubControlVolume>
70 const BoundaryTypes& boundaryTypes(const SubControlVolume& scv) const
71 {
72 if (DiscretizationMethod{} == DiscretizationMethods::box)
73
12/12
✓ Branch 0 taken 320780 times.
✓ Branch 1 taken 26896 times.
✓ Branch 2 taken 320780 times.
✓ Branch 3 taken 26896 times.
✓ Branch 4 taken 135463 times.
✓ Branch 5 taken 47888 times.
✓ Branch 6 taken 135463 times.
✓ Branch 7 taken 47888 times.
✓ Branch 8 taken 9072 times.
✓ Branch 9 taken 47152 times.
✓ Branch 10 taken 9072 times.
✓ Branch 11 taken 47152 times.
1174502 return scvBoundaryTypes[scv.dofIndex()];
74 else
75 DUNE_THROW(Dune::InvalidStateException, "Only use this for the box discretization!");
76 }
77
78 private:
79 std::vector<BoundaryTypes> scvBoundaryTypes;
80 };
81
82 } // end namespace Dumux
83
84 #endif
85