Dune Core Modules (2.6.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
7
8#include <dune/localfunctions/common/localfiniteelementtraits.hh>
9#include <dune/localfunctions/utility/l2interpolation.hh>
10#include <dune/localfunctions/utility/dglocalcoefficients.hh>
11
12namespace Dune
13{
20 template< class BasisF, class CoeffF, class InterpolF>
22 {
24 typedef LocalFiniteElementTraits< typename BasisF::Object,
25 typename CoeffF::Object,
26 typename InterpolF::Object > Traits;
27
28 typedef typename BasisF::Key Key;
29 static const unsigned int dimDomain = BasisF::dimension;
30
31 typedef BasisF BasisFactory;
32 typedef CoeffF CoefficientFactory;
33 typedef InterpolF InterpolationFactory;
34
35 static_assert(std::is_same<Key, typename CoeffF::Key>::value,
36 "incompatible keys between BasisCreator and CoefficientsCreator");
37 static_assert(std::is_same<Key, typename InterpolF::Key>::value,
38 "incompatible keys between BasisCreator and InterpolationCreator" );
39
41 GenericLocalFiniteElement ( const GeometryType &gt, const Key &key )
42 : topologyId_( gt.id() ),
43 key_( key ),
44 finiteElement_()
45 {
47 }
48
51 : topologyId_( other.topologyId_ ),
52 key_( other.key_ ),
53 finiteElement_()
54 {
56 }
57
59 {
60 finiteElement_.release();
61 }
62
65 const typename Traits::LocalBasisType& localBasis () const
66 {
67 return *(finiteElement_.basis_);
68 }
69
73 {
74 return *(finiteElement_.coeff_);
75 }
76
80 {
81 return *(finiteElement_.interpol_);
82 }
83
85 unsigned int size () const
86 {
87 return finiteElement_.basis_->size();
88 }
89
93 {
94 return GeometryType(topologyId_,dimDomain);
95 }
96
99 unsigned int topologyId () const
100 {
101 return topologyId_;
102 }
103 private:
104 struct FiniteElement
105 {
106 FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
107 template <class Topology>
108 void create( const Key &key )
109 {
110 release();
111 basis_ = BasisF::template create<Topology>(key);
112 coeff_ = CoeffF::template create<Topology>(key);
113 interpol_ = InterpolF::template create<Topology>(key);
114 }
115 void release()
116 {
117 if (basis_)
118 BasisF::release(basis_);
119 if (coeff_)
120 CoeffF::release(coeff_);
121 if (interpol_)
122 InterpolF::release(interpol_);
123 basis_=0;
124 coeff_=0;
125 interpol_=0;
126 }
127 template< class Topology >
128 struct Maker
129 {
130 static void apply ( const Key &key, FiniteElement &finiteElement )
131 {
132 finiteElement.template create<Topology>(key);
133 };
134 };
135 typename Traits::LocalBasisType *basis_;
136 typename Traits::LocalCoefficientsType *coeff_;
137 typename Traits::LocalInterpolationType *interpol_;
138 };
139 unsigned int topologyId_;
140 Key key_;
141 FiniteElement finiteElement_;
142 };
143
150 template <class FE>
152 : public GenericLocalFiniteElement< typename FE::BasisFactory,
153 DGLocalCoefficientsFactory< typename FE::BasisFactory >,
154 typename FE::InterpolationFactory>
155 {
156 typedef GenericLocalFiniteElement< typename FE::BasisFactory,
158 typename FE::InterpolationFactory> Base;
159 public:
160 typedef typename Base::Traits Traits;
161
164 DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
165 : Base( gt, key )
166 {}
167 };
175 template <class FE>
177 : public GenericLocalFiniteElement< typename FE::BasisFactory,
178 DGLocalCoefficientsFactory< typename FE::BasisFactory >,
179 LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
180 {
181 typedef GenericLocalFiniteElement< typename FE::BasisFactory,
184 public:
185 typedef typename Base::Traits Traits;
186
189 L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
190 : Base( gt, key )
191 {}
192 };
193}
194
195#endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:147
Dune namespace.
Definition: alignedallocator.hh:10
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:71
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition: localfiniteelement.hh:155
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:164
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis,...
Definition: localfiniteelement.hh:22
GeometryType type() const
Definition: localfiniteelement.hh:92
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfiniteelement.hh:50
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfiniteelement.hh:79
unsigned int size() const
Number of shape functions in this finite element.
Definition: localfiniteelement.hh:85
unsigned int topologyId() const
Definition: localfiniteelement.hh:99
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfiniteelement.hh:41
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfiniteelement.hh:72
const Traits::LocalBasisType & localBasis() const
Definition: localfiniteelement.hh:65
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfiniteelement.hh:180
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:189
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:188
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)