dune-fem  2.4.1-rc
idgridpart.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_HH
2 #define DUNE_FEM_GRIDPART_IDGRIDPART_HH
3 
4 #if not DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
5 #error "Experimental grid extensions required for IdGridPart. Reconfigure with --enable-experimental-grid-extensions to enable IdGridPart."
6 #else
7 
8 #include <dune/grid/common/gridview.hh>
9 
22 
23 namespace Dune
24 {
25 
26  namespace Fem
27  {
28 
29  // Internal Forward Declarations
30  // -----------------------------
31 
32  template< class HostGridPart >
33  class IdGridPart;
34 
35 
36  // IdGridPartTraits
37  // ----------------
38 
39  template< class HostGridPart >
41  {
43 
46 
47  // Traits for dune-grid facades ("Gen-Gurke!")
48  struct GridFamily
49  {
50  typedef typename HostGridPart::ctype ctype;
51 
52  static const int dimension = HostGridPart::dimension;
53  static const int dimensionworld = HostGridPart::dimensionworld;
54 
55  struct Traits
56  {
57  typedef HostGridPart HostGridPartType;
58 
59  struct EmptyData {};
60 
61  // type of data passed to entities, intersections, and iterators
62  // for IdGridPart this is just an empty place holder
64 
65  template< int codim >
66  struct Codim
67  {
68  typedef Dune::Geometry< dimension - codim, dimensionworld, const GridFamily, IdGeometry > Geometry;
69  typedef Dune::Geometry< dimension - codim, dimension, const GridFamily, IdLocalGeometry > LocalGeometry;
70 
71  typedef Dune::Entity< codim, dimension, const GridFamily, IdEntity > Entity;
72  typedef typename HostGridPartType::GridType::template Codim< codim >::EntitySeed EntitySeed;
73  typedef Dune::EntityPointer< const GridFamily, DefaultEntityPointer< Entity > > EntityPointer;
74  };
75 
78 
79  typedef Dune::Intersection< const GridFamily, IntersectionImplType > LeafIntersection;
80  typedef Dune::Intersection< const GridFamily, IntersectionImplType > LevelIntersection;
81 
82  typedef Dune::IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > LeafIntersectionIterator;
83  typedef Dune::IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > LevelIntersectionIterator;
84 
85  typedef Dune::EntityIterator< 0, const GridFamily, DeadIterator< typename Codim< 0 >::Entity > > HierarchicIterator;
86  };
87 
88  template< int codim >
89  struct Codim
90  : public Traits::template Codim< codim >
91  {};
92 
95 
97  };
98 
99  typedef typename HostGridPart::GridType GridType;
100 
102 
103  static const PartitionIteratorType indexSetPartitionType = HostGridPart::indexSetPartitionType;
104  static const InterfaceType indexSetInterfaceType = HostGridPart::indexSetInterfaceType;
105 
108  typedef IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > IntersectionIteratorType;
109 
110  template< int codim >
111  struct Codim
112  {
113  typedef typename GridFamily::Traits::template Codim< codim >::Geometry GeometryType;
114  typedef typename GridFamily::Traits::template Codim< codim >::LocalGeometry LocalGeometryType;
115 
116  typedef typename GridFamily::Traits::template Codim< codim >::EntityPointer EntityPointerType;
117  typedef typename GridFamily::Traits::template Codim< codim >::Entity EntityType;
118 
119  typedef typename GridFamily::Traits::template Codim< codim >::EntitySeed EntitySeedType;
120 
121  template< PartitionIteratorType pitype >
122  struct Partition
123  {
124  typedef EntityIterator< codim, const GridFamily, IdIterator< codim, pitype, const GridFamily > > IteratorType;
125  };
126  };
127 
128  typedef typename HostGridPart::CollectiveCommunicationType CollectiveCommunicationType;
129 
130  static const bool conforming = HostGridPart::Traits::conforming;
131  };
132 
133 
134 
135  // IdGridPart
136  // ----------
137 
138  template< class HostGridPart >
139  class IdGridPart
140  : public GridPartInterface< IdGridPartTraits< HostGridPart > >
141  {
142  typedef IdGridPart< HostGridPart > ThisType;
144 
146 
147  public:
148  typedef HostGridPart HostGridPartType;
149 
150  typedef typename BaseType::GridType GridType;
155 
156  template< int codim >
157  struct Codim
158  : public BaseType::template Codim< codim >
159  {};
160 
161  explicit IdGridPart ( GridType &grid )
162  : hostGridPart_( grid ),
163  indexSet_( hostGridPart_.indexSet() )
164  {}
165 
166  explicit IdGridPart ( const HostGridPartType &hostGridPart )
167  : hostGridPart_( hostGridPart ),
168  indexSet_( hostGridPart_.indexSet() )
169  {}
170 
171  const GridType &grid () const
172  {
173  return hostGridPart().grid();
174  }
175 
176  GridType &grid ()
177  {
178  return hostGridPart_.grid();
179  }
180 
181  const IndexSetType &indexSet () const
182  {
183  return indexSet_;
184  }
185 
186  template< int codim >
188  begin () const
189  {
190  return begin< codim, InteriorBorder_Partition >();
191  }
192 
193  template< int codim, PartitionIteratorType pitype >
194  typename Codim< codim >::template Partition< pitype >::IteratorType
195  begin () const
196  {
197  return IdIterator< codim, pitype, const GridFamily >( data(), hostGridPart().template begin< codim, pitype >() );
198  }
199 
200  template< int codim >
202  end () const
203  {
204  return end< codim, InteriorBorder_Partition >();
205  }
206 
207  template< int codim, PartitionIteratorType pitype >
208  typename Codim< codim >::template Partition< pitype >::IteratorType
209  end () const
210  {
211  return IdIterator< codim, pitype, const GridFamily >( data(), hostGridPart().template end< codim, pitype >() );
212  }
213 
214  int level () const
215  {
216  return hostGridPart().level();
217  }
218 
219  IntersectionIteratorType ibegin ( const typename Codim< 0 >::EntityType &entity ) const
220  {
221  return IdIntersectionIterator< const GridFamily >( data(), hostGridPart().ibegin( entity.impl().hostEntity() ) );
222  }
223 
224  IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
225  {
226  return IdIntersectionIterator< const GridFamily >( data(), hostGridPart().iend( entity.impl().hostEntity() ) );
227  }
228 
229  int boundaryId ( const IntersectionType &intersection ) const
230  {
231  return hostGridPart().boundaryId( intersection.impl().hostIntersection() );
232  }
233 
234  const CollectiveCommunicationType &comm () const { return hostGridPart().comm(); }
235 
236  template< class DataHandle, class Data >
237  void communicate ( CommDataHandleIF< DataHandle, Data > &handle,
238  InterfaceType iftype, CommunicationDirection dir ) const
239  {
240  typedef CommDataHandleIF< DataHandle, Data > HostHandleType;
241  IdDataHandle< HostHandleType, GridFamily > handleWrapper( data(), handle );
242  hostGridPart().communicate( handleWrapper, iftype, dir );
243  }
244 
245  template < class EntitySeed >
247  entity ( const EntitySeed &seed ) const
248  {
250  return EntityImp( data(), hostGridPart().entity( seed ) );
251  }
252 
253  // convert a grid entity to a grid part entity ("Gurke!")
254  template< class Entity >
255  MakeableInterfaceObject< typename Codim< Entity::codimension >::EntityType >
256  convert ( const Entity &entity ) const
257  {
258  // create a grid part entity from a given grid entity
259  typedef typename Codim< Entity::codimension >::EntityType EntityType;
260  typedef typename EntityType::Implementation Implementation;
261  typedef MakeableInterfaceObject< EntityType > EntityObj;
262  // here, grid part information can be passed, if necessary
263  return EntityObj( Implementation( entity ) );
264  }
265 
266  const HostGridPartType &hostGridPart () const { return hostGridPart_; }
267 
269  ExtraData data () const { return ExtraData(); }
270 
271  protected:
272  HostGridPartType hostGridPart_;
273  IndexSetType indexSet_;
274  };
275 
276 
277 
278  // GridEntityAccess for IdEntity
279  // -----------------------------
280 
281  template< int codim, int dim, class GridFamily >
282  struct GridEntityAccess< Dune::Entity< codim, dim, GridFamily, IdEntity > >
283  {
284  typedef Dune::Entity< codim, dim, GridFamily, IdEntity > EntityType;
286  typedef typename HostAccessType::GridEntityType GridEntityType;
287 
288  static const GridEntityType &gridEntity ( const EntityType &entity )
289  {
290  return HostAccessType::gridEntity( entity.impl().hostEntity() );
291  }
292  };
293 
294 
295 
296  // EntitySearch for IdGridPart
297  // ---------------------------
298 
299  template< class HostGridPart, int codim, PartitionIteratorType partition >
300  class EntitySearch< IdGridPart< HostGridPart >, codim, partition >
301  {
302  typedef EntitySearch< IdGridPart< HostGridPart >, codim, partition > ThisType;
303 
304  public:
307 
308  typedef typename GridPartType::template Codim< codim >::EntityType EntityType;
309 
310  typedef typename EntityType::Geometry::GlobalCoordinate GlobalCoordinateType;
311 
312  explicit EntitySearch ( const GridPartType &gridPart )
313  : hostEntitySearch_( gridPart.hostGridPart() ),
314  data_( gridPart.data() )
315  {}
316 
317  EntityType operator() ( const GlobalCoordinateType &x ) const
318  {
319  typedef typename EntityType::Implementation EntityImpl;
320  return EntityImpl( data_, hostEntitySearch_( x ) );
321  }
322 
323  protected:
325  ExtraData data_;
326  };
327 
328  } // namespace Fem
329 
330 } // namespace Dune
331 
332 #endif // #if not DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
333 #endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_HH
ExtraData data() const
Definition: idgridpart.hh:269
GridEntityAccess< typename EntityType::Implementation::HostEntityType > HostAccessType
Definition: idgridpart.hh:285
Definition: gridpart/idgridpart/capabilities.hh:23
Codim< codim >::IteratorType begin() const
Definition: idgridpart.hh:188
Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
Definition: idgridpart.hh:247
Dune::Geometry< dimension-codim, dimension, const GridFamily, IdLocalGeometry > LocalGeometry
Definition: idgridpart.hh:69
IndexSetType indexSet_
Definition: idgridpart.hh:273
Codim< codim >::template Partition< pitype >::IteratorType begin() const
Definition: idgridpart.hh:195
HostGridPartType hostGridPart_
Definition: idgridpart.hh:272
const IndexSetType & indexSet() const
Definition: idgridpart.hh:181
Definition: idgridpart/intersection.hh:20
Traits::CollectiveCommunicationType CollectiveCommunicationType
Collective communication.
Definition: gridpart.hh:96
Definition: gridpart.hh:394
HostGridPart::GridType GridType
Definition: idgridpart.hh:99
IdGridPart< HostGridPart > GridPartType
Definition: idgridpart.hh:42
IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > IntersectionIteratorType
Definition: idgridpart.hh:108
EntityType::Geometry::GlobalCoordinate GlobalCoordinateType
Definition: idgridpart.hh:310
Dune::Intersection< const GridFamily, IntersectionImplType > LeafIntersection
Definition: idgridpart.hh:79
void communicate(CommDataHandleIF< DataHandle, Data > &handle, InterfaceType iftype, CommunicationDirection dir) const
Definition: idgridpart.hh:237
MakeableInterfaceObject< typename Codim< Entity::codimension >::EntityType > convert(const Entity &entity) const
Definition: idgridpart.hh:256
static const int dimension
Definition: idgridpart.hh:52
Definition: idgridpart/datahandle.hh:21
Traits::LevelIntersectionIterator LevelIntersectionIterator
Definition: idgridpart.hh:94
IdGridPart< HostGridPart > GridPartType
Definition: idgridpart.hh:305
BaseType::IntersectionType IntersectionType
Definition: idgridpart.hh:153
GridType & grid()
Definition: idgridpart.hh:176
DeadIntersectionIterator< const GridFamily > IntersectionIteratorImplType
Definition: idgridpart.hh:77
BaseType::IndexSetType IndexSetType
Definition: idgridpart.hh:151
MetaTwistUtility< typename HostGridPart::TwistUtilityType > TwistUtilityType
type of twist utility
Definition: idgridpart.hh:45
IdIndexSet< const GridFamily > IndexSetType
Definition: idgridpart.hh:101
BaseType::CollectiveCommunicationType CollectiveCommunicationType
Definition: idgridpart.hh:154
Definition: deaditerator.hh:157
Dune::Intersection< const GridFamily, IntersectionImplType > LevelIntersection
Definition: idgridpart.hh:80
GridPartType::ExtraData ExtraData
Definition: idgridpart.hh:306
static const GridEntityType & gridEntity(const EntityType &entity)
Definition: idgridpart.hh:288
IdGridPart(const HostGridPartType &hostGridPart)
Definition: idgridpart.hh:166
Definition: entitysearch.hh:131
HostGridPart HostGridPartType
Definition: idgridpart.hh:57
Traits::IntersectionIteratorType IntersectionIteratorType
type of IntersectionIterator
Definition: gridpart.hh:108
GridFamily::Traits::template Codim< codim >::Entity EntityType
Definition: idgridpart.hh:117
const CollectiveCommunicationType & comm() const
Definition: idgridpart.hh:234
GridFamily::Traits::template Codim< codim >::LocalGeometry LocalGeometryType
Definition: idgridpart.hh:114
Dune::IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > LeafIntersectionIterator
Definition: idgridpart.hh:82
Definition: idgridpart/indexset.hh:24
Codim< codim >::IteratorType end() const
Definition: idgridpart.hh:202
HostAccessType::GridEntityType GridEntityType
Definition: idgridpart.hh:286
Dune::EntityIterator< 0, const GridFamily, DeadIterator< typename Codim< 0 >::Entity > > HierarchicIterator
Definition: idgridpart.hh:85
HostGridPart::ctype ctype
Definition: idgridpart.hh:50
EmptyData ExtraData
Definition: idgridpart.hh:63
EntitySearch(const GridPartType &gridPart)
Definition: idgridpart.hh:312
Definition: idgridpart/iterator.hh:20
Dune::IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > LevelIntersectionIterator
Definition: idgridpart.hh:83
const EntitySearch< HostGridPart > hostEntitySearch_
Definition: idgridpart.hh:324
Definition: coordinate.hh:4
IntersectionIteratorType::Intersection IntersectionType
type of Intersection
Definition: gridpart.hh:111
Dune::Entity< codim, dim, GridFamily, IdEntity > EntityType
Definition: idgridpart.hh:284
Dune::Entity< codim, dimension, const GridFamily, IdEntity > Entity
Definition: idgridpart.hh:71
const GridType & grid() const
Definition: idgridpart.hh:171
Definition: idgridpart/geometry.hh:17
Codim< codim >::template Partition< pitype >::IteratorType end() const
Definition: idgridpart.hh:209
Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition: idgridpart.hh:93
HostGridPartType::GridType::template Codim< codim >::EntitySeed EntitySeed
Definition: idgridpart.hh:72
GridFamily::Traits::template Codim< codim >::EntityPointer EntityPointerType
Definition: idgridpart.hh:116
Definition: idgridpart.hh:111
HostGridPart HostGridPartType
Definition: idgridpart.hh:148
Definition: deaditerator.hh:48
GridFamily::Traits::template Codim< codim >::Geometry GeometryType
Definition: idgridpart.hh:113
IntersectionIteratorType iend(const typename Codim< 0 >::EntityType &entity) const
Definition: idgridpart.hh:224
Definition: idgridpart/geometry.hh:18
const GridEntityAccess< Entity >::GridEntityType & gridEntity(const Entity &entity)
Definition: gridpart.hh:410
static const bool conforming
Definition: idgridpart.hh:130
IdGridPart(GridType &grid)
Definition: idgridpart.hh:161
MetaTwistUtility forwards the twist calls to the TwistUtility of the underlying HostTwistUtility.
Definition: metatwistutility.hh:21
int level() const
Definition: idgridpart.hh:214
Definition: idgridpart/intersectioniterator.hh:21
Traits::GridType GridType
type of Grid implementation
Definition: gridpart.hh:90
const HostGridPartType & hostGridPart() const
Definition: idgridpart.hh:266
BaseType::IntersectionIteratorType IntersectionIteratorType
Definition: idgridpart.hh:152
IdIntersection< const GridFamily > IntersectionImplType
Definition: idgridpart.hh:107
IntersectionIteratorType ibegin(const typename Codim< 0 >::EntityType &entity) const
Definition: idgridpart.hh:219
Definition: idgridpart.hh:40
Interface for the GridPart classes A GridPart class allows to access only a specific subset of a grid...
Definition: gridpart.hh:75
GridFamily::Traits::template Codim< codim >::EntitySeed EntitySeedType
Definition: idgridpart.hh:119
Traits::HierarchicIterator HierarchicIterator
Definition: idgridpart.hh:96
GridPartType::template Codim< codim >::EntityType EntityType
Definition: idgridpart.hh:308
static const InterfaceType indexSetInterfaceType
Definition: idgridpart.hh:104
DeadIntersection< const GridFamily > IntersectionImplType
Definition: idgridpart.hh:76
static const PartitionIteratorType indexSetPartitionType
Definition: idgridpart.hh:103
IdIntersectionIterator< const GridFamily > IntersectionIteratorImplType
Definition: idgridpart.hh:106
Definition: idgridpart.hh:157
HostGridPart::CollectiveCommunicationType CollectiveCommunicationType
Definition: idgridpart.hh:128
int boundaryId(const IntersectionType &intersection) const
Definition: idgridpart.hh:229
Dune::Geometry< dimension-codim, dimensionworld, const GridFamily, IdGeometry > Geometry
Definition: idgridpart.hh:68
Definition: idgridpart.hh:48
EntityIterator< codim, const GridFamily, IdIterator< codim, pitype, const GridFamily > > IteratorType
Definition: idgridpart.hh:124
GridFamily::Traits::ExtraData ExtraData
Definition: idgridpart.hh:268
static const int dimensionworld
Definition: idgridpart.hh:53
BaseType::GridType GridType
Definition: idgridpart.hh:150
Dune::EntityPointer< const GridFamily, DefaultEntityPointer< Entity > > EntityPointer
Definition: idgridpart.hh:73