25 #include "../shell/Shell.h"
35 ,
"File/stream to write table data to. Default is is __moose_tables__.dat.n"
36 " By default, this object writes data every second \n"
43 ,
"Format of output file, default is csv"
50 ,
"Number of Tables handled by Streamer "
59 ,
"Handle process call"
65 ,
"Handles reinit call"
72 ,
"Add a table to Streamer"
78 ,
"Add many tables to Streamer"
84 ,
"Remove a table from Streamer"
90 ,
"Remove tables -- if found -- from Streamer"
97 static Finfo* procShared[] =
104 "Shared message for process and reinit",
105 procShared,
sizeof( procShared ) /
sizeof(
const Finfo* )
108 static Finfo * tableStreamFinfos[] =
110 &outfile, &format, &proc, &numTables
113 static string doc[] =
116 "Author",
"Dilawar Singh, 2016, NCBS, Bangalore.",
117 "Description",
"Streamer: Stream moose.Table data to out-streams\n"
126 sizeof( tableStreamFinfos )/
sizeof(
Finfo *),
129 sizeof(doc) /
sizeof(
string)
179 for (
size_t i = 0; i <
tableIds_.size(); i++)
181 int tickNum =
tableIds_[i].element()->getTick();
190 " different clock dt. "
191 " Make sure all tables added to Streamer have the same "
200 for(
size_t i = 0; i <
tables_.size(); i++)
208 vector<unsigned int> invalidTables;
209 for (
size_t i = 1; i <
tableTick_.size(); i++)
215 <<
" has tick (dt) which is different than the first table."
218 << endl <<
" Disabling this table."
220 invalidTables.push_back( i );
224 for (
size_t i = 0; i < invalidTables.size(); i++)
284 for(
size_t i = 0; i <
tableIds_.size(); i++)
308 if( tables.size() == 0 )
310 for( vector<Id>::const_iterator it = tables.begin(); it != tables.end(); it++)
323 for (
size_t i = 0; i <
tableIds_.size(); i++)
330 if( matchIndex > -1 )
345 for( vector<Id>::const_iterator it = tables.begin(); it != tables.end(); it++)
373 if( format.size() > 0)
396 size_t numEntriesInEachTable =
tables_[0]->getVecSize( );
402 vector< vector< double > > collectedData;
403 for(
size_t i = 0; i <
tables_.size( ); i++ )
406 if( tVec.size( ) <= numEntriesInEachTable )
410 ,
"Table " <<
tables_[i]->getName( ) <<
" is not functional. Filling with zero "
413 tVec.resize( numEntriesInEachTable, 0 );
415 collectedData.push_back( tVec );
421 for(
size_t i = 0; i < collectedData[0].size( ); i++ )
425 for(
size_t ii = 0; ii < collectedData.size(); ii++ )
426 data_.push_back( collectedData[ ii ][ i ] );
430 for(
size_t i = 0; i <
tables_.size(); i++ )
void cleanUp(void)
This function is called from Shell when simulation is called to write the left-over data to streamer ...
Element * element() const
Synonym for Id::operator()()
vector< Table * > tables_
string getFormat(void) const
std::string path(const std::string &separator="/") const
vector< double > tableDt_
void setFormat(string format)
vector< double > getVec() const
void removeTable(Id table)
Remove a table from Streamer.
bool createParentDirs(const string &path)
Create directories recursively needed to open the given file p.
static const Cinfo * initCinfo()
double getTickDt(unsigned int i) const
Element * element() const
string getExtension(const string &path, bool without_dot)
Get the extension of a given filepath.
string moosePathToUserPath(string path)
When user gives a path /a/b/c, moose creates a path /a[0]/b[0]/c[0]. This is helpful in cases where o...
static const Cinfo * tableStreamCinfo
unsigned int getVecSize() const
void setOutFilepath(string path)
Streamer & operator=(const Streamer &st)
vector< string > columns_
static const Cinfo * initCinfo()
void process(const Eref &e, ProcPtr p)
This function is called at its clock tick.
void addTable(Id table)
Add a table to streamer.
string getOutFilepath(void) const
void removeTables(vector< Id > table)
Remove multiple tables – if found – from Streamer.
void addTables(vector< Id > tables)
Add multiple tables to Streamer.
string getColumnName() const
string toFilename(const string &path)
Replace all directory sepearator with _. This creates a filepath which can be created in current dire...
void zipWithTime()
This function prepares data to be written to a file.
#define LOG(t, a)
This macro only expands when not compiling for release.
vector< unsigned int > tableTick_
size_t getNumTables(void) const
Get the number of tables handled by Streamer.
void showWarn(string msg)
void reinit(const Eref &e, ProcPtr p)
Reinit.
static void writeToOutFile(const string &filepath, const string &format, const string &openmode, const vector< double > &data, const vector< string > &columns)
Write to a output file in given format.