GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/functionspacebasis.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 0 0 -%
Branches: 6 12 50.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 Provides helper aliases and functionality to obtain the types
11 * and instances of Dune::Functions function space bases that
12 * underlie different discretization schemes
13 */
14 #ifndef DUMUX_DISCRETIZATION_FUNCTION_SPACE_BASIS_HH
15 #define DUMUX_DISCRETIZATION_FUNCTION_SPACE_BASIS_HH
16
17 #if HAVE_DUNE_FUNCTIONS
18
19 #include <dumux/discretization/method.hh>
20 #include <dune/functions/functionspacebases/lagrangebasis.hh>
21
22 namespace Dumux {
23
24 /*!
25 * \ingroup Discretization
26 * \brief Traits class that contains information on the
27 * function space basis used by the discretization
28 * scheme underlying a grid geometry class. Specializations
29 * of the traits for different schemes are provided below.
30 */
31 template< class GridGeometry, class DiscretizationMethod = typename GridGeometry::DiscretizationMethod >
32 struct FunctionSpaceBasisTraits;
33
34 /*!
35 * \ingroup Discretization
36 * \brief Creates a Dune::Functions object of the underlying basis
37 * of a discretization scheme that is not finite elements.
38 */
39 template<class GridGeometry, std::enable_if_t<GridGeometry::discMethod != DiscretizationMethods::fem, int> = 0>
40 typename FunctionSpaceBasisTraits<GridGeometry>::GlobalBasis
41 getFunctionSpaceBasis(const GridGeometry& gridGeometry)
42
6/12
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 13 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 13 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 13 times.
✗ Branch 17 not taken.
54 { return {gridGeometry.gridView()}; }
43
44 /*!
45 * \ingroup Discretization
46 * \brief Returns the Dune::Functions object for the basis of a finite element scheme.
47 */
48 template<class GridGeometry, std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::fem, int> = 0>
49 const typename FunctionSpaceBasisTraits<GridGeometry>::GlobalBasis&
50 getFunctionSpaceBasis(const GridGeometry& gridGeometry)
51 { return gridGeometry.feBasis(); }
52
53
54 ///////////////////////////////////////////////////////////
55 // Specializations of the FunctionSpaceBasisTraits class //
56 ///////////////////////////////////////////////////////////
57
58 //! Traits specialization: box scheme uses lagrange basis of order 1
59 template< class GridGeometry >
60 struct FunctionSpaceBasisTraits<GridGeometry, DiscretizationMethods::Box>
61 { using GlobalBasis = Dune::Functions::LagrangeBasis<typename GridGeometry::GridView, /*order*/1>; };
62
63 //! Traits specialization: cc schemes use lagrange bases of order 0
64 template< class GridGeometry >
65 struct FunctionSpaceBasisTraits<GridGeometry, DiscretizationMethods::CCTpfa>
66 { using GlobalBasis = Dune::Functions::LagrangeBasis<typename GridGeometry::GridView, /*order*/0>; };
67
68 //! Traits specialization: cc schemes use lagrange bases of order 0
69 template< class GridGeometry >
70 struct FunctionSpaceBasisTraits<GridGeometry, DiscretizationMethods::CCMpfa>
71 { using GlobalBasis = Dune::Functions::LagrangeBasis<typename GridGeometry::GridView, /*order*/0>; };
72
73 //! Traits specialization: fem defines its basis
74 template< class GridGeometry >
75 struct FunctionSpaceBasisTraits<GridGeometry, DiscretizationMethods::FEM>
76 { using GlobalBasis = typename GridGeometry::FEBasis; };
77
78 } // end namespace Dumux
79
80 #endif // HAVE_DUNE_FUNCTIONS
81 #endif
82