GADGET-4
snap_io Class Reference

#include <snap_io.h>

Inherits IO_Def.

Classes

struct  io_header
 

Public Member Functions

void init_basic (simparticles *Sp_ptr)
 Function for field registering. More...
 
 snap_io (simparticles *Sp_ptr, MPI_Comm comm, int format)
 
void write_snapshot (int num, mysnaptype snap_type)
 Save snapshot to disk. More...
 
void read_snapshot (int num, mysnaptype snap_type)
 
int acquire_basic_treeinfo (int num, mysnaptype loc_snap_type)
 
void free_basic_treeinfo (void)
 
long long load_orphans (int num, long long treenr, int num_files)
 
void free_orphans (void)
 
void read_ic (const char *fname)
 This function reads initial conditions that are in on of the default file formats of Gadget. More...
 
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 get_datagroup_name (int grnr, char *gname)
 
void write_header_fields (hid_t)
 Write the fields contained in the header group of the HDF5 snapshot file. More...
 
void read_header_fields (const char *fname)
 This function reads the snapshot header in case of hdf5 files (i.e. format 3) More...
 
void read_increase_numbers (int type, int n_for_this_task)
 
int get_filenr_from_header (void)
 
void set_filenr_in_header (int)
 
void * get_base_address_of_structure (enum arrays array, int index)
 
int get_type_of_element (int index)
 
void set_type_of_element (int index, int type)
 
- Public Member Functions inherited from IO_Def
 IO_Def (MPI_Comm comm, int format)
 
virtual ~IO_Def ()
 
void init_field (const char *label, const char *datasetname, enum types_in_memory type_in_memory, enum types_in_file type_in_file_output, enum read_flags read_flag, int values_per_block, enum arrays array, void *pointer_to_field, void(*io_func)(IO_Def *, int, int, void *, int), int typelist_bitmask, int hasunits, double a, double h, double L, double M, double V, double c, bool compression_on=false)
 
int find_files (const char *fname, const char *fname_multiple)
 This function determines on how many files a given snapshot or group/desc catalogue is distributed. More...
 
void read_files_driver (const char *fname, int rep, int numfiles)
 
void write_multiple_files (char *fname, int numfilesperdump, int append_flag=0, int chunk_size=0)
 
void write_compile_time_options_in_hdf5 (hid_t handle)
 
void read_segment (const char *fname, int type, long long offset, long long count, int numfiles)
 
void read_single_file_segment (const char *fname, int filenr, int type, long long offset, unsigned long long count, long long storage_offset, int numfiles)
 
void alloc_and_read_ntype_in_files (const char *fname, int num_files)
 
- Public Member Functions inherited from io_streamcount
size_t my_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 A wrapper for the fwrite() function. More...
 
size_t my_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
 A wrapper for the fread() function. More...
 
void reset_io_byte_count (void)
 
long long get_io_byte_count (void)
 
- Public Member Functions inherited from setcomm
 setcomm (MPI_Comm Comm)
 
 setcomm (const char *str)
 
void initcomm (MPI_Comm Comm)
 
void mpi_printf (const char *fmt,...)
 
void determine_compute_nodes (void)
 

Public Attributes

io_header header
 
- Public Attributes inherited from IO_Def
int N_DataGroups = 0
 
int N_IO_Fields = 0
 
int Max_IO_Fields = 0
 
size_t header_size
 
void * header_buf
 
long long * ntype_in_files
 
char info [100]
 
enum file_contents type_of_file
 
- Public Attributes inherited from io_streamcount
long long byte_count = 0
 
- Public Attributes inherited from setcomm
MPI_Comm Communicator
 
int NTask
 
int ThisTask
 
int PTask
 
int ThisNode
 
int NumNodes = 0
 
int TasksInThisNode
 
int RankInThisNode
 
int MinTasksPerNode
 
int MaxTasksPerNode
 
long long MemoryOnNode
 
long long SharedMemoryOnNode
 

Detailed Description

Definition at line 22 of file snap_io.h.

Constructor & Destructor Documentation

◆ snap_io()

snap_io ( simparticles Sp_ptr,
MPI_Comm  comm,
int  format 
)
inline

Definition at line 27 of file snap_io.h.

Member Function Documentation

◆ acquire_basic_treeinfo()

int acquire_basic_treeinfo ( int  num,
mysnaptype  loc_snap_type 
)

◆ fill_file_header()

void fill_file_header ( int  writeTask,
int  lastTask,
long long *  nloc_part,
long long *  npart 
)
virtual

Implements IO_Def.

Definition at line 643 of file snap_io.cc.

◆ free_basic_treeinfo()

void free_basic_treeinfo ( void  )

◆ free_orphans()

void free_orphans ( void  )

◆ get_base_address_of_structure()

void * get_base_address_of_structure ( enum arrays  array,
int  index 
)
virtual

Implements IO_Def.

Definition at line 522 of file snap_io.cc.

◆ get_datagroup_name()

void get_datagroup_name ( int  grnr,
char *  gname 
)
virtual

Implements IO_Def.

Definition at line 978 of file snap_io.cc.

◆ get_filenr_from_header()

int get_filenr_from_header ( void  )
virtual

Implements IO_Def.

Definition at line 965 of file snap_io.cc.

◆ get_type_of_element()

int get_type_of_element ( int  index)
virtual

Implements IO_Def.

Definition at line 495 of file snap_io.cc.

◆ init_basic()

void init_basic ( simparticles Sp_ptr)

Function for field registering.

For init_field arguments read the documentation of init_field. Don't forget to add the new IO_FLAG to io_private.h

Definition at line 50 of file snap_io.cc.

◆ load_orphans()

long long load_orphans ( int  num,
long long  treenr,
int  num_files 
)

◆ read_file_header()

void read_file_header ( const char *  fname,
int  filenr,
int  readTask,
int  lastTask,
long long *  nloc_part,
long long *  npart,
int *  nstart 
)
virtual

Implements IO_Def.

Definition at line 752 of file snap_io.cc.

◆ read_header_fields()

void read_header_fields ( const char *  fname)
virtual

This function reads the snapshot header in case of hdf5 files (i.e. format 3)

Parameters
fnamefile name of the snapshot as given in the parameter file

Implements IO_Def.

Definition at line 909 of file snap_io.cc.

◆ read_ic()

void read_ic ( const char *  fname)

This function reads initial conditions that are in on of the default file formats of Gadget.

Snapshot files can be used as input files. However, when a snapshot file is used as input, not all the information in the header is used: THE STARTING TIME NEEDS TO BE SET IN THE PARAMETERFILE. Alternatively, the code can be started with All.RestartFlag 2, then snapshots from the code can be used as initial conditions-files without having to change the parameter file. For gas particles, only the internal energy is read, the density and mean molecular weight will be recomputed by the code. When InitGasTemp>0 is given, the gas temperature will be initialized to this value assuming a mean molecular weight either corresponding to complete neutrality, or full ionization.

Parameters
fnamefile name of the ICs
readTypesreadTypes is a bitfield that determines what particle types to read, only if the bit corresponding to a particle type is set, the corresponding data is loaded, otherwise its particle number is set to zero. (This is only implemented for HDF5 files.)

Definition at line 289 of file snap_io.cc.

◆ read_increase_numbers()

void read_increase_numbers ( int  type,
int  n_for_this_task 
)
virtual

Implements IO_Def.

Definition at line 969 of file snap_io.cc.

◆ read_snapshot()

void read_snapshot ( int  num,
mysnaptype  snap_type 
)

Definition at line 244 of file snap_io.cc.

◆ set_filenr_in_header()

void set_filenr_in_header ( int  numfiles)
virtual

Implements IO_Def.

Definition at line 967 of file snap_io.cc.

◆ set_type_of_element()

void set_type_of_element ( int  index,
int  type 
)
virtual

Implements IO_Def.

Definition at line 516 of file snap_io.cc.

◆ write_header_fields()

void write_header_fields ( hid_t  handle)
virtual

Write the fields contained in the header group of the HDF5 snapshot file.

This function stores the fields of the structure io_header as attributes belonging to the header group of the HDF5 file.

Parameters
handlecontains a reference to the header group

Implements IO_Def.

Definition at line 880 of file snap_io.cc.

◆ write_snapshot()

void write_snapshot ( int  num,
mysnaptype  loc_snap_type 
)

Save snapshot to disk.

This function writes a snapshot of the particle distribution to one or several files. If NumFilesPerSnapshot>1, the snapshot is distributed into several files, which are written simultaneously. Each file contains data from a group of processors of size roughly NTask/NumFilesPerSnapshot.

Parameters
numthe snapshot number

Definition at line 559 of file snap_io.cc.

Member Data Documentation

◆ header

io_header header

holds header for snapshot files

Definition at line 125 of file snap_io.h.


The documentation for this class was generated from the following files: