enable write_data for atom styles with bonus data
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define NFIELDSTRINGS 12 // # of field strings
|
||||
enum{ELLIPSOID,LINE,TRIANGLE,BODY}; // also in WriteData
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -272,77 +273,6 @@ void AtomVecHybrid::force_clear(int n, size_t nbytes)
|
||||
if (styles[k]->forceclearflag) styles[k]->force_clear(n,nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_restart_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_restart_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_restart_init(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->unpack_restart_init(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize non-zero atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::create_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->create_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->data_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_data() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_data()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_post(ilocal);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::copy_bonus(int i, int j, int delflag)
|
||||
@ -457,6 +387,130 @@ bigint AtomVecHybrid::memory_usage_bonus()
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_restart_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_restart_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_restart_init(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->unpack_restart_init(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize non-zero atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::create_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->create_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->data_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_data() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_data()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return size_data_bonus
|
||||
match flag to sub-style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::size_data_bonus_query(int flag)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k],"ellipsoid") == 0)
|
||||
return styles[k]->size_data_bonus;
|
||||
if (flag == LINE && strcmp(keywords[k],"line") == 0)
|
||||
return styles[k]->size_data_bonus;
|
||||
if (flag == TRIANGLE && strcmp(keywords[k],"tri") == 0)
|
||||
return styles[k]->size_data_bonus;
|
||||
// this will not work, body style does not set size_data_bonus
|
||||
// if (flag == BODY && strcmp(keywords[k],"body") == 0)
|
||||
// return styles[k]->size_data_bonus;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack bonus info for writing to data file
|
||||
match flag to sub-style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_data_bonus(double **buf, int flag)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k],"ellipsoid") == 0)
|
||||
return styles[k]->pack_data_bonus(buf,flag);
|
||||
if (flag == LINE && strcmp(keywords[k],"line") == 0)
|
||||
return styles[k]->pack_data_bonus(buf,flag);
|
||||
if (flag == TRIANGLE && strcmp(keywords[k],"tri") == 0)
|
||||
return styles[k]->pack_data_bonus(buf,flag);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
write bonus info to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::write_data_bonus(FILE *fp, int n, double **buf, int flag)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k],"ellipsoid") == 0)
|
||||
styles[k]->write_data_bonus(fp,n,buf,flag);
|
||||
if (flag == LINE && strcmp(keywords[k],"line") == 0)
|
||||
styles[k]->write_data_bonus(fp,n,buf,flag);
|
||||
if (flag == TRIANGLE && strcmp(keywords[k],"tri") == 0)
|
||||
styles[k]->write_data_bonus(fp,n,buf,flag);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
assign an index to named atom property and return index
|
||||
returned value encodes which sub-style and index returned by sub-style
|
||||
|
||||
Reference in New Issue
Block a user