Dune Core Modules (2.5.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 >
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 ),
116 hostGridView_( hostGridView )
117 {}
118
119 const Grid &grid () const
120 {
121 assert( grid_ );
122 return *grid_;
123 }
124
125 const IndexSet &indexSet () const
126 {
127 if( !indexSet_ )
128 indexSet_ = IndexSet( hostGridView().indexSet() );
129 return indexSet_;
130 }
131
132 int size ( int codim ) const
133 {
134 return hostGridView().size( codim );
135 }
136
137 int size ( const GeometryType &type ) const
138 {
139 return hostGridView().size( type );
140 }
141
142 template< int codim >
143 typename Codim< codim >::Iterator begin () const
144 {
145 return begin< codim, All_Partition >();
146 }
147
148 template< int codim, PartitionIteratorType pit >
149 typename Codim< codim >::template Partition< pit >::Iterator begin () const
150 {
151 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::begin( grid(), hostGridView() );
152 }
153
154 template< int codim >
155 typename Codim< codim >::Iterator end () const
156 {
157 return end< codim, All_Partition >();
158 }
159
160 template< int codim, PartitionIteratorType pit >
161 typename Codim< codim >::template Partition< pit >::Iterator end () const
162 {
163 return Traits::template Codim< codim >::template Partition< pit >::IteratorImp::end( grid(), hostGridView() );
164 }
165
166 IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
167 {
168 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
169 return IntersectionIteratorImpl( entity, hostGridView().ibegin( Grid::getRealImplementation( entity ).hostEntity() ) );
170 }
171
172 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
173 {
174 typedef GeoGrid::IntersectionIterator< const Grid, typename HostGridView::IntersectionIterator > IntersectionIteratorImpl;
175 return IntersectionIteratorImpl( entity, hostGridView().iend( Grid::getRealImplementation( entity ).hostEntity() ) );
176 }
177
178 const CollectiveCommunication &comm () const
179 {
180 return hostGridView().comm();
181 }
182
183 int overlapSize ( int codim ) const
184 {
185 return hostGridView().overlapSize( codim );
186 }
187
188 int ghostSize ( int codim ) const
189 {
190 return hostGridView().ghostSize( codim );
191 }
192
193 template< class DataHandle, class Data >
194 void communicate ( CommDataHandleIF< DataHandle, Data > &dataHandle,
195 InterfaceType interface,
196 CommunicationDirection direction ) const
197 {
198 typedef CommDataHandleIF< DataHandle, Data > DataHandleIF;
199 typedef GeoGrid::CommDataHandle< Grid, DataHandleIF > WrappedDataHandle;
200
201 WrappedDataHandle wrappedDataHandle( grid(), dataHandle );
202 hostGridView().communicate( wrappedDataHandle, interface, direction );
203 }
204
205 const HostGridView &hostGridView () const { return hostGridView_; }
206
207 private:
208 const Grid *grid_;
209 HostGridView hostGridView_;
210 mutable IndexSet indexSet_;
211 };
212
213 } // namespace GeoGrid
214
215} // namespace Dune
216
217#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:82
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:1115
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.
@ conforming
Output conforming data.
Definition: common.hh:70
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:11
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)