Dune Core Modules (2.4.2)

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, PartitionIteratorType pitype >
27 class GridView;
28
29
30
31 // GridViewTraits
32 // --------------
33
34 template< class HGV, class CoordFunction, class Allocator, PartitionIteratorType pitype >
35 class GridViewTraits
36 {
37 friend class GridView< HGV, CoordFunction, Allocator, pitype >;
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, pitype > 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, pitype, const Grid > IteratorImp;
65
66 typedef typename Grid::Traits::template Codim< codim >::Entity Entity;
67 typedef typename Grid::Traits::template Codim< codim >::EntityPointer EntityPointer;
68
69 typedef typename Grid::template Codim< codim >::Geometry Geometry;
70 typedef typename Grid::template Codim< codim >::LocalGeometry LocalGeometry;
71
72 template< PartitionIteratorType pit >
73 struct Partition
74 {
75 typedef GeoGrid::Iterator< HostGridView, codim, pit, const Grid > IteratorImp;
77 };
78 };
79
80 static const bool conforming = HostGridView::conforming;
81 };
82
83
84
85 // GridView
86 // --------
87
88 template< class HGV, class CoordFunction, class Allocator, PartitionIteratorType pitype >
89 class GridView
90 {
91 typedef GridView< HGV, CoordFunction, Allocator, pitype > This;
92
93 public:
94 typedef GridViewTraits< HGV, CoordFunction, Allocator, pitype > Traits;
95
96 typedef typename Traits::HostGridView HostGridView;
97
98 typedef typename Traits::Grid Grid;
99
100 typedef typename Traits::IndexSet IndexSet;
101
102 typedef typename Traits::Intersection Intersection;
103
104 typedef typename Traits::IntersectionIterator IntersectionIterator;
105
106 typedef typename Traits::CollectiveCommunication CollectiveCommunication;
107
108 template< int codim >
109 struct Codim
110 : public Traits::template Codim< codim >
111 {};
112
113 static const bool conforming = Traits::conforming;
114
115 GridView ( const Grid &grid, const HostGridView &hostGridView )
116 : grid_( &grid ),
117 hostGridView_( hostGridView )
118 {}
119
120 const Grid &grid () const
121 {
122 assert( grid_ );
123 return *grid_;
124 }
125
126 const IndexSet &indexSet () const
127 {
128 if( !indexSet_ )
129 indexSet_ = IndexSet( hostGridView().indexSet() );
130 return indexSet_;
131 }
132
133 int size ( int codim ) const
134 {
135 return hostGridView().size( codim );
136 }
137
138 int size ( const GeometryType &type ) const
139 {
140 return hostGridView().size( type );
141 }
142
143 template< int codim >
144 typename Codim< codim >::Iterator begin () const
145 {
146 return begin< codim, pitype >();
147 }
148
149 template< int codim, PartitionIteratorType pit >
150 typename Codim< codim >::template Partition< pit >::Iterator begin () const
151 {
152 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::begin( grid(), hostGridView() );
153 }
154
155 template< int codim >
156 typename Codim< codim >::Iterator end () const
157 {
158 return end< codim, pitype >();
159 }
160
161 template< int codim, PartitionIteratorType pit >
162 typename Codim< codim >::template Partition< pit >::Iterator end () const
163 {
164 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::end( grid(), hostGridView() );
165 }
166
167 IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
168 {
169 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
170 return IntersectionIteratorImpl( entity, hostGridView().ibegin( Grid::getRealImplementation( entity ).hostEntity() ) );
171 }
172
173 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
174 {
175 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
176 return IntersectionIteratorImpl( entity, hostGridView().iend( Grid::getRealImplementation( entity ).hostEntity() ) );
177 }
178
179 const CollectiveCommunication &comm () const
180 {
181 return hostGridView().comm();
182 }
183
184 int overlapSize ( int codim ) const
185 {
186 return hostGridView().overlapSize( codim );
187 }
188
189 int ghostSize ( int codim ) const
190 {
191 return hostGridView().ghostSize( codim );
192 }
193
194 template< class DataHandle, class Data >
195 void communicate ( CommDataHandleIF< DataHandle, Data > &dataHandle,
196 InterfaceType interface,
197 CommunicationDirection direction ) const
198 {
199 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
200 typedef GeoGrid::CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
201
202 WrappedDataHandle wrappedDataHandle( grid(), dataHandle );
203 hostGridView().communicate( wrappedDataHandle, interface, direction );
204 }
205
206 const HostGridView &hostGridView () const { return hostGridView_; }
207
208 private:
209 const Grid *grid_;
210 HostGridView hostGridView_;
211 mutable IndexSet indexSet_;
212 };
213
214 } // namespace GeoGrid
215
216} // namespace Dune
217
218#endif // #ifndef DUNE_GEOGRID_GRIDVIEW_HH
interface class for an iterator over grid entities
Definition: entityiterator.hh:37
grid wrapper replacing the geometries
Definition: grid.hh:83
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: grid.hh:1305
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:84
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
A set of traits classes to store static information about grid implementation.
A few common exception classes.
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: alignment.hh:10
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)