dune-grid  2.4
hostcorners.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_GEOGRID_HOSTCORNERS_HH
4 #define DUNE_GEOGRID_HOSTCORNERS_HH
5 
6 #include <dune/geometry/type.hh>
7 
8 #if HAVE_ALUGRID && DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
10 #endif
12 
13 namespace Dune
14 {
15 
16  // External Forward Declarations
17  // -----------------------------
18 
19 #if HAVE_ALUGRID && DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
20  template< int, int, class >
21  class ALU3dGridEntity;
22 
23  template< ALU3dGridElementType, class >
24  struct ALU3dImplTraits;
25 #endif
26 
27  namespace GeoGrid
28  {
29 
30  // HostCorners
31  // -----------
32 
33  template< class HostEntity >
35  {
36  typedef typename HostEntity::Geometry HostGeometry;
37 
38  public:
39  typedef typename HostGeometry::GlobalCoordinate Coordinate;
40 
41  explicit HostCorners ( const HostEntity &hostEntity )
42  : hostGeometry_( hostEntity.geometry() )
43  {}
44 
45  GeometryType type () const
46  {
47  return hostGeometry_.type();
48  }
49 
50  Coordinate operator[] ( int i ) const
51  {
52  return hostGeometry_.corner( i );
53  }
54 
55  std::size_t size () const
56  {
57  return hostGeometry_.corners();
58  }
59 
60  private:
61  HostGeometry hostGeometry_;
62  };
63 
64 
65 
66  // HostCorners for ALU3dGrid
67  // -------------------------
68 
69 #if HAVE_ALUGRID && DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
70  template< int dim, class Grid >
71  class HostCorners< Dune::Entity< 0, dim, Grid, ALU3dGridEntity > >
72  {
74 
75  typedef double ALUCoordinate[ 3 ];
76 
77  static const ALU3dGridElementType elementType = remove_const< Grid >::type::elementType;
79 
80  typedef typename remove_const< Grid >::type::MPICommunicatorType Comm;
81  typedef ALU3dImplTraits< elementType, Comm > ImplTraits;
82 
83  public:
84  typedef FieldVector< double, 3 > Coordinate;
85 
86  explicit HostCorners ( const HostEntity &hostEntity )
87  : item_( hostEntity.impl().getItem() )
88  {}
89 
90  GeometryType type () const
91  {
92  if( elementType == tetra )
93  return GeometryType( GenericGeometry::SimplexTopology< dim >::type::id, dim );
94  else
95  return GeometryType( GenericGeometry::CubeTopology< dim >::type::id, dim );
96  }
97 
98  Coordinate operator[] ( int i ) const
99  {
100  const int j = ElementTopologyMapping::dune2aluVertex( i );
101  const ALUCoordinate &point = item_.myvertex( j )->Point();
102 
103  Coordinate corner;
104  for( int k = 0; k < 3; ++k )
105  corner[ k ] = point[ k ];
106  return corner;
107  }
108 
109  std::size_t size () const
110  {
111  return (elementType == tetra ? dim+1 : (1 << dim));
112  }
113 
114  private:
115  const typename ImplTraits::IMPLElementType &item_;
116  };
117 #endif // #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
118 
119  } // namespace GeoGrid
120 
121 } // namespace Dune
122 
123 #endif // #ifndef DUNE_GEOGRID_HOSTCORNERS_HH
static int dune2aluVertex(int index)
Maps vertex index from Dune onto ALU3dGrid reference element.
Definition: topology.hh:199
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Include standard header files.
Definition: agrid.hh:59
GeometryType type() const
Definition: hostcorners.hh:45
Definition: topology.hh:13
HostGeometry::GlobalCoordinate Coordinate
Definition: hostcorners.hh:39
HostCorners(const HostEntity &hostEntity)
Definition: hostcorners.hh:41
Definition: topology.hh:40
Definition: alu3dinclude.hh:201
ALU3dGridElementType
Definition: topology.hh:13
Coordinate operator[](int i) const
Definition: hostcorners.hh:50
Definition: hostcorners.hh:34
Wrapper class for entities.
Definition: common/entity.hh:61
std::size_t size() const
Definition: hostcorners.hh:55