dune-grid  2.1.1
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/3d/capabilities.hh>
00009 #include <dune/grid/alugrid/3d/indexsets.hh>
00010 #include <dune/grid/alugrid/3d/iterator.hh>
00011 #include <dune/grid/alugrid/3d/entity.hh>
00012 #include <dune/grid/alugrid/3d/geometry.hh>
00013 #include <dune/grid/alugrid/3d/grid.hh>
00014 
00020 namespace Dune
00021 {
00022 
00023   template< int dim, int dimworld >
00024   class ALUCubeGrid;
00025 
00026   template< int dim, int dimworld >
00027   class ALUSimplexGrid;
00028 
00029   static const char* ALUGridParallelSerial()
00030   {
00031 #if ALU3DGRID_PARALLEL
00032     return "parallel";
00033 #else 
00034     return "serial";
00035 #endif
00036   }
00037 
00043   template<>
00044   class ALUCubeGrid< 3, 3 >
00045   : public Dune::ALU3dGrid< hexa >
00046   {
00047     typedef ALUCubeGrid< 3, 3 > This;
00048     typedef Dune::ALU3dGrid< hexa > BaseType;
00049 
00050     enum { dim      = 3 }; 
00051     enum { dimworld = 3 }; 
00052 
00053     typedef BaseType::MPICommunicatorType MPICommunicatorType;
00054 
00055    public:
00057     typedef BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType; 
00058 
00060     typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector; 
00061 
00072     ALUCubeGrid(const std::string macroName, 
00073                 const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
00074                 const DuneBoundaryProjectionType* bndProject = 0,
00075                 const DuneBoundaryProjectionVector* bndVector= 0,
00076                 const bool verb = true ) :
00077       BaseType(macroName,mpiComm,bndProject, bndVector) 
00078     {
00079       const bool verbose = verb && this->comm().rank() == 0;
00080       if( verbose ) 
00081       {
00082         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
00083         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00084       }
00085     }
00086 
00096     ALUCubeGrid(const MPICommunicatorType mpiComm,
00097                 const DuneBoundaryProjectionType* bndProject ,
00098                 const DuneBoundaryProjectionVector* bndVector,
00099                 const std::string macroName, 
00100                 const bool verb = true ) :
00101       BaseType("", mpiComm, bndProject, bndVector) 
00102     {
00103       const bool verbose = verb && this->comm().rank() == 0;
00104       if( verbose ) 
00105       {
00106         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
00107         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00108       }
00109     }
00110 
00112     ALUCubeGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator() ) :
00113       BaseType("", mpiComm, 
00114                (const DuneBoundaryProjectionType *) 0, 
00115                (const DuneBoundaryProjectionVector* ) 0) 
00116     {
00117       if(this->comm().rank() == 0)
00118       {
00119         std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
00120       }
00121     }
00122 
00123     enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00124     typedef BaseType::ctype ctype;
00125     typedef BaseType::GridFamily GridFamily;
00126     typedef GridFamily::Traits Traits;
00127     typedef BaseType::LocalIdSetImp LocalIdSetImp;
00128     typedef Traits :: GlobalIdSet GlobalIdSet;
00129     typedef Traits :: LocalIdSet LocalIdSet;
00130     typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00131     typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00132     typedef BaseType::LeafIteratorImp LeafIteratorImp;
00133     typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00134     typedef Traits::Codim<0>::LeafIterator LeafIterator;
00135 
00136     // ALUGrid only typedefs 
00137     typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00138     typedef BaseType::ObjectStreamType      ObjectStreamType;
00139 
00140     template< PartitionIteratorType pitype >
00141     struct Partition
00142     {
00143       typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00144         LevelGridView;
00145       typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00146         LeafGridView;
00147     };
00148 
00149     typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00150     typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00151 
00152     template< PartitionIteratorType pitype >
00153     typename Partition< pitype >::LevelGridView levelView ( int level ) const
00154     {
00155       typedef typename Partition< pitype >::LevelGridView LevelGridView;
00156       typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00157       return LevelGridView( LevelGridViewImp( *this, level ) );
00158     }
00159 
00160     template< PartitionIteratorType pitype >
00161     typename Partition< pitype >::LeafGridView leafView () const
00162     {
00163       typedef typename Partition< pitype >::LeafGridView LeafGridView;
00164       typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00165       return LeafGridView( LeafGridViewImp( *this ) );
00166     }
00167 
00168     LevelGridView levelView ( int level ) const
00169     {
00170       typedef LevelGridView::GridViewImp LevelGridViewImp;
00171       return LevelGridView( LevelGridViewImp( *this, level ) );
00172     }
00173 
00174     LeafGridView leafView () const
00175     {
00176       typedef LeafGridView::GridViewImp LeafGridViewImp;
00177       return LeafGridView( LeafGridViewImp( *this ) );
00178     }
00179 
00180   private: 
00181     friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00182     friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00183     
00184     friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00185     friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00186 
00187     template< class > friend class ALU3dGridFactory;
00188     
00190     ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
00191   
00193     ALUCubeGrid<dim,dimworld>& 
00194     operator = (const ALUCubeGrid& g); 
00195   };
00196 
00197 
00198 
00204   template<>
00205   class ALUSimplexGrid< 3, 3 >
00206   : public Dune::ALU3dGrid< tetra >
00207   {
00208     typedef ALUSimplexGrid< 3, 3 > This;
00209     typedef Dune::ALU3dGrid< tetra > BaseType;
00210 
00211     enum { dim      = 3 };
00212     enum { dimworld = 3 }; 
00213 
00214     typedef BaseType::MPICommunicatorType MPICommunicatorType;
00215 
00216    public:
00218     typedef BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType; 
00219 
00221     typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector; 
00222 
00233     ALUSimplexGrid(const std::string macroName, 
00234                    const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
00235                    const DuneBoundaryProjectionType* bndProject = 0,
00236                    const DuneBoundaryProjectionVector* bndVector = 0,
00237                    const bool verb = true ) :
00238       BaseType(macroName, mpiComm, bndProject, bndVector) 
00239     {
00240       const bool verbose = verb && this->comm().rank() == 0;
00241       if( verbose ) 
00242       {
00243         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
00244         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00245       }
00246     }
00247 
00257     ALUSimplexGrid(const MPICommunicatorType mpiComm,
00258                    const DuneBoundaryProjectionType* bndProject ,
00259                    const DuneBoundaryProjectionVector* bndVector,
00260                    const std::string macroName, 
00261                    const bool verb = true ) :
00262       BaseType("", mpiComm, bndProject, bndVector) 
00263     {
00264       const bool verbose = verb && this->comm().rank() == 0;
00265       if( verbose ) 
00266       {
00267         std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
00268         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00269       }
00270     }
00271 
00273     ALUSimplexGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
00274       BaseType("", mpiComm, 
00275                (const DuneBoundaryProjectionType *) 0, 
00276                (const DuneBoundaryProjectionVector* ) 0) 
00277     {
00278       if(this->comm().rank() == 0)
00279       {
00280         std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
00281       }
00282     }
00283 
00284     enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00285     typedef BaseType::ctype ctype;
00286     typedef BaseType::GridFamily GridFamily;
00287     typedef GridFamily::Traits Traits;
00288     typedef BaseType::LocalIdSetImp LocalIdSetImp;
00289     typedef Traits :: GlobalIdSet GlobalIdSet;
00290     typedef Traits :: LocalIdSet LocalIdSet;
00291     typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00292     typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00293     typedef BaseType::LeafIteratorImp LeafIteratorImp;
00294     typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00295     typedef Traits::Codim<0>::LeafIterator LeafIterator;
00296 
00297     // ALUGrid only typedefs 
00298     typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00299     typedef BaseType::ObjectStreamType      ObjectStreamType;
00300 
00301     template< PartitionIteratorType pitype >
00302     struct Partition
00303     {
00304       typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00305         LevelGridView;
00306       typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00307         LeafGridView;
00308     };
00309 
00310     typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00311     typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00312 
00313     template< PartitionIteratorType pitype >
00314     typename Partition< pitype >::LevelGridView levelView ( int level ) const
00315     {
00316       typedef typename Partition< pitype >::LevelGridView LevelGridView;
00317       typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00318       return LevelGridView( LevelGridViewImp( *this, level ) );
00319     }
00320 
00321     template< PartitionIteratorType pitype >
00322     typename Partition< pitype >::LeafGridView leafView () const
00323     {
00324       typedef typename Partition< pitype >::LeafGridView LeafGridView;
00325       typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00326       return LeafGridView( LeafGridViewImp( *this ) );
00327     }
00328 
00329     LevelGridView levelView ( int level ) const
00330     {
00331       typedef LevelGridView::GridViewImp LevelGridViewImp;
00332       return LevelGridView( LevelGridViewImp( *this, level ) );
00333     }
00334 
00335     LeafGridView leafView () const
00336     {
00337       typedef LeafGridView::GridViewImp LeafGridViewImp;
00338       return LeafGridView( LeafGridViewImp( *this ) );
00339     }
00340 
00341   private:
00342     friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00343     friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00344 
00345     friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00346     friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00347 
00348     template< class > friend class ALU3dGridFactory;
00349 
00351     ALUSimplexGrid( const ALUSimplexGrid & g ); //  : BaseType(g) {}
00352   
00354     ALUSimplexGrid<dim,dimworld>& 
00355     operator = (const ALUSimplexGrid& g); 
00356   };
00357 
00358 } //end  namespace Dune 
00359 
00360 #endif // #ifdef ENABLE_ALUGRID
00361 
00362 #undef alu_inline
00363 #endif