alugrid/2d/alugrid.hh

Go to the documentation of this file.
00001 #ifndef DUNE_ALU2D_ALUGRID_HH
00002 #define DUNE_ALU2D_ALUGRID_HH
00003 
00004 // only include this code, if ENABLE_ALUGRID is defined
00005 #ifdef ENABLE_ALUGRID
00006 
00007 #include <dune/grid/alugrid/2d/capabilities.hh>
00008 #include <dune/grid/alugrid/2d/grid.hh>
00009 
00010 namespace Dune
00011 {
00012 
00018 template<int dimw>
00019 class ALUCubeGrid< 2, dimw >
00020 : public Dune::ALU2dGrid< 2, dimw, ALU2DSPACE quadrilateral >
00021 {
00022   typedef ALUCubeGrid< 2, dimw > This;
00023 
00024   typedef Dune::ALU2dGrid< 2, dimw, ALU2DSPACE quadrilateral > BaseType;
00025   enum { dim      = 2 };
00026   enum { dimworld = dimw };
00027 
00028 public:
00030   typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
00031 
00033   typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
00034 
00043   ALUCubeGrid(const std::string macroName, 
00044               const DuneBoundaryProjectionType* bndProject  = 0,
00045               const DuneBoundaryProjectionVector* bndVector = 0,
00046               const bool verbose = true )
00047     : BaseType(macroName,1, bndProject, bndVector) 
00048   {
00049     if( verbose ) 
00050     {
00051       std::cout << "\nCreated serial ALUCubeGrid<"<<dim<<","<<dimworld;
00052       std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00053     }
00054   }
00055 
00065   ALUCubeGrid(const std::string macroName,
00066               std::istream& macroFile,
00067               const DuneBoundaryProjectionType* bndProject  = 0,
00068               const DuneBoundaryProjectionVector* bndVector = 0, 
00069               const bool verbose = true )
00070     : BaseType("",1, bndProject, bndVector, &macroFile) 
00071   {
00072     if( verbose ) 
00073     {
00074       std::cout << "\nCreated serial ALUCubeGrid<"<<dim<<","<<dimworld;
00075       if( macroName == "" ) 
00076         std::cout <<">. \n\n";     
00077       else 
00078         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00079     }
00080   }
00081 
00083   ALUCubeGrid( ) : BaseType(1) 
00084   {
00085     std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
00086   }
00087 
00089   static inline std::string name () DUNE_DEPRECATED { return "ALUCubeGrid"; }
00090 
00091   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00092   enum { refineStepsForHalf = 1 };
00093   typedef typename BaseType::ctype ctype;
00094   typedef typename BaseType::GridFamily GridFamily;
00095   typedef typename GridFamily::Traits Traits;
00096   typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
00097   typedef typename Traits :: GlobalIdSet GlobalIdSet;
00098   typedef typename Traits :: LocalIdSet LocalIdSet;
00099   typedef typename GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00100   typedef typename GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00101   typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
00102   typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
00103   typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
00104   typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00105 
00106   template< PartitionIteratorType pitype >
00107   struct Partition
00108   {
00109     typedef typename Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00110       LevelGridView;
00111     typedef typename Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00112       LeafGridView;
00113   };
00114 
00115   typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
00116   typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
00117 
00118   template< PartitionIteratorType pitype >
00119   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00120   {
00121     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00122     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00123     return LevelGridView( LevelGridViewImp( *this, level ) );
00124   }
00125 
00126   template< PartitionIteratorType pitype >
00127   typename Partition< pitype >::LeafGridView leafView () const
00128   {
00129     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00130     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00131     return LeafGridView( LeafGridViewImp( *this ) );
00132   }
00133 
00134   LevelGridView levelView ( int level ) const
00135   {
00136     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00137     return LevelGridView( LevelGridViewImp( *this, level ) );
00138   }
00139 
00140   LeafGridView leafView () const
00141   {
00142     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00143     return LeafGridView( LeafGridViewImp( *this ) );
00144   }
00145 
00146 private:
00147   friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00148   friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
00149 
00150   friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00151   friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00152 
00153   template< template< int, int > class, int >
00154   friend class ALU2dGridFactory;
00155   
00157   ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
00158   
00160   ALUCubeGrid<dim,dimworld>& 
00161   operator = (const ALUCubeGrid& g); 
00162 };
00163 
00169 template<int dimw>
00170 class ALUSimplexGrid< 2, dimw >
00171 : public Dune::ALU2dGrid< 2, dimw, ALU2DSPACE triangle >
00172 {
00173   typedef ALUSimplexGrid< 2, dimw > This;
00174 
00175   typedef Dune::ALU2dGrid< 2, dimw, ALU2DSPACE triangle > BaseType;
00176   enum { dim      = 2 };
00177   enum { dimworld = dimw };
00178 
00179 public:
00181   typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
00182 
00184   typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
00185 
00194   ALUSimplexGrid(const std::string macroName,
00195                  const DuneBoundaryProjectionType* bndProject  = 0,
00196                  const DuneBoundaryProjectionVector* bndVector = 0,
00197                  const bool verbose = true )
00198     : BaseType(macroName,1, bndProject, bndVector) 
00199   {
00200     if( verbose )
00201     {
00202       std::cout << "\nCreated serial ALUSimplexGrid<"<<dim<<","<<dimworld;
00203       std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00204     }
00205   }
00206 
00216   ALUSimplexGrid(const std::string macroName,
00217                  std::istream& macroFile,
00218                  const DuneBoundaryProjectionType* bndProject  = 0,
00219                  const DuneBoundaryProjectionVector* bndVector = 0,
00220                  const bool verbose = true )
00221     : BaseType("",1, bndProject, bndVector, &macroFile) 
00222   {
00223     if( verbose ) 
00224     {
00225       std::cout << "\nCreated serial ALUSimplexGrid<"<<dim<<","<<dimworld;
00226       if( macroName == "" ) 
00227         std::cout <<">. \n\n";     
00228       else 
00229         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00230     }
00231   }
00232 
00234   ALUSimplexGrid( ) : BaseType(1) 
00235   {
00236     std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
00237   }
00238 
00240   static inline std::string name () DUNE_DEPRECATED { return "ALUSimplexGrid"; }
00241 
00242   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00243   enum { refineStepsForHalf = 1 };
00244   typedef typename BaseType::ctype ctype;
00245   typedef typename BaseType::GridFamily GridFamily;
00246   typedef typename GridFamily::Traits Traits;
00247   typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
00248   typedef typename Traits :: GlobalIdSet GlobalIdSet;
00249   typedef typename Traits :: LocalIdSet LocalIdSet;
00250   typedef typename GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00251   typedef typename GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00252   typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
00253   typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
00254   typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
00255   typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00256 
00257   template< PartitionIteratorType pitype >
00258   struct Partition
00259   {
00260     typedef typename Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00261       LevelGridView;
00262     typedef typename Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00263       LeafGridView;
00264   };
00265 
00266   typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
00267   typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
00268 
00269   template< PartitionIteratorType pitype >
00270   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00271   {
00272     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00273     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00274     return LevelGridView( LevelGridViewImp( *this, level ) );
00275   }
00276 
00277   template< PartitionIteratorType pitype >
00278   typename Partition< pitype >::LeafGridView leafView () const
00279   {
00280     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00281     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00282     return LeafGridView( LeafGridViewImp( *this ) );
00283   }
00284 
00285   LevelGridView levelView ( int level ) const
00286   {
00287     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00288     return LevelGridView( LevelGridViewImp( *this, level ) );
00289   }
00290 
00291   LeafGridView leafView () const
00292   {
00293     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00294     return LeafGridView( LeafGridViewImp( *this ) );
00295   }
00296 
00297 private:
00298   friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00299   friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
00300 
00301   friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00302   friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00303 
00304   template< template< int, int > class, int >
00305   friend class ALU2dGridFactory;
00306   
00308   ALUSimplexGrid( const ALUSimplexGrid & g ) ; // : BaseType(g) {}
00309   
00311   ALUSimplexGrid<dim,dimworld>& 
00312   operator = (const ALUSimplexGrid& g); 
00313 };
00314 
00342 template <int dim, int dimworld>
00343 class ALUConformGrid {
00344   dune_static_assert((AlwaysFalse<integral_constant<int,dim> >::value),
00345                      "The unspecialized version of ALUConformGrid is defined "
00346                      "for documentation purposes only, only the "
00347                      "specializations can actually be used.");
00348 };
00349 
00350 namespace Capabilities {
00362   template<int dim,int dimw, int cdim >
00363   struct hasEntity<Dune::ALUConformGrid<dim, dimw>, cdim >
00364   {
00365     static const bool v = true;
00366   };
00367 
00371   template<int dim,int dimw>
00372   struct isParallel<const ALUConformGrid<dim, dimw> > {
00373     static const bool v = false;
00374   };
00375 
00379   template<int dim,int dimw>
00380   struct isLevelwiseConforming< ALUConformGrid<dim,dimw> >
00381   {
00382     static const bool v = false;
00383   };
00384 
00388   template<int dim,int dimw>
00389   struct isLeafwiseConforming< ALUConformGrid<dim,dimw> >
00390   {
00391     static const bool v = true;
00392   };
00393 
00397   template<int dim,int dimw>
00398   struct hasBackupRestoreFacilities< ALUConformGrid<dim,dimw> >
00399   {
00400     static const bool v = true;
00401   };
00402 
00403 } // end namespace Capabilities
00404 
00405 
00406 
00412 template<int dimw>
00413 class ALUConformGrid< 2, dimw >
00414 : public Dune::ALU2dGrid< 2, dimw, ALU2DSPACE triangle >
00415 {
00416   typedef ALUConformGrid< 2, dimw > This;
00417 
00418   typedef Dune::ALU2dGrid<2,dimw, ALU2DSPACE triangle> BaseType;
00419   enum { dim      = 2 };
00420   enum { dimworld = dimw };
00421  public:
00423   typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
00424 
00426   typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
00427 
00436   ALUConformGrid(const std::string macroName, 
00437                  const DuneBoundaryProjectionType* bndProject  = 0,
00438                  const DuneBoundaryProjectionVector* bndVector = 0, 
00439                  const bool verbose = true)
00440     : BaseType(macroName, 0, bndProject, bndVector) 
00441   {
00442     if( verbose ) 
00443     {
00444       std::cout << "\nCreated serial ALUConformGrid<"<<dim<<","<<dimworld;
00445       std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00446     }
00447   }
00448 
00458   ALUConformGrid(const std::string macroName,
00459                  std::istream& macroFile, 
00460                  const DuneBoundaryProjectionType* bndProject  = 0,
00461                  const DuneBoundaryProjectionVector* bndVector = 0,
00462                  const bool verbose = true )
00463     : BaseType("", 0, bndProject, bndVector, &macroFile) 
00464   {
00465     if( verbose ) 
00466     {
00467       std::cout << "\nCreated serial ALUConformGrid<"<<dim<<","<<dimworld;
00468       if( macroName == "" ) 
00469         std::cout <<">. \n\n";     
00470       else 
00471         std::cout <<"> from macro grid file '" << macroName << "'. \n\n";     
00472     }
00473   }
00474 
00476   ALUConformGrid( ) : BaseType(0)
00477   {
00478     std::cout << "\nCreated empty ALUConformGrid<"<<dim<<","<<dimworld <<">. \n\n";
00479   }
00480 
00482   static inline std::string name () { return "ALUConformGrid"; }
00483 
00484   enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
00485   enum { refineStepsForHalf = 2 };
00486   typedef typename BaseType::ctype ctype;
00487   typedef typename BaseType::GridFamily GridFamily;
00488   typedef typename GridFamily::Traits Traits;
00489   typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
00490   typedef typename Traits :: GlobalIdSet GlobalIdSet;
00491   typedef typename Traits :: LocalIdSet LocalIdSet;
00492   typedef typename GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00493   typedef typename GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00494   typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
00495   typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
00496   typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
00497   typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
00498 
00499   template< PartitionIteratorType pitype >
00500   struct Partition
00501   {
00502     typedef typename Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > >
00503       LevelGridView;
00504     typedef typename Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > >
00505       LeafGridView;
00506   };
00507 
00508   typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
00509   typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
00510 
00511   template< PartitionIteratorType pitype >
00512   typename Partition< pitype >::LevelGridView levelView ( int level ) const
00513   {
00514     typedef typename Partition< pitype >::LevelGridView LevelGridView;
00515     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00516     return LevelGridView( LevelGridViewImp( *this, level ) );
00517   }
00518 
00519   template< PartitionIteratorType pitype >
00520   typename Partition< pitype >::LeafGridView leafView () const
00521   {
00522     typedef typename Partition< pitype >::LeafGridView LeafGridView;
00523     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00524     return LeafGridView( LeafGridViewImp( *this ) );
00525   }
00526 
00527   LevelGridView levelView ( int level ) const
00528   {
00529     typedef typename LevelGridView::GridViewImp LevelGridViewImp;
00530     return LevelGridView( LevelGridViewImp( *this, level ) );
00531   }
00532 
00533   LeafGridView leafView () const
00534   {
00535     typedef typename LeafGridView::GridViewImp LeafGridViewImp;
00536     return LeafGridView( LeafGridViewImp( *this ) );
00537   }
00538  
00539 private:
00540   friend class Conversion< ALUConformGrid<dimension,dimensionworld> , HasObjectStream > ;
00541   friend class Conversion< const ALUConformGrid<dimension,dimensionworld> , HasObjectStream > ;
00542 
00543   friend class Conversion< ALUConformGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00544   friend class Conversion< const ALUConformGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
00545   
00546   template< template< int, int > class, int >
00547   friend class ALU2dGridFactory;
00548   
00550   ALUConformGrid( const ALUConformGrid & g ) ; // : BaseType(g) {}
00551   
00553   ALUConformGrid<dim,dimworld>& 
00554   operator = (const ALUConformGrid& g); 
00555 };
00556 
00557 } //end  namespace Dune 
00558 
00559 #else
00560 #error "Trying to use <dune/grid/alugrid.hh> without ALUGRID_CPPFLAGS."
00561 #endif // #ifdef ENABLE_ALUGRID
00562 
00563 #endif

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].