referencetopo.hh

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

Generated on Sun Nov 15 22:28:43 2009 for dune-grid by  doxygen 1.5.6