dune-grid
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
grid
geometrygrid
geometrygrid/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_GEOGRID_BACKUPRESTORE_HH
6
#define DUNE_GEOGRID_BACKUPRESTORE_HH
7
8
#include <type_traits>
9
10
#include <dune/common/exceptions.hh>
11
#include <
dune/grid/common/backuprestore.hh
>
12
13
#include <
dune/grid/geometrygrid/declaration.hh
>
14
#include <
dune/grid/geometrygrid/capabilities.hh
>
15
16
namespace
Dune
17
{
18
19
namespace
GeoGrid
20
{
21
22
// BackupRestoreFacilities
23
// -----------------------
24
25
template
<
class
Gr
id
,
bool
hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities< Gr
id
> ::v >
26
class
BackupRestoreFacilities
27
{};
28
29
template
<
class
Gr
id
>
30
class
BackupRestoreFacilities
<
Grid
, true >
31
{
32
typedef
BackupRestoreFacilities< Grid, true >
This;
33
34
protected
:
35
BackupRestoreFacilities
()
36
{}
37
38
private
:
39
BackupRestoreFacilities
(
const
This & );
40
This &operator= (
const
This & );
41
42
protected
:
43
const
Grid
&
asImp
()
const
44
{
45
return
static_cast<
const
Grid
&
>
( *this );
46
}
47
48
Grid
&
asImp
()
49
{
50
return
static_cast<
Grid
&
>
( *this );
51
}
52
};
53
54
}
// namespace GeoGrid
55
56
57
58
// BackupRestoreFacility for GeometryGrid
59
// --------------------------------------
60
61
template
<
class
HostGr
id
,
class
CoordFunction,
class
Allocator >
62
struct
BackupRestoreFacility
<
GeometryGrid
< HostGrid, CoordFunction, Allocator > >
63
{
64
typedef
GeometryGrid< HostGrid, CoordFunction, Allocator >
Grid
;
65
typedef
BackupRestoreFacility< HostGrid >
HostBackupRestoreFacility
;
66
68
template
<
class
Output>
69
static
void
backup
(
const
Grid
&grid,
const
Output &filename_or_stream )
70
{
71
// notice: We should also backup the coordinate function
72
HostBackupRestoreFacility::backup
( grid.
hostGrid
(), filename_or_stream );
73
}
74
76
template
<
class
Input>
77
static
Grid
*
restore
(
const
Input &filename_or_stream )
78
{
79
// notice: assumes the CoordFunction to be default-constructible
80
return
restore_impl(filename_or_stream, std::is_default_constructible<CoordFunction>{});
81
}
82
83
private
:
84
template
<
class
Input>
85
static
Grid
*restore_impl (
const
Input &filename_or_stream, std::true_type )
86
{
87
// notice: We should also restore the coordinate function
88
HostGrid *hostGrid = HostBackupRestoreFacility::restore( filename_or_stream );
89
CoordFunction *coordFunction =
new
CoordFunction();
90
return
new
Grid
( hostGrid, coordFunction );
91
}
92
93
template
<
class
Input>
94
static
Grid *restore_impl (
const
Input &filename_stream, std::false_type )
95
{
96
DUNE_THROW(NotImplemented,
97
"Restoring a GeometryGrid with a CoordFunction that is not default-constructible is not implemented."
);
98
return
nullptr
;
99
}
100
};
101
102
}
// namespace Dune
103
104
#endif
// #ifndef DUNE_GEOGRID_BACKUPRESTORE_HH
declaration.hh
Dune
Include standard header files.
Definition
agrid.hh:60
Dune::GeoGrid
namespace containing the implementations of GeometryGrid
Definition
geometrygrid/backuprestore.hh:20
Dune::BackupRestoreFacility
facility for writing and reading grids
Definition
common/backuprestore.hh:43
Dune::BackupRestoreFacility< HostGrid >::backup
static void backup(const HostGrid &, const std::string &)
Definition
common/backuprestore.hh:51
Dune::Grid
Grid abstract base class.
Definition
common/grid.hh:375
Dune::GeoGrid::BackupRestoreFacilities
Definition
geometrygrid/backuprestore.hh:27
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >
Definition
geometrygrid/backuprestore.hh:31
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >::asImp
const Grid & asImp() const
Definition
geometrygrid/backuprestore.hh:43
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >::BackupRestoreFacilities
BackupRestoreFacilities()
Definition
geometrygrid/backuprestore.hh:35
Dune::GeoGrid::BackupRestoreFacilities< Grid, true >::asImp
Grid & asImp()
Definition
geometrygrid/backuprestore.hh:48
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::HostBackupRestoreFacility
BackupRestoreFacility< HostGrid > HostBackupRestoreFacility
Definition
geometrygrid/backuprestore.hh:65
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::backup
static void backup(const Grid &grid, const Output &filename_or_stream)
Backup the grid to file or stream.
Definition
geometrygrid/backuprestore.hh:69
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::restore
static Grid * restore(const Input &filename_or_stream)
Restore the grid from file or stream.
Definition
geometrygrid/backuprestore.hh:77
Dune::BackupRestoreFacility< GeometryGrid< HostGrid, CoordFunction, Allocator > >::Grid
GeometryGrid< HostGrid, CoordFunction, Allocator > Grid
Definition
geometrygrid/backuprestore.hh:64
Dune::GeometryGrid
grid wrapper replacing the geometries
Definition
geometrygrid/grid.hh:86
Dune::GeometryGrid::hostGrid
const HostGrid & hostGrid() const
obtain constant reference to the host grid
Definition
geometrygrid/grid.hh:533
backuprestore.hh
capabilities.hh
Generated by
1.17.0