Dune Core Modules (2.7.1)

gridview.hh
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_GRIDVIEW_HH
4#define DUNE_GEOGRID_GRIDVIEW_HH
5
8
10#include <dune/grid/common/gridview.hh>
11#include <dune/grid/geometrygrid/datahandle.hh>
12#include <dune/grid/geometrygrid/indexsets.hh>
13#include <dune/grid/geometrygrid/intersection.hh>
14#include <dune/grid/geometrygrid/intersectioniterator.hh>
15#include <dune/grid/geometrygrid/iterator.hh>
16
17namespace Dune
18{
19
20 namespace GeoGrid
21 {
22
23 // Internal Forward Declarations
24 // -----------------------------
25
26 template< class HGV, class CoordFunction, class Allocator >
27 class GridView;
28
29
30
31 // GridViewTraits
32 // --------------
33
34 template< class HGV, class CoordFunction, class Allocator >
35 class GridViewTraits
36 {
37 friend class GridView< HGV, CoordFunction, Allocator >;
38
39 typedef HGV HostGridView;
40
41 typedef typename HostGridView::Grid HostGrid;
42 typedef typename HostGridView::Intersection HostIntersection;
43 typedef typename HostGridView::IntersectionIterator HostIntersectionIterator;
44
45 public:
46 typedef GridView< HostGridView, CoordFunction, Allocator > GridViewImp;
47
49
50 typedef GeoGrid::IndexSet< const Grid, typename HostGridView::IndexSet > IndexSet;
51
53
55 < const Grid, GeoGrid::IntersectionIterator< const Grid, HostIntersectionIterator >, GeoGrid::Intersection< const Grid, HostIntersection > >
56 IntersectionIterator;
57
58 typedef typename HostGridView::CollectiveCommunication CollectiveCommunication;
59
60 template< int codim >
61 struct Codim
62 {
63 typedef GeoGrid::Iterator< HostGridView, codim, All_Partition, const Grid > IteratorImp;
65
66 typedef typename Grid::Traits::template Codim< codim >::Entity Entity;
67
68 typedef typename Grid::template Codim< codim >::Geometry Geometry;
69 typedef typename Grid::template Codim< codim >::LocalGeometry LocalGeometry;
70
71 template< PartitionIteratorType pit >
72 struct Partition
73 {
74 typedef GeoGrid::Iterator< HostGridView, codim, pit, const Grid > IteratorImp;
76 };
77 };
78
79 static const bool conforming = HostGridView::conforming;
80 };
81
82
83
84 // GridView
85 // --------
86
87 template< class HGV, class CoordFunction, class Allocator >
88 class GridView
89 {
90 typedef GridView< HGV, CoordFunction, Allocator > This;
91
92 public:
93 typedef GridViewTraits< HGV, CoordFunction, Allocator > Traits;
94
95 typedef typename Traits::HostGridView HostGridView;
96
97 typedef typename Traits::Grid Grid;
98
99 typedef typename Traits::IndexSet IndexSet;
100
101 typedef typename Traits::Intersection Intersection;
102
103 typedef typename Traits::IntersectionIterator IntersectionIterator;
104
105 typedef typename Traits::CollectiveCommunication CollectiveCommunication;
106
107 template< int codim >
108 struct Codim
109 : public Traits::template Codim< codim >
110 {};
111
112 static const bool conforming = Traits::conforming;
113
114 GridView ( const Grid &grid, const HostGridView &hostGridView )
115 : grid_( &grid ), hostGridView_( hostGridView )
116 {}
117
118 GridView ( const This &other )
119 : grid_( other.grid_ ), hostGridView_( other.hostGridView_ )
120 {}
121
122 GridView ( This &&other )
123 : grid_( other.grid_ ), hostGridView_( std::move( other.hostGridView_ ) )
124 {}
125
126 This &operator= ( const This &other )
127 {
128 grid_ = other.grid_;
129 hostGridView_ = other.hostGridView_;
130 if( indexSet_ )
131 indexSet_.reset( hostGridView().indexSet() );
132 return *this;
133 }
134
135 This &operator= ( This &&other )
136 {
137 grid_ = other.grid_;
138 hostGridView_ = std::move( other.hostGridView_ );
139 if( indexSet_ )
140 indexSet_.reset( hostGridView().indexSet() );
141 return *this;
142 }
143
144 const Grid &grid () const
145 {
146 assert( grid_ );
147 return *grid_;
148 }
149
150 const IndexSet &indexSet () const
151 {
152 indexSet_.reset( hostGridView().indexSet() );
153 return indexSet_;
154 }
155
156 int size ( int codim ) const
157 {
158 return hostGridView().size( codim );
159 }
160
161 int size ( const GeometryType &type ) const
162 {
163 return hostGridView().size( type );
164 }
165
166 template< int codim >
167 typename Codim< codim >::Iterator begin () const
168 {
169 return begin< codim, All_Partition >();
170 }
171
172 template< int codim, PartitionIteratorType pit >
173 typename Codim< codim >::template Partition< pit >::Iterator begin () const
174 {
175 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::begin( grid(), hostGridView() );
176 }
177
178 template< int codim >
179 typename Codim< codim >::Iterator end () const
180 {
181 return end< codim, All_Partition >();
182 }
183
184 template< int codim, PartitionIteratorType pit >
185 typename Codim< codim >::template Partition< pit >::Iterator end () const
186 {
187 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::end( grid(), hostGridView() );
188 }
189
190 IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
191 {
192 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
193 return IntersectionIteratorImpl( entity, hostGridView().ibegin( entity.impl().hostEntity() ) );
194 }
195
196 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
197 {
198 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
199 return IntersectionIteratorImpl( entity, hostGridView().iend( entity.impl().hostEntity() ) );
200 }
201
202 const CollectiveCommunication &comm () const
203 {
204 return hostGridView().comm();
205 }
206
207 int overlapSize ( int codim ) const
208 {
209 return hostGridView().overlapSize( codim );
210 }
211
212 int ghostSize ( int codim ) const
213 {
214 return hostGridView().ghostSize( codim );
215 }
216
217 template< class DataHandle, class Data >
218 void communicate ( CommDataHandleIF< DataHandle, Data > &dataHandle,
219 InterfaceType interface,
220 CommunicationDirection direction ) const
221 {
222 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
223 typedef GeoGrid::CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
224
225 WrappedDataHandle wrappedDataHandle( grid(), dataHandle );
226 hostGridView().communicate( wrappedDataHandle, interface, direction );
227 }
228
229 const HostGridView &hostGridView () const { return hostGridView_; }
230
231 private:
232 const Grid *grid_;
233 HostGridView hostGridView_;
234 mutable IndexSet indexSet_;
235 };
236
237 } // namespace GeoGrid
238
239} // namespace Dune
240
241#endif // #ifndef DUNE_GEOGRID_GRIDVIEW_HH
interface class for an iterator over grid entities
Definition: entityiterator.hh:30
grid wrapper replacing the geometries
Definition: grid.hh:85
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:81
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:162
A set of traits classes to store static information about grid implementation.
A few common exception classes.
@ conforming
Output conforming data.
Definition: common.hh:72
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Dune namespace.
Definition: alignedallocator.hh:14
STL namespace.
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)