dune-grid  2.2.0
common/bndprojection.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU_BNDPROJECTION_HH
2 #define DUNE_ALU_BNDPROJECTION_HH
3 
4 namespace Dune {
5 
8  template <class GridImp, class ctype = double >
10 #ifdef ALUGRID_VERTEX_PROJECTION
11  : public GridImp :: ALUGridVertexProjectionType
12 #endif
13  {
14  typedef GridImp GridType;
15  // type of double coordinate vector
16  typedef ctype coord_t[ GridType :: dimensionworld ];
17  protected:
18 
20  const GridType& grid_;
21  public:
23  typedef typename GridType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
24 
26  typedef typename DuneBoundaryProjectionType :: CoordinateType CoordinateType;
27 
29  ALUGridBoundaryProjection(const GridType& grid)
30  : grid_( grid )
31  {
32  }
33 
35  int operator () (const coord_t &orig,
36  coord_t &prj) const
37  {
38  return this->operator()( orig, 0, prj);
39  }
40 
42  int operator () (const coord_t &orig,
43  const int segmentIndex,
44  coord_t &prj) const
45  {
46 #ifdef ALUGRID_VERTEX_PROJECTION
47  // get boundary projection
48  const DuneBoundaryProjectionType* bndPrj =
49  grid_.boundaryProjection( segmentIndex );
50 
51  // if pointer is zero we do nothing, i.e. identity mapping
52  if( bndPrj )
53  {
54  // call projection operator
55  reinterpret_cast<CoordinateType &> (* (&prj[0])) =
56  (*bndPrj)( reinterpret_cast<const CoordinateType &> (* (&orig[0])) );
57  }
58 #endif
59 
60  // return 1 for success
61  return 1;
62  }
63  };
64 
65 } // end namespace Dune
66 #endif