first stab at implementing dump_modify colname

This commit is contained in:
Axel Kohlmeyer
2022-04-01 07:41:13 -04:00
parent 4042a52db1
commit ce67cb0ca1
8 changed files with 115 additions and 56 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 = { "", "", "", "", "", "", "", "" };
}
/* ---------------------------------------------------------------------- */
@ -63,15 +66,25 @@ void DumpAtom::init_style()
domain->boundary_string(boundstr);
// 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 +214,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);
}
/* ---------------------------------------------------------------------- */
@ -301,7 +314,7 @@ void DumpAtom::header_item(bigint ndump)
fprintf(fp,"%-1.16e %-1.16e\n",boxxlo,boxxhi);
fprintf(fp,"%-1.16e %-1.16e\n",boxylo,boxyhi);
fprintf(fp,"%-1.16e %-1.16e\n",boxzlo,boxzhi);
fprintf(fp,"ITEM: ATOMS %s\n",columns);
fprintf(fp,"ITEM: ATOMS %s\n",columns.c_str());
}
/* ---------------------------------------------------------------------- */
@ -322,7 +335,7 @@ void DumpAtom::header_item_triclinic(bigint ndump)
fprintf(fp,"%-1.16e %-1.16e %-1.16e\n",boxxlo,boxxhi,boxxy);
fprintf(fp,"%-1.16e %-1.16e %-1.16e\n",boxylo,boxyhi,boxxz);
fprintf(fp,"%-1.16e %-1.16e %-1.16e\n",boxzlo,boxzhi,boxyz);
fprintf(fp,"ITEM: ATOMS %s\n",columns);
fprintf(fp,"ITEM: ATOMS %s\n",columns.c_str());
}
/* ---------------------------------------------------------------------- */