dune-grid  2.11
albertagrid/backuprestore.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © 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
static void backup(const Grid &grid, const std::string &filename)
write a hierarchic grid to disk
Definition: albertagrid/backuprestore.hh:30
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in Xdr
Definition: albertagrid.cc:575
static Grid * restore(const std::string &filename)
read a hierarchic grid from disk
Definition: albertagrid/backuprestore.hh:45
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:585
AlbertaGrid< dim, dimworld > Grid
Definition: albertagrid/backuprestore.hh:27
facility for writing and reading grids
Definition: common/backuprestore.hh:42
Include standard header files.
Definition: agrid.hh:59
concept Grid
Requirements for implementations of the Dune::Grid interface.The Grid concept defines interface requi...
Definition: concepts/grid.hh:109
[ provides Dune::Grid ]
Definition: agrid.hh:106
static Grid * restore(std::istream &)
read a hierarchic grid from disk
Definition: albertagrid/backuprestore.hh:57
static void backup(const Grid &, std::ostream &)
write a hierarchic grid to disk
Definition: albertagrid/backuprestore.hh:39