Dune Core Modules (2.8.0)

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#ifndef DUNE_GENERIC_LOCALFINITEELEMENT_HH
4#define DUNE_GENERIC_LOCALFINITEELEMENT_HH
5
8
9#include <dune/localfunctions/common/localfiniteelementtraits.hh>
10#include <dune/localfunctions/utility/l2interpolation.hh>
11#include <dune/localfunctions/utility/dglocalcoefficients.hh>
12
13namespace Dune
14{
21 template< class BasisF, class CoeffF, class InterpolF>
23 {
25 typedef LocalFiniteElementTraits< typename BasisF::Object,
26 typename CoeffF::Object,
27 typename InterpolF::Object > Traits;
28
29 typedef typename BasisF::Key Key;
30 static const unsigned int dimDomain = BasisF::dimension;
31
32 typedef BasisF BasisFactory;
33 typedef CoeffF CoefficientFactory;
34 typedef InterpolF InterpolationFactory;
35
36 static_assert(std::is_same<Key, typename CoeffF::Key>::value,
37 "incompatible keys between BasisCreator and CoefficientsCreator");
38 static_assert(std::is_same<Key, typename InterpolF::Key>::value,
39 "incompatible keys between BasisCreator and InterpolationCreator" );
40
42 GenericLocalFiniteElement ( const GeometryType &gt, const Key &key )
43 : geometry_( gt ),
44 key_( key ),
45 finiteElement_()
46 {
47 Impl::toGeometryTypeIdConstant<dimDomain>(type(), [&](auto geometryTypeId) {
48 finiteElement_.template create<decltype(geometryTypeId)::value>(key_);
49 });
50 }
51
54 : geometry_( other.type() ),
55 key_( other.key_ ),
56 finiteElement_()
57 {
58 Impl::toGeometryTypeIdConstant<dimDomain>(type(), [&](auto geometryTypeId) {
59 finiteElement_.template create<decltype(geometryTypeId)::value>(key_);
60 });
61 }
62
64 {
65 finiteElement_.release();
66 }
67
70 const typename Traits::LocalBasisType& localBasis () const
71 {
72 return *(finiteElement_.basis_);
73 }
74
78 {
79 return *(finiteElement_.coeff_);
80 }
81
85 {
86 return *(finiteElement_.interpol_);
87 }
88
90 unsigned int size () const
91 {
92 return finiteElement_.basis_->size();
93 }
94
98 {
99 return geometry_;
100 }
101 private:
102 struct FiniteElement
103 {
104 FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
105
106 template < GeometryType::Id geometryId >
107 void create( const Key &key )
108 {
109 release();
110 basis_ = BasisF::template create<geometryId>(key);
111 coeff_ = CoeffF::template create<geometryId>(key);
112 interpol_ = InterpolF::template create<geometryId>(key);
113 }
114 void release()
115 {
116 if (basis_)
117 BasisF::release(basis_);
118 if (coeff_)
119 CoeffF::release(coeff_);
120 if (interpol_)
121 InterpolF::release(interpol_);
122 basis_=0;
123 coeff_=0;
124 interpol_=0;
125 }
126 typename Traits::LocalBasisType *basis_;
127 typename Traits::LocalCoefficientsType *coeff_;
128 typename Traits::LocalInterpolationType *interpol_;
129 };
130 GeometryType geometry_;
131 Key key_;
132 FiniteElement finiteElement_;
133 };
134
141 template <class FE>
143 : public GenericLocalFiniteElement< typename FE::BasisFactory,
144 DGLocalCoefficientsFactory< typename FE::BasisFactory >,
145 typename FE::InterpolationFactory>
146 {
147 typedef GenericLocalFiniteElement< typename FE::BasisFactory,
149 typename FE::InterpolationFactory> Base;
150 public:
151 typedef typename Base::Traits Traits;
152
155 DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
156 : Base( gt, key )
157 {}
158 };
166 template <class FE>
168 : public GenericLocalFiniteElement< typename FE::BasisFactory,
169 DGLocalCoefficientsFactory< typename FE::BasisFactory >,
170 LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
171 {
172 typedef GenericLocalFiniteElement< typename FE::BasisFactory,
175 public:
176 typedef typename Base::Traits Traits;
177
180 L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
181 : Base( gt, key )
182 {}
183 };
184}
185
186#endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:130
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:156
Dune namespace.
Definition: alignedallocator.hh:11
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:57
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition: localfiniteelement.hh:146
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:155
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis,...
Definition: localfiniteelement.hh:23
GeometryType type() const
Definition: localfiniteelement.hh:97
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfiniteelement.hh:53
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfiniteelement.hh:84
unsigned int size() const
Number of shape functions in this finite element.
Definition: localfiniteelement.hh:90
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfiniteelement.hh:42
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfiniteelement.hh:77
const Traits::LocalBasisType & localBasis() const
Definition: localfiniteelement.hh:70
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfiniteelement.hh:171
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:180
traits helper struct
Definition: localfiniteelementtraits.hh:11
LB LocalBasisType
Definition: localfiniteelementtraits.hh:14
LC LocalCoefficientsType
Definition: localfiniteelementtraits.hh:18
LI LocalInterpolationType
Definition: localfiniteelementtraits.hh:22
A factory class for the local l2 interpolations taking a basis factory.
Definition: l2interpolation.hh:197
A unique label for each type of element that can occur in a grid.
Helper classes to provide indices for geometrytypes for use in a vector.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)