dune-grid  2.3.0
2d/bndprojection.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_ALU2D_BNDPROJECTION_HH
4 #define DUNE_ALU2D_BNDPROJECTION_HH
5 
7 
9 
10 namespace Dune
11 {
12 
13  template< class Grid >
15  : public ALU2DSPACE VtxProjection ALU2DDIMWORLD(Grid::dimensionworld,Grid::elementType)
16  {
17  typedef ALU2DSPACE VtxProjection ALU2DDIMWORLD (Grid::dimensionworld,Grid::elementType) Base;
18 
19  public:
20  enum { ncoord = Base::ncoord };
21 
22  typedef typename Base::hbndel_t hbndel_t;
23  typedef typename Base::helement_t helement_t;
24 
25  typedef typename Grid::DuneBoundaryProjectionType DuneBoundaryProjectionType;
26 
27  typedef typename DuneBoundaryProjectionType::CoordinateType CoordinateType;
28 
29  explicit ALU2dGridBoundaryProjection ( const Grid &grid )
30  : grid_( grid )
31  {}
32 
33  int operator() ( const hbndel_t *hbndel, const double local, double (&global)[ ncoord ] ) const
34  {
35  return callProjection( grid_.boundaryProjection( hbndel->segmentIndex() ), global );
36  }
37 
38  int operator() ( const helement_t *helement, const double (&local)[ 2 ], double (&global)[ ncoord ] ) const
39  {
40  return callProjection( grid_.globalProjection(), global );
41  }
42 
43  private:
44  static int callProjection ( const DuneBoundaryProjectionType *prj, double (&global)[ ncoord ] )
45  {
46  if( prj )
47  {
48  CoordinateType x, y;
49  for( int i = 0; i < ncoord; ++i )
50  x[ i ] = global[ i ];
51  y = (*prj)( x );
52  for( int i = 0; i < ncoord; ++i )
53  global[ i ] = y[ i ];
54  }
55  return 1;
56  }
57 
58  const Grid &grid_;
59  };
60 
61 } // end namespace Dune
62 
63 #endif // #ifndef DUNE_ALU2D_BNDPROJECTION_HH
#define ALU2DSPACE
Definition: alu2dinclude.hh:34
DuneBoundaryProjectionType::CoordinateType CoordinateType
Definition: 2d/bndprojection.hh:27
Grid::DuneBoundaryProjectionType DuneBoundaryProjectionType
Definition: 2d/bndprojection.hh:25
ALU2dGridBoundaryProjection(const Grid &grid)
Definition: 2d/bndprojection.hh:29
Base::helement_t helement_t
Definition: 2d/bndprojection.hh:23
The dimension of the world the grid lives in.
Definition: common/grid.hh:406
Base::hbndel_t hbndel_t
Definition: 2d/bndprojection.hh:22
int operator()(const hbndel_t *hbndel, const double local, double(&global)[ncoord]) const
Definition: 2d/bndprojection.hh:33
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:386
Definition: 2d/bndprojection.hh:14
#define ALU2DDIMWORLD(dimw, eltype)
Definition: alu2dinclude.hh:37
Definition: 2d/bndprojection.hh:20