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
/**
* @file simulationarchive.h
* @brief Tools for creating and reading a Simulationarchive binary file.
* @author Hanno Rein <hanno@hanno-rein.de>
*
* @section LICENSE
* Copyright (c) 2016 Hanno Rein
*
* This file is part of rebound.
*
* rebound is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* rebound is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rebound. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SIMULATIONARCHIVE_H
#define SIMULATIONARCHIVE_H
#include <stdint.h>
#include "binarydata.h" // for enum REB_BINARYDATA_ERROR_CODE;
// Simulationarchive structure
struct reb_simulationarchive{
FILE* inf; // File pointer (will be kept open)
char* filename; // Filename of open file. This is NULL if this is a memory-mapped file (using fmemopen)
int version; // Simulationarchive version
int reb_version_major; // Major REBOUND Version used to save SA
int reb_version_minor; // Minor REBOUND Version used to save SA
int reb_version_patch; // Patch REBOUND Version used to save SA
double auto_interval; // Interval setting used to create SA (if used)
double auto_walltime; // Walltime setting used to create SA (if used)
uint64_t auto_step; // Steps in-between SA snapshots (if used)
int64_t nblobs; // Total number of snapshots (including initial binary)
uint64_t* offset; // Index of offsets in file (length nblobs)
double* t; // Index of simulation times in file (length nblobs)
};
// Used in the binary file to identify data blobs (snapshots)
// Note: 32 bit enough here as only relative offsets stored.
struct reb_simulationarchive_blob {
int32_t index; // Index of previous blob (binary file is 0, first blob is 1)
int32_t offset_prev; // Offset to beginning of previous blob (size of previous blob).
int32_t offset_next; // Offset to end of following blob (size of following blob).
};
// Used by python.
REB_API void reb_simulation_init_from_simulationarchive_with_messages(struct reb_simulation* r, struct reb_simulationarchive* sa, int64_t snapshot, enum REB_BINARYDATA_ERROR_CODE* warnings);
REB_API struct reb_simulationarchive* reb_simulationarchive_create_from_file_with_messages(const char* filename, enum REB_BINARYDATA_ERROR_CODE* warnings);
REB_API struct reb_simulationarchive* reb_simulationarchive_create_from_buffer_with_messages(char* buffer, size_t size, enum REB_BINARYDATA_ERROR_CODE* warnings);
void reb_simulationarchive_heartbeat(struct reb_simulation* const r); ///< Internal function to handle outputs for the Simulationarchive.
#endif // SIMULATIONARCHIVE_H