dune-localfunctions  2.11
localfunctions/common/localfiniteelement.hh
Go to the documentation of this file.
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 #ifndef DUNE_LOCALFUNCTIONS_COMMON_TYPEERASEDLOCALFINITEELEMENT
6 #define DUNE_LOCALFUNCTIONS_COMMON_TYPEERASEDLOCALFINITEELEMENT
7 
8 #include <memory>
9 #include <type_traits>
10 #include <utility>
11 
12 #include <dune/common/typeutilities.hh>
13 
14 #include <dune/geometry/type.hh>
15 
16 
19 
20 namespace Dune
21 {
22 
38  template<class LBT>
40  {
41  using LocalBasisTraits = LBT;
42  using VirtualLFE = typename Dune::LocalFiniteElementVirtualInterface<LBT>;
43 
44  public:
45 
46  using Traits = typename VirtualLFE::Traits;
47 
55  LocalFiniteElement() = default;
56 
67  template<class LFEImpl,
68  Dune::disableCopyMove<LocalFiniteElement, LFEImpl> = 0 >
69  LocalFiniteElement(LFEImpl&& lfe)
70  : lfe_(new LocalFiniteElementVirtualImp<std::decay_t<LFEImpl>>(std::forward<LFEImpl>(lfe)))
71  , size_(lfe.size())
72  , type_(lfe.type())
73  {}
74 
86  : lfe_(other.lfe_ ? other.lfe_->clone() : nullptr)
87  , size_(other.size())
88  , type_(other.type())
89  {}
90 
101  LocalFiniteElement(LocalFiniteElement&& other) = default;
102 
114  {
115  if (&rhs!=this)
116  {
117  if (rhs.lfe_)
118  lfe_.reset(rhs.lfe_->clone());
119  else
120  lfe_.release();
121  size_ = rhs.size();
122  type_ = rhs.type();
123  }
124  return *this;
125  }
126 
138  LocalFiniteElement& operator=(LocalFiniteElement&& other) = default;
139 
145  operator bool () const
146  {
147  return lfe_;
148  }
149 
156  const typename Traits::LocalBasisType& localBasis () const
157  {
158  return lfe_->localBasis();
159  }
160 
167  const typename Traits::LocalCoefficientsType& localCoefficients () const
168  {
169  return lfe_->localCoefficients();
170  }
171 
178  const typename Traits::LocalInterpolationType& localInterpolation () const
179  {
180  return lfe_->localInterpolation();
181  }
182 
188  unsigned int size () const
189  {
190  return size_;
191  }
192 
198  const GeometryType& type () const
199  {
200  return type_;
201  }
202 
203  private:
204  std::unique_ptr<VirtualLFE> lfe_;
205  unsigned int size_ = 0;
206  Dune::GeometryType type_;
207  };
208 
209 }
210 #endif
const Traits::LocalBasisType & localBasis() const
Access the LocalBasis of the stored local finite element.
Definition: localfunctions/common/localfiniteelement.hh:156
class for wrapping a finite element using the virtual interface
Definition: virtualwrappers.hh:19
typename VirtualLFE::Traits Traits
Definition: localfunctions/common/localfiniteelement.hh:46
LocalFiniteElement()=default
Default constructor.
Definition: bdfmcube.hh:17
const GeometryType & type() const
Get the GeometryType of the stored local finite element.
Definition: localfunctions/common/localfiniteelement.hh:198
LocalFiniteElement & operator=(const LocalFiniteElement &rhs)
Copy assignment.
Definition: localfunctions/common/localfiniteelement.hh:113
const Traits::LocalInterpolationType & localInterpolation() const
Access the LocalInterpolation of the stored local finite element.
Definition: localfunctions/common/localfiniteelement.hh:178
STL namespace.
LocalFiniteElement(const LocalFiniteElement &other)
Copy constructor.
Definition: localfunctions/common/localfiniteelement.hh:85
Type erasure class storing a local finite element.
Definition: localfunctions/common/localfiniteelement.hh:39
const Traits::LocalCoefficientsType & localCoefficients() const
Access the LocalCoefficients of the stored local finite element.
Definition: localfunctions/common/localfiniteelement.hh:167
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:224
unsigned int size() const
Get the number of basis functions of the stored local finite element.
Definition: localfunctions/common/localfiniteelement.hh:188
LocalFiniteElement(LFEImpl &&lfe)
Construct from implementation.
Definition: localfunctions/common/localfiniteelement.hh:69