39CSV<T>::CSV(std::string name,
char separator, std::vector<std::string> columnTags)
41 _dataFile(singleton::directories().getGnuplotOutDir()+
"data/"+_name+
".dat"),
42 _dir(singleton::directories().getGnuplotOutDir()),
43 _separator(separator),
44 _columnTags(columnTags)
50 fout.open(_dataFile.c_str(), std::ios::trunc);
51 if(columnTags.size()>0)
53 setColumnTags(columnTags);
60CSV<T>::CSV(std::string name, std::vector<std::string> columnTags) :
CSV(name,
' ', columnTags){}
66CSV<T>::CSV(std::string name,
char separator) :
CSV(name, separator, std::vector<std::string> {}){}
70void CSV<T>::writeDataFile(T xValue,
const std::vector<T>& yValues,
const std::string& plotNameFile,
int precision)
76 fout.precision(precision);
77 fout.open(DATAF.c_str(), std::ios::out | std::ios::app);
78 fout << BaseType<T>(xValue);
79 for (
unsigned int i = 0; i < yValues.size(); i++) {
80 fout << _separator << BaseType<T>(yValues[i]);
93 std::vector<T> yValues{yValue};
94 writeDataFile(xValue, yValues, plotNameFile, precision);
100template<
typename T >
103 writeDataFile(xValue, yValues, _name, precision);
108template<
typename T >
111 std::vector<T> yValues{yValue};
112 writeDataFile(xValue, yValues, _name,precision);
118template<
typename T >
123 std::ofstream fout(
singleton::directories().getGnuplotOutDir() +
"data/" + plotFileName +
".dat",std::ios::out);
128 for(;k < columnTags.size() -1; k++)
130 fout << columnTags.at(k) << _separator;
133 fout << columnTags.at(k) << std::endl;
138template<
typename T >
141 setColumnTags(columnTags, _name);
144template<
typename T >
148 std::ofstream fout(
singleton::directories().getGnuplotOutDir() +
"data/" + filename +
".dat",std::ios::out);
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.
CSV(std::string name, char separator, std::vector< std::string > columnTags)
Constructor with name for output 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.