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