alugrid.hh

Go to the documentation of this file.
00001 #ifndef DUNE_ALUGRID_HH
00002 #define DUNE_ALUGRID_HH
00003 
00004 // 3d version 
00005 #include "alugrid/3d/indexsets.hh"
00006 #include "alugrid/3d/iterator.hh"
00007 #include "alugrid/3d/entity.hh"
00008 #include "alugrid/3d/geometry.hh"
00009 #include "alugrid/3d/grid.hh"
00010 
00011 // 2d version 
00012 #include <dune/grid/alugrid/2d/grid.hh>
00018 namespace Dune { 
00019 
00020 
00046 template< int dim, int dimworld >
00047 class ALUCubeGrid;
00048   
00054 template<>
00055 class ALUCubeGrid< 3, 3 >
00056 : public Dune::ALU3dGrid< 3, 3, Dune::hexa >
00057 {
00058   typedef ALUCubeGrid< 3, 3 > This;
00059 
00060   typedef Dune::ALU3dGrid<3,3,Dune::hexa> BaseType;
00061   enum { dim      = 3 }; 
00062   enum { dimworld = 3 }; 
00063  public:
00064 #if ALU3DGRID_PARALLEL
00069   ALUCubeGrid(const std::string macroName , MPI_Comm mpiComm = MPI_COMM_WORLD) :
00070     BaseType(macroName,mpiComm) 
00071   {
00072     if(this->comm().rank() == 0)
00073     {
00074       std::cout << "\nCreated parallel ALUCubeGrid<"<<dim<<","<<dimworld;
00075       std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00076     }
00077   }
00079   ALUCubeGrid(MPI_Comm mpiComm = MPI_COMM_WORLD) :
00080     BaseType("",mpiComm) 
00081   {
00082     if(this->comm().rank() == 0)
00083     {
00084       std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
00085     }
00086   }
00087 #else
00092   ALUCubeGrid(const std::string macroName , int mpiComm = 0 ) :
00093     BaseType(macroName) 
00094   {
00095     std::cout << "\nCreated serial ALUCubeGrid<"<<dim<<","<<dimworld;
00096     std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00097   }
00099   ALUCubeGrid(int myrank = -1) :
00100     BaseType("",myrank) 
00101   {
00102     std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
00103   }
00104 #endif
00105   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00106   typedef BaseType::ctype ctype;
00107   typedef BaseType::GridFamily GridFamily;
00108   typedef GridFamily::Traits Traits;
00109   typedef BaseType::LocalIdSetImp LocalIdSetImp;
00110   typedef Traits :: GlobalIdSet GlobalIdSet;
00111   typedef Traits :: LocalIdSet LocalIdSet;
00112   typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00113   typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00114   typedef BaseType::LeafIteratorImp LeafIteratorImp;
00115   typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00116   typedef Traits::Codim<0>::LeafIterator LeafIterator;
00117 
00118   // ALUGrid only typedefs 
00119   typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00120   typedef BaseType::ObjectStreamType      ObjectStreamType;
00121 
00122   template< PartitionIteratorType pitype >
00123   struct Partition
00124   {
00125     typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00126       LevelGridView;
00127     typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00128       LeafGridView;
00129   };
00130 
00131   typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00132   typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00133 
00134   template< PartitionIteratorType pitype >
00135   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00136   {
00137     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00138     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00139     return LevelGridView( LevelGridViewImp( *this, level ) );
00140   }
00141 
00142   template< PartitionIteratorType pitype >
00143   typename Partition< pitype >::LeafGridView leafView () const
00144   {
00145     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00146     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00147     return LeafGridView( LeafGridViewImp( *this ) );
00148   }
00149 
00150   LevelGridView levelView ( int level ) const
00151   {
00152     typedef LevelGridView::GridViewImp LevelGridViewImp;
00153     return LevelGridView( LevelGridViewImp( *this, level ) );
00154   }
00155 
00156   LeafGridView leafView () const
00157   {
00158     typedef LeafGridView::GridViewImp LeafGridViewImp;
00159     return LeafGridView( LeafGridViewImp( *this ) );
00160   }
00161 
00162 private: 
00163   friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00164   friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00165   
00166   friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00167   friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00168   
00170     ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
00171   
00173     ALUCubeGrid<dim,dimworld>& 
00174     operator = (const ALUCubeGrid& g); 
00175 };
00176 
00177   namespace Capabilities {
00189     template<int dim,int dimw, int cdim >
00190     struct hasEntity<Dune::ALUCubeGrid<dim, dimw>, cdim >
00191     {
00192       static const bool v = true;
00193     };
00194 
00198     template<int dim,int dimw>
00199     struct isParallel<const ALUCubeGrid<dim, dimw> > {
00200       static const bool v = true;
00201     };
00202 
00206     template<int dim,int dimw>
00207     struct isLevelwiseConforming< ALUCubeGrid<dim,dimw> >
00208     {
00209       static const bool v = true;
00210     };
00211 
00215     template<int dim,int dimw>
00216     struct hasHangingNodes< ALUCubeGrid<dim,dimw> >
00217     {
00218       static const bool v = true;
00219     };
00220 
00224     template<int dim,int dimw>
00225     struct hasBackupRestoreFacilities< ALUCubeGrid<dim,dimw> >
00226     {
00227       static const bool v = true;
00228     };
00229 
00230   } // end namespace Capabilities
00231 
00232 
00261 template< int dim, int dimworld >
00262 class ALUSimplexGrid;
00263 
00269 template<>
00270 class ALUSimplexGrid< 3, 3 >
00271 : public Dune::ALU3dGrid< 3, 3,Dune::tetra >
00272 {
00273   typedef ALUSimplexGrid< 3, 3 > This;
00274 
00275   typedef Dune::ALU3dGrid<3,3,Dune::tetra> BaseType;
00276   enum { dim      = 3 };
00277   enum { dimworld = 3 }; 
00278  public:
00279 #if ALU3DGRID_PARALLEL
00284   ALUSimplexGrid(const std::string macroName, MPI_Comm mpiComm = MPI_COMM_WORLD) :
00285     BaseType(macroName,mpiComm) 
00286   {
00287     if(this->comm().rank() == 0)
00288     {
00289       std::cout << "\nCreated parallel ALUSimplexGrid<"<<dim<<","<<dimworld;
00290       std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00291     }
00292   }
00294   ALUSimplexGrid(MPI_Comm mpiComm = MPI_COMM_WORLD) :
00295     BaseType("",mpiComm) 
00296   {
00297     if(this->comm().rank() == 0)
00298     {
00299       std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
00300     }
00301   }
00302 #else
00307   ALUSimplexGrid(const std::string macroName , int mpicomm = 0) :
00308     BaseType(macroName) 
00309   {
00310     std::cout << "\nCreated serial ALUSimplexGrid<"<<dim<<","<<dimworld;
00311     std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00312   }
00314   ALUSimplexGrid(int myrank = -1) :
00315     BaseType("",myrank) 
00316   {
00317     std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
00318   }
00319 #endif 
00320   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00321   typedef BaseType::ctype ctype;
00322   typedef BaseType::GridFamily GridFamily;
00323   typedef GridFamily::Traits Traits;
00324   typedef BaseType::LocalIdSetImp LocalIdSetImp;
00325   typedef Traits :: GlobalIdSet GlobalIdSet;
00326   typedef Traits :: LocalIdSet LocalIdSet;
00327   typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00328   typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00329   typedef BaseType::LeafIteratorImp LeafIteratorImp;
00330   typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00331   typedef Traits::Codim<0>::LeafIterator LeafIterator;
00332 
00333   // ALUGrid only typedefs 
00334   typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00335   typedef BaseType::ObjectStreamType      ObjectStreamType;
00336 
00337   template< PartitionIteratorType pitype >
00338   struct Partition
00339   {
00340     typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00341       LevelGridView;
00342     typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00343       LeafGridView;
00344   };
00345 
00346   typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00347   typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00348 
00349   template< PartitionIteratorType pitype >
00350   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00351   {
00352     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00353     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00354     return LevelGridView( LevelGridViewImp( *this, level ) );
00355   }
00356 
00357   template< PartitionIteratorType pitype >
00358   typename Partition< pitype >::LeafGridView leafView () const
00359   {
00360     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00361     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00362     return LeafGridView( LeafGridViewImp( *this ) );
00363   }
00364 
00365   LevelGridView levelView ( int level ) const
00366   {
00367     typedef LevelGridView::GridViewImp LevelGridViewImp;
00368     return LevelGridView( LevelGridViewImp( *this, level ) );
00369   }
00370 
00371   LeafGridView leafView () const
00372   {
00373     typedef LeafGridView::GridViewImp LeafGridViewImp;
00374     return LeafGridView( LeafGridViewImp( *this ) );
00375   }
00376 
00377 private:
00378   friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00379   friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00380 
00381   friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00382   friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00383 
00385     ALUSimplexGrid( const ALUSimplexGrid & g ); //  : BaseType(g) {}
00386   
00388     ALUSimplexGrid<dim,dimworld>& 
00389     operator = (const ALUSimplexGrid& g); 
00390   
00391 };
00392 
00398 template<>
00399 class ALUSimplexGrid< 2, 2 >
00400 : public Dune::ALU2dGrid< 2, 2 >
00401 {
00402   typedef ALUSimplexGrid< 2, 2 > This;
00403 
00404   typedef Dune::ALU2dGrid< 2, 2 > BaseType;
00405   enum { dim      = 2 };
00406   enum { dimworld = 2 };
00407 
00408 public:
00411   ALUSimplexGrid(const std::string macroName ) 
00412     : BaseType(macroName,1) 
00413   {
00414     std::cout << "\nCreated serial ALUSimplexGrid<"<<dim<<","<<dimworld;
00415     std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00416   }
00418   ALUSimplexGrid( ) : BaseType(1) 
00419   {
00420     std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
00421   }
00422   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00423   enum { refineStepsForHalf = 1 };
00424   typedef BaseType::ctype ctype;
00425   typedef BaseType::GridFamily GridFamily;
00426   typedef GridFamily::Traits Traits;
00427   typedef BaseType::LocalIdSetImp LocalIdSetImp;
00428   typedef Traits :: GlobalIdSet GlobalIdSet;
00429   typedef Traits :: LocalIdSet LocalIdSet;
00430   typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00431   typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00432   typedef BaseType::LeafIteratorImp LeafIteratorImp;
00433   typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00434   typedef Traits::Codim<0>::LeafIterator LeafIterator;
00435   typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00436 
00437   template< PartitionIteratorType pitype >
00438   struct Partition
00439   {
00440     typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00441       LevelGridView;
00442     typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00443       LeafGridView;
00444   };
00445 
00446   typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00447   typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00448 
00449   template< PartitionIteratorType pitype >
00450   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00451   {
00452     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00453     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00454     return LevelGridView( LevelGridViewImp( *this, level ) );
00455   }
00456 
00457   template< PartitionIteratorType pitype >
00458   typename Partition< pitype >::LeafGridView leafView () const
00459   {
00460     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00461     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00462     return LeafGridView( LeafGridViewImp( *this ) );
00463   }
00464 
00465   LevelGridView levelView ( int level ) const
00466   {
00467     typedef LevelGridView::GridViewImp LevelGridViewImp;
00468     return LevelGridView( LevelGridViewImp( *this, level ) );
00469   }
00470 
00471   LeafGridView leafView () const
00472   {
00473     typedef LeafGridView::GridViewImp LeafGridViewImp;
00474     return LeafGridView( LeafGridViewImp( *this ) );
00475   }
00476 
00477 private:
00478   friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00479   friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00480 
00481   friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00482   friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00483   
00485     ALUSimplexGrid( const ALUSimplexGrid & g ) ; // : BaseType(g) {}
00486   
00488     ALUSimplexGrid<dim,dimworld>& 
00489     operator = (const ALUSimplexGrid& g); 
00490  };
00491 
00492   namespace Capabilities {
00504     template<int dim,int dimw, int cdim >
00505     struct hasEntity<Dune::ALUSimplexGrid<dim, dimw>, cdim >
00506     {
00507       static const bool v = true;
00508     };
00509 
00513     template<int dim,int dimw>
00514     struct isParallel<const ALUSimplexGrid<dim, dimw> > {
00515       static const bool v = false;
00516     };
00517 
00521     template<int dim,int dimw>
00522     struct isLevelwiseConforming< ALUSimplexGrid<dim,dimw> >
00523     {
00524       static const bool v = true;
00525     };
00526 
00530     template<int dim,int dimw>
00531     struct hasHangingNodes< ALUSimplexGrid<dim,dimw> >
00532     {
00533       static const bool v = true;
00534     };
00535 
00539     template<int dim,int dimw>
00540     struct hasBackupRestoreFacilities< ALUSimplexGrid<dim,dimw> >
00541     {
00542       static const bool v = true;
00543     };
00544 
00545   } // end namespace Capabilities
00546 
00570 template <int dim, int dimworld>
00571 class ALUConformGrid {};
00572 
00578 template<>
00579 class ALUConformGrid< 2, 2 >
00580 : public Dune::ALU2dGrid< 2, 2 >
00581 {
00582   typedef ALUConformGrid< 2, 2 > This;
00583 
00584   typedef Dune::ALU2dGrid<2,2> BaseType;
00585   enum { dim      = 2 };
00586   enum { dimworld = 2 };
00587  public:
00590   ALUConformGrid(const std::string macroName ) 
00591     : BaseType(macroName) 
00592   {
00593     std::cout << "\nCreated serial ALUConformGrid<"<<dim<<","<<dimworld;
00594     std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00595   }
00597   ALUConformGrid( ) : BaseType(0) 
00598   {
00599     std::cout << "\nCreated empty ALUConformGrid<"<<dim<<","<<dimworld <<">. \n\n";
00600   }
00601   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00602   enum { refineStepsForHalf = 2 };
00603   typedef BaseType::ctype ctype;
00604   typedef BaseType::GridFamily GridFamily;
00605   typedef GridFamily::Traits Traits;
00606   typedef BaseType::LocalIdSetImp LocalIdSetImp;
00607   typedef Traits :: GlobalIdSet GlobalIdSet;
00608   typedef Traits :: LocalIdSet LocalIdSet;
00609   typedef GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00610   typedef GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00611   typedef BaseType::LeafIteratorImp LeafIteratorImp;
00612   typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
00613   typedef Traits::Codim<0>::LeafIterator LeafIterator;
00614   typedef BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00615 
00616   template< PartitionIteratorType pitype >
00617   struct Partition
00618   {
00619     typedef Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00620       LevelGridView;
00621     typedef Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00622       LeafGridView;
00623   };
00624 
00625   typedef Partition< All_Partition > :: LevelGridView LevelGridView;
00626   typedef Partition< All_Partition > :: LeafGridView LeafGridView;
00627 
00628   template< PartitionIteratorType pitype >
00629   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00630   {
00631     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00632     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00633     return LevelGridView( LevelGridViewImp( *this, level ) );
00634   }
00635 
00636   template< PartitionIteratorType pitype >
00637   typename Partition< pitype >::LeafGridView leafView () const
00638   {
00639     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00640     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00641     return LeafGridView( LeafGridViewImp( *this ) );
00642   }
00643 
00644   LevelGridView levelView ( int level ) const
00645   {
00646     typedef LevelGridView::GridViewImp LevelGridViewImp;
00647     return LevelGridView( LevelGridViewImp( *this, level ) );
00648   }
00649 
00650   LeafGridView leafView () const
00651   {
00652     typedef LeafGridView::GridViewImp LeafGridViewImp;
00653     return LeafGridView( LeafGridViewImp( *this ) );
00654   }
00655  
00656 private:
00657   friend class Conversion< ALUConformGrid<dimension,dimensionworld> , HasObjectStream > ;
00658   friend class Conversion< const ALUConformGrid<dimension,dimensionworld> , HasObjectStream > ;
00659 
00660   friend class Conversion< ALUConformGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00661   friend class Conversion< const ALUConformGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00662   
00664     ALUConformGrid( const ALUConformGrid & g ) ; // : BaseType(g) {}
00665   
00667     ALUConformGrid<dim,dimworld>& 
00668     operator = (const ALUConformGrid& g); 
00669  };
00670 
00671   namespace Capabilities {
00683     template<int dim,int dimw, int cdim >
00684     struct hasEntity<Dune::ALUConformGrid<dim, dimw>, cdim >
00685     {
00686       static const bool v = true;
00687     };
00688 
00692     template<int dim,int dimw>
00693     struct isParallel<const ALUConformGrid<dim, dimw> > {
00694       static const bool v = false;
00695     };
00696 
00700     template<int dim,int dimw>
00701     struct isLevelwiseConforming< ALUConformGrid<dim,dimw> >
00702     {
00703       static const bool v = false;
00704     };
00705 
00709     template<int dim,int dimw>
00710     struct hasHangingNodes< ALUConformGrid<dim,dimw> >
00711     {
00712       static const bool v = false;
00713     };
00714 
00718     template<int dim,int dimw>
00719     struct hasBackupRestoreFacilities< ALUConformGrid<dim,dimw> >
00720     {
00721       static const bool v = true;
00722     };
00723 
00724   } // end namespace Capabilities
00725 
00726 
00727 } //end  namespace Dune 
00728 #endif

Generated on 21 Nov 2008 with Doxygen (ver 1.5.1) [logfile].