GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/gridcapabilities.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 1 4 25.0%
Functions: 0 29 0.0%
Branches: 5 8 62.5%

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 Core
10 * \brief dune-grid capabilities compatibility layer
11 */
12 #ifndef DUMUX_COMMON_GRID_CAPABILITIES_HH
13 #define DUMUX_COMMON_GRID_CAPABILITIES_HH
14
15 #include <dune/grid/common/capabilities.hh>
16
17 // TODO: The following is a temporary solution to make canCommunicate work.
18 // Once it is resolved upstream
19 // (https://gitlab.dune-project.org/core/dune-grid/issues/78),
20 // it should be guarded by a DUNE_VERSION macro and removed later.
21
22 #if HAVE_DUNE_UGGRID
23 namespace Dune {
24 template<int dim>
25 class UGGrid;
26 } // end namespace Dumux
27 #endif // HAVE_DUNE_UGGRID
28
29 namespace Dumux::Temp::Capabilities {
30
31 template<class Grid, int codim>
32 struct canCommunicate
33 {
34 static const bool v = false;
35 };
36
37 #if HAVE_DUNE_UGGRID
38 template<int dim, int codim>
39 struct canCommunicate<Dune::UGGrid<dim>, codim>
40 {
41 static const bool v = true;
42 };
43 #endif // HAVE_DUNE_UGGRID
44
45 } // namespace Dumux::Temp::Capabilities
46 // end workaround
47
48 namespace Dumux::Detail {
49
50 template<class Grid, int dofCodim>
51 static constexpr bool canCommunicate =
52 Dune::Capabilities::canCommunicate<Grid, dofCodim>::v
53 || Dumux::Temp::Capabilities::canCommunicate<Grid, dofCodim>::v;
54
55 } // namespace Dumux
56
57 namespace Dumux::Grid::Capabilities {
58
59 // Default implementation
60 // The grid capability gives an absolute guarantee
61 // however this does not mean that multithreading is not
62 // supported at all. It might still work for some special cases.
63 // This knowledge is encoded in specializations for the different
64 // grid managers, see dumux/grid/io/gridmanager_*.hh
65 template<class Grid>
66 struct MultithreadingSupported
67 {
68 template<class GV>
69 static bool eval(const GV&) // default is independent of the grid view
70 { return Dune::Capabilities::viewThreadSafe<Grid>::v; }
71 };
72
73 template<class GridView>
74 inline bool supportsMultithreading(const GridView& gridView)
75
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 378 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
408 { return MultithreadingSupported<typename GridView::Grid>::eval(gridView); }
76
77 } // namespace Dumux::Grid::Capabilities
78
79 #endif
80