- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set et ts=4 sw=2 sts=2: 00003 00004 #ifndef DUNE_MONOMLOCALFINITEELEMENT_HH 00005 #define DUNE_MONOMLOCALFINITEELEMENT_HH 00006 00007 #include <cassert> 00008 #include <cstddef> 00009 #include <cstdlib> 00010 #include <vector> 00011 00012 #include <dune/common/deprecated.hh> 00013 #include <dune/common/geometrytype.hh> 00014 #include <dune/common/shared_ptr.hh> 00015 #include <dune/common/static_assert.hh> 00016 00017 #include "common/localfiniteelementtraits.hh" 00018 #include <dune/localfunctions/common/localtoglobaladaptors.hh> 00019 #include "monom/monomlocalbasis.hh" 00020 #include "monom/monomlocalcoefficients.hh" 00021 #include "monom/monomlocalinterpolation.hh" 00022 00023 namespace Dune 00024 { 00025 00033 template<class D, class R, int d, int p> 00034 class MonomLocalFiniteElement 00035 { 00036 enum { static_size = MonomImp::Size<d,p>::val }; 00037 00038 public: 00041 typedef LocalFiniteElementTraits< 00042 MonomLocalBasis<D,R,d,p>, 00043 MonomLocalCoefficients<static_size>, 00044 MonomLocalInterpolation<MonomLocalBasis<D,R,d,p>,static_size> 00045 > Traits; 00046 00049 MonomLocalFiniteElement (GeometryType::BasicType basicType) DUNE_DEPRECATED 00050 : basis(), interpolation(basicType, basis), gt(basicType,d) 00051 {} 00052 00054 MonomLocalFiniteElement (const GeometryType >_) 00055 : basis(), interpolation(gt_, basis), gt(gt_) 00056 {} 00057 00060 const typename Traits::LocalBasisType& localBasis () const 00061 { 00062 return basis; 00063 } 00064 00067 const typename Traits::LocalCoefficientsType& localCoefficients () const 00068 { 00069 return coefficients; 00070 } 00071 00074 const typename Traits::LocalInterpolationType& localInterpolation () const 00075 { 00076 return interpolation; 00077 } 00078 00081 GeometryType type () const 00082 { 00083 return gt; 00084 } 00085 00086 private: 00087 MonomLocalBasis<D,R,d,p> basis; 00088 MonomLocalCoefficients<static_size> coefficients; 00089 MonomLocalInterpolation<MonomLocalBasis<D,R,d,p>,static_size> interpolation; 00090 GeometryType gt; 00091 }; 00092 00094 00106 template<class Geometry, class RF, std::size_t p> 00107 class MonomFiniteElementFactory { 00108 typedef typename Geometry::ctype DF; 00109 static const std::size_t dim = Geometry::mydimension; 00110 00111 typedef MonomLocalFiniteElement<DF, RF, dim, p> LocalFE; 00112 00113 std::vector<shared_ptr<const LocalFE> > localFEs; 00114 00115 void init(const GeometryType >) { 00116 std::size_t index = gt.id() >> 1; 00117 if(localFEs.size() <= index) 00118 localFEs.resize(index+1); 00119 localFEs[index].reset(new LocalFE(gt)); 00120 } 00121 00122 public: 00123 typedef ScalarLocalToGlobalFiniteElementAdaptor<LocalFE, Geometry> 00124 FiniteElement; 00125 00127 00131 template<class ForwardIterator> 00132 MonomFiniteElementFactory(const ForwardIterator &begin, 00133 const ForwardIterator &end) 00134 { 00135 for(ForwardIterator it = begin; it != end; ++it) 00136 init(*it); 00137 } 00138 00140 00143 MonomFiniteElementFactory(const GeometryType >) 00144 { init(gt); } 00145 00147 00150 MonomFiniteElementFactory() { 00151 dune_static_assert(dim <= 3, "MonomFiniteElementFactory knows the " 00152 "available geometry types only up to dimension 3"); 00153 00154 GeometryType gt; 00155 switch(dim) { 00156 case 0: 00157 gt.makeVertex(); init(gt); 00158 break; 00159 case 1: 00160 gt.makeLine(); init(gt); 00161 break; 00162 case 2: 00163 gt.makeTriangle(); init(gt); 00164 gt.makeQuadrilateral(); init(gt); 00165 break; 00166 case 3: 00167 gt.makeTetrahedron(); init(gt); 00168 gt.makePyramid(); init(gt); 00169 gt.makePrism(); init(gt); 00170 gt.makeHexahedron(); init(gt); 00171 break; 00172 default: 00173 // this should never happen -- it should be caught by the static 00174 // assert above. 00175 std::abort(); 00176 }; 00177 } 00178 00180 00190 const FiniteElement make(const Geometry& geometry) { 00191 std::size_t index = geometry.type().id() >> 1; 00192 assert(localFEs.size() > index && localFEs[index]); 00193 return FiniteElement(*localFEs[index], geometry); 00194 } 00195 }; 00196 } 00197 00198 #endif // DUNE_MONOMLOCALFINITEELEMENT_HH
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].