Dune Core Modules (2.7.1)

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 
6 #include <dune/geometry/type.hh>
7 
8 #include <dune/localfunctions/common/localfiniteelementtraits.hh>
9 #include <dune/localfunctions/utility/l2interpolation.hh>
10 #include <dune/localfunctions/utility/dglocalcoefficients.hh>
11 
12 namespace 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 
92  GeometryType type () const
93  {
94  return GeometryType(topologyId_,dimDomain);
95  }
96 
100  DUNE_DEPRECATED_MSG("Use type().id() instead!")
101  unsigned int topologyId () const
102  {
103  return topologyId_;
104  }
105  private:
106  struct FiniteElement
107  {
108  FiniteElement() : basis_(0), coeff_(0), interpol_(0) {}
109  template <class Topology>
110  void create( const Key &key )
111  {
112  release();
113  basis_ = BasisF::template create<Topology>(key);
114  coeff_ = CoeffF::template create<Topology>(key);
115  interpol_ = InterpolF::template create<Topology>(key);
116  }
117  void release()
118  {
119  if (basis_)
120  BasisF::release(basis_);
121  if (coeff_)
122  CoeffF::release(coeff_);
123  if (interpol_)
124  InterpolF::release(interpol_);
125  basis_=0;
126  coeff_=0;
127  interpol_=0;
128  }
129  template< class Topology >
130  struct Maker
131  {
132  static void apply ( const Key &key, FiniteElement &finiteElement )
133  {
134  finiteElement.template create<Topology>(key);
135  };
136  };
137  typename Traits::LocalBasisType *basis_;
138  typename Traits::LocalCoefficientsType *coeff_;
139  typename Traits::LocalInterpolationType *interpol_;
140  };
141  unsigned int topologyId_;
142  Key key_;
143  FiniteElement finiteElement_;
144  };
145 
152  template <class FE>
154  : public GenericLocalFiniteElement< typename FE::BasisFactory,
155  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
156  typename FE::InterpolationFactory>
157  {
158  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
160  typename FE::InterpolationFactory> Base;
161  public:
162  typedef typename Base::Traits Traits;
163 
166  DGLocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
167  : Base( gt, key )
168  {}
169  };
177  template <class FE>
179  : public GenericLocalFiniteElement< typename FE::BasisFactory,
180  DGLocalCoefficientsFactory< typename FE::BasisFactory >,
181  LocalL2InterpolationFactory< typename FE::BasisFactory, false > >
182  {
183  typedef GenericLocalFiniteElement< typename FE::BasisFactory,
186  public:
187  typedef typename Base::Traits Traits;
188 
191  L2LocalFiniteElement ( const GeometryType &gt, const typename Base::Key &key )
192  : Base( gt, key )
193  {}
194  };
195 }
196 
197 #endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:279
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:46
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
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:14
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:157
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:166
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis,...
Definition: localfiniteelement.hh:22
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfiniteelement.hh:79
const Traits::LocalBasisType & localBasis() const
Definition: localfiniteelement.hh:65
GeometryType type() const
Definition: localfiniteelement.hh:92
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfiniteelement.hh:50
unsigned int size() const
Number of shape functions in this finite element.
Definition: localfiniteelement.hh:85
unsigned int topologyId() const
Definition: localfiniteelement.hh:101
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfiniteelement.hh:72
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfiniteelement.hh:41
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfiniteelement.hh:182
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:191
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.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)