My Project
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
19namespace Dune
20{
21
22 // Internal Forward Declarations
23 // -----------------------------
24
25 template< int dim, int dimworld, typename coord_t, PartitionIteratorType defaultpitype >
26 class PolyhedralGridView;
27
28 template< int dim, int dimworld, typename coord_t, PartitionIteratorType ptype >
29 struct PolyhedralGridViewTraits;
30
31
32 // PolyhedralGridView
33 // ------------------
34
35 template< int dim, int dimworld, typename coord_t, PartitionIteratorType defaultpitype >
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#if DUNE_VERSION_NEWER(DUNE_GRID, 2, 7)
49 using Communication = typename Traits::Communication;
50 using CollectiveCommunication = Communication; // deprecated
51#else
52 using MPICommunicator = typename MPIHelper::MPICommunicator;
53 using CollectiveCommunication = Dune::CollectiveCommunication<MPICommunicator>;
54 using Communication = CollectiveCommunication;
55#endif
56 template< int codim >
57 struct Codim
58 : public Traits::template Codim< codim >
59 {};
60
61 static const bool conforming = Traits :: conforming;
62 static const PartitionIteratorType pitype = Traits :: pitype;
63
64 PolyhedralGridView ( const Grid &grid, const int level = 0 )
65 : grid_( &grid )
66 {
67 (void)level;
68 }
69
70 const Grid &grid () const
71 {
72 assert( grid_ );
73 return *grid_;
74 }
75
76 const IndexSet &indexSet () const
77 {
78 return grid().leafIndexSet();
79 }
80
81 bool isConforming() const { return bool(conforming); }
82
83 int size ( int codim ) const
84 {
85 return grid().size( codim );
86 }
87
88 int size ( const GeometryType &type ) const
89 {
90 return grid().size( type );
91 }
92
93 template< int codim >
94 typename Codim< codim >::Iterator begin () const
95 {
96 return begin< codim, defaultpitype >();
97 }
98
99 template< int codim, PartitionIteratorType pit >
100 typename Codim< codim >::template Partition< pit >::Iterator begin () const
101 {
102 typedef typename Traits::template Codim< codim >::template Partition< pit >::IteratorImpl Impl;
103 return Impl( grid().extraData(), true );
104 }
105
106 template< int codim >
107 typename Codim< codim >::Iterator end () const
108 {
109 return end< codim, defaultpitype >();
110 }
111
112 template< int codim, PartitionIteratorType pit >
113 typename Codim< codim >::template Partition< pit >::Iterator end () const
114 {
115 typedef typename Traits::template Codim< codim >::template Partition< pit >::IteratorImpl Impl;
116 return Impl( grid().extraData(), false );
117 }
118
119 IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
120 {
121 typedef typename Traits::IntersectionIteratorImpl IntersectionIteratorImpl;
122 return IntersectionIteratorImpl( grid().extraData(), entity.seed(), true);
123 }
124
125 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
126 {
127 typedef typename Traits::IntersectionIteratorImpl IntersectionIteratorImpl;
128 return IntersectionIteratorImpl( grid().extraData(), entity.seed(), false);
129 }
130
131 const CollectiveCommunication &comm () const
132 {
133 return grid().comm();
134 }
135
136 int overlapSize ( int codim ) const
137 {
138 return grid().overlapSize( codim );
139 }
140
141 int ghostSize ( int codim ) const
142 {
143 return grid().ghostSize( codim );
144 }
145
146 template< class DataHandle, class Data >
147 void communicate ( CommDataHandleIF< DataHandle, Data > /*&dataHandle*/,
148 InterfaceType /*interface*/,
149 CommunicationDirection /*direction*/ ) const
150 {
151 }
152
153 protected:
154 const Grid *grid_;
155 };
156
157 // PolyhedralGridViewTraits
158 // ------------------------
159
160 template< int dim, int dimworld, typename coord_t, PartitionIteratorType ptype >
162 {
164 static const PartitionIteratorType pitype = ptype;
165
168
171
172 typedef Dune::Intersection< const Grid, IntersectionImpl > Intersection;
173 typedef Dune::IntersectionIterator< const Grid, IntersectionIteratorImpl, IntersectionImpl > IntersectionIterator;
174
175 using Communication = typename Grid::Communication;
176 using CollectiveCommunication = Communication;
177
178 template< int codim >
179 struct Codim
180 {
181 typedef typename Grid::Traits::template Codim< codim >::Entity Entity;
182 typedef typename Grid::Traits::template Codim< codim >::EntityPointer EntityPointer;
183
184 typedef typename Grid::template Codim< codim >::Geometry Geometry;
185 typedef typename Grid::template Codim< codim >::LocalGeometry LocalGeometry;
186
187 template< PartitionIteratorType pit >
189 {
191 typedef Dune::EntityIterator< codim, const Grid, IteratorImpl > Iterator;
192 };
193
194 typedef typename Partition< pitype >::Iterator Iterator;
195 };
196
197 static const bool conforming = false;
198 };
199
200} // namespace Dune
201
202#endif // #ifndef DUNE_POLYHEDRALGRID_GRIDVIEW_HH
Definition: indexset.hh:25
Definition: intersectioniterator.hh:16
Definition: intersection.hh:20
Definition: iterator.hh:21
Definition: gridview.hh:37
identical grid wrapper
Definition: grid.hh:163
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: grid.hh:634
int size(int, int codim) const
obtain number of entites on a level
Definition: grid.hh:437
const CommunicationType & comm() const
obtain CollectiveCommunication object
Definition: grid.hh:721
int overlapSize(int) const
obtain size of overlap region for the leaf grid
Definition: grid.hh:625
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10
Definition: gridview.hh:180
Definition: gridview.hh:162
Definition: gridview.hh:59