referencetopo.hh

00001 #ifndef DUNE_ALBERTAGRID_REFERENCETOPO_HH
00002 #define DUNE_ALBERTAGRID_REFERENCETOPO_HH
00003 
00004 #ifdef __ALBERTApp__
00005 namespace Albert {
00006 #endif
00007 
00008 namespace AlbertHelp {
00009 
00010 // NOTE: Vertex numbering in ALBERTA is the same as in Dune 
00011 // therefore no map is provided for that     
00012  
00013 // faces in 2d (i.e. triangle edges )
00014 // which vertices belong to which face
00015 static const int localTriangleFaceNumber [3][2] = { {1,2} , {2,0} , {0,1} };
00016 
00017 // edges in 3d 
00018 // local numbers of vertices belonging to one edge 
00019 // according to Alberta reference element which is for edges different to
00020 // the Dune reference simplex in 3d ,see Alberta doc page 105 
00021 static const int localEdgeNumber [6][2] =
00022 {
00023   {0,1} , {0,2} , {0,3} , // first three vertices like in 2d for faces(edges)
00024   {1,2} , {1,3} , {2,3}   // then all with the last vertex 
00025 };
00026 
00027 // see Albert Doc page 12 for reference element  
00028 // if we look from outside, then face numbering must be clockwise 
00029 // see below that the vertex numbers for each face are the same 
00030 // but in Dune reference element not clockwise ,but this we need for
00031 // calculation the outer normal, see calcOuterNormal in albertagrid.cc
00032 static const int tetraFace_0[3] = {1,3,2};
00033 static const int tetraFace_1[3] = {0,2,3};
00034 static const int tetraFace_2[3] = {0,3,1};
00035 static const int tetraFace_3[3] = {0,1,2};
00036 
00037 // local vertex numbering of faces in the Dune refrence simplex in 3d 
00038 static const int localDuneTetraFaceNumber[4][3] = 
00039 { {1,2,3}, // face 0
00040   {0,3,2}, // face 1 
00041   {0,1,3}, // face 2 
00042   {0,2,1}  // face 3 
00043 };
00044 
00045 static const int * localAlbertaFaceNumber[4] = {tetraFace_0, tetraFace_1,
00046     tetraFace_2 , tetraFace_3 };
00047 
00048 static const int dune2AlbertaEdgeMap[6] = {0, 3, 1, 2, 4, 5};
00049 
00050 template <int dim>
00051 class AlbertaGridReferenceTopology
00052 {
00053   // the real edge map 
00054   int em_[6];
00055   const int (&edgemap_)[6];    
00056 
00057 public:
00059   AlbertaGridReferenceTopology() 
00060     : edgemap_ (em_) 
00061   {
00062     // the edgemap , see ALBERTA docu 
00063     for(int i=0; i<6; i++) em_[i] = dune2AlbertaEdgeMap[i];
00064   }
00065 
00068   int dune2albertaVertex( int i ) const { return i; }
00069 
00071   int dune2albertaEdge( int i ) const
00072   {
00073     assert( i >= 0 );
00074     assert( i < 6 );
00075     return edgemap_[i];
00076   }
00077 };
00078 
00079 //****************************************************************
00080 //
00081 //  specialization of mapVertices 
00082 //  see referencetopo.hh 
00083 //
00084 //****************************************************************
00085 template <int md, int cd>
00086 struct MapVertices
00087 {
00088   static int mapVertices (int i, int face, int edge, int vertex)
00089   {
00090     return i;
00091   }
00092 };
00093 
00094 // faces in 2d 
00095 template <>
00096 struct MapVertices<1,2>
00097 {
00098   static int mapVertices (int i, int face, int edge, int vertex)
00099   {
00100     assert( i >= 0);
00101     assert( i < 2 );
00102     assert( face >= 0 );
00103     assert( face <  3 );
00104     return ALBERTA AlbertHelp::localTriangleFaceNumber[face][i];
00105   }
00106 };
00107 
00108 // faces in 3d 
00109 template <>
00110 struct MapVertices<2,3>
00111 {
00112   static int mapVertices (int i, int face, int edge, int vertex)
00113   {
00114     // we have 3 vertices each of the 4 faces 
00115     assert( i >= 0);
00116     assert( i < 3 );
00117     assert( face >= 0 );
00118     assert( face <  4 );
00119     return ALBERTA AlbertHelp::localDuneTetraFaceNumber[face][i];
00120   }
00121 };
00122 
00123 // edges in 3d 
00124 template <>
00125 struct MapVertices<1,3>
00126 {
00127   static int mapVertices (int i, int face, int edge, int vertex)
00128   {
00129     assert( i >= 0 );
00130     assert( i < 2  );
00131     assert( edge >= 0 );
00132     assert( edge < 6 );
00133     return ALBERTA AlbertHelp :: localEdgeNumber[
00134       ALBERTA AlbertHelp :: dune2AlbertaEdgeMap [edge] ][i];
00135   }
00136 };
00137 
00138 // vertices in 2d and 3d 
00139 template <int cd>
00140 struct MapVertices<0,cd>
00141 {
00142   static int mapVertices (int i, int face, int edge, int vertex)
00143   {
00144     // just return number of vertex 
00145     return vertex;
00146   }
00147 };
00148 
00149 
00150 } // end namespace AlbertHelp 
00151 
00152 #ifdef __ALBERTApp__
00153 } // end namespace Albert  
00154 #endif
00155 
00156 #endif

Generated on 9 Apr 2008 with Doxygen (ver 1.5.2) [logfile].