Dune Core Modules (2.9.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 // SPDX-FileCopyrightInfo: Copyright (C) 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>
10 
11 #include <dune/localfunctions/common/localfiniteelementtraits.hh>
12 #include <dune/localfunctions/utility/l2interpolation.hh>
13 #include <dune/localfunctions/utility/dglocalcoefficients.hh>
14 
15 namespace 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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:125
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
Dune namespace.
Definition: alignedallocator.hh:13
A factory class for the dg local coefficients.
Definition: dglocalcoefficients.hh:59
Takes the basis and interpolation factory from a given LocalFiniteElement (derived from GenericLocalF...
Definition: localfiniteelement.hh:148
DGLocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:157
A LocalFiniteElement implementation based on three TopologyFactories providing the LocalBasis,...
Definition: localfiniteelement.hh:25
const Traits::LocalInterpolationType & localInterpolation() const
Definition: localfiniteelement.hh:86
const Traits::LocalBasisType & localBasis() const
Definition: localfiniteelement.hh:72
GeometryType type() const
Definition: localfiniteelement.hh:99
GenericLocalFiniteElement(const GenericLocalFiniteElement &other)
Definition: localfiniteelement.hh:55
unsigned int size() const
Number of shape functions in this finite element.
Definition: localfiniteelement.hh:92
const Traits::LocalCoefficientsType & localCoefficients() const
Definition: localfiniteelement.hh:79
GenericLocalFiniteElement(const GeometryType &gt, const Key &key)
Definition: localfiniteelement.hh:44
Takes the basis factory from a given LocalFiniteElement (derived from GenericLocalFiniteElement) and ...
Definition: localfiniteelement.hh:173
L2LocalFiniteElement(const GeometryType &gt, const typename Base::Key &key)
Definition: localfiniteelement.hh:182
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 local l2 interpolations taking a basis factory.
Definition: l2interpolation.hh:199
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.80.0 (Apr 29, 22:29, 2024)