2d/bndprojection.hh

Go to the documentation of this file.
00001 #ifndef DUNE_ALU2D_BNDPROJECTION_HH
00002 #define DUNE_ALU2D_BNDPROJECTION_HH
00003 
00004 #include <dune/grid/alugrid/common/bndprojection.hh>
00005 
00006 #include <dune/grid/alugrid/2d/alu2dinclude.hh>
00007 
00008 namespace Dune
00009 {
00010 
00011 #ifdef ALUGRID_SURFACE_2D
00012 
00013   template< class Grid >
00014   class ALU2dGridBoundaryProjection
00015   : public ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType)
00016   {
00017     typedef ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType) Base;
00018 
00019   public:
00020     enum { ncoord = Base::ncoord };
00021 
00022     typedef typename Base::hbndel_t hbndel_t;
00023     typedef typename Base::helement_t helement_t;
00024 
00025     typedef typename Grid::DuneBoundaryProjectionType DuneBoundaryProjectionType;
00026 
00027     typedef typename DuneBoundaryProjectionType::CoordinateType CoordinateType;
00028 
00029     explicit ALU2dGridBoundaryProjection ( const Grid &grid )
00030     : grid_( grid )
00031     {}
00032 
00033     int operator() ( const hbndel_t *hbndel, const double local, double (&global)[ ncoord ] ) const
00034     {
00035       return callProjection( grid_.boundaryProjection( hbndel->segmentIndex() ), global );
00036     }
00037 
00038     int operator() ( const helement_t *helement, const double (&local)[ 2 ], double (&global)[ ncoord ] ) const
00039     {
00040       return callProjection( grid_.globalProjection(), global );
00041     }
00042 
00043   private:
00044     static int callProjection ( const DuneBoundaryProjectionType *prj, double (&global)[ ncoord ] )
00045     {
00046       if( prj ) 
00047       {
00048         CoordinateType x, y;
00049         for( int i = 0; i < ncoord; ++i )
00050           x[ i ] = global[ i ];
00051         y = (*prj)( x );
00052         for( int i = 0; i < ncoord; ++i )
00053           global[ i ] = y[ i ];
00054       }
00055       return 1;
00056     }
00057 
00058     const Grid &grid_;
00059   };
00060 
00061 #else // #ifdef ALUGRID_SURFACE_2D
00062 
00063   template< class Grid >
00064   class ALU2dGridBoundaryProjection
00065   : public ALUGridBoundaryProjection< Grid >
00066   {
00067     typedef ALUGridBoundaryProjection< Grid > Base;
00068 
00069   public:
00070     explicit ALU2dGridBoundaryProjection ( const Grid &grid )
00071     : Base( grid )
00072     {}
00073   };
00074 
00075 #endif // #else // #ifdef ALUGRID_SURFACE_2D
00076 
00077 } // end namespace Dune 
00078 
00079 #endif // #ifndef DUNE_ALU2D_BNDPROJECTION_HH

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].