#include <CDataReader.hpp>
Signals | |
void | addBlock (QString, int) |
void | sendHeaderRow (QString, double) |
void | sendHeaderRow (QString, QVector< qreal >) |
Public Member Functions | |
CDataGadget (int ifile, int snapformat=2, int inumpersnap=1) | |
std::string | get_filename () |
bool | check_files_present () |
void | setSnapFormat (const int &format) |
void | setInumPerSnap (const int &num) |
int | getSnapFormat () const |
bool | readFile () |
int | getTypeStart (enums::types_t type) |
int | getTypeEnd (enums::types_t type) |
double | getTime (void) |
return the snapshot time | |
Private Member Functions | |
void | alloc_mem (void) |
void | free_mem (void) |
void | fixStarIDs () |
void | checkStarSanity () |
void | read_header (void) |
Read the GADGETII snapshot header. | |
void | sendTheHeader () |
bool | read_info (std::string &label) |
int | getTypeIndex (const enums::types_t &type) |
bool | load_snapshot (const char *fname, const int &files) |
void | pd_to_arrays () |
void | add_bytes_read (const int &bytes) |
void | read_blocksize (int &blocksize) |
void | read_label (std::string &label) |
void | add_block (std::string blockname, int blocklen) |
int | get_num_blocks () |
std::string | get_blockname (const int &index) |
int | get_blocklen (const int &index) |
Private Attributes | |
int | _snapFormat |
int | _inumPerSnap |
FILE * | snapfile_ |
int | _present [NPRES] |
CDataGadget::CDataGadget | ( | int | ifile, | |
int | snapformat = 2 , |
|||
int | inumpersnap = 1 | |||
) |
Constructor
void CDataGadget::add_bytes_read | ( | const int & | bytes | ) | [private] |
Function called when a number of bytes is read. Emits a signal readProgress with the percentage and a text, can be connected to the progress bar.
void CDataGadget::alloc_mem | ( | void | ) | [private] |
This routine allocates the memory for the particle data.
bool CDataGadget::check_files_present | ( | ) | [virtual] |
Could implement this using opendir|readdir|closedir from dirent.h but that is specific to GNU so doing it in a general albeit more bothersome way (http://www.linuxquestions.org/questions/programming-9/c-list-files-in-directory-379323/): loop over a number of files and try to open them.
sets the first and last dump
Reimplemented from CDataReader.
void CDataGadget::checkStarSanity | ( | ) | [private] |
routine to check whether the type of the P array locations pointed to by star particles is that of star particles.
This routine must be called after MyP is set to point to P locations!
void CDataGadget::fixStarIDs | ( | ) | [private] |
MyP at this point: should contain IDs. Id: should contain the sorted IDs. to be able to use the MyP from the StarP array as an array index we need to account for the fact that arrays start at 0, IDs at 1, and that broebie particles can have disappeared => no longer a one to one correspondence of ID and P[ID-1]
void CDataGadget::free_mem | ( | void | ) | [private] |
Free the allocated memory
string CDataGadget::get_filename | ( | ) | [virtual] |
if auto_filename_ is true: sets a filename and returns it. otherwise: returns the previously set filename
Reimplemented from CDataReader.
bool CDataGadget::load_snapshot | ( | const char * | fname, | |
const int & | files | |||
) | [private] |
This routine loads particle data from Gadget's default binary file format. A snapshot may be distributed into multiple files.
void CDataGadget::pd_to_arrays | ( | ) | [private] |
a routine to put the read data into the Fortran arrays. We could just read the data directly into those arrays, it would however be better to convert all Fortran code to C code. For this reason we keep read_snapshot this way, nothing has to be changed here if the remainder of the source code is converted.
bool CDataGadget::readFile | ( | ) | [virtual] |
wrapper function: reads the file and calls any necessary sorting/copy/... routines
Before calling this either auto filename should be true (default) and the snapshot number should be set, or auto filename should be false and a snapshot location (through set_filename) should be set. Should implement some checks for this..
Reimplemented from CDataReader.
void CDataGadget::sendTheHeader | ( | ) | [private] |
Send signals with the header information, in case anyone is listening.
int CDataGadget::_inumPerSnap [private] |
Number of files per dump (i.e. written in parallel)
int CDataGadget::_snapFormat [private] |
Gadget snapshot format (1 or 2)