00001
00002
00003 #ifndef DUNE_SCSGMAPPER_HH
00004 #define DUNE_SCSGMAPPER_HH
00005
00006 #include<iostream>
00007 #include "mapper.hh"
00008
00015 namespace Dune
00016 {
00040 template <typename G, typename IS, int c>
00041 class SingleCodimSingleGeomTypeMapper : Mapper<G,SingleCodimSingleGeomTypeMapper<G,IS,c> > {
00042 public:
00043
00050 SingleCodimSingleGeomTypeMapper (const G& grid, const IS& indexset);
00051
00057 template<class EntityType>
00058 int map (const EntityType& e) const;
00059
00066 template<int cc>
00067 int map (const typename G::Traits::template Codim<0>::Entity& e, int i) const;
00068
00077 int size () const;
00078
00085 template<class EntityType>
00086 bool contains (const EntityType& e, int& result) const;
00087
00095 template<int cc>
00096 bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int& result) const;
00097
00100 void update ()
00101 {
00102 }
00103
00104 private:
00105 const G& g;
00106 const IS& is;
00107 };
00108
00111 template <typename G, typename IS, int c>
00112 SingleCodimSingleGeomTypeMapper<G,IS,c>::SingleCodimSingleGeomTypeMapper (const G& grid, const IS& indexset)
00113 : g(grid), is(indexset)
00114 {
00115
00116 if (is.geomTypes(c).size() != 1)
00117 DUNE_THROW(GridError, "mapper treats only a single codim and a single geometry type");
00118 }
00119
00120 template <typename G, typename IS, int c>
00121 template<class EntityType>
00122 int SingleCodimSingleGeomTypeMapper<G,IS,c>::map (const EntityType& e) const
00123 {
00124 enum { cc = EntityType::codimension };
00125 IsTrue< cc == c >::yes();
00126 return is.template index<cc>(e);
00127 }
00128
00129 template <typename G, typename IS, int c>
00130 template<int cc>
00131 int SingleCodimSingleGeomTypeMapper<G,IS,c>::map (const typename G::Traits::template Codim<0>::Entity& e, int i) const
00132 {
00133 IsTrue< cc == c >::yes();
00134 return is.template subIndex<cc>(e,i);
00135 }
00136
00137 template <typename G, typename IS, int c>
00138 int SingleCodimSingleGeomTypeMapper<G,IS,c>::size () const
00139 {
00140 return is.size(c,is.geomTypes(c)[0]);
00141 }
00142
00143 template <typename G, typename IS, int c>
00144 template<class EntityType>
00145 bool SingleCodimSingleGeomTypeMapper<G,IS,c>::contains (const EntityType& e, int& result) const
00146 {
00147 result = map(e);
00148 return true;
00149 }
00150
00151 template <typename G, typename IS, int c>
00152 template<int cc>
00153 bool SingleCodimSingleGeomTypeMapper<G,IS,c>::contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int& result) const
00154 {
00155 result = this->template map<cc>(e,i);
00156 return true;
00157 }
00158
00177 template <typename G, int c>
00178 class LeafSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<G,typename G::Traits::LeafIndexSet,c> {
00179 public:
00180
00181
00182
00183 LeafSingleCodimSingleGeomTypeMapper (const G& grid)
00184 : SingleCodimSingleGeomTypeMapper<G,typename G::Traits::LeafIndexSet,c>(grid,grid.leafIndexSet())
00185 {}
00186 };
00187
00201 template <typename G, int c>
00202 class LevelSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<G,typename G::Traits::LevelIndexSet,c> {
00203 public:
00204
00205
00206
00207
00208 LevelSingleCodimSingleGeomTypeMapper (const G& grid, int level)
00209 : SingleCodimSingleGeomTypeMapper<G,typename G::Traits::LevelIndexSet,c>(grid,grid.levelIndexSet(level))
00210 {}
00211 };
00212
00214 }
00215 #endif