Dune Core Modules (2.9.1)

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