make xyz dumps print out current simulation time

This commit is contained in:
Steve Plimpton
2021-12-21 12:18:26 -07:00
parent ded48cc031
commit 576e787839
3 changed files with 23 additions and 12 deletions

View File

@ -94,11 +94,14 @@ void DumpXYZGZ::write_header(bigint ndump)
{
if (me == 0) {
std::string header = fmt::format("{}\n", ndump);
if (time_flag)
header += fmt::format("Atoms. Timestep: {} Time: {:.6f}\n",
update->ntimestep, update->atime);
else
if (time_flag) {
double tcurrent = update->atime +
(update->ntimestep-update->atimestep) + update->dt;
fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT " Time: %f\n",
update->ntimestep, tcurrent);
} else {
header += fmt::format("Atoms. Timestep: {}\n", update->ntimestep);
}
writer.write(header.c_str(), header.length());
}
}

View File

@ -96,15 +96,20 @@ void DumpXYZZstd::openfile()
if (multifile) delete[] filecurrent;
}
/* ---------------------------------------------------------------------- */
void DumpXYZZstd::write_header(bigint ndump)
{
if (me == 0) {
std::string header = fmt::format("{}\n", ndump);
if (time_flag)
header += fmt::format("Atoms. Timestep: {} Time: {:.6f}\n",
update->ntimestep, update->atime);
else
header += fmt::format("Atoms. Timestep: {}\n", update->ntimestep);
if (time_flag) {
double tcurrent = update->atime +
(update->ntimestep-update->atimestep) + update->dt;
fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT " Time: %f\n",
update->ntimestep, tcurrent);
} else {
fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep);
}
writer.write(header.c_str(), header.length());
}
}

View File

@ -131,11 +131,14 @@ void DumpXYZ::write_header(bigint n)
{
if (me == 0) {
fprintf(fp,BIGINT_FORMAT "\n",n);
if (time_flag)
if (time_flag) {
double tcurrent = update->atime +
(update->ntimestep-update->atimestep) + update->dt;
fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT " Time: %f\n",
update->ntimestep, update->atime);
else
update->ntimestep, tcurrent);
} else {
fprintf(fp,"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep);
}
}
}