DUNE PDELab (git)

gridview.hh
1// SPDX-FileCopyrightText: Copyright © 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
62 template< int codim >
63 struct Codim
64 {
65 typedef GeoGrid::Iterator< HostGridView, codim, All_Partition, const Grid > IteratorImp;
67
68 typedef typename Grid::Traits::template Codim< codim >::Entity Entity;
69
70 typedef typename Grid::template Codim< codim >::Geometry Geometry;
71 typedef typename Grid::template Codim< codim >::LocalGeometry LocalGeometry;
72
73 template< PartitionIteratorType pit >
74 struct Partition
75 {
76 typedef GeoGrid::Iterator< HostGridView, codim, pit, const Grid > IteratorImp;
78 };
79 };
80
81 static const bool conforming = HostGridView::conforming;
82 };
83
84
85
86 // GridView
87 // --------
88
89 template< class HGV, class CoordFunction, class Allocator >
90 class GridView
91 {
92 typedef GridView< HGV, CoordFunction, Allocator > This;
93
94 public:
95 typedef GridViewTraits< HGV, CoordFunction, Allocator > Traits;
96
97 typedef typename Traits::HostGridView HostGridView;
98
99 typedef typename Traits::Grid Grid;
100
101 typedef typename Traits::IndexSet IndexSet;
102
103 typedef typename Traits::Intersection Intersection;
104
105 typedef typename Traits::IntersectionIterator IntersectionIterator;
106
107 typedef typename Traits::Communication Communication;
108
109 template< int codim >
110 struct Codim
111 : public Traits::template Codim< codim >
112 {};
113
114 static const bool conforming = Traits::conforming;
115
116 GridView ( const Grid &grid, const HostGridView &hostGridView )
117 : grid_( &grid ), hostGridView_( hostGridView )
118 {}
119
120 GridView ( const This &other )
121 : grid_( other.grid_ ), hostGridView_( other.hostGridView_ )
122 {}
123
124 GridView ( This &&other )
125 : grid_( other.grid_ ), hostGridView_( std::move( other.hostGridView_ ) )
126 {}
127
128 This &operator= ( const This &other )
129 {
130 grid_ = other.grid_;
131 hostGridView_ = other.hostGridView_;
132 if( indexSet_ )
133 indexSet_.reset( hostGridView().indexSet() );
134 return *this;
135 }
136
137 This &operator= ( This &&other )
138 {
139 grid_ = other.grid_;
140 hostGridView_ = std::move( other.hostGridView_ );
141 if( indexSet_ )
142 indexSet_.reset( hostGridView().indexSet() );
143 return *this;
144 }
145
146 const Grid &grid () const
147 {
148 assert( grid_ );
149 return *grid_;
150 }
151
152 const IndexSet &indexSet () const
153 {
154 indexSet_.reset( hostGridView().indexSet() );
155 return indexSet_;
156 }
157
158 bool isConforming() const { return hostGridView().isConforming(); }
159
160 int size ( int codim ) const
161 {
162 return hostGridView().size( codim );
163 }
164
165 int size ( const GeometryType &type ) const
166 {
167 return hostGridView().size( type );
168 }
169
170 template< int codim >
171 typename Codim< codim >::Iterator begin () const
172 {
173 return begin< codim, All_Partition >();
174 }
175
176 template< int codim, PartitionIteratorType pit >
177 typename Codim< codim >::template Partition< pit >::Iterator begin () const
178 {
179 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::begin( grid(), hostGridView() );
180 }
181
182 template< int codim >
183 typename Codim< codim >::Iterator end () const
184 {
185 return end< codim, All_Partition >();
186 }
187
188 template< int codim, PartitionIteratorType pit >
189 typename Codim< codim >::template Partition< pit >::Iterator end () const
190 {
191 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::end( grid(), hostGridView() );
192 }
193
194 IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
195 {
196 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
197 return IntersectionIteratorImpl( entity, hostGridView().ibegin( entity.impl().hostEntity() ) );
198 }
199
200 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
201 {
202 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
203 return IntersectionIteratorImpl( entity, hostGridView().iend( entity.impl().hostEntity() ) );
204 }
205
206 const Communication &comm () const
207 {
208 return hostGridView().comm();
209 }
210
211 int overlapSize ( int codim ) const
212 {
213 return hostGridView().overlapSize( codim );
214 }
215
216 int ghostSize ( int codim ) const
217 {
218 return hostGridView().ghostSize( codim );
219 }
220
221 template< class DataHandle, class Data >
222 auto communicate ( CommDataHandleIF< DataHandle, Data > &dataHandle,
223 InterfaceType interface,
224 CommunicationDirection direction ) const
225 {
226 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
227 typedef GeoGrid::CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
228
229 WrappedDataHandle wrappedDataHandle( grid(), dataHandle );
230 return hostGridView().communicate( wrappedDataHandle, interface, direction );
231 }
232
233 const HostGridView &hostGridView () const { return hostGridView_; }
234
235 private:
236 const Grid *grid_;
237 HostGridView hostGridView_;
238 mutable IndexSet indexSet_;
239 };
240
241 } // namespace GeoGrid
242
243} // namespace Dune
244
245#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.
Traits for type conversions and type information.
@ 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
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)