enable write_data for atom styles with bonus data

This commit is contained in:
Steve Plimpton
2020-07-06 17:30:45 -06:00
parent 6bf329098e
commit 7918919d30
15 changed files with 447 additions and 128 deletions

View File

@ -23,6 +23,7 @@
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"
using namespace LAMMPS_NS;
using namespace MathConst;
@ -685,6 +686,66 @@ void AtomVecTri::pack_data_post(int ilocal)
rmass[ilocal] = rmass_one;
}
/* ----------------------------------------------------------------------
pack bonus tri info for writing to data file
if buf is NULL, just return count of lines
------------------------------------------------------------------------- */
int AtomVecTri::pack_data_bonus(double **buf, int /*flag*/)
{
int i,j;
double xc,yc,zc;
double dc1[3],dc2[3],dc3[3];
double p[3][3];
double **x = atom->x;
tagint *tag = atom->tag;
int nlocal = atom->nlocal;
int m = 0;
for (i = 0; i < nlocal; i++) {
if (tri[i] < 0) continue;
if (buf) {
buf[m][0] = ubuf(tag[i]).d;
j = tri[i];
MathExtra::quat_to_mat(bonus[j].quat,p);
MathExtra::matvec(p,bonus[j].c1,dc1);
MathExtra::matvec(p,bonus[j].c2,dc2);
MathExtra::matvec(p,bonus[j].c3,dc3);
xc = x[i][0];
yc = x[i][1];
zc = x[i][2];
buf[m][1] = xc + dc1[0];
buf[m][2] = yc + dc1[1];
buf[m][3] = zc + dc1[2];
buf[m][4] = xc + dc2[0];
buf[m][5] = yc + dc2[1];
buf[m][6] = zc + dc2[2];
buf[m][7] = xc + dc3[0];
buf[m][8] = yc + dc3[1];
buf[m][9] = zc + dc3[2];
}
m++;
}
return m;
}
/* ----------------------------------------------------------------------
write bonus tri info to data file
------------------------------------------------------------------------- */
void AtomVecTri::write_data_bonus(FILE *fp, int n, double **buf, int /*flag*/)
{
for (int i = 0; i < n; i++) {
fmt::print(fp,"{} {} {} {} {} {} {} {} {} {} {}",
(tagint) ubuf(buf[i][0]).i,
buf[i][1],buf[i][2],buf[i][3],
buf[i][4],buf[i][5],buf[i][6],
buf[i][7],buf[i][8],buf[i][9]);
}
}
/* ----------------------------------------------------------------------
set equilateral tri of size in bonus data for particle I
oriented symmetrically in xy plane