dune-grid 2.9.0
geometrygrid/gridview.hh
Go to the documentation of this file.
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
8#include <dune/common/typetraits.hh>
9#include <dune/common/exceptions.hh>
10
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 >
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:
49
51
53
55
59
60 typedef typename HostGridView::Communication Communication;
61
65 [[deprecated("Use Communication instead!!")]]
67
68 template< int codim >
69 struct Codim
70 {
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 {
84 };
85 };
86
88 };
89
90
91
92 // GridView
93 // --------
94
95 template< class HGV, class CoordFunction, class Allocator >
97 {
99
100 public:
102
103 typedef typename Traits::HostGridView HostGridView;
104
105 typedef typename Traits::Grid Grid;
106
107 typedef typename Traits::IndexSet IndexSet;
108
110
112
114
118 [[deprecated("Use Communication instead!!")]]
120
121 template< int codim >
122 struct Codim
123 : public Traits::template Codim< codim >
124 {};
125
126 static const bool conforming = Traits::conforming;
127
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 >
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 >
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 {
209 return IntersectionIteratorImpl( entity, hostGridView().ibegin( entity.impl().hostEntity() ) );
210 }
211
212 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
213 {
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 >
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
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
STL namespace.
Include standard header files.
Definition: agrid.hh:60
@ conforming
Output conforming data.
Definition: common.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
interface class for an iterator over grid entities
Definition: entityiterator.hh:32
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/intersectioniterator.hh:83
Grid abstract base class.
Definition: common/grid.hh:375
Definition: geometrygrid/datahandle.hh:27
grid wrapper replacing the geometries
Definition: geometrygrid/grid.hh:86
Definition: geometrygrid/intersectioniterator.hh:21
Definition: geometrygrid/gridview.hh:97
Traits::Grid Grid
Definition: geometrygrid/gridview.hh:105
const Grid & grid() const
Definition: geometrygrid/gridview.hh:158
Traits::IntersectionIterator IntersectionIterator
Definition: geometrygrid/gridview.hh:111
Traits::Communication Communication
Definition: geometrygrid/gridview.hh:113
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
Definition: geometrygrid/gridview.hh:206
int ghostSize(int codim) const
Definition: geometrygrid/gridview.hh:228
Codim< codim >::Iterator end() const
Definition: geometrygrid/gridview.hh:195
Traits::Intersection Intersection
Definition: geometrygrid/gridview.hh:109
const Communication & comm() const
Definition: geometrygrid/gridview.hh:218
Traits::IndexSet IndexSet
Definition: geometrygrid/gridview.hh:107
GridView(const This &other)
Definition: geometrygrid/gridview.hh:132
const HostGridView & hostGridView() const
Definition: geometrygrid/gridview.hh:245
Codim< codim >::template Partition< pit >::Iterator begin() const
Definition: geometrygrid/gridview.hh:189
bool isConforming() const
Definition: geometrygrid/gridview.hh:170
Codim< codim >::template Partition< pit >::Iterator end() const
Definition: geometrygrid/gridview.hh:201
This & operator=(const This &other)
Definition: geometrygrid/gridview.hh:140
int size(int codim) const
Definition: geometrygrid/gridview.hh:172
GridView(const Grid &grid, const HostGridView &hostGridView)
Definition: geometrygrid/gridview.hh:128
int overlapSize(int codim) const
Definition: geometrygrid/gridview.hh:223
Communication CollectiveCommunication
Definition: geometrygrid/gridview.hh:119
auto communicate(CommDataHandleIF< DataHandle, Data > &dataHandle, InterfaceType interface, CommunicationDirection direction) const
Definition: geometrygrid/gridview.hh:234
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
Definition: geometrygrid/gridview.hh:212
int size(const GeometryType &type) const
Definition: geometrygrid/gridview.hh:177
Codim< codim >::Iterator begin() const
Definition: geometrygrid/gridview.hh:183
const IndexSet & indexSet() const
Definition: geometrygrid/gridview.hh:164
GridView(This &&other)
Definition: geometrygrid/gridview.hh:136
Traits::HostGridView HostGridView
Definition: geometrygrid/gridview.hh:103
GridViewTraits< HGV, CoordFunction, Allocator > Traits
Definition: geometrygrid/gridview.hh:101
static const bool conforming
Definition: geometrygrid/gridview.hh:126
Definition: geometrygrid/gridview.hh:38
Communication CollectiveCommunication
Definition: geometrygrid/gridview.hh:66
GeoGrid::IndexSet< const Grid, typename HostGridView::IndexSet > IndexSet
Definition: geometrygrid/gridview.hh:52
GridView< HostGridView, CoordFunction, Allocator > GridViewImp
Definition: geometrygrid/gridview.hh:48
HostGridView::Communication Communication
Definition: geometrygrid/gridview.hh:60
static const bool conforming
Definition: geometrygrid/gridview.hh:87
Dune::Intersection< const Grid, GeoGrid::Intersection< const Grid, HostIntersection > > Intersection
Definition: geometrygrid/gridview.hh:54
Dune::GeometryGrid< HostGrid, CoordFunction, Allocator > Grid
Definition: geometrygrid/gridview.hh:50
Dune::IntersectionIterator< const Grid, GeoGrid::IntersectionIterator< const Grid, HostIntersectionIterator >, GeoGrid::Intersection< const Grid, HostIntersection > > IntersectionIterator
Definition: geometrygrid/gridview.hh:58
Definition: geometrygrid/gridview.hh:70
Grid::template Codim< codim >::Geometry Geometry
Definition: geometrygrid/gridview.hh:76
Grid::template Codim< codim >::LocalGeometry LocalGeometry
Definition: geometrygrid/gridview.hh:77
Dune::EntityIterator< codim, const Grid, IteratorImp > Iterator
Definition: geometrygrid/gridview.hh:72
Grid::Traits::template Codim< codim >::Entity Entity
Definition: geometrygrid/gridview.hh:74
GeoGrid::Iterator< HostGridView, codim, All_Partition, const Grid > IteratorImp
Definition: geometrygrid/gridview.hh:71
Definition: geometrygrid/gridview.hh:81
GeoGrid::Iterator< HostGridView, codim, pit, const Grid > IteratorImp
Definition: geometrygrid/gridview.hh:82
Dune::EntityIterator< codim, const Grid, IteratorImp > Iterator
Definition: geometrygrid/gridview.hh:83
Definition: geometrygrid/gridview.hh:124
Definition: geometrygrid/indexsets.hh:29
void reset()
Definition: geometrygrid/indexsets.hh:97
Definition: geometrygrid/intersection.hh:22
Definition: iterator.hh:30
A set of traits classes to store static information about grid implementation.