diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index fd694e7f48..f43e3bcdf8 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -14,6 +14,7 @@ #include "stdlib.h" #include "atom_vec.h" #include "atom.h" +#include "domain.h" using namespace LAMMPS_NS; @@ -26,6 +27,17 @@ AtomVec::AtomVec(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) mass_type = shape_type = dipole_type = 0; } +/* ---------------------------------------------------------------------- + copy of velocity remap settings from Domain +------------------------------------------------------------------------- */ + +void AtomVec::init() +{ + deform_vremap = domain->deform_vremap; + deform_groupbit = domain->deform_groupbit; + h_rate = domain->h_rate; +} + /* ---------------------------------------------------------------------- unpack one line from Velocities section of data file ------------------------------------------------------------------------- */ diff --git a/src/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index e574c387a5..666ba7bc3f 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -147,7 +147,7 @@ int AtomVecAtomic::pack_comm_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { int i,j,m; - double dx,dy,dz; + double dx,dy,dz,dvx,dvy,dvz; m = 0; if (pbc_flag == 0) { @@ -170,14 +170,35 @@ int AtomVecAtomic::pack_comm_vel(int n, int *list, double *buf, dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; dz = pbc[2]*domain->zprd; } - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } } } return m; @@ -295,7 +316,7 @@ int AtomVecAtomic::pack_border_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { int i,j,m; - double dx,dy,dz; + double dx,dy,dz,dvx,dvy,dvz; m = 0; if (pbc_flag == 0) { @@ -321,17 +342,41 @@ int AtomVecAtomic::pack_border_vel(int n, int *list, double *buf, dy = pbc[1]; dz = pbc[2]; } - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = tag[j]; - buf[m++] = type[j]; - buf[m++] = mask[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } } } return m; diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 12b1591589..22618a9553 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -211,7 +211,7 @@ int AtomVecHybrid::pack_comm_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { int i,j,k,m; - double dx,dy,dz; + double dx,dy,dz,dvx,dvy,dvz; int omega_flag = atom->omega_flag; int angmom_flag = atom->angmom_flag; @@ -248,26 +248,59 @@ int AtomVecHybrid::pack_comm_vel(int n, int *list, double *buf, dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; dz = pbc[2]*domain->zprd; } - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + if (omega_flag) { + buf[m++] = omega[j][0]; + buf[m++] = omega[j][1]; + buf[m++] = omega[j][2]; + } + if (angmom_flag) { + buf[m++] = angmom[j][0]; + buf[m++] = angmom[j][1]; + buf[m++] = angmom[j][2]; + } + for (k = 0; k < nstyles; k++) + m += styles[k]->pack_comm_one(j,&buf[m]); } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + if (omega_flag) { + buf[m++] = omega[j][0]; + buf[m++] = omega[j][1]; + buf[m++] = omega[j][2]; + } + if (angmom_flag) { + buf[m++] = angmom[j][0]; + buf[m++] = angmom[j][1]; + buf[m++] = angmom[j][2]; + } + for (k = 0; k < nstyles; k++) + m += styles[k]->pack_comm_one(j,&buf[m]); } - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_comm_one(j,&buf[m]); } } return m; @@ -409,7 +442,7 @@ int AtomVecHybrid::pack_border_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { int i,j,k,m; - double dx,dy,dz; + double dx,dy,dz,dvx,dvy,dvz; int omega_flag = atom->omega_flag; int angmom_flag = atom->angmom_flag; @@ -449,29 +482,65 @@ int AtomVecHybrid::pack_border_vel(int n, int *list, double *buf, dy = pbc[1]; dz = pbc[2]; } - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = tag[j]; - buf[m++] = type[j]; - buf[m++] = mask[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - for (k = 0; k < nstyles; k++) + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + if (omega_flag) { + buf[m++] = omega[j][0]; + buf[m++] = omega[j][1]; + buf[m++] = omega[j][2]; + } + if (angmom_flag) { + buf[m++] = angmom[j][0]; + buf[m++] = angmom[j][1]; + buf[m++] = angmom[j][2]; + } + for (k = 0; k < nstyles; k++) m += styles[k]->pack_border_one(j,&buf[m]); + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + if (omega_flag) { + buf[m++] = omega[j][0]; + buf[m++] = omega[j][1]; + buf[m++] = omega[j][2]; + } + if (angmom_flag) { + buf[m++] = angmom[j][0]; + buf[m++] = angmom[j][1]; + buf[m++] = angmom[j][2]; + } + for (k = 0; k < nstyles; k++) + m += styles[k]->pack_border_one(j,&buf[m]); + } } } return m;