Debian Codegraph @

dune/localfunctions/meta/discontinuous.hh

raw
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6 #ifndef DUNE_LOCALFUNCTIONS_META_DISCONTINUOUS_HH
7 #define DUNE_LOCALFUNCTIONS_META_DISCONTINUOUS_HH
8
9 #include <utility>
10
11 #include <dune/common/referencehelper.hh>
12 #include <dune/geometry/type.hh>
13 #include <dune/localfunctions/utility/dglocalcoefficients.hh>
14
15 namespace Dune {
16
17 //! \brief Meta-finite element turning a finite-element into "discontinuous" finite-element
18 //! by associating all basis functions to the element interior.
19 /**
20 * \ingroup LocalFunctions
21 *
22 * \tparam LFE Type of the local finite-element, can be a raw type or a reference_wrapper.
23 */
24 template<class LFE>
25 class DiscontinuousLocalFiniteElement
26 {
27 using LFERaw = ResolveRef_t<LFE>;
28
29 using LB = typename LFERaw::Traits::LocalBasisType;
30 using LC = typename LFERaw::Traits::LocalCoefficientsType;
31 using LI = typename LFERaw::Traits::LocalInterpolationType;
32
33 public:
34 //! types of component objects
35 struct Traits {
36 //! type of the Basis
37 using LocalBasisType = LB;
38 //! type of the Coefficients
39 using LocalCoefficientsType = DGLocalCoefficients;
40 //! type of the Interpolation
41 using LocalInterpolationType = LI;
42 };
43
44 private:
45 LFE lfe_;
46 typename Traits::LocalCoefficientsType lc_;
47
48 public:
49 //! Construct a finite element
50 template <class LFE_>
51 explicit DiscontinuousLocalFiniteElement (LFE_&& lfe)
52 : lfe_(std::forward<LFE_>(lfe))
53 , lc_(resolveRef(lfe_).localCoefficients().size())
54 {}
55
56 //! Extract basis of this finite element
57 /**
58 * The returned lvalue must have a lifetime at least as long as the finite
59 * element object it was acquired from.
60 */
61 const typename Traits::LocalBasisType& localBasis () const
62 {
63 return resolveRef(lfe_).localBasis();
64 }
65
66 //! Extract coefficients of this finite element
67 /**
68 * The returned lvalue must have a lifetime at least as long as the finite
69 * element object it was acquired from.
70 */
71 const typename Traits::LocalCoefficientsType& localCoefficients() const
72 {
73 return lc_;
74 }
75
76 //! Extract interpolation of this finite element
77 /**
78 * The returned lvalue must have a lifetime at least as long as the finite
79 * element object it was acquired from.
80 */
81 const typename Traits::LocalInterpolationType& localInterpolation() const
82 {
83 return resolveRef(lfe_).localInterpolation();
84 }
85
86 //! Return the number of basis functions
87 unsigned int size () const
88 {
89 return resolveRef(lfe_).size();
90 }
91
92 //! Return the geometry type the finite element can be bound to
93 const GeometryType type () const
94 {
95 return resolveRef(lfe_).type();
96 }
97 };
98
99 // deduction guide
100 template <class LFE>
101 DiscontinuousLocalFiniteElement (LFE lfe)
102 -> DiscontinuousLocalFiniteElement<LFE>;
103
104 } // namespace Dune
105
106 #endif // DUNE_LOCALFUNCTIONS_META_DISCONTINUOUS_HH