dune-localfunctions
2.2.0
|
00001 #ifndef DUNE_GENERIC_LOCALFINITEELEMENT_HH 00002 #define DUNE_GENERIC_LOCALFINITEELEMENT_HH 00003 00004 #include <dune/geometry/type.hh> 00005 #include <dune/geometry/genericgeometry/conversion.hh> 00006 00007 #include <dune/localfunctions/common/localfiniteelementtraits.hh> 00008 #include <dune/localfunctions/utility/l2interpolation.hh> 00009 #include <dune/localfunctions/utility/dglocalcoefficients.hh> 00010 00011 namespace Dune 00012 { 00019 template< class BasisF, class CoeffF, class InterpolF> 00020 struct GenericLocalFiniteElement 00021 { 00022 typedef GenericLocalFiniteElement<BasisF, CoeffF, InterpolF> This; 00023 typedef LocalFiniteElementTraits< typename BasisF::Object, 00024 typename CoeffF::Object, 00025 typename InterpolF::Object > Traits; 00026 00027 typedef typename BasisF::Key Key; 00028 static const unsigned int dimDomain = BasisF::dimension; 00029 00030 typedef BasisF BasisFactory; 00031 typedef CoeffF CoefficientFactory; 00032 typedef InterpolF InterpolationFactory; 00033 00034 dune_static_assert( (Conversion<Key,typename CoeffF::Key>::sameType), 00035 "incompatible keys between BasisCreator and CoefficientsCreator" ); 00036 dune_static_assert( (Conversion<Key,typename InterpolF::Key>::sameType), 00037 "incompatible keys between BasisCreator and InterpolationCreator" ); 00038 00040 GenericLocalFiniteElement ( unsigned int topologyId, const Key &key ) DUNE_DEPRECATED 00041 : topologyId_( topologyId ), 00042 key_( key ), 00043 finiteElement_() 00044 { 00045 GenericGeometry::IfTopology< FiniteElement::template Maker, dimDomain >::apply( topologyId_, key_, finiteElement_ ); 00046 } 00047 00049 GenericLocalFiniteElement ( const GeometryType >, const Key &key ) 00050 : topologyId_( gt.id() ), 00051 key_( key ), 00052 finiteElement_() 00053 { 00054 GenericGeometry::IfTopology< FiniteElement::template Maker, dimDomain >::apply( topologyId_, key_, finiteElement_ ); 00055 } 00056 00058 GenericLocalFiniteElement ( const GenericLocalFiniteElement &other ) 00059 : topologyId_( other.topologyId_ ), 00060 key_( other.key_ ), 00061 finiteElement_() 00062 { 00063 GenericGeometry::IfTopology< FiniteElement::template Maker, dimDomain >::apply( topologyId_, key_, finiteElement_ ); 00064 } 00065 00066 ~GenericLocalFiniteElement() 00067 { 00068 finiteElement_.release(); 00069 } 00070 00073 const typename Traits::LocalBasisType& localBasis () const 00074 { 00075 return *(finiteElement_.basis_); 00076 } 00077 00080 const typename Traits::LocalCoefficientsType& localCoefficients () const 00081 { 00082 return *(finiteElement_.coeff_); 00083 } 00084 00087 const typename Traits::LocalInterpolationType& localInterpolation () const 00088 { 00089 return *(finiteElement_.interpol_); 00090 } 00091 00094 GeometryType type () const 00095 { 00096 return GeometryType(topologyId_,dimDomain); 00097 /* 00098 if ( GenericGeometry::hasGeometryType( topologyId_, dimDomain ) ) 00099 return GenericGeometry::geometryType( topologyId_, dimDomain ); 00100 return GeometryType(); 00101 */ 00102 } 00103 00106 unsigned int topologyId () const 00107 { 00108 return topologyId_; 00109 } 00110 private: 00111 struct FiniteElement 00112 { 00113 FiniteElement() : basis_(0), coeff_(0), interpol_(0) {} 00114 template <class Topology> 00115 void create( const Key &key ) 00116 { 00117 release(); 00118 basis_ = BasisF::template create<Topology>(key); 00119 coeff_ = CoeffF::template create<Topology>(key); 00120 interpol_ = InterpolF::template create<Topology>(key); 00121 } 00122 void release() 00123 { 00124 if (basis_) 00125 BasisF::release(basis_); 00126 if (coeff_) 00127 CoeffF::release(coeff_); 00128 if (interpol_) 00129 InterpolF::release(interpol_); 00130 basis_=0; 00131 coeff_=0; 00132 interpol_=0; 00133 } 00134 template< class Topology > 00135 struct Maker 00136 { 00137 static void apply ( const Key &key, FiniteElement &finiteElement ) 00138 { 00139 finiteElement.template create<Topology>(key); 00140 }; 00141 }; 00142 typename Traits::LocalBasisType *basis_; 00143 typename Traits::LocalCoefficientsType *coeff_; 00144 typename Traits::LocalInterpolationType *interpol_; 00145 }; 00146 unsigned int topologyId_; 00147 Key key_; 00148 FiniteElement finiteElement_; 00149 }; 00150 00157 template <class FE> 00158 struct DGLocalFiniteElement 00159 : public GenericLocalFiniteElement< typename FE::BasisFactory, 00160 DGLocalCoefficientsFactory< typename FE::BasisFactory >, 00161 typename FE::InterpolationFactory> 00162 { 00163 typedef GenericLocalFiniteElement< typename FE::BasisFactory, 00164 DGLocalCoefficientsFactory< typename FE::BasisFactory >, 00165 typename FE::InterpolationFactory> Base; 00166 public: 00167 typedef typename Base::Traits Traits; 00168 00171 DGLocalFiniteElement ( unsigned int topologyId, const typename Base::Key &key ) DUNE_DEPRECATED 00172 : Base( topologyId, key ) 00173 {} 00174 00177 DGLocalFiniteElement ( const GeometryType >, const typename Base::Key &key ) 00178 : Base( gt, key ) 00179 {} 00180 }; 00188 template <class FE> 00189 struct L2LocalFiniteElement 00190 : public GenericLocalFiniteElement< typename FE::BasisFactory, 00191 DGLocalCoefficientsFactory< typename FE::BasisFactory >, 00192 LocalL2InterpolationFactory< typename FE::BasisFactory, false > > 00193 { 00194 typedef GenericLocalFiniteElement< typename FE::BasisFactory, 00195 DGLocalCoefficientsFactory< typename FE::BasisFactory >, 00196 LocalL2InterpolationFactory< typename FE::BasisFactory, false > > Base; 00197 public: 00198 typedef typename Base::Traits Traits; 00199 00202 L2LocalFiniteElement ( unsigned int topologyId, const typename Base::Key &key ) DUNE_DEPRECATED 00203 : Base( topologyId, key ) 00204 {} 00205 00208 L2LocalFiniteElement ( const GeometryType >, const typename Base::Key &key ) 00209 : Base( gt, key ) 00210 {} 00211 }; 00212 } 00213 00214 #endif