12#ifndef SNAP_READ_WRITE_H
13#define SNAP_READ_WRITE_H
15#include "gadgetconfig.h"
17#include "../data/intposconvert.h"
18#include "../data/simparticles.h"
20#include "../mergertree/mergertree.h"
29#if defined(REARRANGE_OPTION) && defined(MERGERTREE)
30 void init_extra(
simparticles *Sp_ptr, mergertree *MergerTree_ptr);
34 init_extra(Sp_ptr, MergerTree_ptr);
46 void read_ic(
const char *fname);
49 void fill_file_header(
int writeTask,
int lastTask,
long long *nloc_part,
long long *npart);
50 void read_file_header(
const char *fname,
int filenr,
int readTask,
int lastTask,
long long *nloc_part,
long long *npart,
82#if defined(REARRANGE_OPTION) && defined(MERGERTREE)
90 int flag_entropy_instead_u;
91 int flag_doubleprecision;
100 float lpt_scalingfactor;
130 mergertree *MergerTree;
135 long long ntot_type_all[
NTYPES];
137#ifndef OUTPUT_COORDINATES_AS_INTEGERS
145 void snap_init_domain_mapping(
void);
146 void read_increase_particle_numbers(
int type,
int n_for_this_task);
151#ifndef OUTPUT_COORDINATES_AS_INTEGERS
152 static void io_func_pos(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
171 for(
int k = 0; k < 3; k++)
172 thisobj->Ptmp[particle].Pos[k] = in_buffer[k];
175 thisobj->Ptmp[particle].Pos[1] *= 1.0 / 4;
176 thisobj->Ptmp[particle].Pos[2] *= 1.0 / 16;
182 static void io_func_intpos(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
198 for(
int k = 0; k < 3; k++)
199 thisobj->Sp->
P[particle].
IntPos[k] = in_buffer[k];
203 static void io_func_vel(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
210 for(
int k = 0; k < 3; k++)
212 out_buffer[k] = thisobj->Sp->
P[particle].
Vel[k];
221 for(
int k = 0; k < components; k++)
223 thisobj->Sp->
P[particle].
Vel[k] = in_buffer[k];
228 static void io_func_id(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
235 out_buffer[0] = thisobj->Sp->
P[particle].
ID.
get();
240 thisobj->Sp->
P[particle].
ID.
set(in_buffer[0]);
244 static void io_func_mass(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
251 out_buffer[0] = thisobj->Sp->
P[particle].
getMass();
256 thisobj->Sp->
P[particle].
setMass(in_buffer[0]);
260 static void io_func_u(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
272 thisobj->Sp->
SphP[particle].
Entropy = in_buffer[0];
277 static void io_func_sfr(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
284 out_buffer[0] = thisobj->Sp->
SphP[particle].Sfr;
289 thisobj->Sp->
SphP[particle].Sfr = in_buffer[0];
293 static void io_func_metallicity(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
300 if(thisobj->Sp->
P[particle].
getType() == 0)
302 out_buffer[0] = thisobj->Sp->
SphP[particle].Metallicity;
306 out_buffer[0] = thisobj->Sp->
P[particle].Metallicity;
312 thisobj->Sp->
P[particle].Metallicity = in_buffer[0];
317#ifdef OUTPUT_ACCELERATION
318 static void io_func_accel(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
326 for(
int k = 0; k < 3; k++)
329 for(
int k = 0; k < 3; k++)
330 out_buffer[k] = thisobj->Sp->
P[particle].
GravAccel[k];
331#if defined(PMGRID) && defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
333 for(
int k = 0; k < 3; k++)
334 out_buffer[k] +=
All.
cf_a2inv * thisobj->Sp->
P[particle].GravPM[k];
336 for(
int k = 0; k < 3; k++)
337 out_buffer[k] += thisobj->Sp->
P[particle].GravPM[k];
340 for(
int k = 0; k < 3; k++)
346 for(
int k = 0; k < components; k++)
353#ifdef OUTPUT_PRESSURE
354 static void io_func_pressure(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
363#ifdef OUTPUT_TIMESTEP
364 static void io_func_timestep(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
373 static void io_func_timestephydro(
IO_Def *ptr,
int particle,
int components,
void *buffer,
int mode)
global_data_all_processes All
void intpos_to_intpos(MyIntPosType *intpos, MyIntPosType *xyz)
void intpos_to_pos(MyIntPosType *intpos, T *posdiff)
double get_utherm_from_entropy(int i)
int get_filenr_from_header(void)
void read_header_fields(const char *fname)
This function reads the snapshot header in case of hdf5 files (i.e. format 3)
void * get_base_address_of_structure(enum arrays array, int index)
void read_increase_numbers(int type, int n_for_this_task)
int acquire_basic_treeinfo(int num, mysnaptype loc_snap_type)
void read_snapshot(int num, mysnaptype snap_type)
void fill_file_header(int writeTask, int lastTask, long long *nloc_part, long long *npart)
void read_file_header(const char *fname, int filenr, int readTask, int lastTask, long long *nloc_part, long long *npart, int *nstart)
void set_type_of_element(int index, int type)
void write_header_fields(hid_t)
Write the fields contained in the header group of the HDF5 snapshot file.
void get_datagroup_name(int grnr, char *gname)
void read_ic(const char *fname)
This function reads initial conditions that are in on of the default file formats of Gadget.
void set_filenr_in_header(int)
void init_basic(simparticles *Sp_ptr)
Function for field registering.
void free_basic_treeinfo(void)
snap_io(simparticles *Sp_ptr, MPI_Comm comm, int format)
long long load_orphans(int num, long long treenr, int num_files)
int get_type_of_element(int index)
void write_snapshot(int num, mysnaptype snap_type)
Save snapshot to disk.
enum restart_options RestartFlag
double accel_normalize_fac
void setMass(MyDouble mass)
unsigned char getTimeBinHydro(void)
unsigned char getType(void)
vector< MyFloat > GravAccel
MyFloat get_pressure(void)