opm-grid
gridview.hh
1 // -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=2 sw=2 sts=2:
3 #ifndef DUNE_POLYHEDRALGRID_GRIDVIEW_HH
4 #define DUNE_POLYHEDRALGRID_GRIDVIEW_HH
5 
6 //- dune-common includes
7 #include <dune/common/typetraits.hh>
8 
9 //- dune-grid includes
10 #include <dune/grid/common/capabilities.hh>
11 #include <dune/grid/common/gridview.hh>
12 
13 //- polyhedralgrid includes
14 #include <opm/grid/polyhedralgrid/indexset.hh>
15 #include <opm/grid/polyhedralgrid/intersection.hh>
16 #include <opm/grid/polyhedralgrid/intersectioniterator.hh>
17 #include <opm/grid/polyhedralgrid/iterator.hh>
18 
19 namespace Dune
20 {
21 
22  // Internal Forward Declarations
23  // -----------------------------
24 
25  template< int dim, int dimworld, typename coord_t, PartitionIteratorType defaultpitype >
27 
28  template< int dim, int dimworld, typename coord_t, PartitionIteratorType ptype >
30 
31 
32  // PolyhedralGridView
33  // ------------------
34 
35  template< int dim, int dimworld, typename coord_t, PartitionIteratorType defaultpitype >
36  class PolyhedralGridView
37  {
39 
40  public:
42 
43  typedef typename Traits::Grid Grid;
44  typedef typename Traits::IndexSet IndexSet;
45  typedef typename Traits::Intersection Intersection;
46  typedef typename Traits::IntersectionIterator IntersectionIterator;
47 
48  using Communication = typename Traits::Communication;
49  using CollectiveCommunication = Communication; // deprecated
50  template< int codim >
51  struct Codim
52  : public Traits::template Codim< codim >
53  {};
54 
55  static const bool conforming = Traits :: conforming;
56  static const PartitionIteratorType pitype = Traits :: pitype;
57 
58  explicit PolyhedralGridView ( const Grid &grid, const int level = 0 )
59  : grid_( &grid )
60  {
61  (void)level;
62  }
63 
64  const Grid &grid () const
65  {
66  assert( grid_ );
67  return *grid_;
68  }
69 
70  const IndexSet &indexSet () const
71  {
72  return grid().leafIndexSet();
73  }
74 
75  bool isConforming() const { return bool(conforming); }
76 
77  int size ( int codim ) const
78  {
79  return grid().size( codim );
80  }
81 
82  int size ( const GeometryType &type ) const
83  {
84  return grid().size( type );
85  }
86 
87  template< int codim >
88  typename Codim< codim >::Iterator begin () const
89  {
90  return begin< codim, defaultpitype >();
91  }
92 
93  template< int codim, PartitionIteratorType pit >
94  typename Codim< codim >::template Partition< pit >::Iterator begin () const
95  {
96  typedef typename Traits::template Codim< codim >::template Partition< pit >::IteratorImpl Impl;
97  return Impl( grid().extraData(), true );
98  }
99 
100  template< int codim >
101  typename Codim< codim >::Iterator end () const
102  {
103  return end< codim, defaultpitype >();
104  }
105 
106  template< int codim, PartitionIteratorType pit >
107  typename Codim< codim >::template Partition< pit >::Iterator end () const
108  {
109  typedef typename Traits::template Codim< codim >::template Partition< pit >::IteratorImpl Impl;
110  return Impl( grid().extraData(), false );
111  }
112 
113  IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
114  {
115  typedef typename Traits::IntersectionIteratorImpl IntersectionIteratorImpl;
116  return IntersectionIteratorImpl( grid().extraData(), entity.seed(), true);
117  }
118 
119  IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
120  {
121  typedef typename Traits::IntersectionIteratorImpl IntersectionIteratorImpl;
122  return IntersectionIteratorImpl( grid().extraData(), entity.seed(), false);
123  }
124 
125  const CollectiveCommunication &comm () const
126  {
127  return grid().comm();
128  }
129 
130  int overlapSize ( int codim ) const
131  {
132  return grid().overlapSize( codim );
133  }
134 
135  int ghostSize ( int codim ) const
136  {
137  return grid().ghostSize( codim );
138  }
139 
140  template< class DataHandle, class Data >
141  void communicate ( CommDataHandleIF< DataHandle, Data > /*&dataHandle*/,
142  InterfaceType /*interface*/,
143  CommunicationDirection /*direction*/ ) const
144  {
145  }
146 
147  protected:
148  const Grid *grid_;
149  };
150 
151  // PolyhedralGridViewTraits
152  // ------------------------
153 
154  template< int dim, int dimworld, typename coord_t, PartitionIteratorType ptype >
155  struct PolyhedralGridViewTraits
156  {
157  typedef PolyhedralGrid< dim, dimworld, coord_t > Grid;
158  static const PartitionIteratorType pitype = ptype;
159 
160  typedef PolyhedralGridView< dim, dimworld, coord_t, pitype > GridViewImp;
161  typedef PolyhedralGridIndexSet< Grid::dimension, Grid::dimensionworld, coord_t > IndexSet;
162 
163  typedef PolyhedralGridIntersection< const Grid > IntersectionImpl;
164  typedef PolyhedralGridIntersectionIterator< const Grid > IntersectionIteratorImpl;
165 
166  typedef Dune::Intersection< const Grid, IntersectionImpl > Intersection;
167  typedef Dune::IntersectionIterator< const Grid, IntersectionIteratorImpl, IntersectionImpl > IntersectionIterator;
168 
169  using Communication = typename Grid::Communication;
170  using CollectiveCommunication = Communication;
171 
172  template< int codim >
173  struct Codim
174  {
175  typedef typename Grid::Traits::template Codim< codim >::Entity Entity;
176  typedef typename Grid::Traits::template Codim< codim >::EntityPointer EntityPointer;
177 
178  typedef typename Grid::template Codim< codim >::Geometry Geometry;
179  typedef typename Grid::template Codim< codim >::LocalGeometry LocalGeometry;
180 
181  template< PartitionIteratorType pit >
182  struct Partition
183  {
185  typedef Dune::EntityIterator< codim, const Grid, IteratorImpl > Iterator;
186  };
187 
188  typedef typename Partition< pitype >::Iterator Iterator;
189  };
190 
191  static const bool conforming = false;
192  };
193 
194 } // namespace Dune
195 
196 #endif // #ifndef DUNE_POLYHEDRALGRID_GRIDVIEW_HH
typename Traits::Communication Communication
communicator with all other processes having some part of the grid
Definition: grid.hh:311
Definition: gridview.hh:26
int size(int, int codim) const
obtain number of entites on a level
Definition: grid.hh:428
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: grid.hh:625
The namespace Dune is the main namespace for all Dune code.
Definition: CartesianIndexMapper.hpp:9
const CommunicationType & comm() const
obtain CollectiveCommunication object
Definition: grid.hh:712
Definition: iterator.hh:19
Definition: gridview.hh:29
Definition: gridview.hh:51
identical grid wrapper
Definition: declaration.hh:10
Definition: indexset.hh:23
Definition: gridview.hh:173
int overlapSize(int) const
obtain size of overlap region for the leaf grid
Definition: grid.hh:616