dune-grid  2.6-git
geometrygrid/backuprestore.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_GEOGRID_BACKUPRESTORE_HH
4 #define DUNE_GEOGRID_BACKUPRESTORE_HH
5 
7 
10 
11 namespace Dune
12 {
13 
14  namespace GeoGrid
15  {
16 
17  // BackupRestoreFacilities
18  // -----------------------
19 
20  template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities< Grid > ::v >
22  {};
23 
24  template< class Grid >
26  {
28 
29  protected:
31  {}
32 
33  private:
34  BackupRestoreFacilities ( const This & );
35  This &operator= ( const This & );
36 
37  protected:
38  const Grid &asImp () const
39  {
40  return static_cast< const Grid & >( *this );
41  }
42 
43  Grid &asImp ()
44  {
45  return static_cast< Grid & >( *this );
46  }
47  };
48 
49  } // namespace GeoGrid
50 
51 
52 
53  // BackupRestoreFacility for GeometryGrid
54  // --------------------------------------
55 
56  template< class HostGrid, class CoordFunction, class Allocator >
57  struct BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >
58  {
61 
62  static void backup ( const Grid &grid, const std::string &path, const std::string &fileprefix )
63  {
64  // notice: We should also backup the coordinate function
65  HostBackupRestoreFacility::backup( grid.hostGrid(), path, fileprefix );
66  }
67 
68  static void backup ( const Grid &grid, const std::ostream &stream )
69  {
70  // notice: We should also backup the coordinate function
71  HostBackupRestoreFacility::backup( grid.hostGrid(), stream );
72  }
73 
74  static Grid *restore ( const std::string &path, const std::string &fileprefix )
75  {
76  // notice: We should also restore the coordinate function
77  HostGrid *hostGrid = HostBackupRestoreFacility::restore( path, fileprefix );
78  CoordFunction *coordFunction = new CoordFunction();
79  return new Grid( hostGrid, coordFunction );
80  }
81 
82  static Grid *restore ( const std::istream &stream )
83  {
84  // notice: We should also restore the coordinate function
85  HostGrid *hostGrid = HostBackupRestoreFacility::restore( stream );
86  CoordFunction *coordFunction = new CoordFunction();
87  return new Grid( hostGrid, coordFunction );
88  }
89  };
90 
91 } // namespace Dune
92 
93 #endif // #ifndef DUNE_GEOGRID_BACKUPRESTORE_HH
declaration.hh
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >
Definition: geometrygrid/backuprestore.hh:25
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >::BackupRestoreFacilities
BackupRestoreFacilities()
Definition: geometrygrid/backuprestore.hh:30
Dune::Grid
Grid abstract base class.
Definition: common/grid.hh:373
Dune::GeoGrid::BackupRestoreFacilities
Definition: geometrygrid/backuprestore.hh:21
Dune::GeometryGrid::hostGrid
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition: geometrygrid/grid.hh:548
backuprestore.hh
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::restore
static Grid * restore(const std::istream &stream)
Definition: geometrygrid/backuprestore.hh:82
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::Grid
GeometryGrid< HostGrid, CoordFunction, Allocator > Grid
Definition: geometrygrid/backuprestore.hh:59
capabilities.hh
Dune::BackupRestoreFacility
facility for writing and reading grids
Definition: common/backuprestore.hh:40
Dune::GeometryGrid
grid wrapper replacing the geometries
Definition: declaration.hh:10
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::HostBackupRestoreFacility
BackupRestoreFacility< HostGrid > HostBackupRestoreFacility
Definition: geometrygrid/backuprestore.hh:60
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >::asImp
const Grid & asImp() const
Definition: geometrygrid/backuprestore.hh:38
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::backup
static void backup(const Grid &grid, const std::string &path, const std::string &fileprefix)
Definition: geometrygrid/backuprestore.hh:62
Dune
Include standard header files.
Definition: agrid.hh:58
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >::asImp
Grid & asImp()
Definition: geometrygrid/backuprestore.hh:43
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::restore
static Grid * restore(const std::string &path, const std::string &fileprefix)
Definition: geometrygrid/backuprestore.hh:74
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::backup
static void backup(const Grid &grid, const std::ostream &stream)
Definition: geometrygrid/backuprestore.hh:68