dune-grid
2.2.0
|
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 template< class Grid > 00012 class ALU2dGridBoundaryProjection 00013 : public ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType) 00014 { 00015 typedef ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType) Base; 00016 00017 public: 00018 enum { ncoord = Base::ncoord }; 00019 00020 typedef typename Base::hbndel_t hbndel_t; 00021 typedef typename Base::helement_t helement_t; 00022 00023 typedef typename Grid::DuneBoundaryProjectionType DuneBoundaryProjectionType; 00024 00025 typedef typename DuneBoundaryProjectionType::CoordinateType CoordinateType; 00026 00027 explicit ALU2dGridBoundaryProjection ( const Grid &grid ) 00028 : grid_( grid ) 00029 {} 00030 00031 int operator() ( const hbndel_t *hbndel, const double local, double (&global)[ ncoord ] ) const 00032 { 00033 return callProjection( grid_.boundaryProjection( hbndel->segmentIndex() ), global ); 00034 } 00035 00036 int operator() ( const helement_t *helement, const double (&local)[ 2 ], double (&global)[ ncoord ] ) const 00037 { 00038 return callProjection( grid_.globalProjection(), global ); 00039 } 00040 00041 private: 00042 static int callProjection ( const DuneBoundaryProjectionType *prj, double (&global)[ ncoord ] ) 00043 { 00044 if( prj ) 00045 { 00046 CoordinateType x, y; 00047 for( int i = 0; i < ncoord; ++i ) 00048 x[ i ] = global[ i ]; 00049 y = (*prj)( x ); 00050 for( int i = 0; i < ncoord; ++i ) 00051 global[ i ] = y[ i ]; 00052 } 00053 return 1; 00054 } 00055 00056 const Grid &grid_; 00057 }; 00058 00059 } // end namespace Dune 00060 00061 #endif // #ifndef DUNE_ALU2D_BNDPROJECTION_HH