dune-grid  2.9.0
albertagrid/backuprestore.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
6 #define DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
7 
9 
10 namespace Dune
11 {
12 
13  // External Forward Declarations
14  // -----------------------------
15 
16  template< int, int >
17  class AlbertaGrid;
18 
19 
20 
21  // BackupRestoreFacility for AlbertaGrid
22  // -------------------------------------
23 
24  template< int dim, int dimworld >
25  struct BackupRestoreFacility< AlbertaGrid< dim, dimworld > >
26  {
28 
30  static void backup ( const Grid &grid, const std::string &filename )
31  {
32  grid.writeGrid( filename, 0.0 );
33  }
34 
39  static void backup ( const Grid &grid, std::ostream &stream )
40  {
41  DUNE_THROW( NotImplemented, "backup / restore using streams not implemented." );
42  }
43 
45  static Grid *restore ( const std::string &filename )
46  {
47  Grid *grid = new Grid;
48  double time; // ignore time
49  grid->readGrid( filename, time );
50  return grid;
51  }
52 
57  static Grid *restore ( std::istream &stream )
58  {
59  DUNE_THROW( NotImplemented, "backup / restore using streams not implemented." );
60  }
61  };
62 
63 } // namespace Dune
64 
65 #endif // #ifndef DUNE_GRID_ALBERTAGRID_BACKUPRESTORE_HH
Include standard header files.
Definition: agrid.hh:60
[ provides Dune::Grid ]
Definition: agrid.hh:109
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:585
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in Xdr
Definition: albertagrid.cc:575
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/backuprestore.hh:27
static Grid * restore(const std::string &filename)
Definition: albertagrid/backuprestore.hh:45
static void backup(const Grid &grid, std::ostream &stream)
Definition: albertagrid/backuprestore.hh:39
static void backup(const Grid &grid, const std::string &filename)
Definition: albertagrid/backuprestore.hh:30
static Grid * restore(std::istream &stream)
Definition: albertagrid/backuprestore.hh:57
facility for writing and reading grids
Definition: common/backuprestore.hh:43