dune-localfunctions 2.10
Loading...
Searching...
No Matches
localfunctions/utility/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_GENERIC_LOCALFINITEELEMENT_HH
6#define DUNE_GENERIC_LOCALFINITEELEMENT_HH
7
8#include <dune/geometry/type.hh>
9#include <dune/geometry/typeindex.hh>
10
14
15namespace Dune
16{
23 template< class BasisF, class CoeffF, class InterpolF>
25 {
27 typedef LocalFiniteElementTraits< typename BasisF::Object,
28 typename CoeffF::Object,
29 typename InterpolF::Object > Traits;
30
31 typedef typename BasisF::Key Key;
32 static const unsigned int dimDomain = BasisF::dimension;
33
34 typedef BasisF BasisFactory;
35 typedef CoeffF CoefficientFactory;
36 typedef InterpolF InterpolationFactory;
37
38 static_assert(std::is_same<Key, typename CoeffF::Key>::value,
39 "incompatible keys between BasisCreator and CoefficientsCreator");
40 static_assert(std::is_same<Key, typename InterpolF::Key>::value,
41 "incompatible keys between BasisCreator and InterpolationCreator" );
42
44 GenericLocalFiniteElement ( const GeometryType &gt, const Key &key )
45 : geometry_( gt ),
46 key_( key ),
47 finiteElement_()
48 {
49 Impl::toGeometryTypeIdConstant<dimDomain>(type(), [&](auto geometryTypeId) {
50 finiteElement_.template create<decltype(geometryTypeId)::value>(key_);
51 });
52 }
53
56 : geometry_( other.type() ),
57 key_( other.key_ ),
58 finiteElement_()
59 {
60 Impl::toGeometryTypeIdConstant<dimDomain>(type(), [&](auto geometryTypeId) {
61 finiteElement_.template create<decltype(geometryTypeId)::value>(key_);
62 });
63 }
64
66 {
67 finiteElement_.release();
68 }
69
72 const typename Traits::LocalBasisType& localBasis () const
73 {
74 return *(finiteElement_.basis_);
75 }
76
80 {
81 return *(finiteElement_.coeff_);
82 }
83
87 {
88 return *(finiteElement_.interpol_);
89 }
90
92 unsigned int size () const
93 {
94 return finiteElement_.basis_->size();
95 }
96
99 GeometryType type () const
100 {
101 return geometry_;
102 }
103 private:
104 struct FiniteElement
105 {
106 FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
107
108 template < GeometryType::Id geometryId >
109 void create( const Key &key )
110 {
111 release();
112 basis_ = BasisF::template create<geometryId>(key);
113 coeff_ = CoeffF::template create<geometryId>(key);
114 interpol_ = InterpolF::template create<geometryId>(key);
115 }
116 void release()
117 {
118 if (basis_)
119 BasisF::release(basis_);
120 if (coeff_)
121 CoeffF::release(coeff_);
122 if (interpol_)
123 InterpolF::release(interpol_);
124 basis_=0;
125 coeff_=0;
126 interpol_=0;
127 }
128 typename Traits::LocalBasisType *basis_;
129 typename Traits::LocalCoefficientsType *coeff_;
130 typename Traits::LocalInterpolationType *interpol_;
131 };
132 GeometryType geometry_;
133 Key key_;
134 FiniteElement finiteElement_;
135 };
136
143 template <class FE>
145 : public GenericLocalFiniteElement< typename FE::BasisFactory,
146 DGLocalCoefficientsFactory< typename FE::BasisFactory >,
147 typename FE::InterpolationFactory>
148 {
149 typedef GenericLocalFiniteElement< typename FE::BasisFactory,
151 typename FE::InterpolationFactory> Base;
152 public:
153 typedef typename Base::Traits Traits;
154
157 DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
158 : Base( gt, key )
159 {}
160 };
168 template <class FE>
170 : public GenericLocalFiniteElement< typename FE::BasisFactory,
171 DGLocalCoefficientsFactory< typename FE::BasisFactory >,
172 LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
173 {
174 typedef GenericLocalFiniteElement< typename FE::BasisFactory,
177 public:
178 typedef typename Base::Traits Traits;
179
182 L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
183 : Base( gt, key )
184 {}
185 };
186}
187
188#endif
Definition bdfmcube.hh:18
traits helper struct
Definition localfiniteelementtraits.hh:13
LB LocalBasisType
Definition localfiniteelementtraits.hh:16
LC LocalCoefficientsType
Definition localfiniteelementtraits.hh:20
LI LocalInterpolationType
Definition localfiniteelementtraits.hh:24
A factory class for the dg local coefficients.
Definition dglocalcoefficients.hh:59
A factory class for the local l2 interpolations taking a basis factory.
Definition l2interpolation.hh:163
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis,...
Definition localfunctions/utility/localfiniteelement.hh:25
GeometryType type() const
Definition localfunctions/utility/localfiniteelement.hh:99
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition localfunctions/utility/localfiniteelement.hh:55
const Traits::LocalInterpolationType & localInterpolation() const
Definition localfunctions/utility/localfiniteelement.hh:86
unsigned int size() const
Number of shape functions in this finite element.
Definition localfunctions/utility/localfiniteelement.hh:92
CoeffF CoefficientFactory
Definition localfunctions/utility/localfiniteelement.hh:35
BasisF BasisFactory
Definition localfunctions/utility/localfiniteelement.hh:34
BasisF::Key Key
Definition localfunctions/utility/localfiniteelement.hh:31
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition localfunctions/utility/localfiniteelement.hh:44
const Traits::LocalCoefficientsType & localCoefficients() const
Definition localfunctions/utility/localfiniteelement.hh:79
InterpolF InterpolationFactory
Definition localfunctions/utility/localfiniteelement.hh:36
static const unsigned int dimDomain
Definition localfunctions/utility/localfiniteelement.hh:32
LocalFiniteElementTraits< typename BasisF::Object, typename CoeffF::Object, typename InterpolF::Object > Traits
Definition localfunctions/utility/localfiniteelement.hh:29
GenericLocalFiniteElement< BasisF, CoeffF, InterpolF > This
Definition localfunctions/utility/localfiniteelement.hh:26
const Traits::LocalBasisType & localBasis() const
Definition localfunctions/utility/localfiniteelement.hh:72
~GenericLocalFiniteElement()
Definition localfunctions/utility/localfiniteelement.hh:65
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition localfunctions/utility/localfiniteelement.hh:148
Base::Traits Traits
Definition localfunctions/utility/localfiniteelement.hh:153
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition localfunctions/utility/localfiniteelement.hh:157
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, typename FE::InterpolationFactory > Base
Definition localfunctions/utility/localfiniteelement.hh:151
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition localfunctions/utility/localfiniteelement.hh:173
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition localfunctions/utility/localfiniteelement.hh:182
GenericLocalFiniteElement< typename FE::BasisFactory, DGLocalCoefficientsFactory< typename FE::BasisFactory >, LocalL2InterpolationFactory< typename FE::BasisFactory, false > > Base
Definition localfunctions/utility/localfiniteelement.hh:176
Base::Traits Traits
Definition localfunctions/utility/localfiniteelement.hh:178