dune-grid  2.2.0
alugrid/3d/alugrid.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ALU3DGRID_ALUGRID_HH
00002 #define DUNE_ALU3DGRID_ALUGRID_HH
00003 
00004 // only include this code, if ENABLE_ALUGRID is defined
00005 #ifdef ENABLE_ALUGRID
00006 
00007 // 3d version 
00008 #include <dune/grid/alugrid/common/capabilities.hh>
00009 #include <dune/grid/alugrid/3d/capabilities.hh>
00010 #include <dune/grid/alugrid/3d/indexsets.hh>
00011 #include <dune/grid/alugrid/3d/iterator.hh>
00012 #include <dune/grid/alugrid/3d/entity.hh>
00013 #include <dune/grid/alugrid/3d/geometry.hh>
00014 #include <dune/grid/alugrid/3d/grid.hh>
00015 
00021 namespace Dune
00022 {
00023 
00024   template< int dim, int dimworld >
00025   class ALUCubeGrid;
00026 
00027   template< int dim, int dimworld >
00028   class ALUSimplexGrid;
00029 
00030   static const char* ALUGridParallelSerial()
00031   {
00032 #if ALU3DGRID_PARALLEL
00033     return "parallel";
00034 #else 
00035     return "serial";
00036 #endif
00037   }
00038 
00044   template<>
00045   class ALUCubeGrid< 3, 3 >
00046   : public Dune::ALU3dGrid< hexa >
00047   {
00048     typedef ALUCubeGrid< 3, 3 > This;
00049     typedef Dune::ALU3dGrid< hexa > BaseType;
00050 
00051     enum { dim      = 3 }; 
00052     enum { dimworld = 3 }; 
00053 
00054     typedef BaseType::MPICommunicatorType MPICommunicatorType;
00055 
00056    public:
00058     typedef BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType; 
00059 
00061     typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector; 
00062 
00073     ALUCubeGrid(const std::string macroName, 
00074                 const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
00075                 const DuneBoundaryProjectionType* bndProject = 0,
00076                 const DuneBoundaryProjectionVector* bndVector= 0,
00077                 const bool verb = true ) :
00078       BaseType(macroName,mpiComm,bndProject, bndVector, nonconforming ) 
00079     {
00080       const bool verbose = verb && this->comm().rank() == 0;
00081       if( verbose ) 
00082       {
00083         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
00084         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00085       }
00086     }
00087 
00097     ALUCubeGrid(const MPICommunicatorType mpiComm,
00098                 const DuneBoundaryProjectionType* bndProject ,
00099                 const DuneBoundaryProjectionVector* bndVector,
00100                 const std::string macroName, 
00101                 const bool verb = true ) :
00102       BaseType("", mpiComm, bndProject, bndVector, nonconforming ) 
00103     {
00104       const bool verbose = verb && this->comm().rank() == 0;
00105       if( verbose ) 
00106       {
00107         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
00108         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00109       }
00110     }
00111 
00113     ALUCubeGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator() ) :
00114       BaseType("", mpiComm, 
00115                (const DuneBoundaryProjectionType *) 0, 
00116                (const DuneBoundaryProjectionVector* ) 0,
00117                nonconforming ) 
00118     {
00119       if(this->comm().rank() == 0)
00120       {
00121         std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
00122       }
00123     }
00124 
00125     enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00126     typedef BaseType::ctype ctype;
00127     typedef BaseType::GridFamily GridFamily;
00128     typedef GridFamily::Traits Traits;
00129     typedef BaseType::LocalIdSetImp LocalIdSetImp;
00130     typedef Traits :: GlobalIdSet GlobalIdSet;
00131     typedef Traits :: LocalIdSet LocalIdSet;
00132     typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00133     typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00134     typedef BaseType::LeafIteratorImp LeafIteratorImp;
00135     typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00136     typedef Traits::Codim<0>::LeafIterator LeafIterator;
00137 
00138     // ALUGrid only typedefs 
00139     typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00140     typedef BaseType::ObjectStreamType      ObjectStreamType;
00141 
00142     template< PartitionIteratorType pitype >
00143     struct Partition
00144     {
00145       typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00146         LevelGridView;
00147       typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00148         LeafGridView;
00149     };
00150 
00151     typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00152     typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00153 
00154     template< PartitionIteratorType pitype >
00155     typename Partition< pitype >::LevelGridView levelView ( int level ) const
00156     {
00157       typedef typename Partition< pitype >::LevelGridView LevelGridView;
00158       typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00159       return LevelGridView( LevelGridViewImp( *this, level ) );
00160     }
00161 
00162     template< PartitionIteratorType pitype >
00163     typename Partition< pitype >::LeafGridView leafView () const
00164     {
00165       typedef typename Partition< pitype >::LeafGridView LeafGridView;
00166       typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00167       return LeafGridView( LeafGridViewImp( *this ) );
00168     }
00169 
00170     LevelGridView levelView ( int level ) const
00171     {
00172       typedef LevelGridView::GridViewImp LevelGridViewImp;
00173       return LevelGridView( LevelGridViewImp( *this, level ) );
00174     }
00175 
00176     LeafGridView leafView () const
00177     {
00178       typedef LeafGridView::GridViewImp LeafGridViewImp;
00179       return LeafGridView( LeafGridViewImp( *this ) );
00180     }
00181 
00182   private: 
00183     friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00184     friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00185     
00186     friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00187     friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00188 
00189     template< class > friend class ALU3dGridFactory;
00190     
00192     ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
00193   
00195     ALUCubeGrid<dim,dimworld>& 
00196     operator = (const ALUCubeGrid& g); 
00197   };
00198 
00199 
00200 
00206   template<>
00207   class ALUSimplexGrid< 3, 3 >
00208   : public Dune::ALU3dGrid< tetra >
00209   {
00210     typedef ALUSimplexGrid< 3, 3 > This;
00211     typedef Dune::ALU3dGrid< tetra > BaseType;
00212 
00213     enum { dim      = 3 };
00214     enum { dimworld = 3 }; 
00215 
00216     typedef BaseType::MPICommunicatorType MPICommunicatorType;
00217 
00218    public:
00220     typedef BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType; 
00221 
00223     typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector; 
00224 
00235     ALUSimplexGrid(const std::string macroName, 
00236                    const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
00237                    const DuneBoundaryProjectionType* bndProject = 0,
00238                    const DuneBoundaryProjectionVector* bndVector = 0,
00239                    const bool verb = true ) :
00240       BaseType(macroName, mpiComm, bndProject, bndVector, nonconforming ) 
00241     {
00242       const bool verbose = verb && this->comm().rank() == 0;
00243       if( verbose ) 
00244       {
00245         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
00246         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00247       }
00248     }
00249 
00259     ALUSimplexGrid(const MPICommunicatorType mpiComm,
00260                    const DuneBoundaryProjectionType* bndProject ,
00261                    const DuneBoundaryProjectionVector* bndVector,
00262                    const std::string macroName, 
00263                    const bool verb = true ) :
00264       BaseType("", mpiComm, bndProject, bndVector, nonconforming ) 
00265     {
00266       const bool verbose = verb && this->comm().rank() == 0;
00267       if( verbose ) 
00268       {
00269         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
00270         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00271       }
00272     }
00273 
00275     ALUSimplexGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
00276       BaseType("", mpiComm, 
00277                (const DuneBoundaryProjectionType *) 0, 
00278                (const DuneBoundaryProjectionVector* ) 0,
00279                nonconforming ) 
00280     {
00281       if(this->comm().rank() == 0)
00282       {
00283         std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
00284       }
00285     }
00286 
00287     enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00288     typedef BaseType::ctype ctype;
00289     typedef BaseType::GridFamily GridFamily;
00290     typedef GridFamily::Traits Traits;
00291     typedef BaseType::LocalIdSetImp LocalIdSetImp;
00292     typedef Traits :: GlobalIdSet GlobalIdSet;
00293     typedef Traits :: LocalIdSet LocalIdSet;
00294     typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00295     typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00296     typedef BaseType::LeafIteratorImp LeafIteratorImp;
00297     typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00298     typedef Traits::Codim<0>::LeafIterator LeafIterator;
00299 
00300     // ALUGrid only typedefs 
00301     typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00302     typedef BaseType::ObjectStreamType      ObjectStreamType;
00303 
00304     template< PartitionIteratorType pitype >
00305     struct Partition
00306     {
00307       typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00308         LevelGridView;
00309       typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00310         LeafGridView;
00311     };
00312 
00313     typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00314     typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00315 
00316     template< PartitionIteratorType pitype >
00317     typename Partition< pitype >::LevelGridView levelView ( int level ) const
00318     {
00319       typedef typename Partition< pitype >::LevelGridView LevelGridView;
00320       typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00321       return LevelGridView( LevelGridViewImp( *this, level ) );
00322     }
00323 
00324     template< PartitionIteratorType pitype >
00325     typename Partition< pitype >::LeafGridView leafView () const
00326     {
00327       typedef typename Partition< pitype >::LeafGridView LeafGridView;
00328       typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00329       return LeafGridView( LeafGridViewImp( *this ) );
00330     }
00331 
00332     LevelGridView levelView ( int level ) const
00333     {
00334       typedef LevelGridView::GridViewImp LevelGridViewImp;
00335       return LevelGridView( LevelGridViewImp( *this, level ) );
00336     }
00337 
00338     LeafGridView leafView () const
00339     {
00340       typedef LeafGridView::GridViewImp LeafGridViewImp;
00341       return LeafGridView( LeafGridViewImp( *this ) );
00342     }
00343 
00344   private:
00345     friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00346     friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00347 
00348     friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00349     friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00350 
00351     template< class > friend class ALU3dGridFactory;
00352 
00354     ALUSimplexGrid( const ALUSimplexGrid & g ); //  : BaseType(g) {}
00355   
00357     ALUSimplexGrid<dim,dimworld>& 
00358     operator = (const ALUSimplexGrid& g); 
00359   };
00360 
00361 /*- 
00362    (see ALUGrid homepage: http://www.mathematik.uni-freiburg.de/IAM/Research/alugrid/)
00363 
00364    \li Available Implementations 
00365         - quadrilateral and hexahedral elements only nonconforming refinement
00366           - Dune::ALUGrid< 2, 2, cube, nonconforming >  
00367           - Dune::ALUGrid< 2, 3, cube, nonconforming >
00368           - Dune::ALUGrid< 3, 3, cube, nonconforming >
00369         - simplicial elements and nonconforming refinement  
00370           - Dune::ALUGrid< 2, 2, simplex, nonconforming >  
00371           - Dune::ALUGrid< 2, 3, simplex, nonconforming >
00372           - Dune::ALUGrid< 3, 3, simplex, nonconforming >
00373         - simplicial elements and bisection refinement  
00374           - Dune::ALUGrid< 2, 2, simplex, conforming >  
00375           - Dune::ALUGrid< 2, 3, simplex, conforming >
00376           - Dune::ALUGrid< 3, 3, simplex, conforming > (work in progress)
00377 
00378    \note template parameter Comm defaults to MPI_Comm, if MPI is available, No_Comm  otherwise.
00379 */
00380   template< ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
00381   class ALUGrid< 3, 3, elType, refineType, Comm >
00382   : public ALUGridBaseGrid< 3, 3, elType, Comm > :: BaseGrid 
00383   {
00384     typedef ALUGrid< 3, 3, elType, refineType, Comm > This;
00385     typedef typename ALUGridBaseGrid< 3, 3, elType, Comm > :: BaseGrid  BaseType;
00386 
00387     enum { dim      = 3 };
00388     enum { dimworld = 3 }; 
00389 
00390     typedef typename BaseType::MPICommunicatorType MPICommunicatorType;
00391 
00392    public:
00394     typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType; 
00395 
00397     typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector; 
00398 
00409     ALUGrid(const std::string macroName, 
00410             const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
00411             const DuneBoundaryProjectionType* bndProject = 0,
00412             const DuneBoundaryProjectionVector* bndVector = 0,
00413             const bool verb = true ) :
00414       BaseType(macroName, mpiComm, bndProject, bndVector, refineType ) 
00415     {
00416       const bool verbose = verb && this->comm().rank() == 0;
00417       if( verbose ) 
00418       {
00419         std::cout << "\nCreated " << ALUGridParallelSerial() << " " << name() << nameSuffix() 
00420                   << " from macro grid file '" << macroName << "'. \n\n";     
00421       }
00422     }
00423 
00424     static std::string name () { return std::string("ALUGrid"); }
00425 
00426     static std::string nameSuffix() 
00427     { 
00428       std::string elt ( elType == cube ? "cube," : "simplex," ); 
00429       std::string ref ( refineType == nonconforming ? "nonconforming>" : "conforming>" );
00430       std::stringstream suffix; 
00431       suffix << "<"<<dim<<","<<dimworld<<"," << elt << ref;
00432       return suffix.str();
00433     }
00434 
00435 
00445     ALUGrid(const MPICommunicatorType mpiComm,
00446             const DuneBoundaryProjectionType* bndProject ,
00447             const DuneBoundaryProjectionVector* bndVector,
00448             const std::string macroName, 
00449             const bool verb = true ) :
00450       BaseType("", mpiComm, bndProject, bndVector, refineType ) 
00451     {
00452       const bool verbose = verb && this->comm().rank() == 0;
00453       if( verbose ) 
00454       {
00455         std::cout << "\nCreated " << ALUGridParallelSerial() << " " << name() << nameSuffix() 
00456                   << " from macro grid file '" << macroName << "'. \n\n";     
00457       }
00458     }
00459 
00461     ALUGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
00462       BaseType("", mpiComm, 
00463       (const DuneBoundaryProjectionType *) 0, 
00464       (const DuneBoundaryProjectionVector* ) 0,
00465       refineType ) 
00466     {
00467       if(this->comm().rank() == 0)
00468       {
00469         std::cout << "\nCreated empty " << ALUGridParallelSerial() << " " << name() << nameSuffix() << "." << std::endl << std::endl; 
00470       }
00471     }
00472 
00473     enum { dimension=BaseType::dimension,  dimensionworld=BaseType::dimensionworld};
00474     typedef typename BaseType::ctype ctype;
00475     typedef typename BaseType::GridFamily GridFamily;
00476     typedef typename GridFamily::Traits Traits;
00477     typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
00478     typedef typename Traits :: GlobalIdSet GlobalIdSet;
00479     typedef typename Traits :: LocalIdSet LocalIdSet;
00480     typedef typename GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00481     typedef typename GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00482     typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
00483     typedef typename Traits:: template Codim<0>::LeafIterator LeafIteratorType;
00484     typedef typename Traits:: template Codim<0>::LeafIterator LeafIterator;
00485 
00486     // ALUGrid only typedefs 
00487     typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00488     typedef typename BaseType::ObjectStreamType      ObjectStreamType;
00489 
00490     template< PartitionIteratorType pitype >
00491     struct Partition
00492     {
00493       typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00494         LevelGridView;
00495       typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00496         LeafGridView;
00497     };
00498 
00499     typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
00500     typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
00501 
00502     template< PartitionIteratorType pitype >
00503     typename Partition< pitype >::LevelGridView levelView ( int level ) const
00504     {
00505       typedef typename Partition< pitype >::LevelGridView LevelGridView;
00506       typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00507       return LevelGridView( LevelGridViewImp( *this, level ) );
00508     }
00509 
00510     template< PartitionIteratorType pitype >
00511     typename Partition< pitype >::LeafGridView leafView () const
00512     {
00513       typedef typename Partition< pitype >::LeafGridView LeafGridView;
00514       typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00515       return LeafGridView( LeafGridViewImp( *this ) );
00516     }
00517 
00518     LevelGridView levelView ( int level ) const
00519     {
00520       typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00521       return LevelGridView( LevelGridViewImp( *this, level ) );
00522     }
00523 
00524     LeafGridView leafView () const
00525     {
00526       typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00527       return LeafGridView( LeafGridViewImp( *this ) );
00528     }
00529 
00530   private:
00531     friend class Conversion< This , HasObjectStream > ;
00532     friend class Conversion< const This, HasObjectStream > ;
00533 
00534     friend class Conversion< This, HasHierarchicIndexSet > ;
00535     friend class Conversion< const This, HasHierarchicIndexSet > ;
00536 
00537     template< class > friend class ALU3dGridFactory;
00538 
00540     ALUGrid( const ALUGrid & g ); //  : BaseType(g) {}
00541   
00543     This& operator = (const ALUGrid& g); 
00544   };
00545 
00546 } //end  namespace Dune 
00547 
00548 #endif // #ifdef ENABLE_ALUGRID
00549 
00550 #undef alu_inline
00551 #endif