Dune Core Modules (2.6.0)

backuprestore.hh
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
6#include <dune/grid/common/backuprestore.hh>
7
8#include <dune/grid/geometrygrid/declaration.hh>
9#include <dune/grid/geometrygrid/capabilities.hh>
10
11namespace Dune
12{
13
14 namespace GeoGrid
15 {
16
17 // BackupRestoreFacilities
18 // -----------------------
19
20 template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities< Grid > ::v >
21 class BackupRestoreFacilities
22 {};
23
24 template< class Grid >
25 class BackupRestoreFacilities< Grid, true >
26 {
27 typedef BackupRestoreFacilities< Grid, true > This;
28
29 protected:
30 BackupRestoreFacilities ()
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 {
60 typedef BackupRestoreFacility< HostGrid > HostBackupRestoreFacility;
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
grid wrapper replacing the geometries
Definition: grid.hh:82
Grid abstract base class.
Definition: grid.hh:373
Dune namespace.
Definition: alignedallocator.hh:10
facility for writing and reading grids
Definition: backuprestore.hh:41
static Grid * restore(const std::string &filename)
read a hierarchic grid from disk
Definition: backuprestore.hh:76
static void backup(const Grid &grid, const std::string &filename)
write a hierarchic grid to disk
Definition: backuprestore.hh:49
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)