dune-grid 3.0-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
11namespace Dune
12{
13
14 namespace GeoGrid
15 {
16
17 // BackupRestoreFacilities
18 // -----------------------
19
20 template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities< Grid > ::v >
23
24 template< class Grid >
26 {
28
29 protected:
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
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
Include standard header files.
Definition agrid.hh:60
facility for writing and reading grids
Definition common/backuprestore.hh:41
Grid abstract base class.
Definition common/grid.hh:373
Definition geometrygrid/backuprestore.hh:22
Definition geometrygrid/backuprestore.hh:26
const Grid & asImp() const
Definition geometrygrid/backuprestore.hh:38
BackupRestoreFacilities()
Definition geometrygrid/backuprestore.hh:30
Grid & asImp()
Definition geometrygrid/backuprestore.hh:43
BackupRestoreFacility< HostGrid > HostBackupRestoreFacility
Definition geometrygrid/backuprestore.hh:60
static void backup(const Grid &grid, const std::ostream &stream)
Definition geometrygrid/backuprestore.hh:68
static Grid * restore(const std::string &path, const std::string &fileprefix)
Definition geometrygrid/backuprestore.hh:74
static void backup(const Grid &grid, const std::string &path, const std::string &fileprefix)
Definition geometrygrid/backuprestore.hh:62
static Grid * restore(const std::istream &stream)
Definition geometrygrid/backuprestore.hh:82
GeometryGrid< HostGrid, CoordFunction, Allocator > Grid
Definition geometrygrid/backuprestore.hh:59
grid wrapper replacing the geometries
Definition geometrygrid/grid.hh:82
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition geometrygrid/grid.hh:628