dune-grid  2.2.1
hostcorners.hh
Go to the documentation of this file.
1 #ifndef DUNE_GEOGRID_HOSTCORNERS_HH
2 #define DUNE_GEOGRID_HOSTCORNERS_HH
3 
4 #include <dune/geometry/type.hh>
5 
8 
9 namespace Dune
10 {
11 
12  // External Forward Declarations
13  // -----------------------------
14 
15  template< int, int, class >
16  class ALU3dGridEntity;
17 
18  template< ALU3dGridElementType, class >
19  struct ALU3dImplTraits;
20 
21 
22 
23  namespace GeoGrid
24  {
25 
26  // HostCorners
27  // -----------
28 
29  template< class HostEntity >
31  {
32  typedef typename HostEntity::Geometry HostGeometry;
33 
34  public:
35  typedef typename HostGeometry::GlobalCoordinate Coordinate;
36 
37  explicit HostCorners ( const HostEntity &hostEntity )
38  : hostGeometry_( hostEntity.geometry() )
39  {}
40 
41  GeometryType type () const
42  {
43  return hostGeometry_.type();
44  }
45 
46  Coordinate corner ( const int i ) const
47  {
48  return hostGeometry_.corner( i );
49  }
50 
51  unsigned int numCorners () const
52  {
53  return hostGeometry_.corners();
54  }
55 
56  private:
57  HostGeometry hostGeometry_;
58  };
59 
60 
61 
62  // HostCorners for ALU3dGrid
63  // -------------------------
64 
65 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
66  template< int dim, class Grid >
67  class HostCorners< Dune::Entity< 0, dim, Grid, ALU3dGridEntity > >
68  {
70 
71  typedef double ALUCoordinate[ 3 ];
72 
73  static const ALU3dGridElementType elementType = remove_const< Grid >::type::elementType;
75 
76  typedef typename remove_const< Grid >::type::MPICommunicatorType Comm;
77  typedef ALU3dImplTraits< elementType, Comm > ImplTraits;
78 
79  public:
80  typedef FieldVector< double, 3 > Coordinate;
81 
82  explicit HostCorners ( const HostEntity &hostEntity )
83  : item_( hostEntity.impl().getItem() )
84  {}
85 
86  GeometryType type () const
87  {
88  if( elementType == tetra )
89  return GeometryType( GenericGeometry::SimplexTopology< dim >::type::id, dim );
90  else
91  return GeometryType( GenericGeometry::CubeTopology< dim >::type::id, dim );
92  }
93 
94  Coordinate corner ( const int i ) const
95  {
96  const int j = ElementTopologyMapping::dune2aluVertex( i );
97  const ALUCoordinate &point = item_.myvertex( j )->Point();
98 
100  for( int k = 0; k < 3; ++k )
101  corner[ k ] = point[ k ];
102  return corner;
103  }
104 
105  unsigned int numCorners () const
106  {
107  return (elementType == tetra ? dim+1 : (1 << dim));
108  }
109 
110  private:
111  const typename ImplTraits::IMPLElementType &item_;
112  };
113 #endif // #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
114 
115  } // namespace GeoGrid
116 
117 } // namespace Dune
118 
119 #endif // #ifndef DUNE_GEOGRID_HOSTCORNERS_HH