GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/pq1bubble/pq1bubblefecache.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 8 9 88.9%
Functions: 4 4 100.0%
Branches: 5 28 17.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 PQ1BubbleDiscretization
10 * \brief A finite element cache for P1/Q1 function with bubble
11 */
12 #ifndef DUMUX_DISCRETIZATION_PQ1BUBBLE_FECACHE_HH
13 #define DUMUX_DISCRETIZATION_PQ1BUBBLE_FECACHE_HH
14
15 #include <memory>
16
17 #include <dune/common/exceptions.hh>
18 #include <dune/geometry/type.hh>
19
20 #include <dune/localfunctions/common/virtualinterface.hh>
21 #include <dune/localfunctions/common/virtualwrappers.hh>
22
23 #include <dumux/discretization/pq1bubble/pq1bubblelocalfiniteelement.hh>
24
25 namespace Dumux {
26
27 template< class CoordScalar, class Scalar, unsigned int dim>
28 class PQ1BubbleFECache
29 {
30 static_assert(dim == 2 || dim == 3, "P1/Q1 bubble FE spaces only implemented for 2D and 3D grids");
31
32 // These are so-called non-conforming finite element spaces
33 // the local basis is only continuous at given points on the faces
34 using P1Bubble = Dumux::PQ1BubbleLocalFiniteElement<CoordScalar, Scalar, dim, Dune::GeometryTypes::simplex(dim).toId()>;
35 using Q1Bubble = Dumux::PQ1BubbleLocalFiniteElement<CoordScalar, Scalar, dim, Dune::GeometryTypes::cube(dim).toId()>;
36
37 public:
38 using FiniteElementType = Dune::LocalFiniteElementVirtualInterface<typename P1Bubble::Traits::LocalBasisType::Traits>;
39
40 14 PQ1BubbleFECache()
41 : p1BubbleBasis_(std::make_unique<Dune::LocalFiniteElementVirtualImp<P1Bubble>>(P1Bubble{}))
42
3/8
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 14 times.
✗ Branch 12 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
14 , q1BubbleBasis_(std::make_unique<Dune::LocalFiniteElementVirtualImp<Q1Bubble>>(Q1Bubble{}))
43 14 {}
44
45 //! Get local finite element for given GeometryType
46 19787966 const FiniteElementType& get(const Dune::GeometryType& gt) const
47 {
48
1/2
✓ Branch 0 taken 19787966 times.
✗ Branch 1 not taken.
19787966 if (gt.isSimplex())
49 23338844 return *p1BubbleBasis_;
50
1/2
✓ Branch 0 taken 8118544 times.
✗ Branch 1 not taken.
8118544 if (gt.isCube())
51 16237088 return *q1BubbleBasis_;
52 else
53 DUNE_THROW(Dune::NotImplemented,
54 "Lagrange bubble local finite element for geometry type " << gt
55 );
56 }
57
58 private:
59 std::unique_ptr<FiniteElementType> p1BubbleBasis_;
60 std::unique_ptr<FiniteElementType> q1BubbleBasis_;
61 };
62
63 } // end namespace Dumux
64
65 #endif
66