blob: 409f47221bc344bbe275efa14b5daea5fc01c7d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#include <cassert>
#include <iomanip>
#include <limits>
#include <string>
#include <sstream>
#include <hdf5.h>
#include "cctk.h"
#include "cctk_Functions.h"
#include "defs.hh"
#include "timestep.hh"
#include "utils.hh"
namespace CarpetIOF5 {
namespace F5 {
using std::numeric_limits;
using std::setprecision;
using std::ostringstream;
timestep_t::
timestep_t (file_t & file,
CCTK_REAL const time,
char const * const name)
: m_file (file),
m_time (time)
{
// Construct a group name from the simulation time
ostringstream buf;
if (name != 0)
{
// Use the name argument if it is present
buf << name;
}
else
{
// Create a string from the time without losing information
int const precision = numeric_limits<CCTK_REAL>::digits10 + 2;
buf << setprecision (precision) << "T=" << time;
}
m_name = buf.str();
m_hdf5_timestep
= open_or_create_group (m_file.get_hdf5_file(), m_name.c_str());
assert (m_hdf5_timestep >= 0);
write_or_check_attribute (m_hdf5_timestep, "Time", time);
assert (invariant());
}
timestep_t::
~ timestep_t()
{
check (not H5Gclose (m_hdf5_timestep));
}
file_t & timestep_t::
get_file ()
const
{
return m_file;
}
CCTK_REAL timestep_t::
get_time ()
const
{
return m_time;
}
hid_t timestep_t::
get_hdf5_timestep()
const
{
return m_hdf5_timestep;
}
void timestep_t::
get_link_destination (int const proc,
string & filename,
string & objectname)
const
{
get_file().get_link_destination (proc, filename, objectname);
if (objectname.empty())
{
objectname = m_name;
}
else
{
objectname += string ("/") + m_name;
}
}
bool timestep_t::
invariant()
const
{
return m_hdf5_timestep >= 0;
}
} // namespace F5
} // namespace CarpetIOF5
|