dune-grid  2.2.1
albertagrid/backuprestore.hh
Go to the documentation of this file.
1 #ifndef DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
2 #define DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
3 
5 
6 namespace Dune
7 {
8 
9  // External Forward Declarations
10  // -----------------------------
11 
12  template< int, int >
13  class AlbertaGrid;
14 
15 
16 
17  // BackupRestoreFacility for AlbertaGrid
18  // -------------------------------------
19 
20  template< int dim, int dimworld >
21  struct BackupRestoreFacility< AlbertaGrid< dim, dimworld > >
22  {
24 
25  static void backup ( const Grid &grid, const std::string &path, const std::string &fileprefix )
26  {
27  const std::string filename( path + "/" + fileprefix );
28  return grid.writeXdr( filename, 0.0 );
29  }
30 
31  static void backup ( const Grid &grid, const std::ostream &stream )
32  {
33  DUNE_THROW( NotImplemented, "backup / restore using streams not implemented." );
34  }
35 
36  static Grid *restore ( const std::string &path, const std::string &fileprefix )
37  {
38  const std::string filename( path + "/" + fileprefix );
39  Grid *grid = new Grid;
40  double time; // ignore time
41  grid->readGridXdr( filename, time );
42  return grid;
43  }
44 
45  static Grid *restore ( const std::istream &stream )
46  {
47  DUNE_THROW( NotImplemented, "backup / restore using streams not implemented." );
48  }
49  };
50 
51 } // namespace Dune
52 
53 #endif // #ifndef DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH