/usr/include/dune/grid/alugrid/3d/grid.hh is in libdune-grid-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ALU3DGRIDGRID_HH
#define DUNE_ALU3DGRIDGRID_HH
//- System includes
#include <vector>
//- Dune includes
#include <dune/grid/utility/grapedataioformattypes.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/grid/alugrid/common/interfaces.hh>
#include <dune/common/bigunsignedint.hh>
#include <dune/common/deprecated.hh>
#include <dune/geometry/referenceelements.hh>
#include <dune/grid/common/grid.hh>
#include <dune/grid/alugrid/common/defaultindexsets.hh>
#include <dune/grid/common/sizecache.hh>
#include <dune/grid/alugrid/common/intersectioniteratorwrapper.hh>
#include <dune/grid/common/datahandleif.hh>
#include <dune/grid/common/defaultgridview.hh>
// bnd projection stuff
#include <dune/grid/common/boundaryprojection.hh>
#include <dune/grid/alugrid/common/bndprojection.hh>
#include <dune/grid/alugrid/common/objectfactory.hh>
#include <dune/grid/alugrid/common/backuprestore.hh>
//- Local includes
#include "alu3dinclude.hh"
#include "topology.hh"
#include "indexsets.hh"
#include "datahandle.hh"
#include <dune/grid/alugrid/3d/lbdatahandle.hh>
#include <dune/common/parallel/mpihelper.hh>
#if ALU3DGRID_PARALLEL
#include <dune/common/parallel/mpicollectivecommunication.hh>
#else
#include <dune/common/parallel/collectivecommunication.hh>
#endif
namespace Dune
{
// Forward declarations
template<int cd, int dim, class GridImp>
class ALU3dGridEntity;
template<int cd, PartitionIteratorType pitype, class GridImp >
class ALU3dGridLevelIterator;
template<int cd, class GridImp >
class ALU3dGridEntityPointerBase;
template<int cd, class GridImp >
class ALU3dGridEntitySeed;
template<int cd, class GridImp >
class ALU3dGridEntityPointer;
template<int mydim, int coorddim, class GridImp>
class ALU3dGridGeometry;
template<class GridImp>
class ALU3dGridHierarchicIterator;
template<class GridImp>
class ALU3dGridIntersectionIterator;
template<class GridImp>
class ALU3dGridLevelIntersectionIterator;
template<int codim, PartitionIteratorType pitype, class GridImp>
class ALU3dGridLeafIterator;
template <int mydim, int coorddim, class GridImp>
class ALU3dGridMakeableEntity;
template <class GridImp>
class ALU3dGridFaceGeometryInfo;
template< ALU3dGridElementType, class >
class ALU3dGridGlobalIdSet;
template< ALU3dGridElementType, class >
class ALU3dGridLocalIdSet;
template< ALU3dGridElementType, class >
class ALU3dGridHierarchicIndexSet;
template <class EntityImp>
class ALUMemoryProvider;
template< class >
class ALU3dGridFactory;
template <class GridImp, class GeometryImp, int nChild>
class ALULocalGeometryStorage;
template< ALU3dGridElementType elType, class Comm >
struct ALU3dGridCommHelper;
// Internal Forward Declarations
// -----------------------------
#if ALU3DGRID_PARALLEL
template< ALU3dGridElementType elType, class Comm = MPI_Comm >
class ALU3dGrid;
#else // #if ALU3DGRID_PARALLEL
template< ALU3dGridElementType elType, class Comm = No_Comm >
class ALU3dGrid;
#endif // #else // #if ALU3DGRID_PARALLEL
template < class Comm >
struct ALUGridBaseGrid< 3, 3, cube, Comm >
{
typedef ALU3dGrid< hexa, Comm > BaseGrid ;
};
template < class Comm>
struct ALUGridBaseGrid< 3, 3, simplex, Comm >
{
typedef ALU3dGrid< tetra, Comm > BaseGrid ;
};
// ALU3dGridCommunications
// -----------------------
struct ALU3dGridCommunicationsBase
{
template < class GitterImpl >
void checkForConformingRefinement( GitterImpl* grid,
const bool conformingRefinement )
{
#ifdef ALUGRID_3D_CONFORMING_REFINEMENT
if( grid && conformingRefinement )
{
grid->enableConformingClosure();
grid->disableGhostCells();
}
#endif
}
};
template< ALU3dGridElementType elType, class Comm >
struct ALU3dGridCommunications;
template< ALU3dGridElementType elType >
struct ALU3dGridCommunications< elType, No_Comm > : public ALU3dGridCommunicationsBase
{
using ALU3dGridCommunicationsBase :: checkForConformingRefinement ;
typedef ALU3dGridLocalIdSet< elType, No_Comm > GlobalIdSet;
typedef int GlobalId;
typedef ALU3DSPACE GitterDuneImpl GitterImplType;
typedef Dune::CollectiveCommunication< No_Comm > CollectiveCommunication;
explicit ALU3dGridCommunications ( No_Comm comm ) {}
int nlinks () const { return 0; }
GitterImplType *createALUGrid ( const std::string ¯oName, ALU3DSPACE ProjectVertex *projection,
const bool conformingRefinement )
{
GitterImplType* grid = ( macroName.empty() ) ?
new GitterImplType() : new GitterImplType ( macroName.c_str(), projection );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid ;
}
GitterImplType *createALUGrid ( std::istream& stream, ALU3DSPACE ProjectVertex *projection,
const bool conformingRefinement )
{
#ifdef ALUGRID_CONSTRUCTION_WITH_STREAMS
GitterImplType* grid = new GitterImplType ( stream, projection );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid ;
#else
return 0;
#endif
}
static No_Comm defaultComm () { return No_Comm(); }
static int getRank ( No_Comm comm ) { return 0; }
static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid )
{
ALU3DSPACE Gitter::Geometric::BuilderIF* builder =
dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF* >( &grid.container() );
if( ! builder )
DUNE_THROW(InvalidStateException,"dynamic_cast of ALUGrid builder failed");
return *builder;
}
static void duneNotifyMacroGridChanges ( GitterImplType &grid ) {}
CollectiveCommunication ccobj_;
};
#if ALU3DGRID_PARALLEL
template< ALU3dGridElementType elType >
struct ALU3dGridCommunications< elType, MPI_Comm > : public ALU3dGridCommunicationsBase
{
using ALU3dGridCommunicationsBase :: checkForConformingRefinement ;
typedef ALU3dGridGlobalIdSet< elType, MPI_Comm > GlobalIdSet;
typedef ALUGridId< ALUMacroKey > GlobalId;
typedef ALU3DSPACE GitterDunePll GitterImplType;
typedef Dune::CollectiveCommunication< MPI_Comm > CollectiveCommunication;
explicit ALU3dGridCommunications ( MPI_Comm comm )
: ccobj_( comm ), mpAccess_( comm )
{}
int nlinks () const { return mpAccess_.nlinks(); }
GitterImplType *createALUGrid ( const std::string ¯oName, ALU3DSPACE ProjectVertex *projection,
const bool conformingRefinement )
{
GitterImplType* grid = new GitterImplType( macroName.c_str(), mpAccess_, projection );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid;
}
GitterImplType *createALUGrid ( std::istream& stream, ALU3DSPACE ProjectVertex *projection,
const bool conformingRefinement )
{
#ifdef ALUGRID_CONSTRUCTION_WITH_STREAMS
GitterImplType* grid = new GitterImplType ( stream, mpAccess_, projection );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid ;
#else
return 0;
#endif
}
static MPI_Comm defaultComm () { return MPI_COMM_WORLD; }
static int getRank ( MPI_Comm comm )
{
int rank = 0;
MPI_Comm_rank( comm, &rank );
return rank;
}
static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid )
{
ALU3DSPACE Gitter::Geometric::BuilderIF* builder =
dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF* >( &grid.containerPll() );
if( ! builder )
DUNE_THROW(InvalidStateException,"dynamic_cast of ALUGrid builder failed");
return *builder;
}
static void duneNotifyMacroGridChanges ( GitterImplType &grid )
{
grid.duneNotifyMacroGridChanges();
}
CollectiveCommunication ccobj_;
ALU3DSPACE MpAccessMPI mpAccess_;
};
#endif // #if ALU3DGRID_PARALLEL
// ALU3dGridFamily
// ---------------
template< ALU3dGridElementType elType, class Comm >
struct ALU3dGridFamily
{
typedef ALU3dGrid< elType, Comm > GridImp;
typedef ALU3dGridFamily< elType, Comm > GridFamily;
static const int dim = 3;
static const int dimworld = 3;
//! Type of the local id set
typedef ALU3dGridLocalIdSet< elType, Comm > LocalIdSetImp;
//! Type of the global id set
typedef typename ALU3dGridCommunications< elType, Comm >::GlobalIdSet GlobalIdSetImp;
//! type of ALU3dGrids global id
typedef typename ALU3dGridCommunications< elType, Comm >::GlobalId GlobalIdType;
//! type of ALU3dGrids local id
typedef int LocalIdType;
struct Traits
{
//! type of ALU3dGrids local id
typedef typename GridFamily::LocalIdType LocalIdType;
//! type of ALU3dGrids global id
typedef typename GridFamily::GlobalIdType GlobalIdType;
typedef typename GridFamily::GridImp Grid;
typedef Dune::Intersection< const Grid, LeafIntersectionWrapper< const Grid > > LeafIntersection;
typedef Dune::Intersection< const Grid, LevelIntersectionWrapper< const Grid > > LevelIntersection;
typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorWrapper< const Grid >, LeafIntersectionWrapper< const Grid > > IntersectionIterator;
typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorWrapper< const Grid >, LeafIntersectionWrapper< const Grid > > LeafIntersectionIterator;
typedef Dune::IntersectionIterator< const Grid, LevelIntersectionIteratorWrapper< const Grid >, LevelIntersectionWrapper< const Grid > > LevelIntersectionIterator;
typedef Dune::EntityIterator< 0, const Grid, ALU3dGridHierarchicIterator< const Grid > > HierarchicIterator;
typedef DuneBoundaryProjection< dimworld > DuneBoundaryProjectionType;
typedef std::vector< const DuneBoundaryProjectionType * > DuneBoundaryProjectionVector;
template< int cd >
struct Codim
{
// IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
typedef ALU3dGridGeometry< dim-cd, dimworld, const Grid > GeometryImpl;
typedef ALU3dGridGeometry< dim-cd, dim, const Grid > LocalGeometryImpl;
typedef Dune::Geometry< dim-cd, dimworld, const Grid, ALU3dGridGeometry > Geometry;
typedef Dune::Geometry< dim-cd, dim, const Grid, ALU3dGridGeometry > LocalGeometry;
typedef Dune::Entity< cd, dim, const Grid, ALU3dGridEntity > Entity;
// minimal information to generate entities
typedef ALU3dGridEntitySeed< cd , const Grid> EntitySeed ;
typedef ALU3dGridEntityPointer< cd, const Grid > EntityPointerImpl;
typedef Dune::EntityPointer< const Grid, EntityPointerImpl > EntityPointer;
template< PartitionIteratorType pitype >
struct Partition
{
typedef Dune::EntityIterator< cd, const Grid, ALU3dGridLevelIterator< cd, pitype, const Grid > > LevelIterator;
typedef Dune::EntityIterator< cd, const Grid, ALU3dGridLeafIterator< cd, pitype, const Grid > > LeafIterator;
}; // struct Partition
typedef typename Partition< All_Partition >::LevelIterator LevelIterator;
typedef typename Partition< All_Partition >::LeafIterator LeafIterator;
}; // struct Codim
template< PartitionIteratorType pitype >
struct Partition
{
typedef Dune::GridView<DefaultLevelGridViewTraits< const Grid, pitype > > LevelGridView;
typedef Dune::GridView<DefaultLeafGridViewTraits< const Grid, pitype > > LeafGridView;
}; // struct Partition
//! Type of the level index set
typedef DefaultIndexSet< GridImp, typename Codim< 0 > :: LevelIterator > LevelIndexSetImp;
//! Type of the leaf index set
typedef DefaultIndexSet< GridImp, typename Codim< 0 > :: LeafIterator > LeafIndexSetImp;
typedef IndexSet< Grid, LevelIndexSetImp > LevelIndexSet;
typedef IndexSet< Grid, LeafIndexSetImp > LeafIndexSet;
typedef IdSet< Grid, LocalIdSetImp, LocalIdType > LocalIdSet;
typedef IdSet< Grid, GlobalIdSetImp, GlobalIdType > GlobalIdSet;
typedef Dune::CollectiveCommunication< Comm > CollectiveCommunication;
}; // struct Traits
//! Type of the level index set implementation
typedef typename Traits :: LevelIndexSetImp LevelIndexSetImp;
//! Type of the leaf index set implementation
typedef typename Traits :: LeafIndexSetImp LeafIndexSetImp;
}; // struct ALU3dGridFamily
//**********************************************************************
//
// --ALU3dGrid
// --Grid
//
//**********************************************************************
/**
\brief [<em> provides \ref Dune::Grid </em>]
\brief 3D grid with support for hexahedrons and tetrahedrons.
The ALU3dGrid implements the Dune GridInterface for 3d tetrahedral and
hexahedral meshes. This grid can be locally adapted and used in parallel
computations using dynamic load balancing.
@note
Adaptive parallel grid supporting dynamic load balancing, written
mainly by Bernard Schupp. This grid supports hexahedrons and tetrahedrons.
(see ALUGrid homepage: http://www.mathematik.uni-freiburg.de/IAM/Research/alugrid/)
Two tools are available for partitioning :
\li Metis ( version 4.0 and higher, see http://glaros.dtc.umn.edu/gkhome/views/metis/metis/ )
\li ParMETIS ( http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview )
For installation instructions see http://www.dune-project.org/external_libraries/install_alugrid.html .
@author Robert Kloefkorn
*/
template< ALU3dGridElementType elType, class Comm >
class ALU3dGrid
: public GridDefaultImplementation< 3, 3, alu3d_ctype,
ALU3dGridFamily< elType, Comm > >,
public HasObjectStream,
public HasHierarchicIndexSet
{
typedef ALU3dGrid< elType, Comm > ThisType;
typedef GridDefaultImplementation< 3, 3, alu3d_ctype, ALU3dGridFamily< elType, Comm > > BaseType;
// for compatibility: MyType := ThisType
typedef ThisType MyType;
// friend declarations
friend class ALU3dGridEntity< 0, 3, const ThisType>;
friend class ALU3dGridEntity< 1, 3, const ThisType>;
friend class ALU3dGridEntity< 2, 3, const ThisType>;
friend class ALU3dGridEntity< 3, 3, const ThisType>;
friend class ALU3dGridIntersectionIterator< ThisType >;
friend class ALU3dGridEntityPointerBase< 0, const ThisType >;
friend class ALU3dGridEntityPointerBase< 1, const ThisType >;
friend class ALU3dGridEntityPointerBase< 2, const ThisType >;
friend class ALU3dGridEntityPointerBase< 3, const ThisType >;
friend class ALU3dGridEntityPointer< 0, const ThisType >;
friend class ALU3dGridEntityPointer< 1, const ThisType >;
friend class ALU3dGridEntityPointer< 2, const ThisType >;
friend class ALU3dGridEntityPointer< 3, const ThisType >;
friend class ALU3dGridIntersectionIterator< const ThisType >;
friend class ALU3dGridHierarchicIterator< const ThisType >;
friend class ALU3dGridHierarchicIndexSet< elType, Comm >;
friend class ALU3dGridGlobalIdSet< elType, Comm >;
friend class ALU3dGridLocalIdSet< elType, Comm >;
friend class Conversion< ThisType, HasObjectStream >;
friend class Conversion< const ThisType, HasObjectStream >;
friend class Conversion< ThisType, HasHierarchicIndexSet >;
friend class Conversion< const ThisType, HasHierarchicIndexSet >;
friend struct ALU3dGridCommHelper< elType, Comm >;
// new intersection iterator is a wrapper which get itersectioniteratoimp as pointers
public:
typedef ALU3dGridIntersectionIterator<const ThisType>
IntersectionIteratorImp;
typedef ALU3dGridIntersectionIterator<const ThisType>
LeafIntersectionIteratorImp;
typedef ALU3dGridLevelIntersectionIterator<const ThisType>
LevelIntersectionIteratorImp;
friend class IntersectionIteratorWrapper < const ThisType, LeafIntersectionIteratorImp > ;
friend class IntersectionIteratorWrapper < const ThisType, LevelIntersectionIteratorImp > ;
friend class LeafIntersectionIteratorWrapper < const ThisType > ;
friend class LevelIntersectionIteratorWrapper< const ThisType > ;
//**********************************************************
// The Interface Methods
//**********************************************************
public:
enum { refineStepsForHalf = 1 };
static const ALU3dGridElementType elementType = elType;
typedef typename ALU3DSPACE GatherScatterType::ObjectStreamType ObjectStreamType;
typedef ObjectStreamType InStreamType ;
typedef ObjectStreamType OutStreamType ;
typedef ALU3dGridFamily< elType, Comm > GridFamily;
typedef typename GridFamily::Traits Traits;
static const int dimension = BaseType::dimension;
static const int dimensionworld = BaseType::dimensionworld;
protected:
typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Geometry > GeometryObject;
friend class ALULocalGeometryStorage< const ThisType, GeometryObject, 8 >;
public:
//! Type of the hierarchic index set
typedef ALU3dGridHierarchicIndexSet< elType, Comm > HierarchicIndexSet;
//! Type of the level index set, needed by data handle
typedef typename GridFamily::LevelIndexSetImp LevelIndexSetImp;
//! Type of the leaf index set, needed by data handle
typedef typename GridFamily::LeafIndexSetImp LeafIndexSetImp;
//! reference element type
typedef ReferenceElement< alu3d_ctype, dimension > ReferenceElementType;
//! \brief boundary projection type
typedef typename Traits::DuneBoundaryProjectionType DuneBoundaryProjectionType;
//! \brief boundary projection type
typedef typename Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
//! type of ALUGrid Vertex Projection Interface
typedef ALU3DSPACE ProjectVertex ALUGridVertexProjectionType;
//! type of collective communication object
typedef typename Traits::CollectiveCommunication CollectiveCommunication;
public:
typedef MakeableInterfaceObject<typename Traits::template Codim<0>::Entity> EntityObject;
typedef MakeableInterfaceObject<typename Traits::template Codim<1>::Entity> FaceObject;
typedef MakeableInterfaceObject<typename Traits::template Codim<2>::Entity> EdgeObject;
typedef MakeableInterfaceObject<typename Traits::template Codim<3>::Entity> VertexObject;
typedef ALUGridObjectFactory< ThisType > GridObjectFactoryType;
protected:
friend class ALUGridBoundaryProjection< ThisType, alu3d_ctype >;
// type of ALUGrid boundary projection wrapper
typedef ALUGridBoundaryProjection< ThisType, alu3d_ctype > ALUGridBoundaryProjectionType;
//! Type of the local id set
typedef typename GridFamily::LocalIdSetImp LocalIdSetImp;
typedef typename GridFamily::GlobalIdSetImp GlobalIdSetImp;
public:
//! Type of the global id set
typedef typename Traits::GlobalIdSet GlobalIdSet;
//! Type of the local id set
typedef typename Traits::LocalIdSet LocalIdSet;
protected:
typedef ALU3dGridLeafIterator< 0, All_Partition, const ThisType > LeafIteratorImp;
typedef typename Traits::template Codim< 0 >::LeafIterator LeafIteratorType;
typedef typename Traits::template Codim< 0 >::LeafIterator LeafIterator;
typedef ALU3dGridHierarchicIterator< const ThisType > HierarchicIteratorImp;
typedef typename ALU3dImplTraits< elType, Comm >::GitterImplType GitterImplType;
//! max number of levels
enum {
//! \brief maximal number of levels is 32
MAXL = 32
};
//! element chunk for refinement
enum {
//! \brief normal default number of new elements for new adapt method
newElementsChunk_ = 128
};
//! upper estimate on number of elements that could be created when a new element is created
enum {
/** \brief if one element is refined then it
causes apporximately not more than
this number of new elements */
refineEstimate_ = 8
};
public:
typedef Comm MPICommunicatorType;
typedef ALU3dGridCommunications< elType, Comm > Communications;
protected:
typedef ALU3dGridVertexList< Comm > VertexListType;
typedef ALU3dGridLeafVertexList< Comm > LeafVertexListType;
//! Constructor which reads an ALU3dGrid Macro Triang file
//! or given GridFile
ALU3dGrid ( const std::string ¯oTriangFilename,
const MPICommunicatorType mpiComm,
const DuneBoundaryProjectionType *bndPrj,
const DuneBoundaryProjectionVector *bndVec,
const ALUGridRefinementType refinementType ) DUNE_DEPRECATED_MSG("ALUGrid is deprecated, please use the new module DUNE-ALUGrid.");
public:
//! \brief Desctructor
virtual ~ALU3dGrid();
//! \brief for grid identification
static inline std::string name ();
/** \brief Return maximum level defined in this grid. Levels are numbered
maxLevel with 0 the coarsest level.
*/
int maxLevel() const;
//! Iterator to first entity of given codim on level
template<int cd, PartitionIteratorType pitype>
typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
lbegin (int level) const;
//! one past the end on this level
template<int cd, PartitionIteratorType pitype>
typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
lend (int level) const;
//! Iterator to first entity of given codim on level
template<int cd>
typename Traits::template Codim<cd>::
template Partition<All_Partition>::LevelIterator
lbegin (int level) const;
//! one past the end on this level
template<int cd>
typename Traits::template Codim<cd>::
template Partition<All_Partition>::LevelIterator
lend (int level) const;
private:
//! General definiton for a leaf iterator
template <int codim, PartitionIteratorType pitype>
typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
leafbegin(int level) const;
//! General definition for an end iterator on leaf level
template <int codim, PartitionIteratorType pitype>
typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
leafend(int level) const;
//! General definiton for a leaf iterator
template <int codim>
typename Traits::template Codim<codim>::LeafIterator
leafbegin(int level) const;
//! General definition for an end iterator on leaf level
template <int codim>
typename Traits::template Codim<codim>::LeafIterator
leafend(int level) const;
//! Iterator to first entity of codim 0 on leaf level (All_Partition)
LeafIteratorType leafbegin (int level) const;
//! one past the end on this leaf level (codim 0 and All_Partition)
LeafIteratorType leafend (int level) const;
//! Iterator to first entity of codim 0 on leaf level (All_Partition)
LeafIteratorType leafbegin () const;
//! one past the end on this leaf level (codim 0 and All_Partition)
LeafIteratorType leafend () const;
public:
//! General definiton for a leaf iterator
template <int codim, PartitionIteratorType pitype>
typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
leafbegin() const;
//! General definition for an end iterator on leaf level
template <int codim, PartitionIteratorType pitype>
typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
leafend() const;
//! General definiton for a leaf iterator
template <int codim>
typename Traits::template Codim<codim>::LeafIterator
leafbegin() const;
//! General definition for an end iterator on leaf level
template <int codim>
typename Traits::template Codim<codim>::LeafIterator
leafend() const;
private:
//! General definiton for a leaf iterator
template <int codim, PartitionIteratorType pitype>
typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
createLeafIteratorBegin (int level) const;
//! General definition for an end iterator on leaf level
template <int codim, PartitionIteratorType pitype>
typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
createLeafIteratorEnd(int level) const;
public:
//! number of grid entities per level and codim
int size (int level, int cd) const;
//! number of leaf entities per codim in this process
int size (int codim) const;
//! number of entities per level and geometry type in this process
int size (int level, GeometryType type) const;
//! number of boundary segments
size_t numBoundarySegments() const;
//! number of leaf entities per geometry type in this process
int size (GeometryType type) const;
//! number of grid entities on all levels for given codim
int global_size (int cd) const ;
// (no interface method) number of grid entities in the entire grid for given codim
int hierSetSize (int cd) const;
//! get global id set of grid
const GlobalIdSet &globalIdSet () const
{
if( !globalIdSet_ )
globalIdSet_ = new GlobalIdSetImp( *this );
return *globalIdSet_;
}
//! get global id set of grid
const LocalIdSet & localIdSet () const { return localIdSet_; }
//! get leaf index set of the grid
const typename Traits :: LeafIndexSet & leafIndexSet () const;
//! get level index set of the grid
const typename Traits :: LevelIndexSet & levelIndexSet (int level) const;
/** \brief Calculates load of each process and repartition the grid if neccessary.
For parameters of the load balancing process see the README file
of the ALUGrid package.
*/
bool loadBalance ();
/** \brief Calculates load of each process and repartition the grid if neccessary.
For parameters of the load balancing process see the README file
of the ALUGrid package.
\param data the data handler class that must implement three methods:
\code
// calls data inline on macro element. From there the data of
// all children can be written to the message buffer.
// MessageBufferImp implements the MessageBufferIF interface.
template<class MessageBufferImp>
void inlineData ( MessageBufferImp& buff, Dune::Entity<0> & e);
// calls data xtract on macro element. From there the data of
// all children can be restored from the message buffer.
// numChildren is the number of all children underneath the
// macro element e.
// MessageBufferImp implements the MessageBufferIF interface.
template<class MessageBufferImp>
void xtractData ( MessageBufferImp& buff, Dune::Entity<0> & e, size_t numChildren );
// This method is called at the end of the load balancing process
// before adaptation markers are removed. Here the user can apply
// a data compression or other features. This method can be
// empty if nothing should be done.
void compress ();
\endcode
*/
template <class DataHandle>
bool loadBalance (DataHandle & data);
template< class DataHandleImpl, class Data >
bool loadBalance ( CommDataHandleIF< DataHandleImpl, Data > &dataHandle )
{
typedef ALUGridLoadBalanceDataHandle< ThisType, DataHandleImpl, Data > LBHandle;
LBHandle lbHandle( *this, dataHandle );
return loadBalance( lbHandle );
}
/** \brief ghostSize is one for codim 0 and zero otherwise for this grid */
int ghostSize (int level, int codim) const;
/** \brief overlapSize is zero for this grid */
int overlapSize (int level, int codim) const { return 0; }
/** \brief ghostSize is one for codim 0 and zero otherwise for this grid */
int ghostSize (int codim) const;
/** \brief overlapSize is zero for this grid */
int overlapSize (int codim) const { return 0; }
/** \brief @copydoc Dune::Grid::communicate */
template<class DataHandleImp,class DataTypeImp>
void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data,
InterfaceType iftype, CommunicationDirection dir, int level) const;
/** \brief Communicate information on distributed entities on the leaf grid.
Template parameter is a model of Dune::CommDataHandleIF.
*/
template<class DataHandleImp,class DataTypeImp>
void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data,
InterfaceType iftype, CommunicationDirection dir) const;
private:
typedef ALU3DSPACE GatherScatter GatherScatterType;
public:
/** \brief @copydoc Dune::Grid::comm() */
const CollectiveCommunication &comm () const { return communications().ccobj_; }
//! returns if a least one entity was marked for coarsening
bool preAdapt ( );
//! clear all entity new markers
void postAdapt ( );
/** \brief @copydoc Dune::Grid::adapt() */
bool adapt ();
/** \brief @copydoc Dune::Grid::adapt()
\param handle handler for restriction and prolongation operations
which is a Model of the AdaptDataHandleInterface class.
*/
template< class GridImp, class DataHandle >
bool adapt ( AdaptDataHandleInterface< GridImp, DataHandle > &handle );
//! uses the interface, mark on entity and refineLocal
void globalRefine ( int refCount );
template< class GridImp, class DataHandle >
void globalRefine ( int refCount, AdaptDataHandleInterface< GridImp, DataHandle > &handle );
//**********************************************************
// End of Interface Methods
//**********************************************************
/** \brief write Grid to file in specified FileFormatType
*/
template <GrapeIOFileFormatType ftype>
bool writeGrid( const std::string filename, alu3d_ctype time ) const ;
bool writeGrid_Xdr( const std::string filename, alu3d_ctype time ) const ;
//! write leaf grid in macro grid format to ascii file
bool writeGrid_Ascii( const std::string filename, alu3d_ctype time, bool scientific = false ) const ;
/** \brief write macro grid in ALUGrid macro format to path/filename.rank
*/
bool writeMacroGrid( const std::string path, const std::string filename ) const ;
/** \brief read Grid from file filename and store time of mesh in time
*/
template <GrapeIOFileFormatType ftype>
bool readGrid( const std::string filename, alu3d_ctype & time );
/** \brief backup to ostream */
void backup( std::ostream& ) const ;
/** \brief restore from istream */
void restore( std::istream& ) ;
// (no interface method) get hierarchic index set of the grid
const HierarchicIndexSet & hierarchicIndexSet () const { return hIndexSet_; }
// set max of given mxl and actual maxLevel
// for loadBalance
void setMaxLevel (int mxl);
// no interface method, but has to be public
void updateStatus ();
//! @copydoc Dune::Grid::mark
bool mark( int refCount , const typename Traits::template Codim<0>::Entity & e);
//! @copydoc Dune::Grid::getMark
int getMark( const typename Traits::template Codim<0>::Entity & e) const;
public:
static MPICommunicatorType defaultCommunicator ()
{
return Communications::defaultComm();
}
using BaseType :: getRealImplementation ;
template< class IntersectionType >
static const typename BaseType
:: template ReturnImplementationType< IntersectionType >
:: ImplementationType &
getRealIntersection ( const IntersectionType &intersection )
{
return getRealImplementation( intersection );
}
//! deliver all geometry types used in this grid
const std::vector<GeometryType>& geomTypes (int codim) const { return geomTypes_[codim]; }
// return reference to org ALU3dGrid
// private method, but otherwise we have to friend class all possible
// types of LevelIterator ==> later
GitterImplType &myGrid () const;
virtual GitterImplType *createALUGrid ( const std::string ¯oName )
{
assert( communications_ );
return communications_->createALUGrid( macroName, vertexProjection(), conformingRefinement() );
}
virtual GitterImplType *createALUGrid ( std::istream& stream )
{
assert( communications_ );
return communications_->createALUGrid( stream, vertexProjection(), conformingRefinement() );
}
ALUGridVertexProjectionType* vertexProjection() { return (ALUGridVertexProjectionType *) vertexProjection_; }
// return appropriate ALUGrid builder
virtual typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder () const
{
return Communications::getBuilder( myGrid() );
}
// helper function for factory
virtual void duneNotifyMacroGridChanges ()
{
Communications::duneNotifyMacroGridChanges( myGrid() );
}
//! return reference to Dune reference element according to elType
const ReferenceElementType & referenceElement() const { return referenceElement_; }
template < class EntitySeed >
typename Traits :: template Codim< EntitySeed :: codimension > :: EntityPointer
entityPointer( const EntitySeed& seed ) const
{
enum { codim = EntitySeed :: codimension };
typedef ALU3dGridEntityPointer < codim, const ThisType > ALUPointer ;
return ALUPointer( factory(), seed ) ;
}
// number of links to other processors, for internal use only
int nlinks () const { return communications().nlinks(); }
LeafVertexListType & getLeafVertexList() const
{
if( !leafVertexList_.up2Date() ) leafVertexList_.setupVxList(*this);
return leafVertexList_;
}
int getLevelOfLeafVertex ( const typename ALU3dImplTraits< elType, Comm >::VertexType &vertex ) const
{
assert( leafVertexList_.up2Date() );
return leafVertexList_.getLevel(vertex);
}
VertexListType & getVertexList(int level) const
{
assert( level >= 0 );
assert( level <= maxLevel() );
VertexListType & vxList = vertexList_[level];
if(!vxList.up2Date()) vxList.setupVxList(*this,level);
return vxList;
}
ALU3dGridItemListType & getGhostLeafList(int codim) const
{
assert( codim >= 1 );
assert( codim <= 3 );
return ghostLeafList_[codim-1];
}
ALU3dGridItemListType & getGhostLevelList(int codim, int level) const
{
assert( codim >= 1 );
assert( codim <= 3 );
assert( level >= 0 );
assert( level <= maxLevel() );
return ghostLevelList_[codim-1][level];
}
ALU3dGridItemListType & getEdgeList(int level) const
{
assert( level >= 0 );
assert( level <= maxLevel() );
return levelEdgeList_[level];
}
protected:
//! Copy constructor should not be used
ALU3dGrid( const ThisType & );
//! assignment operator should not be used
const ThisType &operator= ( const ThisType & );
//! reset size and global size, update Level- and LeafIndexSet, if they exist
void calcExtras();
//! calculate maxlevel
void calcMaxLevel();
//! make grid walkthrough and calc global size
void recalcGlobalSize();
//! check whether macro grid format is of our type
void checkMacroGridFile (const std::string filename);
//! check whether macro grid has the right element type
void checkMacroGrid ();
//! return boudanry projection for given segment Id
const DuneBoundaryProjectionType* boundaryProjection(const int segmentIndex) const
{
if( bndPrj_ )
{
return bndPrj_;
}
else
{
// pointer can be zero (which is emulates the identity mapping then)
assert( bndVec_ );
assert( segmentIndex < (int) bndVec_->size() );
return (*bndVec_)[ segmentIndex ];
}
}
const Communications &communications () const
{
assert( communications_ );
return *communications_;
}
const GridObjectFactoryType& factory() const {
#ifdef USE_SMP_PARALLEL
assert( (int) factoryVec_.size() > GridObjectFactoryType :: threadNumber() );
return factoryVec_[ GridObjectFactoryType :: threadNumber() ];
#else
return factory_;
#endif
}
public:
// return true if conforming refinement is enabled
bool conformingRefinement() const
{
return (refinementType_ == conforming) ;
}
// return true if ghost cells are available
bool ghostCellsEnabled () const
{
#ifdef ALUGRID_3D_CONFORMING_REFINEMENT
return myGrid().ghostCellsEnabled();
#else
return true ;
#endif
}
protected:
/////////////////////////////////////////////////////////////////
//
// Internal variables
//
/////////////////////////////////////////////////////////////////
// the real ALU grid
mutable GitterImplType *mygrid_;
// max level of grid
int maxlevel_;
// count how much elements where marked
mutable int coarsenMarked_;
mutable int refineMarked_;
// at the moment the number of different geom types is 1
enum { numberOfGeomTypes = 1 };
std::vector< std::vector<GeometryType> > geomTypes_;
// our hierarchic index set
HierarchicIndexSet hIndexSet_;
// out global id set
mutable GlobalIdSetImp *globalIdSet_;
// out global id set
LocalIdSetImp localIdSet_;
// the level index set ( default type )
mutable std::vector < LevelIndexSetImp * > levelIndexVec_;
// the leaf index set
mutable LeafIndexSetImp * leafIndexSet_;
// the reference element
const ReferenceElementType& referenceElement_;
mutable VertexListType vertexList_[MAXL];
mutable ALU3dGridItemListType ghostLeafList_[ dimension ];
mutable ALU3dGridItemListType ghostLevelList_[ dimension ][MAXL];
mutable ALU3dGridItemListType levelEdgeList_[MAXL];
mutable LeafVertexListType leafVertexList_;
// the type of our size cache
typedef SizeCache<MyType> SizeCacheType;
SizeCacheType * sizeCache_;
#ifdef USE_SMP_PARALLEL
std::vector< GridObjectFactoryType > factoryVec_;
#else
GridObjectFactoryType factory_;
#endif
// variable to ensure that postAdapt ist called after adapt
bool lockPostAdapt_;
// pointer to Dune boundary projection
const DuneBoundaryProjectionType* bndPrj_;
// pointer to Dune boundary projection
const DuneBoundaryProjectionVector* bndVec_;
// boundary projection for vertices
ALUGridBoundaryProjectionType* vertexProjection_ ;
// pointer to communications object
Communications *communications_;
// refinement type (nonconforming or conforming)
const ALUGridRefinementType refinementType_ ;
}; // end class ALU3dGrid
bool checkMacroGrid ( ALU3dGridElementType elType ,
const std::string filename );
const char* elType2Name( ALU3dGridElementType elType );
namespace Capabilities
{
template< ALU3dGridElementType elType, class Comm, int cdim >
struct hasEntity< Dune::ALU3dGrid< elType, Comm >, cdim >
{
static const bool v = true;
};
template< ALU3dGridElementType elType, class Comm >
struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel< ALU3dGrid< elType, Comm > >
{
static const bool DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") v = true;
};
template< ALU3dGridElementType elType, class Comm >
struct isLevelwiseConforming< ALU3dGrid< elType, Comm > >
{
static const bool v = true;
};
template< ALU3dGridElementType elType, class Comm >
struct hasBackupRestoreFacilities< ALU3dGrid< elType, Comm > >
{
static const bool v = true;
};
} // end namespace Capabilities
} // end namespace Dune
#include "grid_inline.hh"
#if COMPILE_ALUGRID_INLINE
#include "grid_imp.cc"
#endif
#endif
|