backuprestore.hh 2.24 KB
Newer Older
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
1
2
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
Praetorius, Simon's avatar
Praetorius, Simon committed
3
4
#ifndef DUNE_CURVED_SURFACE_GRID_BACKUPRESTORE_HH
#define DUNE_CURVED_SURFACE_GRID_BACKUPRESTORE_HH
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
5
6
7
8
9
10
11

#include <dune/grid/common/backuprestore.hh>

#include <dune/curvedsurfacegrid/capabilities.hh>

namespace Dune
{
Praetorius, Simon's avatar
Praetorius, Simon committed
12
  namespace CGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
13
14
15
16
17
  {

    // BackupRestoreFacilities
    // -----------------------

Praetorius, Simon's avatar
Praetorius, Simon committed
18
    template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities<Grid> ::v >
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
19
20
21
22
    class BackupRestoreFacilities
    {};

    template< class Grid >
Praetorius, Simon's avatar
Praetorius, Simon committed
23
    class BackupRestoreFacilities<Grid, true>
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
24
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
25
      using Self = BackupRestoreFacilities<Grid, true>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
26
27
28
29
30
31

    protected:
      BackupRestoreFacilities ()
      {}

    private:
Praetorius, Simon's avatar
Praetorius, Simon committed
32
33
      BackupRestoreFacilities (const Self&);
      Self& operator= (const Self&);
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
34
35

    protected:
Praetorius, Simon's avatar
Praetorius, Simon committed
36
      const Grid& asImp () const
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
37
      {
Praetorius, Simon's avatar
Praetorius, Simon committed
38
        return static_cast<const Grid&>(*this);
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
39
40
      }

Praetorius, Simon's avatar
Praetorius, Simon committed
41
      Grid& asImp ()
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
42
      {
Praetorius, Simon's avatar
Praetorius, Simon committed
43
        return static_cast<Grid&>(*this);
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
44
45
46
      }
    };

Praetorius, Simon's avatar
Praetorius, Simon committed
47
  } // namespace CGeo
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
48
49
50
51
52
53



  // BackupRestoreFacility for CurvedSurfaceGrid
  // -------------------------------------------

54
55
  template< class GridFunction, int order >
  struct BackupRestoreFacility<CurvedSurfaceGrid<GridFunction, order>>
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
56
  {
57
58
    using Grid = CurvedSurfaceGrid<GridFunction, order>;
    using HostGrid = typename Grid::HostGrid;
Praetorius, Simon's avatar
Praetorius, Simon committed
59
    using HostBackupRestoreFacility = BackupRestoreFacility<HostGrid>;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
60

Praetorius, Simon's avatar
Praetorius, Simon committed
61
    static void backup (const Grid& grid, const std::string& filename)
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
62
63
    {
      // notice: We should also backup the coordinate function
64
      HostBackupRestoreFacility::backup(grid.hostGrid(), filename);
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
65
66
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
67
    static void backup (const Grid& grid, const std::ostream& stream)
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
68
69
    {
      // notice: We should also backup the coordinate function
Praetorius, Simon's avatar
Praetorius, Simon committed
70
      HostBackupRestoreFacility::backup(grid.hostGrid(), stream);
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
71
72
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
73
    static Grid* restore (const std::string& filename)
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
74
    {
75
76
      assert(false && "Restore not yet implemented for CurvedSurfaceGrid");
      return nullptr;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
77
78
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
79
    static Grid* restore (const std::istream& stream)
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
80
    {
81
82
      assert(false && "Restore not yet implemented for CurvedSurfaceGrid");
      return nullptr;
Stenger, Florian's avatar
v0.1.0  
Stenger, Florian committed
83
84
85
86
87
    }
  };

} // namespace Dune

Praetorius, Simon's avatar
Praetorius, Simon committed
88
#endif // DUNE_CURVED_SURFACE_GRID_BACKUPRESTORE_HH