dune-grid  2.4.1
common/grid.hh
Go to the documentation of this file.
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_GRID_HH
4 #define DUNE_GRID_HH
5 
9 // system includes
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 
14 // dune-common includes
15 #include <dune/common/fvector.hh>
16 #include <dune/common/typetraits.hh>
17 #include <dune/common/deprecated.hh>
18 
19 // dune-geometry includes
20 #include <dune/geometry/type.hh>
21 
22 // local includes
30 
31 // include this file after all other, because other files might undef the
32 // macros that are defined in that file
33 #include <dune/common/bartonnackmanifcheck.hh>
34 
35 namespace Dune {
36 
347  // Forward Declarations
348  // --------------------
349 
350  template<int mydim, int cdim, class GridImp,template<int,int,class> class GeometryImp> class Geometry;
351  template< int mydim, int cdim, class GridImp > class GlobalGeometryReference;
352  template< int mydim, int cdim, class GridImp > class LocalGeometryReference;
353  // dim is necessary because Entity will be specialized for codim==0 _and_ codim==dim
354  // EntityImp gets GridImp as 3rd template parameter to distinguish between const and mutable grid
355  template<int codim, int dim, class GridImp,template<int,int,class> class EntityImp> class Entity;
356  template<class GridImp, class EntityPointerImp> class EntityPointer;
357  template< int codim, class Grid, class IteratorImp > class EntityIterator;
358  template<class GridImp, class EntitySeedImp> class EntitySeed;
359  template< class GridImp, class IntersectionImp > class Intersection;
360  template< class GridImp, class IntersectionIteratorImp, class IntersectionImp > class IntersectionIterator;
361  template< class GridImp, class IndexSetImp, class IndexTypeImp = unsigned int, class TypesImp = std::vector< GeometryType > > class IndexSet;
362  template<class GridImp, class IdSetImp, class IdTypeImp> class IdSet;
363 
364 
365  //************************************************************************
366  // G R I D
367  //************************************************************************
368 
387  template< int dim, int dimworld, class ct, class GridFamily>
388  class Grid {
389  typedef typename GridFamily::Traits::Grid GridImp;
391  public:
392 
393  //===========================================================
397  //===========================================================
398 
400  enum {
403  };
404 
406  enum {
408  dimensionworld=dimworld
409  };
411 
412  //===========================================================
416  //===========================================================
417 
419  template <PartitionIteratorType pitype>
420  struct Partition
421  {
422  typedef typename GridFamily::Traits::template Partition<pitype>::LevelGridView
424  typedef typename GridFamily::Traits::template Partition<pitype>::LeafGridView
426  };
430 
431 
436  template <int cd>
437  struct Codim
438  {
440  typedef typename GridFamily::Traits::template Codim<cd>::Geometry Geometry;
441 
443  typedef typename GridFamily::Traits::template Codim<cd>::LocalGeometry LocalGeometry;
444 
446  typedef typename GridFamily::Traits::template Codim<cd>::Entity Entity;
447 
449  typedef typename GridFamily::Traits::template Codim<cd>::EntityPointer EntityPointer;
450 
452  typedef typename GridFamily::Traits::template Codim<cd>::EntitySeed EntitySeed;
453 
455  template <PartitionIteratorType pitype>
456  struct Partition
457  {
464  typedef typename GridFamily::Traits::template Codim<cd>::template Partition<pitype>::LevelIterator LevelIterator;
471  typedef typename GridFamily::Traits::template Codim<cd>::template Partition<pitype>::LeafIterator LeafIterator;
472  };
473 
476  typedef typename GridFamily::Traits::template Codim<cd>::LevelIterator LevelIterator;
477 
480  typedef typename GridFamily::Traits::template Codim<cd>::LeafIterator LeafIterator;
481  };
482 
486  typedef typename GridFamily::Traits::LeafIntersection LeafIntersection;
487 
491  typedef typename GridFamily::Traits::LevelIntersection LevelIntersection;
492 
498  typedef typename GridFamily::Traits::LeafIntersectionIterator LeafIntersectionIterator;
499 
505  typedef typename GridFamily::Traits::LevelIntersectionIterator LevelIntersectionIterator;
506 
512  typedef typename GridFamily::Traits::HierarchicIterator HierarchicIterator;
513 
518  typedef typename GridFamily::Traits::LevelIndexSet LevelIndexSet;
519 
524  typedef typename GridFamily::Traits::LeafIndexSet LeafIndexSet;
525 
532  typedef typename GridFamily::Traits::GlobalIdSet GlobalIdSet;
533 
539  typedef typename GridFamily::Traits::LocalIdSet LocalIdSet;
540 
545  typedef typename GridFamily::Traits::CollectiveCommunication CollectiveCommunication;
546 
548  typedef ct ctype;
550 
551 
552  //===========================================================
556  //===========================================================
557 
561  int maxLevel() const
562  {
563  CHECK_INTERFACE_IMPLEMENTATION(asImp().maxLevel());
564  return asImp().maxLevel();
565  }
566 
568  int size (int level, int codim) const
569  {
570  CHECK_INTERFACE_IMPLEMENTATION(asImp().size(level,codim));
571  return asImp().size(level,codim);
572  }
573 
575  int size (int codim) const
576  {
577  CHECK_INTERFACE_IMPLEMENTATION(asImp().size(codim));
578  return asImp().size(codim);
579  }
580 
582  int size (int level, GeometryType type) const
583  {
584  CHECK_INTERFACE_IMPLEMENTATION(asImp().size(level,type));
585  return asImp().size(level,type);
586  }
587 
589  int size (GeometryType type) const
590  {
591  CHECK_INTERFACE_IMPLEMENTATION(asImp().size(type));
592  return asImp().size(type);
593  }
595 
596 
601  size_t numBoundarySegments () const
602  {
603  CHECK_INTERFACE_IMPLEMENTATION( asImp().numBoundarySegments());
604  return asImp().numBoundarySegments();
605  }
606 
607  //===========================================================
611  //===========================================================
612 
614  template<PartitionIteratorType pitype>
615  typename Partition<pitype>::LevelGridView
616  DUNE_DEPRECATED_MSG( "After DUNE 2.4, grid views will always model the All_Partition. The template method levelGridView< pitype > will be removed without replacement. Use levelGridView() instead." )
617  levelGridView(int level) const {
618  CHECK_INTERFACE_IMPLEMENTATION((asImp().template levelGridView<pitype>(level)));
619  return asImp().template levelGridView<pitype>(level);
620  }
621 
623  template<PartitionIteratorType pitype>
624  typename Partition<pitype>::LeafGridView
625  DUNE_DEPRECATED_MSG( "After DUNE 2.4, grid views will always model the All_Partition. The template method leafGridView< pitype > will be removed without replacement. Use leafGridView() instead." )
626  leafGridView() const {
627  CHECK_INTERFACE_IMPLEMENTATION((asImp().template leafGridView<pitype>()));
628  return asImp().template leafGridView<pitype>();
629  }
630 
632  LevelGridView levelGridView(int level) const {
633  CHECK_INTERFACE_IMPLEMENTATION((asImp().levelGridView(level)));
634  return asImp().levelGridView(level);
635  }
636 
639  CHECK_INTERFACE_IMPLEMENTATION((asImp().leafGridView()));
640  return asImp().leafGridView();
641  }
642 
644 
645 
646  //===========================================================
650  //===========================================================
651 
653  template<int cd, PartitionIteratorType pitype>
654  typename Codim<cd>::template Partition<pitype>::LevelIterator
655  DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin and will be removed after Dune 2.4.")
656  lbegin (int level) const
657  {
658  CHECK_INTERFACE_IMPLEMENTATION((asImp().template lbegin<cd,pitype>(level)));
659  return asImp().template lbegin<cd,pitype>(level);
660  }
661 
663  template<int cd, PartitionIteratorType pitype>
664  typename Codim<cd>::template Partition<pitype>::LevelIterator
665  DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end and will be removed after Dune 2.4.")
666  lend (int level) const
667  {
668  CHECK_INTERFACE_IMPLEMENTATION((asImp().template lend<cd,pitype>(level)));
669  return asImp().template lend<cd,pitype>(level);
670  }
671 
673  template<int cd>
674  typename Codim<cd>::template Partition<All_Partition>::LevelIterator
675  DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin and will be removed after Dune 2.4.")
676  lbegin (int level) const
677  {
678  CHECK_INTERFACE_IMPLEMENTATION((asImp().template lbegin<cd>(level)));
679  return asImp().template lbegin<cd>(level);
680  }
681 
683  template<int cd>
684  typename Codim<cd>::template Partition<All_Partition>::LevelIterator
685  DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end and will be removed after Dune 2.4.")
686  lend (int level) const
687  {
688  CHECK_INTERFACE_IMPLEMENTATION((asImp().template lend<cd>(level)));
689  return asImp().template lend<cd>(level);
690  }
691 
693  template<int cd, PartitionIteratorType pitype>
694  typename Codim<cd>::template Partition<pitype>::LeafIterator
695  DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin and will be removed after Dune 2.4.")
696  leafbegin () const
697  {
698  CHECK_INTERFACE_IMPLEMENTATION((asImp().template leafbegin<cd,pitype>()));
699  return asImp().template leafbegin<cd,pitype>();
700  }
701 
703  template<int cd, PartitionIteratorType pitype>
704  typename Codim<cd>::template Partition<pitype>::LeafIterator
705  DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end and will be removed after Dune 2.4.")
706  leafend () const
707  {
708  CHECK_INTERFACE_IMPLEMENTATION((asImp().template leafend<cd,pitype>()));
709  return asImp().template leafend<cd,pitype>();
710  }
711 
713  template<int cd>
714  typename Codim<cd>::template Partition<All_Partition>::LeafIterator
715  DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin and will be removed after Dune 2.4.")
716  leafbegin () const
717  {
718  CHECK_INTERFACE_IMPLEMENTATION((asImp().template leafbegin<cd,All_Partition>()));
719  return asImp().template leafbegin<cd,All_Partition>();
720  }
721 
723  template<int cd>
724  typename Codim<cd>::template Partition<All_Partition>::LeafIterator
725  DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end and will be removed after Dune 2.4.")
726  leafend () const
727  {
728  CHECK_INTERFACE_IMPLEMENTATION((asImp().template leafend<cd,All_Partition>()));
729  return asImp().template leafend<cd,All_Partition>();
730  }
732 
733 
734  //===========================================================
738  //===========================================================
739 
741  const GlobalIdSet &globalIdSet () const
742  {
743  CHECK_INTERFACE_IMPLEMENTATION(asImp().globalIdSet());
744  return asImp().globalIdSet();
745  }
746 
748  const LocalIdSet &localIdSet () const
749  {
750  CHECK_INTERFACE_IMPLEMENTATION(asImp().localIdSet());
751  return asImp().localIdSet();
752  }
753 
755  const LevelIndexSet &levelIndexSet ( int level ) const
756  {
757  CHECK_INTERFACE_IMPLEMENTATION(asImp().levelIndexSet(level));
758  return asImp().levelIndexSet(level);
759  }
760 
762  const LeafIndexSet &leafIndexSet () const
763  {
764  CHECK_INTERFACE_IMPLEMENTATION(asImp().leafIndexSet());
765  return asImp().leafIndexSet();
766  }
768 
769 
770  //===========================================================
774  //===========================================================
775 
781  void globalRefine (int refCount)
782  {
783  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(asImp().globalRefine(refCount));
784  return;
785  }
786 
794  bool mark( int refCount, const typename Codim<0>::Entity & e )
795  {
796  return asImp().mark(refCount,e);
797  }
798 
805  int getMark(const typename Codim<0>::Entity & e) const
806  {
807  return asImp().getMark(e);
808  }
809 
816  bool preAdapt ()
817  {
818  return asImp().preAdapt();
819  }
820 
835  bool adapt ()
836  {
837  return asImp().adapt();
838  }
839 
844  void postAdapt()
845  {
846  return asImp().postAdapt();
847  }
849 
850 
851  //===========================================================
855  //===========================================================
856 
858  int overlapSize (int level, int codim) const
859  {
860  CHECK_INTERFACE_IMPLEMENTATION(asImp().overlapSize(level,codim));
861  return asImp().overlapSize(level,codim);
862  }
863 
865  int overlapSize (int codim) const
866  {
867  CHECK_INTERFACE_IMPLEMENTATION(asImp().overlapSize(codim));
868  return asImp().overlapSize(codim);
869  }
870 
872  int ghostSize (int level, int codim) const
873  {
874  CHECK_INTERFACE_IMPLEMENTATION(asImp().ghostSize(level,codim));
875  return asImp().ghostSize(level,codim);
876  }
877 
879  int ghostSize (int codim) const
880  {
881  CHECK_INTERFACE_IMPLEMENTATION(asImp().ghostSize(codim));
882  return asImp().ghostSize(codim);
883  }
884 
896  template<class DataHandleImp, class DataTypeImp>
898  {
899  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().template communicate<DataHandleImp,DataTypeImp>(data,iftype,dir,level)));
900  return;
901  }
902 
913  template<class DataHandleImp, class DataTypeImp>
915  {
916  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION((asImp().template communicate<DataHandleImp,DataTypeImp>(data,iftype,dir)));
917  return;
918  }
919 
922  {
923  CHECK_INTERFACE_IMPLEMENTATION(asImp().comm());
924  return asImp().comm();
925  }
927 
931  bool loadBalance()
932  {
933  CHECK_INTERFACE_IMPLEMENTATION(asImp().loadBalance());
934  return asImp().loadBalance();
935  }
936 
944  template<class DataHandle>
945  bool loadBalance (DataHandle& data)
946  {
947  CHECK_INTERFACE_IMPLEMENTATION(asImp().loadBalance(data));
948  return asImp().loadBalance(data);
949  }
950 
959  template < class EntitySeed >
960  DUNE_DEPRECATED_MSG("entityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use entity() instead to directly obtain an Entity object.")
961  typename Codim< EntitySeed :: codimension > :: EntityPointer
962  entityPointer( const EntitySeed& seed ) const
963  {
964  CHECK_INTERFACE_IMPLEMENTATION( asImp().entityPointer( seed ) );
965  return asImp().entityPointer( seed );
966  }
967 
969  template < class EntitySeed >
970  typename Codim< EntitySeed :: codimension > :: Entity
971  entity( const EntitySeed& seed ) const
972  {
973  //CHECK_INTERFACE_IMPLEMENTATION( asImp().entity( seed ) );
974  return asImp().entity( seed );
975  }
976  protected:
978  GridImp& asImp () {return static_cast<GridImp &> (*this);}
980  const GridImp& asImp () const {return static_cast<const GridImp &>(*this);}
981  };
982 
983 #undef CHECK_INTERFACE_IMPLEMENTATION
984 #undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
985 
986 
1025  template<int dim,
1026  int dimworld,
1027  class ct,
1028  class GridFamily>
1029  class GridDefaultImplementation : public Grid <dim,dimworld,ct,GridFamily>
1030  {
1031  typedef typename GridFamily::Traits::Grid GridImp;
1032 
1033  public:
1039  typedef typename GridFamily::Traits Traits;
1040 
1042  template< int codim >
1043  typename Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.") lbegin ( int level ) const
1044  {
1045  return asImp().levelGridView( level ).template begin< codim >();
1046  }
1047 
1049  template< int codim >
1050  typename Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end.") lend ( int level ) const
1051  {
1052  return asImp().levelGridView( level ).template end< codim >();
1053  }
1054 
1056  template< int codim, PartitionIteratorType pitype >
1057  typename Traits::template Codim< codim >::template Partition< pitype >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.")
1058  lbegin ( int level ) const
1059  {
1060  return asImp().levelGridView( level ).template begin< codim, pitype >();
1061  }
1062 
1064  template< int codim, PartitionIteratorType pitype >
1065  typename Traits::template Codim< codim >::template Partition< pitype >::LevelIterator DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end.")
1066  lend ( int level ) const
1067  {
1068  return asImp().levelGridView( level ).template end< codim, pitype >();
1069  }
1070 
1072  template< int codim >
1073  typename Traits::template Codim< codim >::LeafIterator DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin.") leafbegin () const
1074  {
1075  return asImp().leafGridView().template begin< codim >();
1076  }
1077 
1079  template< int codim >
1080  typename Traits::template Codim< codim >::LeafIterator DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end.") leafend () const
1081  {
1082  return asImp().leafGridView().template end< codim >();
1083  }
1084 
1086  template< int codim, PartitionIteratorType pitype >
1087  typename Traits::template Codim< codim >::template Partition< pitype >::LeafIterator DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin.")
1088  leafbegin () const
1089  {
1090  return asImp().leafGridView().template begin< codim, pitype >();
1091  }
1092 
1094  template< int codim, PartitionIteratorType pitype >
1095  typename Traits::template Codim< codim >::template Partition< pitype >::LeafIterator DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end.")
1096  leafend () const
1097  {
1098  return asImp().leafGridView().template end< codim, pitype >();
1099  }
1100 
1102  template<PartitionIteratorType pitype>
1103  typename Traits::template Partition<pitype>::LevelGridView
1104  DUNE_DEPRECATED_MSG( "After DUNE 2.4, grid views will always model the All_Partition. The template method levelGridView< pitype > will be removed without replacement. Use levelGridView() instead." )
1105  levelGridView(int level) const {
1106  typedef typename Traits::template Partition<pitype>::LevelGridView View;
1107  typedef typename View::GridViewImp ViewImp;
1108  return View(ViewImp(asImp(),level));
1109  }
1110 
1112  template<PartitionIteratorType pitype>
1113  typename Traits::template Partition<pitype>::LeafGridView
1114  DUNE_DEPRECATED_MSG( "After DUNE 2.4, grid views will always model the All_Partition. The template method leafGridView< pitype > will be removed without replacement. Use leafGridView() instead." )
1115  leafGridView() const {
1116  typedef typename Traits::template Partition<pitype>::LeafGridView View;
1117  typedef typename View::GridViewImp ViewImp;
1118  return View(ViewImp(asImp()));
1119  }
1120 
1122  typename Traits::template Partition<All_Partition>::LevelGridView
1123  levelGridView(int level) const {
1124  typedef typename Traits::template Partition<All_Partition>::LevelGridView View;
1125  typedef typename View::GridViewImp ViewImp;
1126  return View(ViewImp(asImp(),level));
1127  }
1128 
1130  typename Traits::template Partition<All_Partition>::LeafGridView
1131  leafGridView() const {
1132  typedef typename Traits::template Partition<All_Partition>::LeafGridView View;
1133  typedef typename View::GridViewImp ViewImp;
1134  return View(ViewImp(asImp()));
1135  }
1136 
1137  //***************************************************************
1138  // Interface for Adaptation
1139  //***************************************************************
1140 
1163  bool mark( int refCount, const typename Traits :: template Codim<0>::Entity & e )
1164  {
1165  return false;
1166  }
1167 
1175  int getMark ( const typename Traits::template Codim< 0 >::Entity &e ) const
1176  {
1177  return 0;
1178  }
1179 
1187  bool adapt () { return false; }
1188 
1190  bool preAdapt () { return false; }
1191 
1193  void postAdapt() {}
1194 
1196  int ghostSize (int level, int codim) const { return 0; }
1197 
1199  int overlapSize (int level, int codim) const { return 0; }
1200 
1202  int ghostSize (int codim) const { return 0; }
1203 
1205  int overlapSize (int codim) const { return 0; }
1206 
1208  template<class DataHandleImp, class DataTypeImp>
1210  InterfaceType iftype, CommunicationDirection dir, int level) const
1211  {}
1212 
1214  template<class DataHandleImp, class DataTypeImp>
1216  InterfaceType iftype, CommunicationDirection dir) const
1217  {}
1218 
1221  {
1222  return false;
1223  }
1224 
1226  template<class DataHandle>
1227  bool loadBalance (DataHandle& data)
1228  {
1229  return false;
1230  }
1231 
1232  protected:
1239  template<class T>
1241  : public T // implement friendship via subclassing
1242  {
1243  public:
1245  typedef typename T::Implementation ImplementationType;
1246  private:
1247  // constructor in only need to compile
1248  ReturnImplementationType(const T& t) : T(t) {}
1249  };
1250 
1251  template<class T>
1253  : public T // implement friendship via subclassing
1254  {
1255  public:
1256  typedef const typename T::Implementation ImplementationType;
1257  private:
1258  // constructor in only need to compile
1259  ReturnImplementationType(const T& t) : T(t) {}
1260  };
1261 
1263  // This rather involved return type computation does the following:
1264  //
1265  // 1) It detects whether the function was passed an lvalue or an
1266  // rvalue by checking whether InterfaceType is a reference (in which
1267  // case the argument is an lvalue). This relies on the special template
1268  // matching rules for unqualified rvalue references.
1269  // 2) If it is an lvalue, it
1270  // - strips the reference from InterfaceType
1271  // - uses the resulting type to extract the implementation type
1272  // - re-adds an lvalue reference
1273  // This procedure transfers a possible cv-qualification from the
1274  // interface type to the implementation type
1275  // 3) If it is an lvalue, it
1276  // - strips the reference anyway. This is required to make this TMP
1277  // compile if the other branch (lvalue) is taken because in that
1278  // case, the compiler still evaluates the rvalue result and without
1279  // the reference stripping step, it would pass a reference into
1280  // ReturnImplementationType, which would in turn cause a compiler
1281  // error.
1282  // - looks up the implementation type with the stripped interface type
1283  // - removes a possible const from the result; the type is a temporary
1284  // anyway, so there is no reason to keep the const qualifier around.
1285  template <class InterfaceType>
1286  static typename std::conditional<
1287  std::is_reference<
1289  >::value,
1290  typename std::add_lvalue_reference<
1291  typename ReturnImplementationType<
1292  typename std::remove_reference<
1294  >::type
1295  >::ImplementationType
1296  >::type,
1297  typename std::remove_const<
1298  typename ReturnImplementationType<
1299  typename std::remove_reference<
1301  >::type
1302  >::ImplementationType
1303  >::type
1304  >::type
1305  getRealImplementation (InterfaceType &&i) { return i.impl(); }
1306 
1307 
1308  protected:
1310  };
1311 
1325  template <int dim, int dimw, class GridImp,
1326  template<int,int,class> class GeometryImp,
1327  template<int,int,class> class EntityImp,
1328  template<int,class> class EntityPointerImp,
1329  template<int,PartitionIteratorType,class> class LevelIteratorImp,
1330  template<class> class LeafIntersectionImp,
1331  template<class> class LevelIntersectionImp,
1332  template<class> class LeafIntersectionIteratorImp,
1333  template<class> class LevelIntersectionIteratorImp,
1334  template<class> class HierarchicIteratorImp,
1335  template<int,PartitionIteratorType,class> class LeafIteratorImp,
1336  class LevelIndexSetImp, class LeafIndexSetImp,
1337  class GlobalIdSetImp, class GIDType, class LocalIdSetImp, class LIDType, class CCType,
1338  template<class,PartitionIteratorType> class LevelGridViewTraits,
1339  template<class,PartitionIteratorType> class LeafGridViewTraits,
1340  template<int,class> class EntitySeedImp,
1341  template<int,int,class> class LocalGeometryImp = GeometryImp
1342  >
1343  struct GridTraits
1344  {
1346  typedef GridImp Grid;
1347 
1356 
1359 
1364  template <int cd>
1365  struct Codim
1366  {
1367  public:
1368  typedef GeometryImp<dim-cd, dimw, const GridImp> GeometryImpl;
1369  typedef LocalGeometryImp<dim-cd, dim, const GridImp> LocalGeometryImpl;
1371 
1372  typedef Dune::Geometry<dim-cd, dimw, const GridImp, GeometryImp> Geometry;
1374  typedef Dune::Geometry<dim-cd, dim, const GridImp, LocalGeometryImp> LocalGeometry;
1376  // we could - if needed - introduce another struct for dimglobal of Geometry
1378 
1381 
1384 
1389  template <PartitionIteratorType pitype>
1390  struct Partition
1391  {
1396  };
1397 
1400 
1403 
1404  private:
1405  friend class Dune::Entity<cd, dim, const GridImp, EntityImp>;
1406  typedef EntityPointerImp<cd,const GridImp> EntityPointerImpl;
1407  };
1408 
1413  template <PartitionIteratorType pitype>
1414  struct Partition
1415  {
1419 
1423  };
1424 
1433 
1435  typedef CCType CollectiveCommunication;
1436  };
1437 
1438  // Definition of capabilities for the interface class
1439  namespace Capabilities
1440  {
1441 
1442  // capabilities for the interface class depend on the implementation
1443  template< int dim, int dimworld, typename ct, class GridFamily , int codim >
1444  struct hasEntity< Grid< dim, dimworld, ct, GridFamily >, codim >
1445  {
1447  };
1448 
1449  // capabilities for the interface class depend on the implementation
1450  template< int dim, int dimworld, typename ct, class GridFamily , int cdim >
1451  struct hasEntity< GridDefaultImplementation<dim,dimworld,ct,GridFamily>, cdim >
1452  {
1454  typedef typename GridType::Traits::Grid GridImp;
1455  static const bool v = hasEntity<GridImp,cdim>::v;
1456  };
1457 
1458  } // end namespace Capabilities
1459 
1465  template <class InterfaceType>
1466  struct MakeableInterfaceObject : public InterfaceType
1467  {
1468  typedef typename InterfaceType::Implementation ImplementationType;
1470  explicit MakeableInterfaceObject ( const ImplementationType &realImp )
1471  : InterfaceType( realImp )
1472  {}
1473  };
1474 }
1475 
1476 #include "geometry.hh"
1477 #include "entity.hh"
1478 #include "entitypointer.hh"
1479 #include "intersection.hh"
1480 #include "intersectioniterator.hh"
1481 #include "entityiterator.hh"
1482 #include "indexidset.hh"
1483 
1484 #endif // #ifndef DUNE_GRID_HH
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first entity of given codim on leaf grid for PartitionType All_Partition.
Definition: common/grid.hh:1073
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
Traits::template Partition< All_Partition >::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: common/grid.hh:1131
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: common/grid.hh:1220
Definition: common/grid.hh:351
GridFamily::Traits::template Codim< cd >::LeafIterator LeafIterator
A type that is a model of Dune::LeafIterator with partition type All_Partition.
Definition: common/grid.hh:480
Index Set Interface base class.
Definition: common/grid.hh:361
LocalGeometryImp< dim-cd, dim, const GridImp > LocalGeometryImpl
Definition: common/grid.hh:1369
bool mark(int refCount, const typename Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: common/grid.hh:794
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:23
Partition< All_Partition >::LevelIterator LevelIterator
The type of the entity pointer for entities of this codim.
Definition: common/grid.hh:1402
The dimension of the world the grid lives in.
Definition: common/grid.hh:408
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level for PartitionType All_Partition. ...
Definition: common/grid.hh:1043
GridFamily::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator LeafIterator
A type that is a model of Dune::LeafIterator<cd,pitype,...> which is a type of iterator that may be u...
Definition: common/grid.hh:471
int size(GeometryType type) const
Return number of leaf entities per geometry type in this process.
Definition: common/grid.hh:589
Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: common/grid.hh:626
const CollectiveCommunication & comm() const
return const reference to a collective communication object. The return type is a model of Dune::Coll...
Definition: common/grid.hh:921
Dune::Intersection< const GridImp, LeafIntersectionImp< const GridImp > > LeafIntersection
The type of the intersection at the leafs of the grid.
Definition: common/grid.hh:1349
Definition: geometryreference.hh:89
GridFamily::Traits::LeafIndexSet LeafIndexSet
A type that is a model of Dune::IndexSet which provides a consecutive, but non persistent, numbering for entities in the leaf grid.
Definition: common/grid.hh:524
Dune::EntitySeed< const GridImp, EntitySeedImp< cd, const GridImp > > EntitySeed
The type of the entity seed of this codim.
Definition: common/grid.hh:1383
int size(int codim) const
Return number of leaf entities of a given codim in this process.
Definition: common/grid.hh:575
int ghostSize(int codim) const
Return size of ghost region for a given codim on the leaf grid.
Definition: common/grid.hh:879
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:360
GridFamily::Traits::template Partition< pitype >::LeafGridView LeafGridView
Definition: common/grid.hh:425
int overlapSize(int level, int codim) const
overlapSize is zero by default
Definition: common/grid.hh:1199
GridFamily::Traits::template Codim< cd >::LevelIterator LevelIterator
A type that is a model of Dune::LevelIterator with partition type All_Partition.
Definition: common/grid.hh:476
GridFamily::Traits::template Codim< cd >::Geometry Geometry
A type that is a model of Dune::Geometry<dim-cd,dimworld>.
Definition: common/grid.hh:440
Types for GridView.
Definition: common/grid.hh:420
bool loadBalance(DataHandle &data)
default implementation of load balance does nothing and returns false
Definition: common/grid.hh:1227
Wrapper class for entities.
Definition: common/entity.hh:61
MakeableInterfaceObject(const ImplementationType &realImp)
create interface object by calling the contructor of the base class
Definition: common/grid.hh:1470
Wrapper and interface class for a static iterator (EntityPointer)
bool loadBalance()
Re-balances the load each process has to handle for a parallel grid,.
Definition: common/grid.hh:931
Specialize with 'true' for all codims that a grid implements entities for. (default=false) ...
Definition: common/capabilities.hh:57
GridFamily::Traits::LevelIntersectionIterator LevelIntersectionIterator
A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine...
Definition: common/grid.hh:505
A traits struct that collects all associated types of one grid model.
Definition: common/grid.hh:1343
Definition: objectfactory.hh:23
IndexSet< const GridImp, LeafIndexSetImp > LeafIndexSet
The type of the leaf index set.
Definition: common/grid.hh:1428
const LeafIndexSet & leafIndexSet() const
return const reference to the grids leaf index set
Definition: common/grid.hh:762
Wrapper class for pointers to entities.
Definition: common/entitypointer.hh:112
Traits associated with a specific grid partition type.
Definition: common/grid.hh:1414
CCType CollectiveCommunication
The type of the collective communication.
Definition: common/grid.hh:1435
GridFamily::Traits::LocalIdSet LocalIdSet
A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entiti...
Definition: common/grid.hh:539
int overlapSize(int codim) const
overlapSize is zero by default
Definition: common/grid.hh:1205
static const bool v
Definition: common/capabilities.hh:59
Dune::GridView< LevelGridViewTraits< const GridImp, pitype > > LevelGridView
The type of the level grid view associated with this partition type.
Definition: common/grid.hh:1418
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: common/grid.hh:1163
int maxLevel() const
Return maximum level defined in this grid. Levels are numbered 0 ... maxLevel with 0 the coarsest lev...
Definition: common/grid.hh:561
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Communicate information on distributed entities on a given level Template parameter is a model of Dun...
Definition: common/grid.hh:897
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: common/grid.hh:428
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end on the leaf grid for PartitionType All_Partition
Definition: common/grid.hh:1080
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level for PartitionType All_Partition
Definition: common/grid.hh:1050
Traits::template Partition< All_Partition >::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: common/grid.hh:1123
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: common/grid.hh:1215
GeometryImp< dim-cd, dimw, const GridImp > GeometryImpl
Definition: common/grid.hh:1368
Describes the parallel communication interface class for MessageBuffers and DataHandles.
GridFamily::Traits::LevelIndexSet LevelIndexSet
A type that is a model of Dune::IndexSet which provides a consecutive, but non persistent, numbering for entities on a grid level.
Definition: common/grid.hh:518
Dune::Entity< cd, dim, const GridImp, EntityImp > Entity
The type of the entity.
Definition: common/grid.hh:1377
ct ctype
Define type used for coordinates in grid module.
Definition: common/grid.hh:548
const GlobalIdSet & globalIdSet() const
return const reference to the grids global id set
Definition: common/grid.hh:741
bool preAdapt()
To be called after entities have been marked and before adapt() is called.
Definition: common/grid.hh:816
Traits associated with a specific grid partition type.
Definition: common/grid.hh:1390
Dune::IntersectionIterator< const GridImp, LeafIntersectionIteratorImp< const GridImp >, LeafIntersectionImp< const GridImp > > LeafIntersectionIterator
The type of the intersection iterator at the leafs of the grid.
Definition: common/grid.hh:1353
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: common/grid.hh:601
bool adapt()
Refine all positive marked leaf entities coarsen all negative marked entities if possible.
Definition: common/grid.hh:1187
Definition: common/geometry.hh:24
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
void globalRefine(int refCount)
Refine the grid refCount times using the default refinement rule.
Definition: common/grid.hh:781
LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: common/grid.hh:638
Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: common/grid.hh:971
GridDefaultImplementation< dim, dimworld, ct, GridFamily > GridType
Definition: common/grid.hh:1453
GridFamily::Traits Traits
The traits of this class.
Definition: common/grid.hh:1039
const GridImp & asImp() const
Barton-Nackman trick.
Definition: common/grid.hh:980
const LocalIdSet & localIdSet() const
return const reference to the grids local id set
Definition: common/grid.hh:748
LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: common/grid.hh:632
Wrapper class for geometries.
Definition: common/geometry.hh:65
void postAdapt()
To be called after grid has been adapted and information left over by the adaptation has been process...
Definition: common/grid.hh:844
Traits associated with a specific codim.
Definition: common/grid.hh:1365
InterfaceType::Implementation ImplementationType
Definition: common/grid.hh:1468
Provides base classes for index and id sets.
Helper class to choose correct implementation return type for getRealImplementation.
Definition: common/grid.hh:1240
GridFamily::Traits::LevelIntersection LevelIntersection
A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimensio...
Definition: common/grid.hh:491
Dune::GridView< LeafGridViewTraits< const GridImp, pitype > > LeafGridView
The type of the leaf grid view associated with this partition type.
Definition: common/grid.hh:1422
Traits::template Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: common/grid.hh:1115
Dune::Intersection< const GridImp, LevelIntersectionImp< const GridImp > > LevelIntersection
The type of the intersection at the levels of the grid.
Definition: common/grid.hh:1351
bool loadBalance(DataHandle &data)
Re-balances the load each process has to handle for a parallel grid and moves the data...
Definition: common/grid.hh:945
interface class for an iterator over grid entitiesAn entity iterator is an iterator over a subset of ...
Definition: entityiterator.hh:35
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:388
int ghostSize(int level, int codim) const
Return size of ghost region for a given codim on a given level.
Definition: common/grid.hh:872
int overlapSize(int level, int codim) const
Return size of overlap for a given codim on a given level.
Definition: common/grid.hh:858
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir) const
Communicate information on distributed entities on the leaf grid Template parameter is a model of Dun...
Definition: common/grid.hh:914
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: common/grid.hh:446
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition: common/grid.hh:1209
IdSet< const GridImp, GlobalIdSetImp, GIDType > GlobalIdSet
The type of the global id set.
Definition: common/grid.hh:1430
Dune::IntersectionIterator< const GridImp, LevelIntersectionIteratorImp< const GridImp >, LevelIntersectionImp< const GridImp > > LevelIntersectionIterator
The type of the intersection iterator at the levels of the grid.
Definition: common/grid.hh:1355
static std::conditional< std::is_reference< InterfaceType >::value, typename std::add_lvalue_reference< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type, typename std::remove_const< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: common/grid.hh:1305
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
int size(int level, GeometryType type) const
Return number of entities per level and geometry type in this process.
Definition: common/grid.hh:582
int ghostSize(int level, int codim) const
ghostSize is zero by default
Definition: common/grid.hh:1196
GridFamily::Traits::template Codim< cd >::LocalGeometry LocalGeometry
A type that is a model of Dune::Geometry<dim-cd,dim>.
Definition: common/grid.hh:443
Partition< All_Partition >::LeafIterator LeafIterator
The type of the iterator over all leaf entities of this codim.
Definition: common/grid.hh:1399
GridImp Grid
The type that implements the grid.
Definition: common/grid.hh:1346
int getMark(const typename Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: common/grid.hh:805
Codim< cd >::template Partition< pitype >::LeafIterator leafend() const
one past the end on the leaf level grid
Definition: common/grid.hh:706
A set of traits classes to store static information about grid implementation.
GridFamily::Traits::GlobalIdSet GlobalIdSet
A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entiti...
Definition: common/grid.hh:532
Dune::Geometry< dim-cd, dimw, const GridImp, GeometryImp > Geometry
IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
Definition: common/grid.hh:1372
T::Implementation ImplementationType
The correct type of the implementation to return.
Definition: common/grid.hh:1245
int ghostSize(int codim) const
ghostSize is zero by default
Definition: common/grid.hh:1202
Dune::Geometry< dim-cd, dim, const GridImp, LocalGeometryImp > LocalGeometry
The type of the local geometry associated with the entity.
Definition: common/grid.hh:1374
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
IndexSet< const GridImp, LevelIndexSetImp > LevelIndexSet
The type of the level index set.
Definition: common/grid.hh:1426
Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: common/grid.hh:962
The dimension of the grid.
Definition: common/grid.hh:402
Dune::EntityIterator< 0, const GridImp, HierarchicIteratorImp< const GridImp > > HierarchicIterator
The type of the hierarchic iterator.
Definition: common/grid.hh:1358
A struct collecting all types depending on the partition iterator type.
Definition: common/grid.hh:456
const T::Implementation ImplementationType
Definition: common/grid.hh:1256
GridFamily::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator LevelIterator
A type that is a model of Dune::LevelIterator<cd,pitype,...> which is s type of iterator that may be ...
Definition: common/grid.hh:464
int overlapSize(int codim) const
Return size of overlap region for a given codim on the leaf grid.
Definition: common/grid.hh:865
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity, i.e. here the default implementation returns 0...
Definition: common/grid.hh:1175
int size(int level, int codim) const
Return number of grid entities of a given codim on a given level in this process. ...
Definition: common/grid.hh:568
Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: common/grid.hh:656
const LevelIndexSet & levelIndexSet(int level) const
return const reference to the grids level index set for level level
Definition: common/grid.hh:755
Wrapper and interface classes for element geometries.
GridFamily::Traits::template Codim< cd >::EntityPointer EntityPointer
A type that is a model of Dune::EntityPointer<cd,dim,...>.
Definition: common/grid.hh:449
GridImp & asImp()
Barton-Nackman trick.
Definition: common/grid.hh:978
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Grid view abstract base class.
Definition: common/gridview.hh:58
Dune::EntityPointer< const GridImp, EntityPointerImp< cd, const GridImp > > EntityPointer
The type of the entity pointer for entities of this codim.
Definition: common/grid.hh:1380
A Traits struct that collects all associated types of one implementation.
Definition: common/grid.hh:437
GridFamily::Traits::LeafIntersectionIterator LeafIntersectionIterator
A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine...
Definition: common/grid.hh:498
GridFamily::Traits::template Codim< cd >::EntitySeed EntitySeed
A type that is a model (not yet) of Dune::EntitySeed<cd,dim,...>.
Definition: common/grid.hh:452
Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: common/grid.hh:617
void postAdapt()
clean up some markers
Definition: common/grid.hh:1193
Interface class EntitySeed.
GridFamily::Traits::HierarchicIterator HierarchicIterator
A type that is a model of Dune::HierarchicIterator A type of iterator that allows to examine...
Definition: common/grid.hh:512
IdSet< const GridImp, LocalIdSetImp, LIDType > LocalIdSet
The type of the local id set.
Definition: common/grid.hh:1432
Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: common/grid.hh:666
bool preAdapt()
returns true, if at least one entity is marked for adaption
Definition: common/grid.hh:1190
Partition< All_Partition >::LeafGridView LeafGridView
Definition: common/grid.hh:429
GridFamily::Traits::template Partition< pitype >::LevelGridView LevelGridView
Definition: common/grid.hh:423
GridFamily::Traits::CollectiveCommunication CollectiveCommunication
A type that is a model of Dune::CollectiveCommunication. It provides a portable way for collective co...
Definition: common/grid.hh:545
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible...
Definition: common/grid.hh:835
Traits::template Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: common/grid.hh:1105
Dune::EntityIterator< cd, const GridImp, LeafIteratorImp< cd, pitype, const GridImp > > LeafIterator
The type of the iterator over the leaf entities of this codim on this partition.
Definition: common/grid.hh:1395
GridFamily::Traits::LeafIntersection LeafIntersection
A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimensio...
Definition: common/grid.hh:486
Id Set Interface.
Definition: common/grid.hh:362
Dune::EntityIterator< cd, const GridImp, LevelIteratorImp< cd, pitype, const GridImp > > LevelIterator
The type of the iterator over the level entities of this codim on this partition. ...
Definition: common/grid.hh:1393
Codim< cd >::template Partition< pitype >::LeafIterator leafbegin() const
Iterator to first entity of given codim on leaf grid.
Definition: common/grid.hh:696