Dune Core Modules (2.4.2)

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
18
19// dune-geometry includes
20#include <dune/geometry/type.hh>
21
22// local includes
23#include <dune/grid/common/gridenums.hh>
24#include <dune/grid/common/exceptions.hh>
27#include <dune/grid/common/gridview.hh>
28#include <dune/grid/common/defaultgridview.hh>
30
31// include this file after all other, because other files might undef the
32// macros that are defined in that file
34
35namespace 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 {
402 dimension=dim
403 };
404
406 enum {
408 dimensionworld=dimworld
409 };
411
412 //===========================================================
416 //===========================================================
417
419 template <PartitionIteratorType pitype>
421 {
422 typedef typename GridFamily::Traits::template Partition<pitype>::LevelGridView
423 LevelGridView;
424 typedef typename GridFamily::Traits::template Partition<pitype>::LeafGridView
425 LeafGridView;
426 };
429 typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
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>
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
638 LeafGridView leafGridView() const {
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
763 {
764 CHECK_INTERFACE_IMPLEMENTATION(asImp().leafIndexSet());
765 return asImp().leafIndexSet();
766 }
768
769
770 //===========================================================
774 //===========================================================
775
781 void globalRefine (int refCount)
782 {
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
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
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." )
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
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>
1252 class ReturnImplementationType<const 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:
1309 using Grid< dim, dimworld, ct, GridFamily >::asImp;
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 >
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>
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>
1415 {
1419
1423 };
1424
1433
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 {
1446 static const bool v = hasEntity< typename GridFamily::Traits::Grid, codim >::v;
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 {
1453 typedef GridDefaultImplementation<dim,dimworld,ct,GridFamily> GridType;
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>
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
Provides check for implementation of interface methods when using static polymorphism,...
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:59
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:73
interface class for an iterator over grid entities
Definition: entityiterator.hh:37
Wrapper class for pointers to entities.
Definition: entitypointer.hh:113
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Wrapper class for entities.
Definition: entity.hh:62
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Wrapper class for geometries.
Definition: geometry.hh:66
Helper class to choose correct implementation return type for getRealImplementation.
Definition: grid.hh:1242
T::Implementation ImplementationType
The correct type of the implementation to return.
Definition: grid.hh:1245
Definition: grid.hh:1030
Traits::template Codim< codim >::LeafIterator DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin.") leafbegin() const
Iterator to first entity of given codim on leaf grid for PartitionType All_Partition.
Definition: grid.hh:1073
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: grid.hh:1305
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: grid.hh:1215
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin.") leafbegin() const
Iterator to first entity of given codim on leaf grid.
Definition: grid.hh:1087
bool adapt()
Refine all positive marked leaf entities coarsen all negative marked entities if possible.
Definition: grid.hh:1187
bool mark(int refCount, const typename Traits ::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: grid.hh:1163
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end.") leafend() const
one past the end on the leaf level grid
Definition: grid.hh:1095
void postAdapt()
clean up some markers
Definition: grid.hh:1193
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: grid.hh:1175
Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.") lbegin(int level) const
Iterator to first entity of given codim on level for PartitionType All_Partition.
Definition: grid.hh:1043
int ghostSize(int level, int codim) const
ghostSize is zero by default
Definition: grid.hh:1196
Traits::template Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: grid.hh:1115
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end.") lend(int level) const
one past the end on this level
Definition: grid.hh:1065
bool preAdapt()
returns true, if at least one entity is marked for adaption
Definition: grid.hh:1190
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition: grid.hh:1209
bool loadBalance(DataHandle &data)
default implementation of load balance does nothing and returns false
Definition: grid.hh:1227
Traits::template Codim< codim >::LeafIterator DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end.") leafend() const
one past the end on the leaf grid for PartitionType All_Partition
Definition: grid.hh:1080
int ghostSize(int codim) const
ghostSize is zero by default
Definition: grid.hh:1202
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.") lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: grid.hh:1057
int overlapSize(int level, int codim) const
overlapSize is zero by default
Definition: grid.hh:1199
Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end.") lend(int level) const
one past the end on this level for PartitionType All_Partition
Definition: grid.hh:1050
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: grid.hh:1220
Traits::template Partition< All_Partition >::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: grid.hh:1123
GridFamily::Traits Traits
The traits of this class.
Definition: grid.hh:1039
int overlapSize(int codim) const
overlapSize is zero by default
Definition: grid.hh:1205
Traits::template Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: grid.hh:1105
Traits::template Partition< All_Partition >::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: grid.hh:1131
Grid view abstract base class.
Definition: gridview.hh:59
Grid abstract base class.
Definition: grid.hh:388
const LevelIndexSet & levelIndexSet(int level) const
return const reference to the grids level index set for level level
Definition: grid.hh:755
int size(int level, GeometryType type) const
Return number of entities per level and geometry type in this process.
Definition: grid.hh:582
GridFamily::Traits::LocalIdSet LocalIdSet
A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entiti...
Definition: grid.hh:539
GridFamily::Traits::LeafIntersectionIterator LeafIntersectionIterator
A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine,...
Definition: grid.hh:498
int size(int level, int codim) const
Return number of grid entities of a given codim on a given level in this process.
Definition: grid.hh:568
bool preAdapt()
To be called after entities have been marked and before adapt() is called.
Definition: grid.hh:816
GridFamily::Traits::LevelIndexSet LevelIndexSet
A type that is a model of Dune::IndexSet which provides a consecutive, but non persistent,...
Definition: grid.hh:518
GridFamily::Traits::CollectiveCommunication CollectiveCommunication
A type that is a model of Dune::CollectiveCommunication. It provides a portable way for collective co...
Definition: grid.hh:545
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: grid.hh:914
Codim< cd >::template Partition< pitype >::LeafIterator DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin and will be removed after Dune 2.4.") leafbegin() const
Iterator to first entity of given codim on leaf grid.
Definition: grid.hh:695
GridFamily::Traits::HierarchicIterator HierarchicIterator
A type that is a model of Dune::HierarchicIterator A type of iterator that allows to examine,...
Definition: grid.hh:512
GridFamily::Traits::LeafIntersection LeafIntersection
A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimensio...
Definition: grid.hh:486
Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: grid.hh:617
GridFamily::Traits::LevelIntersectionIterator LevelIntersectionIterator
A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine,...
Definition: grid.hh:505
LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: grid.hh:638
GridFamily::Traits::GlobalIdSet GlobalIdSet
A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entiti...
Definition: grid.hh:532
const GridImp & asImp() const
Barton-Nackman trick.
Definition: grid.hh:980
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.") typename Codim< EntitySeed
obtain EntityPointer from EntitySeed.
Definition: grid.hh:960
void postAdapt()
To be called after grid has been adapted and information left over by the adaptation has been process...
Definition: grid.hh:844
Codim< cd >::template Partition< pitype >::LeafIterator DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end and will be removed after Dune 2.4.") leafend() const
one past the end on the leaf level grid
Definition: grid.hh:705
bool mark(int refCount, const typename Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: grid.hh:794
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:408
GridFamily::Traits::LeafIndexSet LeafIndexSet
A type that is a model of Dune::IndexSet which provides a consecutive, but non persistent,...
Definition: grid.hh:524
Codim< cd >::template Partition< All_Partition >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin and will be removed after Dune 2.4.") lbegin(int level) const
Iterator to first entity of given codim on level for PartitionType All_Partition.
Definition: grid.hh:675
int ghostSize(int level, int codim) const
Return size of ghost region for a given codim on a given level.
Definition: grid.hh:872
int maxLevel() const
Return maximum level defined in this grid. Levels are numbered 0 ... maxLevel with 0 the coarsest lev...
Definition: grid.hh:561
Codim< cd >::template Partition< All_Partition >::LeafIterator DUNE_DEPRECATED_MSG("The method leafend() is superseded by leafGridView().end and will be removed after Dune 2.4.") leafend() const
one past the end on the leaf grid for PartitionType All_Partition
Definition: grid.hh:725
@ dimension
The dimension of the grid.
Definition: grid.hh:402
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: grid.hh:601
Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: grid.hh:626
const GlobalIdSet & globalIdSet() const
return const reference to the grids global id set
Definition: grid.hh:741
int getMark(const typename Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: grid.hh:805
GridFamily::Traits::LevelIntersection LevelIntersection
A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimensio...
Definition: grid.hh:491
int overlapSize(int codim) const
Return size of overlap region for a given codim on the leaf grid.
Definition: grid.hh:865
const LeafIndexSet & leafIndexSet() const
return const reference to the grids leaf index set
Definition: grid.hh:762
Codim< cd >::template Partition< pitype >::LevelIterator DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end and will be removed after Dune 2.4.") lend(int level) const
one past the end on this level
Definition: grid.hh:665
const LocalIdSet & localIdSet() const
return const reference to the grids local id set
Definition: grid.hh:748
LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: grid.hh:632
bool loadBalance(DataHandle &data)
Re-balances the load each process has to handle for a parallel grid and moves the data.
Definition: grid.hh:945
Codim< cd >::template Partition< All_Partition >::LevelIterator DUNE_DEPRECATED_MSG("The method lend( level ) is superseded by levelGridView( level ).end and will be removed after Dune 2.4.") lend(int level) const
one past the end on this level for PartitionType All_Partition
Definition: grid.hh:685
Codim< cd >::template Partition< pitype >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin and will be removed after Dune 2.4.") lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: grid.hh:655
bool loadBalance()
Re-balances the load each process has to handle for a parallel grid,.
Definition: grid.hh:931
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: grid.hh:897
Codim< cd >::template Partition< All_Partition >::LeafIterator DUNE_DEPRECATED_MSG("The method leafbegin() is superseded by leafGridView().begin and will be removed after Dune 2.4.") leafbegin() const
Iterator to first entity of given codim on leaf grid for PartitionType All_Partition.
Definition: grid.hh:715
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: grid.hh:428
int ghostSize(int codim) const
Return size of ghost region for a given codim on the leaf grid.
Definition: grid.hh:879
int overlapSize(int level, int codim) const
Return size of overlap for a given codim on a given level.
Definition: grid.hh:858
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible.
Definition: grid.hh:835
int size(int codim) const
Return number of leaf entities of a given codim in this process.
Definition: grid.hh:575
ct ctype
Define type used for coordinates in grid module.
Definition: grid.hh:548
void globalRefine(int refCount)
Refine the grid refCount times using the default refinement rule.
Definition: grid.hh:781
int size(GeometryType type) const
Return number of leaf entities per geometry type in this process.
Definition: grid.hh:589
const CollectiveCommunication & comm() const
return const reference to a collective communication object. The return type is a model of Dune::Coll...
Definition: grid.hh:921
Id Set Interface.
Definition: indexidset.hh:414
Index Set Interface base class.
Definition: indexidset.hh:76
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:84
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
A set of traits classes to store static information about grid implementation.
Wrapper and interface class for a static iterator (EntityPointer)
Interface class EntitySeed.
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
Implements a vector constructed from a given type representing a field and a compile-time given size.
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
Provides base classes for index and id sets.
Dune namespace.
Definition: alignment.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22
Traits associated with a specific grid partition type.
Definition: grid.hh:1391
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: grid.hh:1395
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: grid.hh:1393
Traits associated with a specific codim.
Definition: grid.hh:1366
Partition< All_Partition >::LeafIterator LeafIterator
The type of the iterator over all leaf entities of this codim.
Definition: grid.hh:1399
Dune::Entity< cd, dim, const GridImp, EntityImp > Entity
The type of the entity.
Definition: grid.hh:1377
Dune::Geometry< dim-cd, dim, const GridImp, LocalGeometryImp > LocalGeometry
The type of the local geometry associated with the entity.
Definition: grid.hh:1374
Partition< All_Partition >::LevelIterator LevelIterator
The type of the entity pointer for entities of this codim.
Definition: grid.hh:1402
Dune::Geometry< dim-cd, dimw, const GridImp, GeometryImp > Geometry
IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
Definition: grid.hh:1372
Dune::EntityPointer< const GridImp, EntityPointerImp< cd, const GridImp > > EntityPointer
The type of the entity pointer for entities of this codim.
Definition: grid.hh:1380
Dune::EntitySeed< const GridImp, EntitySeedImp< cd, const GridImp > > EntitySeed
The type of the entity seed of this codim.
Definition: grid.hh:1383
Traits associated with a specific grid partition type.
Definition: grid.hh:1415
Dune::GridView< LevelGridViewTraits< const GridImp, pitype > > LevelGridView
The type of the level grid view associated with this partition type.
Definition: grid.hh:1418
Dune::GridView< LeafGridViewTraits< const GridImp, pitype > > LeafGridView
The type of the leaf grid view associated with this partition type.
Definition: grid.hh:1422
A traits struct that collects all associated types of one grid model.
Definition: grid.hh:1344
Dune::IntersectionIterator< const GridImp, LeafIntersectionIteratorImp< const GridImp >, LeafIntersectionImp< const GridImp > > LeafIntersectionIterator
The type of the intersection iterator at the leafs of the grid.
Definition: grid.hh:1353
Dune::IntersectionIterator< const GridImp, LevelIntersectionIteratorImp< const GridImp >, LevelIntersectionImp< const GridImp > > LevelIntersectionIterator
The type of the intersection iterator at the levels of the grid.
Definition: grid.hh:1355
Dune::Intersection< const GridImp, LeafIntersectionImp< const GridImp > > LeafIntersection
The type of the intersection at the leafs of the grid.
Definition: grid.hh:1349
CCType CollectiveCommunication
The type of the collective communication.
Definition: grid.hh:1435
IdSet< const GridImp, GlobalIdSetImp, GIDType > GlobalIdSet
The type of the global id set.
Definition: grid.hh:1430
Dune::Intersection< const GridImp, LevelIntersectionImp< const GridImp > > LevelIntersection
The type of the intersection at the levels of the grid.
Definition: grid.hh:1351
Dune::EntityIterator< 0, const GridImp, HierarchicIteratorImp< const GridImp > > HierarchicIterator
The type of the hierarchic iterator.
Definition: grid.hh:1358
IndexSet< const GridImp, LevelIndexSetImp > LevelIndexSet
The type of the level index set.
Definition: grid.hh:1426
IndexSet< const GridImp, LeafIndexSetImp > LeafIndexSet
The type of the leaf index set.
Definition: grid.hh:1428
IdSet< const GridImp, LocalIdSetImp, LIDType > LocalIdSet
The type of the local id set.
Definition: grid.hh:1432
GridImp Grid
The type that implements the grid.
Definition: grid.hh:1346
A struct collecting all types depending on the partition iterator type.
Definition: grid.hh:457
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: grid.hh:464
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: grid.hh:471
A Traits struct that collects all associated types of one implementation.
Definition: grid.hh:438
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: grid.hh:446
GridFamily::Traits::template Codim< cd >::LocalGeometry LocalGeometry
A type that is a model of Dune::Geometry<dim-cd,dim>.
Definition: grid.hh:443
GridFamily::Traits::template Codim< cd >::LevelIterator LevelIterator
A type that is a model of Dune::LevelIterator with partition type All_Partition.
Definition: grid.hh:476
GridFamily::Traits::template Codim< cd >::Geometry Geometry
A type that is a model of Dune::Geometry<dim-cd,dimworld>.
Definition: grid.hh:440
GridFamily::Traits::template Codim< cd >::EntitySeed EntitySeed
A type that is a model (not yet) of Dune::EntitySeed<cd,dim,...>.
Definition: grid.hh:452
GridFamily::Traits::template Codim< cd >::EntityPointer EntityPointer
A type that is a model of Dune::EntityPointer<cd,dim,...>.
Definition: grid.hh:449
GridFamily::Traits::template Codim< cd >::LeafIterator LeafIterator
A type that is a model of Dune::LeafIterator with partition type All_Partition.
Definition: grid.hh:480
Types for GridView.
Definition: grid.hh:421
Definition: grid.hh:1467
MakeableInterfaceObject(const ImplementationType &realImp)
create interface object by calling the contructor of the base class
Definition: grid.hh:1470
A unique label for each type of element that can occur in a grid.
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)