dune-grid  2.2.1
2d/bndprojection.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU2D_BNDPROJECTION_HH
2 #define DUNE_ALU2D_BNDPROJECTION_HH
3 
5 
7 
8 namespace Dune
9 {
10 
11  template< class Grid >
13  : public ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType)
14  {
15  typedef ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType) Base;
16 
17  public:
18  enum { ncoord = Base::ncoord };
19 
20  typedef typename Base::hbndel_t hbndel_t;
21  typedef typename Base::helement_t helement_t;
22 
23  typedef typename Grid::DuneBoundaryProjectionType DuneBoundaryProjectionType;
24 
25  typedef typename DuneBoundaryProjectionType::CoordinateType CoordinateType;
26 
27  explicit ALU2dGridBoundaryProjection ( const Grid &grid )
28  : grid_( grid )
29  {}
30 
31  int operator() ( const hbndel_t *hbndel, const double local, double (&global)[ ncoord ] ) const
32  {
33  return callProjection( grid_.boundaryProjection( hbndel->segmentIndex() ), global );
34  }
35 
36  int operator() ( const helement_t *helement, const double (&local)[ 2 ], double (&global)[ ncoord ] ) const
37  {
38  return callProjection( grid_.globalProjection(), global );
39  }
40 
41  private:
42  static int callProjection ( const DuneBoundaryProjectionType *prj, double (&global)[ ncoord ] )
43  {
44  if( prj )
45  {
46  CoordinateType x, y;
47  for( int i = 0; i < ncoord; ++i )
48  x[ i ] = global[ i ];
49  y = (*prj)( x );
50  for( int i = 0; i < ncoord; ++i )
51  global[ i ] = y[ i ];
52  }
53  return 1;
54  }
55 
56  const Grid &grid_;
57  };
58 
59 } // end namespace Dune
60 
61 #endif // #ifndef DUNE_ALU2D_BNDPROJECTION_HH