// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_CURVED_SURFACE_GRID_BACKUPRESTORE_HH #define DUNE_CURVED_SURFACE_GRID_BACKUPRESTORE_HH #include <dune/grid/common/backuprestore.hh> #include <dune/curvedsurfacegrid/capabilities.hh> namespace Dune { namespace CGeo { // BackupRestoreFacilities // ----------------------- template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities<Grid> ::v > class BackupRestoreFacilities {}; template< class Grid > class BackupRestoreFacilities<Grid, true> { using Self = BackupRestoreFacilities<Grid, true>; protected: BackupRestoreFacilities () {} private: BackupRestoreFacilities (const Self&); Self& operator= (const Self&); protected: const Grid& asImp () const { return static_cast<const Grid&>(*this); } Grid& asImp () { return static_cast<Grid&>(*this); } }; } // namespace CGeo // BackupRestoreFacility for CurvedSurfaceGrid // ------------------------------------------- template< class HostGrid, class CoordFunction, int order, class Allocator > struct BackupRestoreFacility<CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>> { using Grid = CurvedSurfaceGrid<HostGrid, CoordFunction, order, Allocator>; using HostBackupRestoreFacility = BackupRestoreFacility<HostGrid>; static void backup (const Grid& grid, const std::string& filename) { // notice: We should also backup the coordinate function HostBackupRestoreFacility::backup( grid.hostGrid(), filename ); } static void backup (const Grid& grid, const std::ostream& stream) { // notice: We should also backup the coordinate function HostBackupRestoreFacility::backup(grid.hostGrid(), stream); } static Grid* restore (const std::string& filename) { // notice: We should also restore the coordinate function HostGrid* hostGrid = HostBackupRestoreFacility::restore(filename); CoordFunction* coordFunction = new CoordFunction(); return new Grid(hostGrid, coordFunction); } static Grid* restore (const std::istream& stream) { HostGrid* hostGrid = HostBackupRestoreFacility::restore(stream); CoordFunction* coordFunction = new CoordFunction(); return new Grid(hostGrid, coordFunction); } }; } // namespace Dune #endif // DUNE_CURVED_SURFACE_GRID_BACKUPRESTORE_HH