Merge branch 'develop' into avoid-bigint-format-scanf

This commit is contained in:
Axel Kohlmeyer
2022-04-08 17:39:25 -04:00
72 changed files with 10564 additions and 1526 deletions

View File

@ -38,6 +38,9 @@ DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
buffer_allow = 1;
buffer_flag = 1;
format_default = nullptr;
key2col = { { "id", 0 }, { "type", 1 }, { "x", 2 }, { "y", 3 },
{ "z", 4 }, { "ix", 5 }, { "iy", 6 }, { "iz", 7 } };
keyword_user = { "", "", "", "", "", "", "", "" };
}
/* ---------------------------------------------------------------------- */
@ -64,14 +67,25 @@ void DumpAtom::init_style()
// setup column string
std::string default_columns;
if (scale_flag == 0 && image_flag == 0)
columns = (char *) "id type x y z";
default_columns = "id type x y z";
else if (scale_flag == 0 && image_flag == 1)
columns = (char *) "id type x y z ix iy iz";
default_columns = "id type x y z ix iy iz";
else if (scale_flag == 1 && image_flag == 0)
columns = (char *) "id type xs ys zs";
default_columns = "id type xs ys zs";
else if (scale_flag == 1 && image_flag == 1)
columns = (char *) "id type xs ys zs ix iy iz";
default_columns = "id type xs ys zs ix iy iz";
int icol = 0;
columns.clear();
for (auto item : utils::split_words(default_columns)) {
if (columns.size()) columns += " ";
if (keyword_user[icol].size()) columns += keyword_user[icol];
else columns += item;
++icol;
}
// setup function ptrs
@ -201,9 +215,9 @@ void DumpAtom::header_unit_style_binary()
void DumpAtom::header_columns_binary()
{
int len = strlen(columns);
int len = columns.size();
fwrite(&len, sizeof(int), 1, fp);
fwrite(columns, sizeof(char), len, fp);
fwrite(columns.c_str(), sizeof(char), len, fp);
}
/* ---------------------------------------------------------------------- */
@ -293,9 +307,7 @@ void DumpAtom::header_item(bigint ndump)
}
if (time_flag) fmt::print(fp,"ITEM: TIME\n{:.16}\n",compute_time());
fmt::print(fp,"ITEM: TIMESTEP\n{}\n"
"ITEM: NUMBER OF ATOMS\n{}\n",
update->ntimestep, ndump);
fmt::print(fp, "ITEM: TIMESTEP\n{}\nITEM: NUMBER OF ATOMS\n{}\n", update->ntimestep, ndump);
fmt::print(fp,"ITEM: BOX BOUNDS {}\n"
"{:>1.16e} {:>1.16e}\n"
@ -316,9 +328,7 @@ void DumpAtom::header_item_triclinic(bigint ndump)
}
if (time_flag) fmt::print(fp,"ITEM: TIME\n{:.16}\n",compute_time());
fmt::print(fp,"ITEM: TIMESTEP\n{}\n"
"ITEM: NUMBER OF ATOMS\n{}\n",
update->ntimestep, ndump);
fmt::print(fp, "ITEM: TIMESTEP\n{}\nITEM: NUMBER OF ATOMS\n{}\n", update->ntimestep, ndump);
fmt::print(fp,"ITEM: BOX BOUNDS xy xz yz {}\n"
"{:>1.16e} {:>1.16e} {:>1.16e}\n"