dune-fem  2.4.1-rc
gridpart.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
2 #define DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
3 
4 //- dune-common includes
5 #include <dune/common/bartonnackmanifcheck.hh>
6 #include <dune/common/deprecated.hh>
7 
8 //- dune-grid includes
9 #include <dune/grid/common/datahandleif.hh>
10 #include <dune/grid/common/entity.hh>
11 #include <dune/grid/common/grid.hh>
12 
13 //- dune-fem includes
18 
19 namespace Dune
20 {
21 
22  namespace Fem
23  {
24 
67  template< class GridPartTraits >
76  : public GridPartPolicies< GridPartTraits >
77  {
79 
81 
82  public:
84  typedef GridPartTraits Traits;
85 
87  typedef typename Traits::GridPartType GridPartType;
88 
90  typedef typename Traits::GridType GridType;
91 
93  typedef typename Traits::IndexSetType IndexSetType;
94 
96  typedef typename Traits::CollectiveCommunicationType CollectiveCommunicationType;
97 
99  typedef typename Traits::TwistUtilityType TwistUtilityType;
100 
102  static const PartitionIteratorType indexSetPartitionType
103  = Traits::indexSetPartitionType;
104  static const InterfaceType indexSetInterfaceType
105  = Traits::indexSetInterfaceType;
106 
108  typedef typename Traits::IntersectionIteratorType IntersectionIteratorType;
109 
111  typedef typename IntersectionIteratorType::Intersection IntersectionType;
112 
113  typedef typename PoliciesType::GridViewType GridViewType;
114 
115  typedef typename GridType::ctype ctype;
116 
117  static const int dimension = GridType::dimension;
118  static const int dimensionworld = GridType::dimensionworld;
119 
120  template< int codim >
121  struct Codim
122  {
123  typedef typename Traits::template Codim< codim >::GeometryType GeometryType;
124  typedef typename Traits::template Codim< codim >::LocalGeometryType LocalGeometryType;
125 
126  typedef typename Traits::template Codim< codim >::EntityPointerType EntityPointerType;
127  typedef typename Traits::template Codim< codim >::EntityType EntityType;
128 
129  typedef typename Traits::template Codim< codim >::EntitySeedType EntitySeedType;
130 
131  template< PartitionIteratorType pitype >
132  struct Partition
133  {
134  typedef typename Traits::template Codim< codim >::template Partition< pitype >::IteratorType
136  };
137 
139  };
140 
141  public:
143  const GridType &grid () const
144  {
145  CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
146  return asImp().grid();
147  }
149  GridType &grid ()
150  {
151  CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
152  return asImp().grid();
153  }
154 
156  GridViewType gridView () const
157  DUNE_DEPRECATED_MSG("gridPart.gridView() is deprecated, use direct cast to GridPart::GridViewType instead")
158  {
159  return static_cast< GridViewType >( asImp() );
160  }
161 
163  const IndexSetType& indexSet() const
164  {
165  CHECK_INTERFACE_IMPLEMENTATION((asImp().indexSet()));
166  return asImp().indexSet();
167  }
168 
173  template< int codim >
175  begin () const
176  {
177  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template begin< codim >()) );
178  return asImp().template begin< codim >();
179  }
180 
186  template< int codim, PartitionIteratorType pitype >
187  typename Codim< codim >::template Partition< pitype >::IteratorType
188  begin () const
189  {
190  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template begin< codim, pitype >()) );
191  return asImp().template begin< codim, pitype >();
192  }
193 
198  template< int codim >
200  end () const
201  {
202  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template end< codim >()) );
203  return asImp().template end< codim >();
204  }
205 
211  template< int codim, PartitionIteratorType pitype >
212  typename Codim< codim >::template Partition< pitype >::IteratorType
213  end () const
214  {
215  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template end< codim, pitype >()) );
216  return asImp().template end< codim, pitype >();
217  }
218 
220  int level () const
221  {
222  CHECK_INTERFACE_IMPLEMENTATION((asImp().level()));
223  return asImp().level();
224  }
225 
227  IntersectionIteratorType
228  ibegin ( const typename Codim< 0 >::EntityType &entity ) const
229  {
230  CHECK_INTERFACE_IMPLEMENTATION( (asImp().ibegin( entity )) );
231  return asImp().ibegin( entity );
232  }
233 
235  IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
236  {
237  CHECK_INTERFACE_IMPLEMENTATION( (asImp().iend( entity )) );
238  return asImp().iend( entity );
239  }
240 
242  int boundaryId ( const IntersectionType &intersection ) const
243  {
244  CHECK_INTERFACE_IMPLEMENTATION( asImp().boundaryId( intersection ) );
245  return asImp().boundaryId( intersection );
246  }
247 
249  const CollectiveCommunicationType &comm () const
250  {
251  CHECK_INTERFACE_IMPLEMENTATION( asImp().comm() );
252  return asImp().comm();
253  }
254 
256  template< class DataHandleImp, class DataType >
257  void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
258  InterfaceType iftype, CommunicationDirection dir ) const
259  {
260  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION( (asImp().communicate( data, iftype, dir )) );
261  }
262 
264  template < class EntitySeed >
266  entity ( const EntitySeed &seed ) const
267  {
268  CHECK_INTERFACE_IMPLEMENTATION( asImp().entity( seed ) );
269  return asImp().entity( seed );
270  }
271 
278  template <class Entity>
279  const Entity& convert( const Entity& entity ) const
280  {
281  CHECK_INTERFACE_IMPLEMENTATION( asImp().convert( entity ) );
282  return asImp().convert( entity );
283  }
284 
288  int sequence () const
289  {
290  CHECK_INTERFACE_IMPLEMENTATION( asImp().sequence() );
291  return asImp().sequence() ;
292  }
293 
294  protected:
297 
298  private:
299  GridPartType &asImp () { return static_cast< GridPartType & >( *this ); }
300  const GridPartType &asImp () const { return static_cast< const GridPartType & >( *this ); }
301  };
302 
303 
304 
306  template< class GridPartTraits >
308  : public GridPartInterface< GridPartTraits >
309  {
311 
312  public:
314  typedef GridPartTraits Traits;
316  typedef typename Traits::GridType GridType;
319 
322 
325  protected:
326  GridType &grid_;
327  DofManagerType &dofManager_;
328 
329  protected:
331  GridPartDefault ( GridType &grid )
332  : grid_( grid ),
333  dofManager_( DofManagerType :: instance( grid_ ) )
334  {}
335 
336  GridPartDefault ( const ThisType &other )
337  : grid_( other.grid_ ),
338  dofManager_( DofManagerType :: instance( grid_ ) )
339  {}
340 
342  {}
343 
344  public:
346  const GridType &grid () const { return grid_; }
347 
349  GridType &grid () { return grid_; }
350 
352  const CollectiveCommunicationType &comm () const
353  {
354  return grid().comm();
355  }
356 
364  template < class EntitySeed >
365  typename Traits::template Codim< EntitySeed::codimension >::EntityType
366  entity ( const EntitySeed &seed ) const
367  {
368  return grid().entity( seed );
369  }
370 
375  template <class Entity>
376  const Entity& convert( const Entity& entity ) const
377  {
378  return entity;
379  }
380 
385  int sequence () const
386  {
387  return dofManager_.sequence();
388  }
389  };
390 
393  template< class Entity >
395 
396  template< int codim, int dim, class Grid, template< int, int, class > class EntityImpl >
397  struct GridEntityAccess< Dune::Entity< codim, dim, Grid, EntityImpl > >
398  {
399  typedef Dune::Entity< codim, dim, Grid, EntityImpl > EntityType;
400  typedef Dune::Entity< codim, dim, Grid, EntityImpl > GridEntityType;
401 
402  static const GridEntityType &gridEntity ( const EntityType &entity )
403  {
404  return entity;
405  }
406  };
407 
408  template< class Entity >
410  gridEntity ( const Entity &entity )
411  {
413  }
414 
415  } // namespace Fem
416 
417 } // namespace Dune
418 
419 #endif // #define DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
Default implementation for the GridPart classes.
Definition: gridpart.hh:307
Codim< codim >::template Partition< pitype >::IteratorType end() const
obtain end iterator for the given partition
Definition: gridpart.hh:213
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:318
GridType & grid_
Definition: gridpart.hh:326
Traits::GridType GridType
Grid implementation.
Definition: gridpart.hh:316
GridViewType gridView() const
convert grid part into a dune grid view
Definition: gridpart.hh:156
const CollectiveCommunicationType & comm() const
obtain collective communication object
Definition: gridpart.hh:352
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:346
Traits::CollectiveCommunicationType CollectiveCommunicationType
Collective communication.
Definition: gridpart.hh:96
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:257
Definition: gridpart.hh:394
Codim< codim >::IteratorType end() const
obtain end iterator for the interior-border partition
Definition: gridpart.hh:200
GridType::ctype ctype
Definition: gridpart.hh:115
static const InterfaceType indexSetInterfaceType
Definition: gridpart.hh:105
Traits::CollectiveCommunicationType CollectiveCommunicationType
Collective communication.
Definition: gridpart.hh:321
Traits::template Codim< codim >::GeometryType GeometryType
Definition: gridpart.hh:123
IntersectionIteratorType ibegin(const typename Codim< 0 >::EntityType &entity) const
ibegin of corresponding intersection iterator for given entity
Definition: gridpart.hh:228
const Entity & convert(const Entity &entity) const
convert the grid&#39;s entity to a grid part entity Usually the parameter is GridType :: Codim< codim > :...
Definition: gridpart.hh:279
Traits::template Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:366
GridType::CollectiveCommunication CollectiveCommunicationType
Definition: adaptiveleafgridpart.hh:264
const CollectiveCommunicationType & comm() const
obtain collective communication object
Definition: gridpart.hh:249
Definition: datacollector.hh:45
Traits::GridPartType GridPartType
Type of the implementation.
Definition: gridpart.hh:87
Partition< InteriorBorder_Partition >::IteratorType IteratorType
Definition: gridpart.hh:138
Definition: gridpart.hh:121
int sequence() const
return sequence number to update structures depending on the grid part
Definition: gridpart.hh:288
const IndexSetType & indexSet() const
Returns reference to index set of the underlying grid.
Definition: gridpart.hh:163
static const int dimension
Definition: gridpart.hh:117
Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:266
GridPartDefault(const ThisType &other)
Definition: gridpart.hh:336
GridPartTraits Traits
Type of the Traits.
Definition: gridpart.hh:314
Codim< codim >::IteratorType begin() const
obtain begin iterator for the interior-border partition
Definition: gridpart.hh:175
Dune::Entity< codim, dim, Grid, EntityImpl > GridEntityType
Definition: gridpart.hh:400
Traits::template Codim< codim >::EntityPointerType EntityPointerType
Definition: gridpart.hh:126
Codim< codim >::template Partition< pitype >::IteratorType begin() const
obtain begin iterator for the given partition
Definition: gridpart.hh:188
Traits::template Codim< codim >::EntitySeedType EntitySeedType
Definition: gridpart.hh:129
Traits::IntersectionIteratorType IntersectionIteratorType
type of IntersectionIterator
Definition: gridpart.hh:108
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:143
GridType & grid()
Returns reference to the underlying grid.
Definition: gridpart.hh:349
Traits::TwistUtilityType TwistUtilityType
Twist utility type.
Definition: gridpart.hh:99
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize...
Definition: dofmanager.hh:1047
Definition: coordinate.hh:4
IntersectionIteratorType::Intersection IntersectionType
type of Intersection
Definition: gridpart.hh:111
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:93
static const PartitionIteratorType indexSetPartitionType
Maximum Partition type, the index set provides indices for.
Definition: gridpart.hh:103
GridPartDefault(GridType &grid)
constructor
Definition: gridpart.hh:331
IntersectionIteratorType iend(const typename Codim< 0 >::EntityType &entity) const
iend of corresponding intersection iterator for given entity
Definition: gridpart.hh:235
Traits::template Codim< codim >::LocalGeometryType LocalGeometryType
Definition: gridpart.hh:124
DofManager< GridType > DofManagerType
type of DofManager
Definition: gridpart.hh:324
GridPartInterface()
do not create explicit instances of this class
Definition: gridpart.hh:296
const GridEntityAccess< Entity >::GridEntityType & gridEntity(const Entity &entity)
Definition: gridpart.hh:410
Traits::template Codim< codim >::template Partition< pitype >::IteratorType IteratorType
Definition: gridpart.hh:135
static const GridEntityType & gridEntity(const EntityType &entity)
Definition: gridpart.hh:402
Definition: policies.hh:21
Traits::GridType GridType
type of Grid implementation
Definition: gridpart.hh:90
GridPartTraits Traits
Type of the Traits.
Definition: gridpart.hh:84
~GridPartDefault()
Definition: gridpart.hh:341
int boundaryId(const IntersectionType &intersection) const
return boundary if given an intersection
Definition: gridpart.hh:242
Interface for the GridPart classes A GridPart class allows to access only a specific subset of a grid...
Definition: gridpart.hh:75
Grid GridType
type of the grid
Definition: adaptiveleafgridpart.hh:256
DofManagerType & dofManager_
Definition: gridpart.hh:327
PoliciesType::GridViewType GridViewType
Definition: gridpart.hh:113
Dune::Entity< codim, dim, Grid, EntityImpl > EntityType
Definition: gridpart.hh:399
int sequence() const
return sequence number to update structures depending on the grid part
Definition: gridpart.hh:385
Definition: adaptiveleafindexset.hh:33
const Entity & convert(const Entity &entity) const
convert the grid&#39;s entity to a grid part entity Usually the parameter is GridType :: Codim< codim > :...
Definition: gridpart.hh:376
GridType & grid()
Returns reference to the underlying grid.
Definition: gridpart.hh:149
static const int dimensionworld
Definition: gridpart.hh:118
int level() const
Level of the grid part.
Definition: gridpart.hh:220
Traits::template Codim< codim >::EntityType EntityType
Definition: gridpart.hh:127