GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/fem/fegridgeometry.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 5 6 83.3%
Functions: 2 2 100.0%
Branches: 14 50 28.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 FEMDiscretization
10 * \brief The grid geometry class for models using finite element schemes.
11 * This is basically a wrapper around a function space basis.
12 */
13 #ifndef DUMUX_DISCRETIZATION_FE_GRID_GEOMETRY_HH
14 #define DUMUX_DISCRETIZATION_FE_GRID_GEOMETRY_HH
15
16 #include <unordered_map>
17
18 #include <dumux/common/indextraits.hh>
19 #include <dumux/common/defaultmappertraits.hh>
20
21 #include <dumux/discretization/method.hh>
22 #include <dumux/discretization/basegridgeometry.hh>
23 #include <dumux/discretization/checkoverlapsize.hh>
24 #include <dumux/discretization/extrusion.hh>
25 #include <dumux/discretization/fem/feelementgeometry.hh>
26
27 namespace Dumux {
28
29 /*!
30 * \ingroup FEMDiscretization
31 * \brief Default Traits class for the fem grid geometry.
32 * \tparam The finite element function space basis
33 * \tparam MapperTraits Traits class containing data types for mappers
34 */
35 template<class FEBasis, class MapperTraits = DefaultMapperTraits<typename FEBasis::GridView>>
36 struct DefaultFEGridGeometryTraits : public MapperTraits
37 {
38 template<class GridGeometry>
39 using LocalView = FEElementGeometry<GridGeometry>;
40 };
41
42 /*!
43 * \ingroup FEMDiscretization
44 * \brief The grid geometry class for models using finite element schemes.
45 * This is basically a wrapper around a function space basis.
46 * \tparam FEB The finite element function space basis
47 * \tparam MapperTraits Traits class containing data types for mappers
48 */
49 template<class FEB, class Traits = DefaultFEGridGeometryTraits<FEB>>
50 class FEGridGeometry
51 : public BaseGridGeometry< typename FEB::GridView, Traits >
52 {
53 using ThisType = FEGridGeometry<FEB, Traits>;
54 using ParentType = BaseGridGeometry<typename FEB::GridView, Traits>;
55
56 using GridIndexType = typename IndexTraits<typename FEB::GridView>::GridIndex;
57 using LocalIndexType = typename IndexTraits<typename FEB::GridView>::LocalIndex;
58
59 public:
60 //! export the discretization method this geometry belongs to
61 using DiscretizationMethod = DiscretizationMethods::FEM;
62 static constexpr DiscretizationMethod discMethod{};
63
64 //! export the grid view type
65 using GridView = typename FEB::GridView;
66 //! export the type of extrusion
67 using Extrusion = Extrusion_t<Traits>;
68 //! export the type of finite element basis
69 using FEBasis = FEB;
70 //! export local view
71 using LocalView = typename Traits::template LocalView<ThisType>;
72
73 //! Constructor
74 4 FEGridGeometry(std::shared_ptr<FEBasis> feBasis)
75 : ParentType(feBasis->gridView())
76
0/4
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12 , feBasis_(feBasis)
77 {
78 // Check if the overlap size is what we expect
79
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
8 if (!CheckOverlapSize<DiscretizationMethod>::isValid(*feBasis))
80 DUNE_THROW(Dune::InvalidStateException, "The finite element discretization method only works with zero overlap for parallel computations. "
81 << " Set the parameter \"Grid.Overlap\" in the input file.");
82 4 }
83
84 //! The total number of degrees of freedom
85 auto numDofs() const
86 { return feBasis_->size(); }
87
88 //! The total number of degrees of freedom
89 const FEBasis& feBasis() const
90
12/24
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
8 { return *feBasis_; }
91
92 //! If a vertex / d.o.f. is on a periodic boundary
93 bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
94 { DUNE_THROW(Dune::NotImplemented, "Periodic BC support for FEM schemes"); }
95
96 //! The index of the vertex / d.o.f. on the other side of the periodic boundary
97 GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
98 { DUNE_THROW(Dune::NotImplemented, "Periodic BC support for FEM schemes"); }
99
100 //! Returns the map between dofs across periodic boundaries
101 [[deprecated("Will be removed after release 3.9. Implement periodicDofMap() if periodic bcs are supported.")]]
102 const std::unordered_map<GridIndexType, GridIndexType>& periodicVertexMap() const
103 { DUNE_THROW(Dune::NotImplemented, "Periodic BC support for FEM schemes"); }
104
105 private:
106 std::shared_ptr<FEBasis> feBasis_;
107 };
108
109 } // end namespace Dumux
110
111 #endif
112