39CSV<T>::CSV(std::string name,
char separator, std::vector<std::string> columnTags, std::string format)
41 _dataFile(singleton::directories().getGnuplotOutDir()+
"data/"+_name+format),
42 _dir(singleton::directories().getGnuplotOutDir()),
43 _separator(separator),
44 _columnTags(columnTags),
51 fout.open(_dataFile.c_str(), std::ios::trunc);
52 if(columnTags.size()>0)
54 setColumnTags(columnTags);
61CSV<T>::CSV(std::string name, std::vector<std::string> columnTags) :
CSV(name,
' ', columnTags){}
67CSV<T>::CSV(std::string name,
char separator) :
CSV(name, separator, std::vector<std::string> {}){}
71void CSV<T>::writeDataFile(T xValue,
const std::vector<T>& yValues,
const std::string& plotNameFile,
int precision)
77 fout.precision(precision);
78 fout.open(DATAF.c_str(), std::ios::out | std::ios::app);
79 fout << BaseType<T>(xValue);
80 for (
unsigned int i = 0; i < yValues.size(); i++) {
81 fout << _separator << BaseType<T>(yValues[i]);
94 std::vector<T> yValues{yValue};
95 writeDataFile(xValue, yValues, plotNameFile, precision);
101template<
typename T >
104 writeDataFile(xValue, yValues, _name, precision);
109template<
typename T >
112 std::vector<T> yValues{yValue};
113 writeDataFile(xValue, yValues, _name,precision);
119template<
typename T >
124 std::ofstream fout(
singleton::directories().getGnuplotOutDir() +
"data/" + plotFileName + _format,std::ios::out);
129 for(;k < columnTags.size() -1; k++)
131 fout << columnTags.at(k) << _separator;
134 fout << columnTags.at(k) << std::endl;
139template<
typename T >
142 setColumnTags(columnTags, _name);
145template<
typename T >
149 std::ofstream fout(
singleton::directories().getGnuplotOutDir() +
"data/" + filename + _format,std::ios::out);
CSV(std::string name, char separator, std::vector< std::string > columnTags, std::string format=".dat")
Constructor with name for output file.
void writeDataFile(T xValue, T yValue, const std::string &plotFileName, int precision=16)
former datFileOut functions these functions create a datafile in the csv format in order to write in ...
void setColumnTags(const std::vector< std::string > columnTags, std::string &plotFileName)
adds column tags at the beginning of the csv data file.
class for marking output with some text
std::string getGnuplotOutDir() const
These functions help you to create file names.
Directories & directories()
Top level namespace for all of OpenLB.
Definition of singletons: global, publicly available information.