SEVN
Loading...
Searching...
No Matches
IO Class Reference

#include <IO.h>

Public Member Functions

 IO ()
 
 IO (int argc, char **argv)
 
 ~IO ()
 
void load_stars ()
 
void load (int n, char **val)
 
std::string get_logstring ()
 
void reset_log ()
 
template<typename T >
void fill_matrix_test (std::vector< std::vector< T > > &matrix, std::ifstream &file)
 
bool rseed_provided ()
 Parameters call. More...
 
void print_output (std::vector< std::vector< double > > &printmatrix, const std::string &_name, const unsigned long &_rseed, const size_t &_ID, const bool binaryprint=false)
 
void print_formatted_output (std::vector< std::vector< double > > &printmatrix, const std::string &_name, const unsigned long &_rseed, const size_t &_ID, const bool binaryprint=false)
 
void print_evolved_summary (const std::string &_name, const unsigned long &_rseed, const size_t &_ID)
 
void print_failed_summary (const std::string &_name, const unsigned long &_rseed, const size_t &_ID)
 
void print_failed_initilisation_summary (const size_t &_ID)
 
void print_params (std::string filename="used_params.svpar")
 
void print_log (std::string filename="logfile.dat")
 
void log_put (std::string &loginfo)
 
void create_folder (const std::string &name)
 
std::string get_output_folder_name ()
 
std::string get_SEVNpath () const
 
std::vector< std::vector< double > > load_auxiliary_table (std::string name) const
 

Public Attributes

std::vector< std::vector< std::vector< std::vector< double > > > > tables
 
std::vector< std::vector< std::vector< std::vector< double > > > > tables_HE
 
std::vector< double > Z
 
std::vector< double > Z_HE
 
std::vector< std::vector< double > > allzams
 
std::vector< std::vector< double > > allzams_HE
 
std::vector< std::vector< std::string > > STARS_MATRIX
 
std::random_device rd
 
std::vector< std::string > printcolumns_star
 
std::vector< std::string > printcolumns_binary
 
std::vector< size_t > printIDs_star
 
std::vector< size_t > printIDs_binary
 
size_t ntables
 
int nthreads
 
std::string output_mode
 
std::string binput_mode
 
std::string winds_mode
 
std::string RL_mode
 
std::string tides_mode
 
std::string GW_mode
 
std::string mix_mode
 
std::string COLL_mode
 
std::string HARD_mode
 
std::string CIRC_mode
 
std::string SNK_mode
 
std::string CE_mode
 
std::string SEVNpath
 
SEVNpar svpar
 
int tablesloaded
 

Protected Member Functions

void set_init_variables ()
 
bool check_sorted ()
 
void set_STARMATRIX_labels ()
 

Private Member Functions

void columns_to_print (std::string &list_cols, std::vector< std::string > &printcolumns)
 
void read (std::vector< std::vector< std::vector< std::vector< double > > > > &tables, const std::string &tables_dir, const std::vector< std::string > &zstring, std::vector< double > &Z)
 
void read_tables ()
 
void inspect_tables ()
 
void load_tables ()
 
template<typename T >
void fill_matrix (std::vector< std::vector< T > > &matrix, std::ifstream &file, bool reset=false) const
 
void print_list_summary (std::ofstream &outstream, std::string basename, const std::string &_name, const unsigned long &_rseed, const size_t &_ID)
 
void print_formatted_ascii (const std::string &filename, std::vector< std::vector< double > > &printmatrix, const std::string &_name, const unsigned long &_rseed, const size_t &_ID, const bool binaryprint, const std::string &separator, const size_t &_w_id, const size_t &_w_name, const size_t &_w_header, const size_t &_precision, const std::string &comment)
 
void print_ascii (std::vector< std::vector< double > > &printmatrix, const std::string &_name, const unsigned long &_rseed, const size_t &_ID, const bool binaryprint)
 
void print_csv (std::vector< std::vector< double > > &printmatrix, const std::string &_name, const unsigned long &_rseed, const size_t &_ID, const bool binaryprint)
 
void print_bin (std::vector< std::vector< double > > &printmatrix, const std::string &_name, const unsigned long &_rseed, const size_t &_ID, const bool binaryprint)
 
void inspect_dirs ()
 
void inspect_dir (const std::string &motherdir, std::vector< std::string > &_zstring, std::vector< double > &_Z, std::string inspectdir="")
 
void inspect_object (dirent *object, const std::string &motherdir, std::vector< std::string > &_zstring, std::vector< double > &_Z)
 

Private Attributes

bool load_called = false
 
std::string output_folder_name ="output"
 
std::vector< std::vector< double > > printmatrix
 
SevnLogging svlog
 
std::string tables_dir
 
std::string tables_dir_HE
 
std::string list_file
 
std::string list_cols_star
 
std::string list_cols_binary
 
std::ifstream in
 
std::vector< std::string > zstring
 
std::vector< std::string > zstring_HE
 

Static Private Attributes

static std::ofstream liststars
 
static std::ofstream failedstars
 
static std::ofstream failedinits
 
static std::ofstream outputfile
 
static std::ofstream logfile
 
static std::string logstring
 
static std::vector< std::string > labels_STARMATRIX
 

Constructor & Destructor Documentation

◆ IO() [1/2]

IO::IO ( )
inline

◆ IO() [2/2]

IO::IO ( int  argc,
char **  argv 
)
inline

◆ ~IO()

IO::~IO ( )
inline

Member Function Documentation

◆ check_sorted()

bool IO::check_sorted ( )
inlineprotected

Check if the tables Z, ZHE, allzams, allzams_HE are sorted

Returns

◆ columns_to_print()

void IO::columns_to_print ( std::string &  list_cols,
std::vector< std::string > &  printcolumns 
)
private

Transfer the name from a string containing the name separated by a : to a vector of string. It checks that each name in list cols is one of the name included in Property::PrintMap or in BinaryProperty::PrintMAP

Parameters
list_colsA string containing the property names separated with a :
printcolumnsVector of sting to fill with names from list_cols.

◆ create_folder()

void IO::create_folder ( const std::string &  name)
inline

◆ fill_matrix()

template<typename T >
void IO::fill_matrix ( std::vector< std::vector< T > > &  matrix,
std::ifstream &  file,
bool  reset = false 
) const
inlineprivate

Fill a matrix (2D vector) taking elements from a file

Template Parameters
Tmatrix type
Parameters
matrix2D vector
fileopen file containg the data
resetif true clear the matrix before to fill it otherwise just append

◆ fill_matrix_test()

template<typename T >
void IO::fill_matrix_test ( std::vector< std::vector< T > > &  matrix,
std::ifstream &  file 
)
inline

◆ get_logstring()

std::string IO::get_logstring ( )
inline

◆ get_output_folder_name()

std::string IO::get_output_folder_name ( )
inline

◆ get_SEVNpath()

std::string IO::get_SEVNpath ( ) const
inline

◆ inspect_dir()

void IO::inspect_dir ( const std::string &  motherdir,
std::vector< std::string > &  _zstring,
std::vector< double > &  _Z,
std::string  inspectdir = "" 
)
inlineprivate

◆ inspect_dirs()

void IO::inspect_dirs ( )
inlineprivate

◆ inspect_object()

void IO::inspect_object ( dirent *  object,
const std::string &  motherdir,
std::vector< std::string > &  _zstring,
std::vector< double > &  _Z 
)
inlineprivate

◆ inspect_tables()

void IO::inspect_tables ( )
private

◆ load()

void IO::load ( int  n,
char **  val 
)

Load the simulation parameters and the tables

Parameters
nnumber of elements in val
vallist of strings

◆ load_auxiliary_table()

std::vector< std::vector< double > > IO::load_auxiliary_table ( std::string  name) const
inline

Utilities to load auxiliary data tables. The files needs to be all inside the folder SEVN/auxiliary_data

Parameters
namename of the file
Returns
a 2D vector of double storing the given auxiliary table @Note lines starting with # or / are skipped

◆ load_stars()

void IO::load_stars ( )

Load stars or binary from a list

Fill STARS_MATRIX (2D string matrix) reading the line of the file given in input (name of the file is stored in list_file)

◆ load_tables()

void IO::load_tables ( )
private

◆ log_put()

void IO::log_put ( std::string &  loginfo)
Parameters
loginfo

◆ print_ascii()

void IO::print_ascii ( std::vector< std::vector< double > > &  printmatrix,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID,
const bool  binaryprint 
)
private

Print the output in ascii format with header

◆ print_bin()

void IO::print_bin ( std::vector< std::vector< double > > &  printmatrix,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID,
const bool  binaryprint 
)
private

Print the output in binary format with header

◆ print_csv()

void IO::print_csv ( std::vector< std::vector< double > > &  printmatrix,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID,
const bool  binaryprint 
)
private

Print the output in csv format with header

◆ print_evolved_summary()

void IO::print_evolved_summary ( const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID 
)

Print the evolved summary in ascii format. The info are printed in the file opened as liststars in IO.h. The name of the file is equal to evolved_<NTHREAD>.dat and it will be saved in the ouput folder chosen in input.

Parameters
_namename assigned to the star
_IDID assigen to the star

Print the evolved summary in ascii format. The info are printed in the file opened as liststars in IO.h. The name of the file is equal to evolved.dat and it will be saved in the ouput folder chosen in input.

Parameters
_namename assigned to the star
_IDID assigen to the star

◆ print_failed_initilisation_summary()

void IO::print_failed_initilisation_summary ( const size_t &  _ID)

◆ print_failed_summary()

void IO::print_failed_summary ( const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID 
)

Print the summary of the failed system in ascii format. The info are printed in the file opened as failedstars in IO.h. The name of the file is equal to failed_<NTHREAD>.dat and it will be saved in the ouput folder chosen in input.

Parameters
_name
_ID

◆ print_formatted_ascii()

void IO::print_formatted_ascii ( const std::string &  filename,
std::vector< std::vector< double > > &  printmatrix,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID,
const bool  binaryprint,
const std::string &  separator,
const size_t &  _w_id,
const size_t &  _w_name,
const size_t &  _w_header,
const size_t &  _precision,
const std::string &  comment 
)
private

Formatted ascii print of values contained in the a 2D vector of doubles. In addition to the value in printmatrix two columns are added with the name and the ID of the star.

Parameters
filenamename of the file where to write the data
printmatrix2D vector of doubles to print
_namename of the star (it will be the second column in addition to the data in printmatrix)
_IDID of the star (it will the first column in addition to the data in printmatrix)
binaryprintif true the system calling print is a binary, so the printmatrix contains the info of the two stars and of their orbit
separatorfield delimiter for the output file
_w_idfield width of the id column
_w_namefield width of the name column
_w_headerfield with of all the other columns
_precisiondecimal precision
Note
The name of the columns shown in the header are taken from IO::printcolumns_star and IO::printcolumns_binary. The order of the columns name and of the columns in printmatrix has to be the same, but it is not checked here (see IO::columns_to_print for other details on how this is managed in the class).

Print the output in hdf5 format with header

◆ print_formatted_output()

void IO::print_formatted_output ( std::vector< std::vector< double > > &  printmatrix,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID,
const bool  binaryprint = false 
)
inline

◆ print_list_summary()

void IO::print_list_summary ( std::ofstream &  outstream,
std::string  basename,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID 
)
private

Print the evolved summary in ascii format. The info are printed in the file opened as liststars in IO.h. The name of the file is equal to evolved.dat and it will be saved in the ouput folder chosen in input.

Parameters
_namename assigned to the star
_IDID assigen to the star

PRINT FORMAT PARAMETERS

PRINT HEADER

PRINT DATA

◆ print_log()

void IO::print_log ( std::string  filename = "logfile.dat")

Flush the string logstring to the logfile output and clear logstring

Parameters
filenameName of the file where to save the log

◆ print_output()

void IO::print_output ( std::vector< std::vector< double > > &  printmatrix,
const std::string &  _name,
const unsigned long &  _rseed,
const size_t &  _ID,
const bool  binaryprint = false 
)

◆ print_params()

void IO::print_params ( std::string  filename = "used_params.svpar")
inline

◆ read()

void IO::read ( std::vector< std::vector< std::vector< std::vector< double > > > > &  tables,
const std::string &  tables_dir,
const std::vector< std::string > &  zstring,
std::vector< double > &  Z 
)
private

◆ read_tables()

void IO::read_tables ( )
inlineprivate

◆ reset_log()

void IO::reset_log ( )
inline

◆ rseed_provided()

bool IO::rseed_provided ( )
inline

Parameters call.

◆ set_init_variables()

void IO::set_init_variables ( )
inlineprotected

◆ set_STARMATRIX_labels()

void IO::set_STARMATRIX_labels ( )
inlineprotected

Set the labels referred to the columns of the STARMATRIX table depending on input type NOTICE: so far we assume that a list of input system contains all binaries or all stars not a mix

Member Data Documentation

◆ allzams

std::vector<std::vector<double> > IO::allzams

◆ allzams_HE

std::vector<std::vector<double> > IO::allzams_HE

◆ binput_mode

std::string IO::binput_mode

Handle the formalism for the input for binaries

◆ CE_mode

std::string IO::CE_mode

Formalism for Common envelope processes options

◆ CIRC_mode

std::string IO::CIRC_mode

Formalism for hardening processes options

◆ COLL_mode

std::string IO::COLL_mode

Formalism for mixing processes options

◆ failedinits

std::ofstream IO::failedinits
staticprivate

◆ failedstars

std::ofstream IO::failedstars
staticprivate

◆ GW_mode

std::string IO::GW_mode

Formalism for DA and DE in GW rad processes

◆ HARD_mode

std::string IO::HARD_mode

Formalism for hardening processes options

◆ in

std::ifstream IO::in
private

◆ labels_STARMATRIX

std::vector< std::string > IO::labels_STARMATRIX
staticprivate

Vector that stores the label of the STARMATRIX column, it is set with set_STARMATRIX_labels, called by load_txt

◆ list_cols_binary

std::string IO::list_cols_binary
private

Default list of binary properties to print in output, defined in IO::load

◆ list_cols_star

std::string IO::list_cols_star
private

Default list of stellar properties to print in output, defined in IO::load

◆ list_file

std::string IO::list_file
private

◆ liststars

std::ofstream IO::liststars
staticprivate

◆ load_called

bool IO::load_called = false
private

Flag to check if load has been already called for this instance. The idea is that if we want to change parameters we have to instanciate another object

◆ logfile

std::ofstream IO::logfile
staticprivate

◆ logstring

std::string IO::logstring
staticprivate

◆ mix_mode

std::string IO::mix_mode

Formalism for mixing processes options

◆ ntables

size_t IO::ntables

◆ nthreads

int IO::nthreads

◆ output_folder_name

std::string IO::output_folder_name ="output"
private

◆ output_mode

std::string IO::output_mode

Handle the file output type

◆ outputfile

std::ofstream IO::outputfile
staticprivate

◆ printcolumns_binary

std::vector<std::string> IO::printcolumns_binary

◆ printcolumns_star

std::vector<std::string> IO::printcolumns_star

List of string containing the name of the stellar properties to print in output. It is composed by a default lit of columns (IO::list_cols_star, defined in IO::load) plus some extra columns selected at runtime by the user with the -scol flag see IO::load

◆ printIDs_binary

std::vector<size_t> IO::printIDs_binary

◆ printIDs_star

std::vector<size_t> IO::printIDs_star

◆ printmatrix

std::vector<std::vector<double> > IO::printmatrix
private

◆ rd

std::random_device IO::rd

◆ RL_mode

std::string IO::RL_mode

Formalism for DA and DE in RL process

◆ SEVNpath

std::string IO::SEVNpath

◆ SNK_mode

std::string IO::SNK_mode

Formalism for SN kick processes options

◆ STARS_MATRIX

std::vector< std::vector<std::string> > IO::STARS_MATRIX

◆ svlog

SevnLogging IO::svlog
private

◆ svpar

SEVNpar IO::svpar

◆ tables

std::vector<std::vector<std::vector<std::vector<double> > > > IO::tables

◆ tables_dir

std::string IO::tables_dir
private

◆ tables_dir_HE

std::string IO::tables_dir_HE
private

◆ tables_HE

std::vector<std::vector<std::vector<std::vector<double> > > > IO::tables_HE

◆ tablesloaded

int IO::tablesloaded

◆ tides_mode

std::string IO::tides_mode

Formalism for DA and DE in tidal processes

◆ winds_mode

std::string IO::winds_mode

Formalism for DA and DE in Winds accretion processes

◆ Z

std::vector<double> IO::Z

◆ Z_HE

std::vector<double> IO::Z_HE

◆ zstring

std::vector<std::string> IO::zstring
private

◆ zstring_HE

std::vector<std::string> IO::zstring_HE
private

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