00001 #ifndef GLOBAL_P2_INDEX
00002 #define GLOBAL_P2_INDEX
00003
00017 #include <dune/common/geometrytype.hh>
00018 #include <dune/grid/common/mcmgmapper.hh>
00019 #include <dune/disc/shapefunctions/shapefunctions.hh>
00020
00021 namespace Dune {
00022
00024 template<int dim>
00025 struct P2Layout
00026 {
00027 bool contains (Dune::GeometryType gt)
00028 {
00029
00030 if (gt.dim()==0 || gt.dim()==1)
00031 return true;
00032
00033
00034 return gt.isCube();
00035
00038 }
00039 };
00040
00049 template <class GridType, int dim>
00050 class GlobalP2Index {};
00051
00053 template <class GridType>
00054 class GlobalP2Index<GridType,3> {
00055 public:
00056
00057 template <class IndexSet, class DT, class RT>
00058 static int map(const typename GridType::template Codim<0>::Entity& entity,
00059 const Dune::MultipleCodimMultipleGeomTypeMapper<GridType, IndexSet, P2Layout>& mapper,
00060 const Dune::ShapeFunction<DT,RT,3,1>* shapeFunction) {
00061
00062
00063 switch (shapeFunction->codim()) {
00064 case 0:
00065 return mapper.template map<0>(entity, shapeFunction->entity());
00066 case 1:
00067 return mapper.template map<1>(entity, shapeFunction->entity());
00068 case 2:
00069 return mapper.template map<2>(entity, shapeFunction->entity());
00070 case 3:
00071 return mapper.template map<3>(entity, shapeFunction->entity());
00072 default:
00073 DUNE_THROW(Dune::NotImplemented, "Found a shape function associated to an entity of codim " << shapeFunction->codim());
00074 }
00075 }
00076
00077 };
00078
00080 template <class GridType>
00081 class GlobalP2Index<GridType,2> {
00082 public:
00083
00084 template <class IndexSet>
00085 static int map(const typename GridType::template Codim<0>::Entity& entity,
00086 const Dune::MultipleCodimMultipleGeomTypeMapper<GridType, IndexSet, P2Layout>& mapper,
00087 const Dune::ShapeFunction<double,double,2,1>* shapeFunction) {
00088
00089
00090 switch (shapeFunction->codim()) {
00091 case 0:
00092 return mapper.template map<0>(entity, shapeFunction->entity());
00093 case 1:
00094 return mapper.template map<1>(entity, shapeFunction->entity());
00095 case 2:
00096 return mapper.template map<2>(entity, shapeFunction->entity());
00097 default:
00098 DUNE_THROW(Dune::NotImplemented, "Found a shape function associated to an entity of codim " << shapeFunction->codim());
00099 }
00100 }
00101
00102 };
00103
00105 template <class GridType>
00106 class GlobalP2Index<GridType,1> {
00107 public:
00108
00109 template <class IndexSet>
00110 static int map(const typename GridType::template Codim<0>::Entity& entity,
00111 const Dune::MultipleCodimMultipleGeomTypeMapper<GridType, IndexSet, P2Layout>& mapper,
00112 const Dune::ShapeFunction<double,double,1,1>* shapeFunction) {
00113
00114
00115 switch (shapeFunction->codim()) {
00116 case 0:
00117 return mapper.template map<0>(entity, shapeFunction->entity());
00118 case 1:
00119 return mapper.template map<1>(entity, shapeFunction->entity());
00120 default:
00121 DUNE_THROW(Dune::NotImplemented, "Found a shape function associated to an entity of codim " << shapeFunction->codim());
00122 }
00123 }
00124
00125 };
00126
00127 }
00128 #endif