dune-grid  2.2beta1
albertagrid/backuprestore.hh
Go to the documentation of this file.
00001 #ifndef DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
00002 #define DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
00003 
00004 #include <dune/grid/common/backuprestore.hh>
00005 
00006 namespace Dune
00007 {
00008 
00009   // External Forward Declarations
00010   // -----------------------------
00011 
00012   template< int, int >
00013   class AlbertaGrid;
00014 
00015 
00016 
00017   // BackupRestoreFacility for AlbertaGrid
00018   // -------------------------------------
00019 
00020   template< int dim, int dimworld >
00021   struct BackupRestoreFacility< AlbertaGrid< dim, dimworld > >
00022   {
00023     typedef AlbertaGrid< dim, dimworld > Grid;
00024 
00025     static void backup ( const Grid &grid, const std::string &path, const std::string &fileprefix )
00026     {
00027       const std::string filename( path + "/" + fileprefix );
00028       return grid.writeXdr( filename, 0.0 );
00029     }
00030 
00031     static void backup ( const Grid &grid, const std::ostream &stream )
00032     {
00033       DUNE_THROW( NotImplemented, "backup / restore using streams not implemented." );
00034     }
00035 
00036     static Grid *restore ( const std::string &path, const std::string &fileprefix )
00037     {
00038       const std::string filename( path + "/" + fileprefix );
00039       Grid *grid = new Grid;
00040       double time; // ignore time
00041       grid->readGridXdr( filename, time );
00042       return grid;
00043     }
00044 
00045     static Grid *restore ( const std::istream &stream )
00046     {
00047       DUNE_THROW( NotImplemented, "backup / restore using streams not implemented." );
00048     }
00049   };
00050 
00051 } // namespace Dune
00052 
00053 #endif // #ifndef DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH