GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/adaptive/markelements.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 17 17 100.0%
Functions: 1 1 100.0%
Branches: 19 34 55.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 Adaptive
10 * \brief A function to mark element for refinement or coarsening
11 */
12 #ifndef DUMUX_ADAPTIVE_MARKELEMENTS_HH
13 #define DUMUX_ADAPTIVE_MARKELEMENTS_HH
14
15 #include <dune/grid/common/rangegenerators.hh>
16
17 namespace Dumux {
18
19 /*!
20 * \ingroup Adaptive
21 * \brief A function to mark element for refinement or coarsening
22 * \param grid the grid to mark the entities on
23 * \param indicator indicated per element whether to refine, coarsen, do nothing. It has a ()-operator taking an element
24 * \param verbose If verbose output to std::cout is enabled
25 * \return bool whether or not anything has been marked
26 */
27 template<class Grid, class Indicator>
28 22 bool markElements(Grid& grid, const Indicator& indicator, bool verbose = true)
29 {
30 // mark elements according to indicator
31 22 std::size_t refine = 0;
32 22 std::size_t coarsen = 0;
33
8/12
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 2 times.
✓ Branch 13 taken 18 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 18 times.
✗ Branch 17 not taken.
121091 for (const auto& element : elements(grid.leafGridView(), Dune::Partitions::interior))
34 {
35
1/2
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
121047 const auto mark = indicator(element);
36
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 16 times.
121047 if (mark > 0)
37 {
38
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4926 grid.mark(1, element);
39 4926 ++refine;
40 }
41
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
116121 else if (mark < 0)
42 {
43
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
29139 grid.mark(-1, element);
44 29139 ++coarsen;
45 }
46 }
47
48 // abort if nothing in grid is marked
49
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
25 const std::size_t sumRefine = grid.comm().sum(refine);
50
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
25 const std::size_t sumCoarsen = grid.comm().sum(coarsen);
51
52
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
28 if (grid.comm().rank() == 0 && verbose)
53 22 std::cout << sumRefine << " cells have been marked to be refined, "
54 44 << sumCoarsen << " to be coarsened." << std::endl;
55
56 // return whether or not anything has been marked
57 22 return sumRefine != 0 || sumCoarsen != 0;
58 }
59
60 } //end namespace Dumux
61
62 #endif
63