00001 #ifndef DUNE_GRIDPART_HH
00002 #define DUNE_GRIDPART_HH
00003
00004 #warning "GridParts are deprecated. Use GridViews instead."
00005 #warning "For more information see dune/grid/common/gridview.hh."
00006
00007
00008
00009
00010 #include <dune/grid/common/grid.hh>
00011 #include <dune/grid/common/defaultindexsets.hh>
00012 #include <dune/grid/common/datahandleif.hh>
00013
00014 #include <dune/common/bartonnackmanifcheck.hh>
00015 #include <dune/common/deprecated.hh>
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 namespace Dune {
00061
00062
00063
00064
00065
00066
00067
00068 template <class GridImp, PartitionIteratorType pitype>
00069 class LevelGridPartTraits;
00070 template <class GridImp, PartitionIteratorType pitype>
00071 class LeafGridPartTraits;
00072 template <class GridImp, PartitionIteratorType pitype>
00073 class HierarchicGridPartTraits;
00074
00075
00076
00077
00078
00079
00080
00081
00082 template <class GridPartTraits>
00083 class GridPartInterface {
00084 public:
00086 typedef GridPartTraits Traits;
00087
00089 typedef typename GridPartTraits::GridPartType GridPartType;
00090
00091
00093 typedef typename GridPartTraits::GridType GridType;
00094
00096 typedef typename GridPartTraits::IndexSetType IndexSetType;
00097
00099 typedef typename GridPartTraits::IntersectionIteratorType IntersectionIteratorType;
00100
00102 typedef typename GridType::template Codim<0>::Entity EntityCodim0Type;
00103
00105 enum { conforming = GridPartTraits :: conforming };
00106 public:
00108 const GridType & grid () const
00109 {
00110 CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
00111 return asImp().grid();
00112 }
00114 GridType & grid ()
00115 {
00116 CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
00117 return asImp().grid();
00118 }
00119
00121 const IndexSetType& indexSet() const
00122 {
00123 CHECK_INTERFACE_IMPLEMENTATION((asImp().indexSet()));
00124 return asImp().indexSet();
00125 }
00126
00130 template <int cd>
00131 typename GridPartTraits::template Codim<cd>::IteratorType
00132 begin() const
00133 {
00134 CHECK_INTERFACE_IMPLEMENTATION((asImp().template begin<cd>()));
00135 return asImp().template begin<cd>();
00136 }
00137
00141 template <int cd>
00142 typename GridPartTraits::template Codim<cd>::IteratorType
00143 end() const
00144 {
00145 CHECK_INTERFACE_IMPLEMENTATION((asImp().template end<cd>()));
00146 return asImp().template end<cd>();
00147 }
00148
00150 int level() const
00151 {
00152 CHECK_INTERFACE_IMPLEMENTATION((asImp().level()));
00153 return asImp().level();
00154 }
00155
00157 IntersectionIteratorType ibegin(const EntityCodim0Type & en) const
00158 {
00159 CHECK_INTERFACE_IMPLEMENTATION((asImp().ibegin(en)));
00160 return asImp().ibegin(en);
00161 }
00162
00164 IntersectionIteratorType iend(const EntityCodim0Type & en) const
00165 {
00166 CHECK_INTERFACE_IMPLEMENTATION((asImp().iend(en)));
00167 return asImp().iend(en);
00168 }
00169
00171 template <class DataHandleImp,class DataType>
00172 void communicate(CommDataHandleIF<DataHandleImp,DataType> & data,
00173 InterfaceType iftype, CommunicationDirection dir) const
00174 {
00175 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().communicate(data,iftype,dir)));
00176 }
00177
00178 protected:
00180 GridPartInterface () {}
00181
00182 private:
00183
00184 GridPartType& asImp() {
00185 return static_cast<GridPartType&>(*this);
00186 }
00187
00188
00189 const GridPartType& asImp() const {
00190 return static_cast<const GridPartType&>(*this);
00191 }
00192 };
00193
00194
00195 template <class GridPartTraits>
00196 class GridPartDefault :
00197 public GridPartInterface<GridPartTraits> {
00198 public:
00200 typedef typename GridPartTraits::GridType GridType;
00202 typedef typename GridPartTraits::IndexSetType IndexSetType;
00203
00204 protected:
00206 GridPartDefault(GridType& grid, const IndexSetType& iset) :
00207 GridPartInterface<GridPartTraits>(),
00208 grid_(grid),
00209 iset_(iset) {}
00210
00211 ~GridPartDefault() {}
00212
00213 public:
00215 const GridType& grid() const { return grid_; }
00216
00218 GridType& grid() { return grid_; }
00219
00221 const IndexSetType& indexSet() const { return iset_; }
00222
00223 private:
00224 GridType& grid_;
00225 const IndexSetType& iset_;
00226 };
00227
00228
00229 template <class GridImp, PartitionIteratorType pitype = Interior_Partition>
00230 class LevelGridPart :
00231 public GridPartDefault<LevelGridPartTraits<GridImp,pitype> > {
00232 public:
00233
00235 typedef LevelGridPartTraits<GridImp,pitype> Traits;
00237 typedef typename Traits::GridType GridType;
00239 typedef typename Traits::IndexSetType IndexSetType;
00240
00242 typedef typename Traits::IntersectionType IntersectionType ;
00243
00245 typedef typename Traits::IntersectionIteratorType IntersectionIteratorType ;
00246
00248 template <int cd>
00249 struct Codim {
00252 typedef typename Traits::template Codim<cd>::IteratorType IteratorType;
00253 };
00254
00256 enum { conforming = Traits :: conforming };
00257 private:
00258 typedef typename GridType::template Codim<0>::Entity EntityCodim0Type;
00259
00260 public:
00261
00263 LevelGridPart(GridType& grid, int level ) :
00264 GridPartDefault<Traits>(grid,isetWrapper_),
00265 isetWrapper_(grid,level),
00266 level_(level) {}
00267
00269 LevelGridPart(const GridType& grid) :
00270 GridPartDefault<Traits>(grid,isetWrapper_),
00271 isetWrapper_(grid,grid.maxLevel()),
00272 level_(grid.maxLevel()) {}
00273
00275 LevelGridPart(const LevelGridPart& other) :
00276 GridPartDefault<Traits>(other.grid_,isetWrapper_),
00277 isetWrapper_(other.grid_,other.level_),
00278 level_(other.level_) {}
00279
00281 template <int cd>
00282 typename Traits::template Codim<cd>::IteratorType begin() const {
00283 return this->grid().template lbegin<cd,pitype>(level_);
00284 }
00285
00287 template <int cd>
00288 typename Traits::template Codim<cd>::IteratorType end() const {
00289 return this->grid().template lend<cd,pitype>(level_);
00290 }
00291
00293 IntersectionIteratorType ibegin(const EntityCodim0Type & en) const
00294 {
00295 return en.ilevelbegin();
00296 }
00297
00299 IntersectionIteratorType iend(const EntityCodim0Type & en) const
00300 {
00301 return en.ilevelend();
00302 }
00303
00305 int level() const { return level_; }
00306
00308 template <class DataHandleImp,class DataType>
00309 void communicate(CommDataHandleIF<DataHandleImp,DataType> & data,
00310 InterfaceType iftype, CommunicationDirection dir) const
00311 {
00312 this->grid().communicate(data,iftype,dir,level());
00313 }
00314
00315 private:
00317 IndexSetType isetWrapper_;
00318 const int level_;
00319 };
00320
00321
00322 template <class GridImp, PartitionIteratorType pitype>
00323 struct LevelGridPartTraits {
00324
00326 typedef GridImp GridType;
00327
00329 typedef LevelGridPart<GridImp,pitype> GridPartType;
00330
00332 typedef WrappedLevelIndexSet<GridType> IndexSetType;
00333
00335 typedef typename GridType::Traits::
00336 LevelIntersection IntersectionType;
00337
00339 typedef typename GridType::template Codim<0>::Entity::
00340 LevelIntersectionIterator IntersectionIteratorType;
00341
00343 template <int cd>
00344 struct Codim {
00346 typedef typename GridImp::template Codim<cd>::template Partition<pitype>::LevelIterator IteratorType;
00347 };
00348
00350 enum { conforming = Capabilities::isLevelwiseConforming<GridType>::v };
00351 };
00352
00353
00354 template <class GridImp, PartitionIteratorType pitype = Interior_Partition>
00355 class LeafGridPart :
00356 public GridPartDefault<LeafGridPartTraits<GridImp,pitype> > {
00357 public:
00358
00360 typedef LeafGridPartTraits<GridImp,pitype> Traits;
00362 typedef typename Traits::GridType GridType;
00364 typedef typename Traits::IndexSetType IndexSetType;
00365
00367 typedef typename Traits::IntersectionType IntersectionType ;
00368
00370 typedef typename Traits::IntersectionIteratorType IntersectionIteratorType ;
00371
00373 template <int cd>
00374 struct Codim {
00376 typedef typename Traits::template Codim<cd>::IteratorType IteratorType;
00377 };
00378
00380 enum { conforming = Traits :: conforming };
00381 private:
00382 typedef typename GridType::template Codim<0>::Entity EntityCodim0Type;
00383
00384 public:
00385
00387 LeafGridPart(GridType& grid) :
00388 GridPartDefault<Traits>(grid, isetWrapper_),
00389 isetWrapper_(grid) {}
00390
00392 LeafGridPart(const LeafGridPart& other) :
00393 GridPartDefault<Traits>(other.grid_,isetWrapper_),
00394 isetWrapper_(other.grid_)
00395 {}
00396
00398 template <int cd>
00399 typename Traits::template Codim<cd>::IteratorType begin() const {
00400 return this->grid().template leafbegin<cd,pitype>();
00401 }
00402
00404 template <int cd>
00405 typename Traits::template Codim<cd>::IteratorType end() const {
00406 return this->grid().template leafend<cd,pitype>();
00407 }
00408
00410 IntersectionIteratorType ibegin(const EntityCodim0Type & en) const
00411 {
00412 return en.ileafbegin();
00413 }
00414
00416 IntersectionIteratorType iend(const EntityCodim0Type & en) const
00417 {
00418 return en.ileafend();
00419 }
00420
00422 int level() const { return this->grid().maxLevel(); }
00423
00425 template <class DataHandleImp,class DataType>
00426 void communicate(CommDataHandleIF<DataHandleImp,DataType> & data,
00427 InterfaceType iftype, CommunicationDirection dir) const
00428 {
00429 this->grid().communicate(data,iftype,dir);
00430 }
00431
00432 private:
00434 IndexSetType isetWrapper_;
00435 };
00436
00437
00438 template <class GridImp,PartitionIteratorType pitype>
00439 struct LeafGridPartTraits {
00440
00442 typedef GridImp GridType;
00443
00445 typedef LeafGridPart<GridImp,pitype> GridPartType;
00446
00448 typedef WrappedLeafIndexSet<GridType> IndexSetType;
00449
00451 typedef typename GridType::Traits::
00452 LeafIntersection IntersectionType;
00453
00455 typedef typename GridType::template Codim<0>::Entity::
00456 LeafIntersectionIterator IntersectionIteratorType;
00457
00459 template <int cd>
00460 struct Codim {
00462 typedef typename GridImp::template Codim<cd>::template Partition<pitype>::LeafIterator IteratorType;
00463 };
00464
00466 enum { conforming = Capabilities::isLeafwiseConforming<GridType>::v };
00467 };
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 template <class GridImp, PartitionIteratorType pitype = Interior_Partition>
00480 class HierarchicGridPart :
00481 public GridPartDefault< HierarchicGridPartTraits<GridImp,pitype> > {
00482 public:
00483
00485 typedef HierarchicGridPartTraits<GridImp,pitype> Traits;
00487 typedef typename Traits::GridType GridType;
00489 typedef typename Traits::IndexSetType IndexSetType;
00490
00492 typedef typename Traits::IntersectionIteratorType IntersectionIteratorType ;
00493
00495 template <int cd>
00496 struct Codim {
00497 typedef typename Traits::template Codim<cd>::IteratorType IteratorType;
00498 };
00499
00501 enum { conforming = Traits :: conforming };
00502 private:
00503 typedef typename GridType::template Codim<0>::Entity EntityCodim0Type;
00504
00505 public:
00506
00508 HierarchicGridPart(GridType& grid) :
00509 GridPartDefault<Traits>(grid, isetWrapper_),
00510 isetWrapper_(grid) {}
00511
00513 HierarchicGridPart(GridType& grid, const IndexSetType & ) :
00514 GridPartDefault<Traits>(grid, isetWrapper_),
00515 isetWrapper_(grid) {}
00516
00518 HierarchicGridPart(const HierarchicGridPart& other) :
00519 GridPartDefault<Traits>(other.grid_, isetWrapper_),
00520 isetWrapper_(other.grid_) {}
00521
00523 template <int cd>
00524 typename Traits::template Codim<cd>::IteratorType begin() const {
00525 return this->grid().template leafbegin<cd,pitype>();
00526 }
00527
00529 template <int cd>
00530 typename Traits::template Codim<cd>::IteratorType end() const {
00531 return this->grid().template leafend<cd,pitype>();
00532 }
00533
00535 IntersectionIteratorType ibegin(const EntityCodim0Type & en) const
00536 {
00537 return en.ileafbegin();
00538 }
00539
00541 IntersectionIteratorType iend(const EntityCodim0Type & en) const
00542 {
00543 return en.ileafend();
00544 }
00545
00547 int level() const { return this->grid().maxLevel(); }
00548
00550 template <class DataHandleImp,class DataType>
00551 void communicate(CommDataHandleIF<DataHandleImp,DataType> & data,
00552 InterfaceType iftype, CommunicationDirection dir) const
00553 {
00554 this->grid().communicate(data,iftype,dir);
00555 }
00556
00557 private:
00559 IndexSetType isetWrapper_;
00560 };
00561
00562
00563
00564 template <class GridImp,PartitionIteratorType pitype>
00565 struct HierarchicGridPartTraits {
00567 typedef GridImp GridType;
00569 typedef HierarchicGridPart<GridImp,pitype> GridPartType;
00571 typedef WrappedHierarchicIndexSet<GridType> IndexSetType;
00573 typedef typename GridType::template Codim<0>::Entity::
00574 LeafIntersectionIterator IntersectionIteratorType;
00575
00577 template <int cd>
00578 struct Codim {
00580 typedef typename GridImp::template Codim<cd>::template Partition<pitype>::LeafIterator IteratorType;
00581 };
00582
00584 enum { conforming = Capabilities::isLeafwiseConforming<GridType>::v };
00585 };
00586
00587 #undef CHECK_INTERFACE_IMPLEMENTATION
00588 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
00589
00590
00591 }
00592
00593 #endif
00594
00595
00596
00597
00598
00599
00600 #ifdef DUNE_FEM_GRIDPART_HH
00601 #error "Including <dune/grid/common/gridpart.hh> is deprecated."
00602 #error "Include <dune/fem/gridpart/gridpart.hh> instead."
00603 #endif