Skip to content

Commit

Permalink
remove the T in dataset printing and json dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
tremblap committed Mar 7, 2024
1 parent 53e3f29 commit b0c466c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/data/FluidDataSeries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,21 @@ class FluidDataSeries
if (series.rows() < maxFrames)
{
for (index t = 0; t < series.rows(); t++)
result << setw(10) << "t" << t << ": "
result << setw(10) << t << ": "
<< printFrame(series.row(t), maxCols) << endl;
}
else
{
for (index t = 0; t < maxFrames / 2; t++)
result << setw(10) << "t" << t << ": "
result << setw(10) << t << ": "
<< printFrame(series.row(t), maxCols) << endl;

result << setw(10) << "..." << std::endl;

for (index t = maxFrames / 2; t > 0; t--)
{
index rownum = series.rows() - t;
result << setw(10) << "t" << (rownum) << ": "
result << setw(10) << (rownum) << ": "
<< printFrame(series.row(rownum), maxCols) << endl;
}
}
Expand Down
14 changes: 11 additions & 3 deletions include/data/FluidJSON.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,20 @@ void to_json(nlohmann::json &j, const FluidDataSeries<std::string, T, 1> &ds) {
auto ids = ds.getIds();
auto data = ds.getData();
j["cols"] = ds.pointSize();
char timestring[6];
index maxlength = 0;
for (index r = 0; r < ds.size(); r++) {
auto length = data[r].rows();
maxlength = std::max(maxlength, length);
}
index stringlen = std::ceil(std::log10(maxlength-1));
std::stringstream timestring;
for (index r = 0; r < ds.size(); r++) {
auto series = data[r];
for (index s = 0; s < series.rows(); s++) {
std::snprintf(timestring,6,"T%04ld",s);
j["data"][ids[r]][timestring] = data[r].row(s);
timestring.str("");
timestring.clear();
timestring << std::setw(stringlen) << std::setfill('0') << s;
j["data"][ids[r]][timestring.str()] = data[r].row(s);
}
}
}
Expand Down

0 comments on commit b0c466c

Please sign in to comment.