Loading [MathJax]/extensions/tex2jax.js

Dune Core Modules (unstable)

localfiniteelement.hh
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
13
14#include <dune/geometry/type.hh>
15
16
17#include <dune/localfunctions/common/virtualinterface.hh>
18#include <dune/localfunctions/common/virtualwrappers.hh>
19
20namespace 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,
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
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
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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
class for wrapping a finite element using the virtual interface
Definition: virtualwrappers.hh:240
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:225
Type erasure class storing a local finite element.
Definition: localfiniteelement.hh:40
LocalFiniteElement(LocalFiniteElement &&other)=default
Move constructor.
LocalFiniteElement(const LocalFiniteElement &other)
Copy constructor.
Definition: localfiniteelement.hh:85
LocalFiniteElement()=default
Default constructor.
const Traits::LocalCoefficientsType & localCoefficients() const
Access the LocalCoefficients of the stored local finite element.
Definition: localfiniteelement.hh:167
const Traits::LocalInterpolationType & localInterpolation() const
Access the LocalInterpolation of the stored local finite element.
Definition: localfiniteelement.hh:178
const Traits::LocalBasisType & localBasis() const
Access the LocalBasis of the stored local finite element.
Definition: localfiniteelement.hh:156
unsigned int size() const
Get the number of basis functions of the stored local finite element.
Definition: localfiniteelement.hh:188
LocalFiniteElement & operator=(const LocalFiniteElement &rhs)
Copy assignment.
Definition: localfiniteelement.hh:113
LocalFiniteElement(LFEImpl &&lfe)
Construct from implementation.
Definition: localfiniteelement.hh:69
LocalFiniteElement & operator=(LocalFiniteElement &&other)=default
Move assignment.
const GeometryType & type() const
Get the GeometryType of the stored local finite element.
Definition: localfiniteelement.hh:198
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition: typeutilities.hh:45
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
A unique label for each type of element that can occur in a grid.
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 10, 22:40, 2025)