DUNE-FEM (unstable)

idgridpart.hh
1#ifndef DUNE_FEM_GRIDPART_IDGRIDPART_HH
2#define DUNE_FEM_GRIDPART_IDGRIDPART_HH
3
4#include <dune/grid/common/gridview.hh>
5
6#include <dune/fem/gridpart/common/deaditerator.hh>
7#include <dune/fem/gridpart/common/entitysearch.hh>
8#include <dune/fem/gridpart/common/extendedentity.hh>
9#include <dune/fem/gridpart/common/gridpart.hh>
10#include <dune/fem/gridpart/common/metatwistutility.hh>
11#include <dune/fem/gridpart/idgridpart/capabilities.hh>
12#include <dune/fem/gridpart/idgridpart/datahandle.hh>
13#include <dune/fem/gridpart/idgridpart/entity.hh>
14#include <dune/fem/gridpart/idgridpart/geometry.hh>
15#include <dune/fem/gridpart/idgridpart/indexset.hh>
16#include <dune/fem/gridpart/idgridpart/intersection.hh>
17#include <dune/fem/gridpart/idgridpart/intersectioniterator.hh>
18#include <dune/fem/gridpart/idgridpart/iterator.hh>
19
20namespace Dune
21{
22
23 namespace Fem
24 {
25
26 // Internal Forward Declarations
27 // -----------------------------
28
29 template< class HostGridPartImp >
30 class IdGridPart;
31
32
33 // IdGridPartTraits
34 // ----------------
35
36 template< class HostGridPartImp >
37 struct IdGridPartTraits
38 {
39 typedef IdGridPart< HostGridPartImp > GridPartType;
40
42 typedef MetaTwistUtility< typename HostGridPartImp :: TwistUtilityType > TwistUtilityType;
43
44 // Traits for dune-grid facades ("Gen-Gurke!")
45 struct GridFamily
46 {
47 typedef typename HostGridPartImp::ctype ctype;
48
49 static const int dimension = HostGridPartImp::dimension;
50 static const int dimensionworld = HostGridPartImp::dimensionworld;
51
52 struct Traits
53 {
54 typedef HostGridPartImp HostGridPartType;
55
56 struct EmptyData {};
57
58 // type of data passed to entities, intersections, and iterators
59 // for IdGridPart this is just an empty place holder
60 typedef EmptyData ExtraData;
61
62 template< int codim >
63 struct Codim
64 {
65 typedef Dune::Geometry< dimension - codim, dimensionworld, const GridFamily, IdGeometry > Geometry;
66 typedef Dune::Geometry< dimension - codim, dimension, const GridFamily, IdLocalGeometry > LocalGeometry;
67
69 typedef typename HostGridPartType::GridType::template Codim< codim >::EntitySeed EntitySeed;
70 };
71
72 typedef DeadIntersection< const GridFamily > IntersectionImplType;
73 typedef DeadIntersectionIterator< const GridFamily > IntersectionIteratorImplType;
74
77
80
82 };
83
84 template< int codim >
85 struct Codim
86 : public Traits::template Codim< codim >
87 {};
88
89 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
90 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
91
92 typedef typename Traits::HierarchicIterator HierarchicIterator;
93 };
94 typedef typename GridFamily::Traits::HostGridPartType HostGridPartType;
95
96 typedef typename HostGridPartType::GridType GridType;
97
98 typedef IdIndexSet< const GridFamily > IndexSetType;
99
100 static const PartitionIteratorType indexSetPartitionType = HostGridPartType::indexSetPartitionType;
101 static const InterfaceType indexSetInterfaceType = HostGridPartType::indexSetInterfaceType;
102
103 typedef IdIntersectionIterator < const GridFamily > IntersectionIteratorImplType;
104 typedef IdIntersection< const GridFamily > IntersectionImplType;
105 typedef IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > IntersectionIteratorType;
106
107 template< int codim >
108 struct Codim
109 {
110 typedef typename GridFamily::Traits::template Codim< codim >::Geometry GeometryType;
111 typedef typename GridFamily::Traits::template Codim< codim >::LocalGeometry LocalGeometryType;
112
113 typedef typename GridFamily::Traits::template Codim< codim >::Entity EntityType;
114 typedef typename GridFamily::Traits::template Codim< codim >::EntitySeed EntitySeedType;
115
116 template< PartitionIteratorType pitype >
117 struct Partition
118 {
119 typedef EntityIterator< codim, const GridFamily, IdIterator< codim, pitype, const GridFamily > > IteratorType;
120 };
121 };
122
123 typedef typename HostGridPartType::CommunicationType CommunicationType;
124
125 static const bool conforming = HostGridPartType::Traits::conforming;
126 };
127
128
129
130 // IdGridPart
131 // ----------
132
133 template< class HostGridPartImp >
134 class IdGridPart
135 : public GridPartDefault< IdGridPartTraits< HostGridPartImp > >
136 {
137 typedef IdGridPart< HostGridPartImp > ThisType;
138 typedef GridPartDefault< IdGridPartTraits< HostGridPartImp > > BaseType;
139
140 typedef typename IdGridPartTraits< HostGridPartImp >::GridFamily GridFamily;
141
142 public:
143 typedef typename GridFamily::Traits::HostGridPartType HostGridPartType;
144
145 typedef typename BaseType::GridType GridType;
146 typedef typename BaseType::IndexSetType IndexSetType;
147 typedef typename BaseType::IntersectionIteratorType IntersectionIteratorType;
148 typedef typename BaseType::IntersectionType IntersectionType;
149 typedef typename BaseType::CommunicationType CommunicationType;
150
151 template< int codim >
152 struct Codim
153 : public BaseType::template Codim< codim >
154 {};
155
156 explicit IdGridPart ( GridType &grid )
157 : BaseType( grid ),
158 hostGridPart_( grid ),
159 indexSet_( hostGridPart_.indexSet() )
160 {}
161
162 explicit IdGridPart ( const IdGridPart &other )
163 : BaseType( other ),
164 hostGridPart_( other.hostGridPart() ),
165 indexSet_( hostGridPart_.indexSet() )
166 {}
167
168 IdGridPart& operator= ( const IdGridPart& other ) = default;
169
170 explicit IdGridPart ( const HostGridPartType &hostGridPart )
171 : BaseType( const_cast< GridType& > ( hostGridPart.grid() ) ),
172 hostGridPart_( hostGridPart ),
173 indexSet_( hostGridPart_.indexSet() )
174 {}
175
176 const IndexSetType &indexSet () const
177 {
178 return indexSet_;
179 }
180
181 template< int codim >
182 typename Codim< codim >::IteratorType
183 begin () const
184 {
185 return begin< codim, InteriorBorder_Partition >();
186 }
187
188 template< int codim, PartitionIteratorType pitype >
189 typename Codim< codim >::template Partition< pitype >::IteratorType
190 begin () const
191 {
192 return IdIterator< codim, pitype, const GridFamily >( data(), hostGridPart().template begin< codim, pitype >() );
193 }
194
195 template< int codim >
196 typename Codim< codim >::IteratorType
197 end () const
198 {
199 return end< codim, InteriorBorder_Partition >();
200 }
201
202 template< int codim, PartitionIteratorType pitype >
203 typename Codim< codim >::template Partition< pitype >::IteratorType
204 end () const
205 {
206 return IdIterator< codim, pitype, const GridFamily >( data(), hostGridPart().template end< codim, pitype >() );
207 }
208
209 int level () const
210 {
211 return hostGridPart().level();
212 }
213
214 IntersectionIteratorType ibegin ( const typename Codim< 0 >::EntityType &entity ) const
215 {
216 return IdIntersectionIterator< const GridFamily >( data(), hostGridPart().ibegin( entity.impl().hostEntity() ) );
217 }
218
219 IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
220 {
221 return IdIntersectionIterator< const GridFamily >( data(), hostGridPart().iend( entity.impl().hostEntity() ) );
222 }
223
224 template< class DataHandle, class Data >
225 void communicate ( CommDataHandleIF< DataHandle, Data > &handle,
226 InterfaceType iftype, CommunicationDirection dir ) const
227 {
228 typedef CommDataHandleIF< DataHandle, Data > HostHandleType;
229 IdDataHandle< HostHandleType, GridFamily > handleWrapper( data(), handle );
230 hostGridPart().communicate( handleWrapper, iftype, dir );
231 }
232
233 template < class EntitySeed >
234 typename Codim< EntitySeed::codimension >::EntityType
235 entity ( const EntitySeed &seed ) const
236 {
237 typedef typename Codim< EntitySeed::codimension >::EntityType::Implementation EntityImp;
238 return EntityImp( data(), hostGridPart().entity( seed ) );
239 }
240
241 // convert a grid entity to a grid part entity ("Gurke!")
242 template< class Entity >
243 MakeableInterfaceObject< typename Codim< Entity::codimension >::EntityType >
244 convert ( const Entity &entity ) const
245 {
246 // make sure we have a grid entity
247 const auto& gridEntity = Fem::gridEntity( entity );
248
249 // create a grid part entity from a given grid entity
250 typedef typename Codim< Entity::codimension >::EntityType EntityType;
251 typedef typename EntityType::Implementation Implementation;
252 typedef MakeableInterfaceObject< EntityType > EntityObj;
253 // here, grid part information can be passed, if necessary
254 return EntityObj( Implementation( data(), hostGridPart().convert( gridEntity ) ) );
255 }
256
257 const HostGridPartType &hostGridPart () const { return hostGridPart_; }
258
259 HostGridPartType &hostGridPart () { return hostGridPart_; }
260
261 typedef typename GridFamily::Traits::ExtraData ExtraData;
262 ExtraData data () const { return ExtraData(); }
263
264 protected:
265 HostGridPartType hostGridPart_;
266 IndexSetType indexSet_;
267 };
268
269
270
271 // GridEntityAccess for IdEntity
272 // -----------------------------
273
274 template< int codim, int dim, class GridFamily >
275 struct GridEntityAccess< Dune::ExtendedEntity< codim, dim, GridFamily, IdEntity > >
276 {
278 typedef GridEntityAccess< typename EntityType::Implementation::HostEntityType > HostAccessType;
279 typedef typename HostAccessType::GridEntityType GridEntityType;
280
281 static const GridEntityType &gridEntity ( const EntityType &entity )
282 {
283 return HostAccessType::gridEntity( entity.impl().hostEntity() );
284 }
285 };
286
287
288
289 // EntitySearch for IdGridPart
290 // ---------------------------
291
292 template< class HostGridPart, int codim, PartitionIteratorType partition >
293 class EntitySearch< IdGridPart< HostGridPart >, codim, partition >
294 {
295 typedef EntitySearch< IdGridPart< HostGridPart >, codim, partition > ThisType;
296
297 public:
298 typedef IdGridPart< HostGridPart > GridPartType;
299 typedef typename GridPartType::ExtraData ExtraData;
300
301 typedef typename GridPartType::template Codim< codim >::EntityType EntityType;
302
303 typedef typename EntityType::Geometry::GlobalCoordinate GlobalCoordinateType;
304
305 explicit EntitySearch ( const GridPartType &gridPart )
306 : hostEntitySearch_( gridPart.hostGridPart() ),
307 data_( gridPart.data() )
308 {}
309
310 EntityType operator() ( const GlobalCoordinateType &x ) const
311 {
312 typedef typename EntityType::Implementation EntityImpl;
313 return EntityImpl( data_, hostEntitySearch_( x ) );
314 }
315
316 protected:
317 const EntitySearch< HostGridPart > hostEntitySearch_;
318 ExtraData data_;
319 };
320
321 } // namespace Fem
322
323} // namespace Dune
324
325#endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_HH
interface class for an iterator over grid entities
Definition: entityiterator.hh:32
Wrapper class for wrapped entities added a cast operator to the host entity.
Definition: extendedentity.hh:23
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: gridpart.hh:388
Traits::CommunicationType CommunicationType
Collective communication.
Definition: gridpart.hh:391
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:423
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:382
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: gridpart.hh:385
Traits::GridType GridType
Grid implementation.
Definition: gridpart.hh:380
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:292
Wrapper class for geometries.
Definition: geometry.hh:71
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
@ conforming
Output conforming data.
Definition: common.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)