diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index d22e9abfb3..f8f99ae8a8 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -97,7 +97,7 @@ void AtomVecTemplate::process_args(int narg, char **arg) } /* ---------------------------------------------------------------------- - initialize other atom quantities + initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecTemplate::create_atom_post(int ilocal) diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 5450b23293..4fcebc2f84 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -70,21 +70,17 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) } /* ---------------------------------------------------------------------- - create one atom of itype at coord - modify what default AtomVec::create_atom() just created + initialize non-zero atom quantities ------------------------------------------------------------------------- */ -void AtomVecPeri::create_atom(int itype, double *coord) +void AtomVecPeri::create_atom_post(int ilocal) { - AtomVec::create_atom(itype,coord); - int ilocal = atom->nlocal-1; - atom->vfrac[ilocal] = 1.0; atom->rmass[ilocal] = 1.0; atom->s0[ilocal] = DBL_MAX; - atom->x0[ilocal][0] = coord[0]; - atom->x0[ilocal][1] = coord[1]; - atom->x0[ilocal][2] = coord[2]; + atom->x0[ilocal][0] = atom->x[ilocal][0]; + atom->x0[ilocal][1] = atom->x[ilocal][1]; + atom->x0[ilocal][2] = atom->x[ilocal][2]; } /* ---------------------------------------------------------------------- diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 3b41950a6f..13a62eb194 100644 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class AtomVecPeri : public AtomVec { public: AtomVecPeri(class LAMMPS *); - void create_atom(int, double *); + void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); diff --git a/src/USER-DPD/atom_vec_dpd.cpp b/src/USER-DPD/atom_vec_dpd.cpp index d1768d473e..27e0f70a20 100644 --- a/src/USER-DPD/atom_vec_dpd.cpp +++ b/src/USER-DPD/atom_vec_dpd.cpp @@ -17,13 +17,7 @@ #include "atom_vec_dpd.h" #include "atom.h" -#include "comm.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" -#include "memory.h" #include "error.h" -#include "utils.h" using namespace LAMMPS_NS; @@ -34,904 +28,55 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp) molecular = 0; mass_type = 1; - comm_x_only = comm_f_only = 0; // we communicate not only x forward but also dpdTheta - size_forward = 7; // 3 + dpdTheta + uCond + uMech + uChem - size_reverse = 3; // 3 - size_border = 12; // 6 + dpdTheta + uCond + uMech + uChem + uCG + uCGnew - size_velocity = 3; - size_data_atom = 6; // we read id + type + dpdTheta + x + y + z - size_data_vel = 4; - xcol_data = 4; // 1=id 2=type 3=dpdTheta 4=x - atom->rho_flag = 1; atom->dpd_flag = 1; + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file + + fields_grow = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem"; + fields_copy = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; + fields_comm = (char *) "dpdTheta uCond uMech uChem"; + fields_comm_vel = (char *) "dpdTheta uCond uMech uChem"; + fields_reverse = NULL; + fields_border = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; + fields_border_vel = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; + fields_exchange = (char *) "dpdTheta uCond uMech uChem uCG uCGnew"; + fields_restart = (char *) "dpdTheta uCond uMech uChem"; + fields_create = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem"; + fields_data_atom = (char *) "id type dpdTheta x"; + fields_data_vel = (char *) "omega"; + + setup_fields(); } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + initialize other atom quantities after AtomVec::unpack_restart() ------------------------------------------------------------------------- */ -void AtomVecDPD::grow(int n) +void AtomVecDPD::unpack_restart_init(int ilocal) { - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0) - error->one(FLERR,"Per-processor system is too big"); - - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - rho = memory->grow(atom->rho, nmax, "atom:rho"); - dpdTheta = memory->grow(atom->dpdTheta, nmax, "atom:dpdTheta"); - uCond = memory->grow(atom->uCond,nmax,"atom:uCond"); - uMech = memory->grow(atom->uMech,nmax,"atom:uMech"); - uChem = memory->grow(atom->uChem,nmax,"atom:uChem"); - uCG = memory->grow(atom->uCG,nmax,"atom:uCG"); - uCGnew = memory->grow(atom->uCGnew,nmax,"atom:uCGnew"); - duChem = memory->grow(atom->duChem,nmax,"atom:duChem"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); + atom->uCG[ilocal] = 0.0; + atom->uCGnew[ilocal] = 0.0; } /* ---------------------------------------------------------------------- - reset local array ptrs + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecDPD::grow_reset() +void AtomVecDPD::data_atom_post(int ilocal) { - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - rho = atom->rho; - dpdTheta = atom->dpdTheta; - uCond = atom->uCond; - uMech = atom->uMech; - uChem = atom->uChem; - uCG = atom->uCG; - uCGnew = atom->uCGnew; - duChem = atom->duChem; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecDPD::copy(int i, int j, int delflag) -{ - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - dpdTheta[j] = dpdTheta[i]; - uCond[j] = uCond[i]; - uMech[j] = uMech[i]; - uChem[j] = uChem[i]; - uCG[j] = uCG[i]; - uCGnew[j] = uCGnew[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - } - } 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]; - } - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDPD::unpack_comm(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - dpdTheta[i] = buf[m++]; - uCond[i] = buf[m++]; - uMech[i] = buf[m++]; - uChem[i] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDPD::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - dpdTheta[i] = buf[m++]; - uCond[i] = buf[m++]; - uMech[i] = buf[m++]; - uChem[i] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDPD::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - buf[m++] = uCG[j]; - buf[m++] = uCGnew[j]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - buf[m++] = uCG[j]; - buf[m++] = uCGnew[j]; - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - buf[m++] = uCG[j]; - buf[m++] = uCGnew[j]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - buf[m++] = uCG[j]; - buf[m++] = uCGnew[j]; - } - } 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - 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]; - } - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - buf[m++] = uCG[j]; - buf[m++] = uCGnew[j]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_comm_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::pack_border_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = dpdTheta[j]; - buf[m++] = uCond[j]; - buf[m++] = uMech[j]; - buf[m++] = uChem[j]; - buf[m++] = uCG[j]; - buf[m++] = uCGnew[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDPD::unpack_border(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - dpdTheta[i] = buf[m++]; - uCond[i] = buf[m++]; - uMech[i] = buf[m++]; - uChem[i] = buf[m++]; - uCG[i] = buf[m++]; - uCGnew[i] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDPD::unpack_border_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - dpdTheta[i] = buf[m++]; - uCond[i] = buf[m++]; - uMech[i] = buf[m++]; - uChem[i] = buf[m++]; - uCG[i] = buf[m++]; - uCGnew[i] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - dpdTheta[i] = buf[m++]; - uCond[i] = buf[m++]; - uMech[i] = buf[m++]; - uChem[i] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - dpdTheta[i] = buf[m++]; - uCond[i] = buf[m++]; - uMech[i] = buf[m++]; - uChem[i] = buf[m++]; - uCG[i] = buf[m++]; - uCGnew[i] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - xyz must be 1st 3 values, so comm::exchange() can test on them -------------------------------------------------------------------------- */ - -int AtomVecDPD::pack_exchange(int i, double *buf) -{ - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = dpdTheta[i]; - buf[m++] = uCond[i]; - buf[m++] = uMech[i]; - buf[m++] = uChem[i]; - buf[m++] = uCG[i]; - buf[m++] = uCGnew[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDPD::unpack_exchange(double *buf) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - dpdTheta[nlocal] = buf[m++]; - uCond[nlocal] = buf[m++]; - uMech[nlocal] = buf[m++]; - uChem[nlocal] = buf[m++]; - uCG[nlocal] = buf[m++]; - uCGnew[nlocal] = buf[m++]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; - return m; -} - -/* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes -------------------------------------------------------------------------- */ - -int AtomVecDPD::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 15 * nlocal; // 11 + dpdTheta + uCond + uMech + uChem - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); - - return n; -} - -/* ---------------------------------------------------------------------- - pack atom I's data for restart file including extra quantities - xyz must be 1st 3 values, so that read_restart can test on them - molecular types may be negative, but write as positive -------------------------------------------------------------------------- */ - -int AtomVecDPD::pack_restart(int i, double *buf) -{ - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = dpdTheta[i]; - buf[m++] = uCond[i]; - buf[m++] = uMech[i]; - buf[m++] = uChem[i]; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities -------------------------------------------------------------------------- */ - -int AtomVecDPD::unpack_restart(double *buf) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - dpdTheta[nlocal] = buf[m++]; - uCond[nlocal] = buf[m++]; - uMech[nlocal] = buf[m++]; - uChem[nlocal] = buf[m++]; - uCG[nlocal] = 0.0; - uCGnew[nlocal] = 0.0; - - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; - return m; -} - -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecDPD::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - rho[nlocal] = 0.0; - dpdTheta[nlocal] = 0.0; - uCond[nlocal] = 0.0; - uMech[nlocal] = 0.0; - uChem[nlocal] = 0.0; - uCG[nlocal] = 0.0; - uCGnew[nlocal] = 0.0; - duChem[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecDPD::data_atom(double *coord, tagint imagetmp, char **values) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - dpdTheta[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - if (dpdTheta[nlocal] <= 0) - error->one(FLERR,"Internal temperature in Atoms section of date file must be > zero"); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - rho[nlocal] = 0.0; - uCond[nlocal] = 0.0; - uMech[nlocal] = 0.0; - uChem[nlocal] = 0.0; - uCG[nlocal] = 0.0; - uCGnew[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecDPD::data_atom_hybrid(int nlocal, char **values) -{ - dpdTheta[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - - return 1; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecDPD::pack_data(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(type[i]).d; - buf[i][2] = dpdTheta[i]; - buf[i][3] = x[i][0]; - buf[i][4] = x[i][1]; - buf[i][5] = x[i][2]; - buf[i][6] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][7] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][8] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecDPD::pack_data_hybrid(int i, double *buf) -{ - buf[0] = dpdTheta[i]; - return 1; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecDPD::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i, - buf[i][2],buf[i][3],buf[i][4],buf[i][5], - (int) ubuf(buf[i][6]).i,(int) ubuf(buf[i][7]).i, - (int) ubuf(buf[i][8]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecDPD::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e",buf[0]); - return 1; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecDPD::memory_usage() -{ - bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - if (atom->memcheck("rho")) bytes += memory->usage(rho,nmax); - if (atom->memcheck("dpdTheta")) bytes += memory->usage(dpdTheta,nmax); - if (atom->memcheck("uCond")) bytes += memory->usage(uCond,nmax); - if (atom->memcheck("uMech")) bytes += memory->usage(uMech,nmax); - if (atom->memcheck("uChem")) bytes += memory->usage(uChem,nmax); - if (atom->memcheck("uCG")) bytes += memory->usage(uCG,nmax); - if (atom->memcheck("uCGnew")) bytes += memory->usage(uCGnew,nmax); - if (atom->memcheck("duChem")) bytes += memory->usage(duChem,nmax); - - return bytes; + atom->rho[ilocal] = 0.0; + atom->uCond[ilocal] = 0.0; + atom->uMech[ilocal] = 0.0; + atom->uChem[ilocal] = 0.0; + atom->uCG[ilocal] = 0.0; + atom->uCGnew[ilocal] = 0.0; + + if (atom->dpdTheta[ilocal] <= 0) + error->one(FLERR,"Internal temperature in Atoms section of date file " + "must be > zero"); } diff --git a/src/USER-DPD/atom_vec_dpd.h b/src/USER-DPD/atom_vec_dpd.h index 234d2ccce7..20c8a9a2d2 100644 --- a/src/USER-DPD/atom_vec_dpd.h +++ b/src/USER-DPD/atom_vec_dpd.h @@ -27,46 +27,8 @@ namespace LAMMPS_NS { class AtomVecDPD : public AtomVec { public: AtomVecDPD(class LAMMPS *); - virtual ~AtomVecDPD() {} - void grow(int); - void grow_reset(); - void copy(int, int, int); - virtual int pack_comm(int, int *, double *, int, int *); - virtual int pack_comm_vel(int, int *, double *, int, int *); - int pack_comm_hybrid(int, int *, double *); - virtual void unpack_comm(int, int, double *); - virtual void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_reverse(int, int, double *); - void unpack_reverse(int, int *, double *); - virtual int pack_border(int, int *, double *, int, int *); - virtual int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - virtual void unpack_border(int, int, double *); - virtual void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - virtual int pack_exchange(int, double *); - virtual int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - bigint memory_usage(); - double *uCond,*uMech,*uChem,*uCG,*uCGnew,*rho,*dpdTheta; - double *duChem; - - protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - + void unpack_restart_init(int); + void data_atom_post(int); }; } @@ -76,15 +38,6 @@ class AtomVecDPD : public AtomVec { /* ERROR/WARNING messages: -E: Per-processor system is too big - -The number of owned atoms plus ghost atoms on a single -processor must fit in 32-bit integer. - -E: Invalid atom type in Atoms section of data file - -Atom types must range from 1 to specified # of types. - E: Internal temperature in Atoms section of data file must be > zero All internal temperatures must be > zero diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index 552a89c04a..fc73bf4dd5 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -46,929 +46,61 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) { if (lmp->citeme) lmp->citeme->add(cite_user_eff_package); - comm_x_only = comm_f_only = 0; - - mass_type = 1; - molecular = 0; forceclearflag = 1; - size_forward = 4; - size_reverse = 4; - size_border = 9; - size_velocity = 3; - size_data_atom = 8; - size_data_vel = 5; - xcol_data = 6; - atom->ecp_flag = 0; atom->electron_flag = 1; atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->ervel_flag = atom->erforce_flag = 1; -} -/* ---------------------------------------------------------------------- - grow atom-electron arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file -void AtomVecElectron::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; + fields_grow = (char *) "q spin eradius ervel erforce"; + fields_copy = (char *) "q spin eradius ervel"; + fields_comm = (char *) "eradius"; + fields_comm_vel = (char *) "eradius"; + fields_reverse = (char *) "erforce"; + fields_border = (char *) "q spin eradius"; + fields_border_vel = (char *) "q spin eradius"; + fields_exchange = (char *) "q spin eradius ervel"; + fields_restart = (char *) "q spin eradius ervel"; + fields_create = (char *) "q spin eradius ervel"; + fields_data_atom = (char *) "id type q spin eradius x"; + fields_data_vel = (char *) "ervel"; - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - q = memory->grow(atom->q,nmax,"atom:q"); - spin = memory->grow(atom->spin,nmax,"atom:spin"); - eradius = memory->grow(atom->eradius,nmax,"atom:eradius"); - ervel = memory->grow(atom->ervel,nmax,"atom:ervel"); - erforce = memory->grow(atom->erforce,nmax*comm->nthreads,"atom:erforce"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecElectron::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - q = atom->q; - eradius = atom->eradius; ervel = atom->ervel; erforce = atom->erforce; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecElectron::copy(int i, int j, int delflag) -{ - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - q[j] = q[i]; - spin[j] = spin[i]; - eradius[j] = eradius[i]; - ervel[j] = ervel[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); + setup_fields(); } /* ---------------------------------------------------------------------- */ -void AtomVecElectron::force_clear(int n, size_t nbytes) +void AtomVecElectron::force_clear(int /*n*/, size_t nbytes) { - memset(&erforce[n],0,nbytes); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = eradius[j]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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++] = eradius[j]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = eradius[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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++] = eradius[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++] = eradius[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; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_comm_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = eradius[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecElectron::unpack_comm(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - eradius[i] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecElectron::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - eradius[i] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - eradius[i] = buf[m++]; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = erforce[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_reverse_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - buf[m++] = erforce[i]; - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecElectron::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - erforce[j] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::unpack_reverse_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - erforce[j] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = ubuf(spin[j]).d; - buf[m++] = eradius[j]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = ubuf(spin[j]).d; - buf[m++] = eradius[j]; - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = ubuf(spin[j]).d; - buf[m++] = eradius[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[2]; - } - if (domain->triclinic == 0) { - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = ubuf(spin[j]).d; - buf[m++] = eradius[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = q[j]; - buf[m++] = ubuf(spin[j]).d; - buf[m++] = eradius[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 (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::pack_border_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = q[j]; - buf[m++] = ubuf(spin[j]).d; - buf[m++] = eradius[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecElectron::unpack_border(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - q[i] = buf[m++]; - spin[i] = (int) ubuf(buf[m++]).i; - eradius[i] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecElectron::unpack_border_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - q[i] = buf[m++]; - spin[i] = (int) ubuf(buf[m++]).i; - eradius[i] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - q[i] = buf[m++]; - spin[i] = (int) ubuf(buf[m++]).i; - eradius[i] = buf[m++]; - } - return m; + memset(&atom->erforce[0],0,nbytes); } /* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - xyz must be 1st 3 values, so comm::exchange() can test on them + initialize non-zero atom quantities ------------------------------------------------------------------------- */ -int AtomVecElectron::pack_exchange(int i, double *buf) +void AtomVecElectron::create_atom_post(int ilocal) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = q[i]; - buf[m++] = ubuf(spin[i]).d; - buf[m++] = eradius[i]; - buf[m++] = ervel[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecElectron::unpack_exchange(double *buf) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - q[nlocal] = buf[m++]; - spin[nlocal] = (int) ubuf(buf[m++]).i; - eradius[nlocal] = buf[m++]; - ervel[nlocal] = buf[m++]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; - return m; + atom->spin[ilocal] = 1; + atom->eradius[ilocal] = 1.0; } /* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -int AtomVecElectron::size_restart() +void AtomVecElectron::data_atom_post(int ilocal) { - int i; - - int nlocal = atom->nlocal; - int n = 15 * nlocal; // Associated with pack_restart - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); - - return n; -} - -/* ---------------------------------------------------------------------- - pack atom I's data for restart file including extra quantities - xyz must be 1st 3 values, so that read_restart can test on them - molecular types may be negative, but write as positive -------------------------------------------------------------------------- */ - -int AtomVecElectron::pack_restart(int i, double *buf) -{ - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - - buf[m++] = q[i]; - buf[m++] = ubuf(spin[i]).d; - buf[m++] = eradius[i]; - buf[m++] = ervel[i]; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities -------------------------------------------------------------------------- */ - -int AtomVecElectron::unpack_restart(double *buf) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - - q[nlocal] = buf[m++]; - spin[nlocal] = (int) ubuf(buf[m++]).i; - eradius[nlocal] = buf[m++]; - ervel[nlocal] = buf[m++]; - - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; - return m; -} - -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecElectron::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - q[nlocal] = 0.0; - spin[nlocal] = 1; - eradius[nlocal] = 1.0; - ervel[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecElectron::data_atom(double *coord, imageint imagetmp, char **values) -{ - int nlocal = atom->nlocal; - - if (nlocal == nmax) grow(0); - - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - q[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - spin[nlocal] = utils::inumeric(FLERR,values[3],true,lmp); - if (spin[nlocal] == 3) atom->ecp_flag = 1; - - eradius[nlocal] = utils::numeric(FLERR,values[4],true,lmp); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - ervel[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecElectron::data_atom_hybrid(int nlocal, char **values) -{ - q[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - spin[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - eradius[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - if (eradius[nlocal] < 0.0) - error->one(FLERR,"Invalid eradius in Atoms section of data file"); - - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - ervel[nlocal] = 0.0; - - return 3; -} - -/* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file -------------------------------------------------------------------------- */ - -void AtomVecElectron::data_vel(int m, char **values) -{ - v[m][0] = utils::numeric(FLERR,values[0],true,lmp); - v[m][1] = utils::numeric(FLERR,values[1],true,lmp); - v[m][2] = utils::numeric(FLERR,values[2],true,lmp); - ervel[m] = utils::numeric(FLERR,values[3],true,lmp); -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Velocities section of data file -------------------------------------------------------------------------- */ - -int AtomVecElectron::data_vel_hybrid(int m, char **values) -{ - ervel[m] = utils::numeric(FLERR,values[0],true,lmp); - return 1; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecElectron::pack_data(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(type[i]).d; - buf[i][2] = q[i]; - buf[i][3] = ubuf(spin[i]).d; - buf[i][4] = eradius[i]; - buf[i][5] = x[i][0]; - buf[i][6] = x[i][1]; - buf[i][7] = x[i][2]; - buf[i][8] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][9] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][10] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecElectron::pack_data_hybrid(int i, double *buf) -{ - buf[0] = q[i]; - buf[1] = ubuf(spin[i]).d; - buf[2] = eradius[i]; - return 3; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecElectron::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT - " %d %-1.16e %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,buf[i][2], - (int) ubuf(buf[i][3]).i,buf[i][4],buf[i][5],buf[i][6],buf[i][7], - (int) ubuf(buf[i][8]).i,(int) ubuf(buf[i][9]).i, - (int) ubuf(buf[i][10]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecElectron::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %d %-1.16e",buf[0],(int) ubuf(buf[1]).i,buf[2]); - return 3; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecElectron::pack_vel(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = v[i][0]; - buf[i][2] = v[i][1]; - buf[i][3] = v[i][2]; - buf[i][4] = ervel[i]; - } -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -int AtomVecElectron::pack_vel_hybrid(int i, double *buf) -{ - buf[0] = ervel[i]; - return 1; -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecElectron::write_vel(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e %-1.16e\n", - (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3],buf[i][4]); -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file -------------------------------------------------------------------------- */ - -int AtomVecElectron::write_vel_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e",buf[0]); - return 1; + atom->ervel[ilocal] = 0.0; + if (atom->spin[ilocal] == 3) atom->ecp_flag = 1; } /* ---------------------------------------------------------------------- @@ -998,24 +130,28 @@ void AtomVecElectron::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { + int *spin = atom->spin; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = spin[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { + double *eradius = atom->eradius; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = eradius[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 2) { + double *ervel = atom->ervel; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = ervel[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 3) { + double *erforce = atom->erforce; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = erforce[i]; else buf[n] = 0.0; @@ -1023,29 +159,3 @@ void AtomVecElectron::pack_property_atom(int index, double *buf, } } } - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecElectron::memory_usage() -{ - bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - - if (atom->memcheck("q")) bytes += memory->usage(q,nmax); - if (atom->memcheck("spin")) bytes += memory->usage(spin,nmax); - if (atom->memcheck("eradius")) bytes += memory->usage(eradius,nmax); - if (atom->memcheck("ervel")) bytes += memory->usage(ervel,nmax); - if (atom->memcheck("erforce")) - bytes += memory->usage(erforce,nmax*comm->nthreads); - - return bytes; -} diff --git a/src/USER-EFF/atom_vec_electron.h b/src/USER-EFF/atom_vec_electron.h index 6e79775c3d..fabb03438d 100644 --- a/src/USER-EFF/atom_vec_electron.h +++ b/src/USER-EFF/atom_vec_electron.h @@ -27,56 +27,11 @@ namespace LAMMPS_NS { class AtomVecElectron : public AtomVec { public: AtomVecElectron(class LAMMPS *); - ~AtomVecElectron() {} - void grow(int); - void grow_reset(); - void copy(int, int, int); void force_clear(int, size_t); - int pack_comm(int, int *, double *, int, int *); - int pack_comm_vel(int, int *, double *, int, int *); - int pack_comm_hybrid(int, int *, double *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_reverse(int, int, double *); - int pack_reverse_hybrid(int, int, double *); - void unpack_reverse(int, int *, double *); - int unpack_reverse_hybrid(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - void unpack_border(int, int, double *); - void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - int pack_exchange(int, double *); - int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void data_vel(int, char **); - int data_vel_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - void pack_vel(double **); - int pack_vel_hybrid(int, double *); - void write_vel(FILE *, int, double **); - int write_vel_hybrid(FILE *, double *); + void create_atom_post(int); + void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); - bigint memory_usage(); - - private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - int *spin; - double *q,*eradius,*ervel,*erforce; }; } diff --git a/src/USER-MESO/atom_vec_edpd.cpp b/src/USER-MESO/atom_vec_edpd.cpp index edc7a34331..59cee397b5 100644 --- a/src/USER-MESO/atom_vec_edpd.cpp +++ b/src/USER-MESO/atom_vec_edpd.cpp @@ -10,6 +10,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ + #include "atom_vec_edpd.h" #include #include "atom.h" @@ -28,817 +29,65 @@ using namespace LAMMPS_NS; AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp) { - if(strcmp(update->unit_style,"lj") != 0) + if (strcmp(update->unit_style,"lj") != 0) error->all(FLERR,"Atom style edpd requires lj units"); molecular = 0; mass_type = 1; forceclearflag = 1; - comm_x_only = comm_f_only = 0; - comm->ghost_velocity = 1; - - size_forward = 3 + 5; // edpd_temp + vest[4] - size_reverse = 3 + 1; // edpd_flux - size_border = 6 + 6; // edpd_temp + edpd_cv + vest[4] - size_velocity = 3; - size_data_atom = 5 + 2; // we read id + type + edpd_temp + edpd_cv + xyz[3] - size_data_vel = 4; - xcol_data = 5; - atom->edpd_flag = 1; atom->vest_flag = 1; -} -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file -void AtomVecEDPD::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR,"Per-processor system is too big"); + fields_grow = (char *) "edpd_cv edpd_temp edpd_flux vest"; + fields_copy = (char *) "edpd_cv edpd_temp edpd_flux vest"; + fields_comm = (char *) "edpd_temp vest"; + fields_comm_vel = (char *) "edpd_temp vest"; + fields_reverse = (char *) "edpd_flux"; + fields_border = (char *) "edpd_cv edpd_temp vest"; + fields_border_vel = (char *) "edpd_cv edpd_temp vest"; + fields_exchange = (char *) "edpd_cv edpd_temp vest"; + fields_restart = (char * ) "edpd_cv edpd_temp vest"; + fields_create = (char *) "edpd_cv edpd_temp edpd_flux vest"; + fields_data_atom = (char *) "id type edpd_temp edpd_cv x"; + fields_data_vel = NULL; - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - edpd_cv= memory->grow(atom->edpd_cv, nmax, "atom:edpd_cv"); - edpd_temp = memory->grow(atom->edpd_temp, nmax, "atom:edpd_temp"); - edpd_flux = memory->grow(atom->edpd_flux, nmax*comm->nthreads,"atom:edpd_flux"); - vest = memory->grow(atom->vest, nmax, 4, "atom:vest"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecEDPD::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - edpd_cv = atom->cv; edpd_temp = atom->edpd_temp; edpd_flux = atom->edpd_flux; - vest = atom->vest; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecEDPD::copy(int i, int j, int delflag) -{ - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - edpd_temp[j] = edpd_temp[i]; - edpd_flux[j] = edpd_flux[i]; - edpd_cv[j] = edpd_cv[i]; - vest[j][0] = vest[i][0]; - vest[j][1] = vest[i][1]; - vest[j][2] = vest[i][2]; - vest[j][3] = vest[i][3]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); -} - - -void AtomVecEDPD::force_clear(int n, size_t nbytes) -{ - memset(&edpd_flux[n],0,nbytes); -} - - -/* ---------------------------------------------------------------------- */ - -int AtomVecEDPD::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = edpd_temp[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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++] = edpd_temp[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } - return m; + setup_fields(); } /* ---------------------------------------------------------------------- */ -int AtomVecEDPD::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) +void AtomVecEDPD::force_clear(int /*n*/, size_t nbytes) { - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = edpd_temp[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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]; - buf[m++] = edpd_temp[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } 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]; - } - buf[m++] = edpd_temp[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEDPD::unpack_comm(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - edpd_temp[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - vest[i][3] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEDPD::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - edpd_temp[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - vest[i][3] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEDPD::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = edpd_flux[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEDPD::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - edpd_flux[j] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEDPD::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = edpd_temp[j]; - buf[m++] = edpd_cv[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = edpd_temp[j]; - buf[m++] = edpd_cv[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEDPD::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = edpd_temp[j]; - buf[m++] = edpd_cv[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = edpd_temp[j]; - buf[m++] = edpd_cv[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = edpd_temp[j]; - buf[m++] = edpd_cv[j]; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - buf[m++] = vest[j][0] + dvx; - buf[m++] = vest[j][1] + dvy; - buf[m++] = vest[j][2] + dvz; - buf[m++] = vest[j][3]; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = vest[j][3]; - } - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEDPD::unpack_border(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - edpd_temp[i] = buf[m++]; - edpd_cv[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - vest[i][3] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEDPD::unpack_border_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - edpd_temp[i] = buf[m++]; - edpd_cv[i] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - vest[i][3] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); + memset(&atom->edpd_flux[0],0,nbytes); } /* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - xyz must be 1st 3 values, so comm::exchange() can test on them + initialize non-zero atom quantities ------------------------------------------------------------------------- */ -int AtomVecEDPD::pack_exchange(int i, double *buf) +void AtomVecEDPD::create_atom_post(int ilocal) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = edpd_temp[i]; - buf[m++] = edpd_cv[i]; - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][2]; - buf[m++] = vest[i][3]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEDPD::unpack_exchange(double *buf) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - edpd_temp[nlocal] = buf[m++]; - edpd_cv[nlocal] = buf[m++]; - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = buf[m++]; - vest[nlocal][3] = buf[m++]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; - return m; + atom->edpd_temp[ilocal] = 1.0; + atom->edpd_cv[ilocal]= 1.0e5; + atom->vest[ilocal][3] = atom->edpd_temp[ilocal]; } /* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -int AtomVecEDPD::size_restart() +void AtomVecEDPD::data_atom_post(int ilocal) { - int i; - - int nlocal = atom->nlocal; - int n = (11 + 6) * nlocal; // 11 + edpd_temp + edpd_cv + vest[4] - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); - - return n; -} - -/* ---------------------------------------------------------------------- - pack atom I's data for restart file including extra quantities - xyz must be 1st 3 values, so that read_restart can test on them - molecular types may be negative, but write as positive -------------------------------------------------------------------------- */ - -int AtomVecEDPD::pack_restart(int i, double *buf) -{ - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = edpd_temp[i]; - buf[m++] = edpd_cv[i]; - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][2]; - buf[m++] = vest[i][3]; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; - return m; -} - -/* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities -------------------------------------------------------------------------- */ - -int AtomVecEDPD::unpack_restart(double *buf) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } - - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - - edpd_temp[nlocal] = buf[m++]; - edpd_cv[nlocal]= buf[m++]; - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = buf[m++]; - vest[nlocal][3] = buf[m++]; - - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; - return m; -} - -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecEDPD::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - edpd_temp[nlocal] = 1.0; - edpd_flux[nlocal] = 0.0; - edpd_cv[nlocal]= 1.0E5; - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - vest[nlocal][3] = edpd_temp[nlocal]; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecEDPD::data_atom(double *coord, imageint imagetmp, char **values) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - edpd_temp[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - edpd_cv[nlocal] = utils::numeric(FLERR,values[3],true,lmp); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - vest[nlocal][3] = edpd_temp[nlocal]; - edpd_flux[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecEDPD::pack_data(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(type[i]).d; - buf[i][2] = edpd_temp[i]; - buf[i][3] = edpd_cv[i]; - buf[i][4] = x[i][0]; - buf[i][5] = x[i][1]; - buf[i][6] = x[i][2]; - buf[i][7] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][8] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][9] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecEDPD::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i, - buf[i][2],buf[i][3],buf[i][4],buf[i][5],buf[i][6], - (int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i,(int) ubuf(buf[i][9]).i); -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecEDPD::memory_usage() -{ - bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - if (atom->memcheck("edpd_temp")) bytes += memory->usage(edpd_temp,nmax); - if (atom->memcheck("edpd_flux")) bytes += memory->usage(edpd_flux,nmax*comm->nthreads); - if (atom->memcheck("edpd_cv")) bytes += memory->usage(edpd_cv,nmax); - if (atom->memcheck("vest")) bytes += memory->usage(vest,nmax,4); - - return bytes; + atom->edpd_flux[ilocal] = 0.0; + atom->vest[ilocal][0] = 0.0; + atom->vest[ilocal][1] = 0.0; + atom->vest[ilocal][2] = 0.0; + atom->vest[ilocal][3] = atom->edpd_temp[ilocal]; } diff --git a/src/USER-MESO/atom_vec_edpd.h b/src/USER-MESO/atom_vec_edpd.h index 36a4cae97b..7d41b51665 100644 --- a/src/USER-MESO/atom_vec_edpd.h +++ b/src/USER-MESO/atom_vec_edpd.h @@ -27,39 +27,9 @@ namespace LAMMPS_NS { class AtomVecEDPD : public AtomVec { public: AtomVecEDPD(class LAMMPS *); - virtual ~AtomVecEDPD() {} - void grow(int); - void grow_reset(); - void copy(int, int, int); void force_clear(int, size_t); - virtual int pack_comm(int, int *, double *, int, int *); - virtual int pack_comm_vel(int, int *, double *, int, int *); - virtual void unpack_comm(int, int, double *); - virtual void unpack_comm_vel(int, int, double *); - int pack_reverse(int, int, double *); - void unpack_reverse(int, int *, double *); - virtual int pack_border(int, int *, double *, int, int *); - virtual int pack_border_vel(int, int *, double *, int, int *); - virtual void unpack_border(int, int, double *); - virtual void unpack_border_vel(int, int, double *); - virtual int pack_exchange(int, double *); - virtual int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - void pack_data(double **); - void write_data(FILE *, int, double **); - bigint memory_usage(); - - protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double **vest; // store intermediate velocity for using mvv integrator - double *edpd_temp,*edpd_flux,*edpd_cv; // temperature, heat flux, and heat capacity + void create_atom_post(int); + void data_atom_post(int); }; } diff --git a/src/atom.cpp b/src/atom.cpp index e1736e321c..d238db5e65 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -459,8 +459,8 @@ void Atom::peratom_create() add_peratom("radius",&radius,DOUBLE,0); add_peratom("omega",&omega,DOUBLE,3); - add_peratom("amgmom",&angmom,DOUBLE,3); add_peratom("torque",&torque,DOUBLE,3,1); // set per-thread flag + add_peratom("angmom",&angmom,DOUBLE,3); add_peratom("ellipsoid",&ellipsoid,INT,0); add_peratom("line",&line,INT,0); @@ -524,6 +524,31 @@ void Atom::peratom_create() add_peratom("sp",&sp,DOUBLE,4); add_peratom("fm",&fm,DOUBLE,3,1); add_peratom("fm_long",&fm_long,DOUBLE,3,1); + + // USER-EFF package + + add_peratom("spin",&spin,INT,0); + add_peratom("eradius",&eradius,DOUBLE,0); + add_peratom("ervel",&ervel,DOUBLE,0); + add_peratom("erforce",&erforce,DOUBLE,0,1); // set per-thread flag + + // USER-DPD package + + add_peratom("rho",&eradius,DOUBLE,0); + add_peratom("dpdTheta",&dpdTheta,DOUBLE,0); + add_peratom("uCond",&uCond,DOUBLE,0); + add_peratom("uMech",&uMech,DOUBLE,0); + add_peratom("uChem",&uChem,DOUBLE,0); + add_peratom("uCG",&uCG,DOUBLE,0); + add_peratom("uCGnew",&uCGnew,DOUBLE,0); + add_peratom("duChem",&duChem,DOUBLE,0); + + // USER-MESO package + + add_peratom("edpd_cv",&edpd_cv,DOUBLE,0); + add_peratom("edpd_temp",&edpd_temp,DOUBLE,0); + add_peratom("edpd_flux",&edpd_flux,DOUBLE,0,1); // set per-thread flag + add_peratom("vest",&vest,DOUBLE,4); } /* ---------------------------------------------------------------------- @@ -1605,8 +1630,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset) call style-specific routine to parse line ------------------------------------------------------------------------- */ -void Atom::data_bodies(int n, char *buf, AtomVecBody *avec_body, - tagint id_offset) +void Atom::data_bodies(int n, char *buf, AtomVec *avec_body, tagint id_offset) { int j,m,nvalues,tagdata,ninteger,ndouble; diff --git a/src/atom.h b/src/atom.h index 6cc5dff72a..a105b3e5b1 100644 --- a/src/atom.h +++ b/src/atom.h @@ -121,7 +121,7 @@ class Atom : protected Pointers { // USER-MESO package - double **cc, **cc_flux; // cc = chemical concentration + double **cc,**cc_flux; // cc = chemical concentration double *edpd_temp,*edpd_flux; // temperature and heat flux double *edpd_cv; // heat capacity int cc_species; @@ -141,13 +141,12 @@ class Atom : protected Pointers { double **vest; // -------------------------------------------------------------------- - // 1st customization section: customize by adding new flag - // existence flags for per-atom vectors and arrays + // 1st customization section: customize by adding new flags + // most are existence flags for per-atom vectors and arrays // 1 if variable is used, 0 if not int sphere_flag,ellipsoid_flag,line_flag,tri_flag,body_flag; int peri_flag,electron_flag; - int ecp_flag; int wavepacket_flag,sph_flag; int molecule_flag,molindex_flag,molatom_flag; @@ -158,10 +157,14 @@ class Atom : protected Pointers { int rho_flag,e_flag,cv_flag,vest_flag; int dpd_flag,edpd_flag,tdpd_flag; - // USER-SPIN package + // SPIN package int sp_flag; + // USER-EFF package + + int ecp_flag; + // USER-SMD package int smd_flag; @@ -286,7 +289,7 @@ class Atom : protected Pointers { void data_dihedrals(int, char *, int *, tagint, int); void data_impropers(int, char *, int *, tagint, int); void data_bonus(int, char *, class AtomVec *, tagint); - void data_bodies(int, char *, class AtomVecBody *, tagint); + void data_bodies(int, char *, class AtomVec *, tagint); void data_fix_compute_variable(int, int); virtual void allocate_type_arrays(); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 776d7a4619..ed56151d33 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -38,11 +38,13 @@ enum{DOUBLE,INT,BIGINT}; AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) { nmax = 0; + + molecular = 0; bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 0; mass_type = dipole_type = 0; forceclearflag = 0; - size_data_bonus = 0; maxexchange = 0; + bonus_flag = 0; kokkosable = 0; @@ -309,6 +311,8 @@ void AtomVec::copy(int i, int j, int delflag) } } + if (bonus_flag) copy_bonus(i,j,delflag); + if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); @@ -349,7 +353,7 @@ int AtomVec::pack_comm(int n, int *list, double *buf, } } - if (comm) { + if (ncomm) { for (nn = 0; nn < ncomm; nn++) { pdata = mcomm.pdata[nn]; datatype = mcomm.datatype[nn]; @@ -403,6 +407,8 @@ int AtomVec::pack_comm(int n, int *list, double *buf, } } + if (bonus_flag) m += pack_comm_bonus(n,list,&buf[m]); + return m; } @@ -522,6 +528,8 @@ int AtomVec::pack_comm_vel(int n, int *list, double *buf, } } + if (bonus_flag) m += pack_comm_bonus(n,list,&buf[m]); + return m; } @@ -581,6 +589,8 @@ void AtomVec::unpack_comm(int n, int first, double *buf) } } } + + if (bonus_flag) unpack_comm_bonus(n,first,&buf[m]); } /* ---------------------------------------------------------------------- */ @@ -642,6 +652,8 @@ void AtomVec::unpack_comm_vel(int n, int first, double *buf) } } } + + if (bonus_flag) unpack_comm_bonus(n,first,&buf[m]); } /* ---------------------------------------------------------------------- */ @@ -874,6 +886,8 @@ int AtomVec::pack_border(int n, int *list, double *buf, int pbc_flag, int *pbc) } } + if (bonus_flag) m += pack_border_bonus(n,list,&buf[m]); + if (atom->nextra_border) for (int iextra = 0; iextra < atom->nextra_border; iextra++) m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); @@ -1006,6 +1020,8 @@ int AtomVec::pack_border_vel(int n, int *list, double *buf, } } + if (bonus_flag) m += pack_border_bonus(n,list,&buf[m]); + if (atom->nextra_border) for (int iextra = 0; iextra < atom->nextra_border; iextra++) m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); @@ -1074,6 +1090,8 @@ void AtomVec::unpack_border(int n, int first, double *buf) } } + if (bonus_flag) m += unpack_border_bonus(n,first,&buf[m]); + if (atom->nextra_border) for (int iextra = 0; iextra < atom->nextra_border; iextra++) m += modify->fix[atom->extra_border[iextra]]-> @@ -1144,6 +1162,8 @@ void AtomVec::unpack_border_vel(int n, int first, double *buf) } } + if (bonus_flag) m += unpack_border_bonus(n,first,&buf[m]); + if (atom->nextra_border) for (int iextra = 0; iextra < atom->nextra_border; iextra++) m += modify->fix[atom->extra_border[iextra]]-> @@ -1232,6 +1252,8 @@ int AtomVec::pack_exchange(int i, double *buf) } } + if (bonus_flag) m += pack_exchange_bonus(i,&buf[m]); + if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); @@ -1322,6 +1344,8 @@ int AtomVec::unpack_exchange(double *buf) } } + if (bonus_flag) m += unpack_exchange_bonus(nlocal,&buf[m]); + if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) m += modify->fix[atom->extra_grow[iextra]]-> @@ -1366,6 +1390,8 @@ int AtomVec::size_restart() } } + if (bonus_flag) n += size_restart_bonus(); + if (atom->nextra_restart) for (int iextra = 0; iextra < atom->nextra_restart; iextra++) for (i = 0; i < nlocal; i++) @@ -1459,6 +1485,8 @@ int AtomVec::pack_restart(int i, double *buf) } } + if (bonus_flag) m += pack_restart_bonus(i,&buf[m]); + // if needed, restore values after packing pack_restart_post(i); @@ -1558,6 +1586,8 @@ int AtomVec::unpack_restart(double *buf) } } + if (bonus_flag) m += unpack_restart_bonus(nlocal,&buf[m]); + // if needed, initialize other peratom values unpack_restart_init(nlocal); @@ -1635,7 +1665,7 @@ void AtomVec::create_atom(int itype, double *coord) } } - // if needed, initialize other peratom values + // if needed, initialize non-zero peratom values create_atom_post(nlocal); @@ -2295,6 +2325,8 @@ bigint AtomVec::memory_usage() } } + if (bonus_flag) bytes += memory_usage_bonus(); + return bytes; } @@ -2359,8 +2391,9 @@ void AtomVec::setup_fields() // NOTE: check for others vars in atom_vec.cpp/h ?? // NOTE: need to set maxexchange, e.g for style hybrid? - if (ncomm == 0) comm_x_only = 1; - else comm_x_only = 0; + comm_x_only = 1; + if (ncomm) comm_x_only = 0; + if (bonus_flag && size_forward_bonus) comm_x_only = 0; if (nreverse == 0) comm_f_only = 1; else comm_f_only = 0; @@ -2371,6 +2404,7 @@ void AtomVec::setup_fields() if (cols == 0) size_forward++; else size_forward += cols; } + if (bonus_flag) size_forward += size_forward_bonus; size_reverse = 3; for (n = 0; n < nreverse; n++) { @@ -2385,6 +2419,7 @@ void AtomVec::setup_fields() if (cols == 0) size_border++; else size_border += cols; } + if (bonus_flag) size_border += size_border_bonus; size_velocity = 3; for (n = 0; n < ncomm_vel; n++) { @@ -2444,7 +2479,10 @@ int AtomVec::process_fields(char *list, const char *default_list, Method *method for (i = 0; i < nperatom; i++) if (strcmp(field,peratom[i].name) == 0) break; - if (i == nperatom) error->all(FLERR,"Atom_style unrecognized peratom field"); + if (i == nperatom) { + printf("FIELD %s\n",field); + error->all(FLERR,"Atom_style unrecognized peratom field"); + } index[nfield++] = i; // error if field is in default list or appears multiple times diff --git a/src/atom_vec.h b/src/atom_vec.h index 8ed6fff35f..33bf4a3ccd 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -36,11 +36,16 @@ class AtomVec : protected Pointers { int size_velocity; // # of velocity based quantities int size_data_atom; // number of values in Atom line int size_data_vel; // number of values in Velocity line - int size_data_bonus; // number of values in Bonus line int xcol_data; // column (1-N) where x is in Atom line int maxexchange; // max size of exchanged atom // only needs to be set if size > BUFEXTRA + int bonus_flag; // 1 if stores bonus data + int size_forward_bonus; // # in forward bonus comm + int size_border_bonus; // # in border bonus comm + int size_restart_bonus_one; // # in restart bonus comm + int size_data_bonus; // number of values in Bonus line + class Molecule **onemols; // list of molecules for style template int nset; // # of molecules in list @@ -62,6 +67,7 @@ class AtomVec : protected Pointers { AtomVec(class LAMMPS *); virtual ~AtomVec(); + void store_args(int, char **); virtual void process_args(int, char **); virtual void init(); @@ -70,13 +76,18 @@ class AtomVec : protected Pointers { void grow(int); void copy(int, int, int); - void clear_bonus() {} + + virtual void copy_bonus(int, int, int) {} + virtual void clear_bonus() {} int pack_comm(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *); void unpack_comm(int, int, double *); void unpack_comm_vel(int, int, double *); + virtual int pack_comm_bonus(int, int *, double *) {} + virtual void unpack_comm_bonus(int, int, double *) {} + int pack_reverse(int, int, double *); void unpack_reverse(int, int *, double *); @@ -85,16 +96,27 @@ class AtomVec : protected Pointers { void unpack_border(int, int, double *); void unpack_border_vel(int, int, double *); + virtual int pack_border_bonus(int, int *, double *) {} + virtual int unpack_border_bonus(int, int, double *) {} + int pack_exchange(int, double *); int unpack_exchange(double *); + virtual int pack_exchange_bonus(int, double *) {} + virtual int unpack_exchange_bonus(int, double *) {} + int size_restart(); - virtual void pack_restart_pre(int) {} int pack_restart(int, double *); - virtual void pack_restart_post(int) {} int unpack_restart(double *); + + virtual void pack_restart_pre(int) {} + virtual void pack_restart_post(int) {} virtual void unpack_restart_init(int) {} + virtual int size_restart_bonus() {} + virtual int pack_restart_bonus(int, double *) {} + virtual int unpack_restart_bonus(int, double *) {} + void create_atom(int, double *); virtual void create_atom_post(int) {} @@ -102,13 +124,15 @@ class AtomVec : protected Pointers { virtual void data_atom_post(int) {} void data_atom_bonus(int, char **) {} - void data_vel(int, char **); + void data_body(int, int, int, int *, double *) {} + + void pack_data(double **); + void write_data(FILE *, int, double **); virtual void pack_data_pre(int) {} - void pack_data(double **); virtual void pack_data_post(int) {} - int pack_data_hybrid(int, double *) {return 0;} - void write_data(FILE *, int, double **); + + void data_vel(int, char **); void pack_vel(double **); void write_vel(FILE *, int, double **); @@ -125,6 +149,7 @@ class AtomVec : protected Pointers { void pack_property_atom(int, double *, int, int) {} bigint memory_usage(); + virtual bigint memory_usage_bonus() {} protected: int nmax; // local copy of atom->nmax diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 5e83946078..1a8c2defd9 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -18,7 +18,6 @@ #include "style_body.h" #include "body.h" #include "atom.h" -#include "comm.h" #include "domain.h" #include "modify.h" #include "fix.h" @@ -33,17 +32,17 @@ using namespace LAMMPS_NS; AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; + bonus_flag = 1; - // size_forward and size_border set in settings(), via Body class + // first 3 sizes do not include values from body itself + // 1st,2nd body counts are added in process_args() via body style + // 3rd body count is added in size_restart_bonus() + // size_data_bonus is not used by Atom class for body style - comm_x_only = comm_f_only = 0; - size_forward = 0; - size_reverse = 6; - size_border = 0; - size_velocity = 6; - size_data_atom = 7; - size_data_vel = 7; - xcol_data = 5; + size_forward_bonus = 4; + size_border_bonus = 9; + size_restart_bonus_one = 9; + size_data_bonus = 0; atom->body_flag = 1; atom->rmass_flag = 1; @@ -58,6 +57,26 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) if (sizeof(double) == sizeof(int)) intdoubleratio = 1; else if (sizeof(double) == 2*sizeof(int)) intdoubleratio = 2; else error->all(FLERR,"Internal error in atom_style body"); + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file + + fields_grow = (char *) "radius rmass angmom torque body"; + fields_copy = (char *) "radius rmass angmom"; + fields_comm = NULL; + fields_comm_vel = (char *) "angmom"; + fields_reverse = (char *) "torque"; + fields_border = (char *) "radius rmass"; + fields_border_vel = (char *) "radius rmass angmom"; + fields_exchange = (char *) "radius rmass angmom"; + fields_restart = (char *) "radius rmass angmom"; + fields_create = (char *) "radius rmass angmom tri"; + fields_data_atom = (char *) "id type body rmass x"; + fields_data_vel = (char *) "angmom"; + + setup_fields(); } /* ---------------------------------------------------------------------- */ @@ -96,65 +115,18 @@ void AtomVecBody::process_args(int narg, char **arg) #undef BodyStyle #undef BODY_CLASS - else error->all(FLERR,utils::check_packages_for_style("body",arg[0],lmp).c_str()); + else error->all(FLERR,utils:: + check_packages_for_style("body",arg[0],lmp).c_str()); bptr->avec = this; icp = bptr->icp; dcp = bptr->dcp; // max size of forward/border comm - // 7,16 are packed in pack_comm/pack_border // bptr values = max number of additional ivalues/dvalues from Body class - size_forward = 7 + bptr->size_forward; - size_border = 18 + bptr->size_border; -} - -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecBody::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR,"Per-processor system is too big"); - - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - radius = memory->grow(atom->radius,nmax,"atom:radius"); - rmass = memory->grow(atom->rmass,nmax,"atom:rmass"); - angmom = memory->grow(atom->angmom,nmax,3,"atom:angmom"); - torque = memory->grow(atom->torque,nmax*comm->nthreads,3,"atom:torque"); - body = memory->grow(atom->body,nmax,"atom:body"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecBody::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - radius = atom->radius; rmass = atom->rmass; - angmom = atom->angmom; torque = atom->torque; - body = atom->body; + size_forward_bonus += bptr->size_forward; + size_border_bonus += bptr->size_border; } /* ---------------------------------------------------------------------- @@ -176,24 +148,9 @@ void AtomVecBody::grow_bonus() if delflag and atom J has bonus data, then delete it ------------------------------------------------------------------------- */ -void AtomVecBody::copy(int i, int j, int delflag) +void AtomVecBody::copy_bonus(int i, int j, int delflag) { - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - radius[j] = radius[i]; - rmass[j] = rmass[i]; - angmom[j][0] = angmom[i][0]; - angmom[j][1] = angmom[i][1]; - angmom[j][2] = angmom[i][2]; + int *body = atom->body; // if deleting atom J via delflag and J has bonus data, then delete it @@ -201,7 +158,7 @@ void AtomVecBody::copy(int i, int j, int delflag) int k = body[j]; icp->put(bonus[k].iindex); dcp->put(bonus[k].dindex); - copy_bonus(nlocal_bonus-1,k); + copy_bonus_all(nlocal_bonus-1,k); nlocal_bonus--; } @@ -210,10 +167,6 @@ void AtomVecBody::copy(int i, int j, int delflag) if (body[i] >= 0 && i != j) bonus[body[i]].ilocal = j; body[j] = body[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); } /* ---------------------------------------------------------------------- @@ -221,9 +174,9 @@ void AtomVecBody::copy(int i, int j, int delflag) also reset body that points to I to now point to J ------------------------------------------------------------------------- */ -void AtomVecBody::copy_bonus(int i, int j) +void AtomVecBody::copy_bonus_all(int i, int j) { - body[bonus[i].ilocal] = j; + atom->body[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -240,167 +193,21 @@ void AtomVecBody::clear_bonus() dcp->put(bonus[i].dindex); } nghost_bonus = 0; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->clear_bonus(); } /* ---------------------------------------------------------------------- */ -int AtomVecBody::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - double *quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (body[j] >= 0) { - quat = bonus[body[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]); - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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; - if (body[j] >= 0) { - quat = bonus[body[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]); - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - double *quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (body[j] >= 0) { - quat = bonus[body[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]); - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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; - if (body[j] >= 0) { - quat = bonus[body[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]); - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - 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 (body[j] >= 0) { - quat = bonus[body[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]); - } - 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]; - } - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_comm_hybrid(int n, int *list, double *buf) +int AtomVecBody::pack_comm_bonus(int n, int *list, double *buf) { int i,j,m; double *quat; + int *body = atom->body; + m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -413,22 +220,22 @@ int AtomVecBody::pack_comm_hybrid(int n, int *list, double *buf) m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]); } } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecBody::unpack_comm(int n, int first, double *buf) +void AtomVecBody::unpack_comm_bonus(int n, int first, double *buf) { int i,m,last; double *quat; + int *body = atom->body; + m = 0; last = first + n; for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; if (body[i] >= 0) { quat = bonus[body[i]].quat; quat[0] = buf[m++]; @@ -442,359 +249,16 @@ void AtomVecBody::unpack_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -void AtomVecBody::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - double *quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - if (body[i] >= 0) { - quat = bonus[body[i]].quat; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - m += bptr->unpack_comm_body(&bonus[body[i]],&buf[m]); - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - double *quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - if (body[i] >= 0) { - quat = bonus[body[i]].quat; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - m += bptr->unpack_comm_body(&bonus[body[i]],&buf[m]); - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_reverse_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecBody::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::unpack_reverse_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - double *quat,*inertia; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (body[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[body[j]].quat; - inertia = bonus[body[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - buf[m++] = ubuf(bonus[body[j]].ninteger).d; - buf[m++] = ubuf(bonus[body[j]].ndouble).d; - m += bptr->pack_border_body(&bonus[body[j]],&buf[m]); - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (body[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[body[j]].quat; - inertia = bonus[body[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - buf[m++] = ubuf(bonus[body[j]].ninteger).d; - buf[m++] = ubuf(bonus[body[j]].ndouble).d; - m += bptr->pack_border_body(&bonus[body[j]],&buf[m]); - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - double *quat,*inertia; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (body[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[body[j]].quat; - inertia = bonus[body[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - buf[m++] = ubuf(bonus[body[j]].ninteger).d; - buf[m++] = ubuf(bonus[body[j]].ndouble).d; - m += bptr->pack_border_body(&bonus[body[j]],&buf[m]); - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (body[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[body[j]].quat; - inertia = bonus[body[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - buf[m++] = ubuf(bonus[body[j]].ninteger).d; - buf[m++] = ubuf(bonus[body[j]].ndouble).d; - m += bptr->pack_border_body(&bonus[body[j]],&buf[m]); - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - 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; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - if (body[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[body[j]].quat; - inertia = bonus[body[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - buf[m++] = ubuf(bonus[body[j]].ninteger).d; - buf[m++] = ubuf(bonus[body[j]].ndouble).d; - m += bptr->pack_border_body(&bonus[body[j]],&buf[m]); - } - 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]; - } - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::pack_border_hybrid(int n, int *list, double *buf) +int AtomVecBody::pack_border_bonus(int n, int *list, double *buf) { int i,j,m; double *quat,*inertia; + int *body = atom->body; + m = 0; for (i = 0; i < n; i++) { j = list[i]; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; if (body[j] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -811,29 +275,23 @@ int AtomVecBody::pack_border_hybrid(int n, int *list, double *buf) buf[m++] = ubuf(bonus[body[j]].ndouble).d; m += bptr->pack_border_body(&bonus[body[j]],&buf[m]); } - } + } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecBody::unpack_border(int n, int first, double *buf) +int AtomVecBody::unpack_border_bonus(int n, int first, double *buf) { int i,j,m,last; double *quat,*inertia; + int *body = atom->body; + m = 0; last = first + n; for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; body[i] = (int) ubuf(buf[m++]).i; if (body[i] == 0) body[i] = -1; else { @@ -860,106 +318,6 @@ void AtomVecBody::unpack_border(int n, int first, double *buf) } } - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecBody::unpack_border_vel(int n, int first, double *buf) -{ - int i,j,m,last; - double *quat,*inertia; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - body[i] = (int) ubuf(buf[m++]).i; - if (body[i] == 0) body[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - quat = bonus[j].quat; - inertia = bonus[j].inertia; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - inertia[0] = buf[m++]; - inertia[1] = buf[m++]; - inertia[2] = buf[m++]; - bonus[j].ninteger = (int) ubuf(buf[m++]).i; - bonus[j].ndouble = (int) ubuf(buf[m++]).i; - // corresponding put() calls are in clear_bonus() - bonus[j].ivalue = icp->get(bonus[j].ninteger,bonus[j].iindex); - bonus[j].dvalue = dcp->get(bonus[j].ndouble,bonus[j].dindex); - m += bptr->unpack_border_body(&bonus[j],&buf[m]); - bonus[j].ilocal = i; - body[i] = j; - nghost_bonus++; - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBody::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,j,m,last; - double *quat,*inertia; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - body[i] = (int) ubuf(buf[m++]).i; - if (body[i] == 0) body[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - quat = bonus[j].quat; - inertia = bonus[j].inertia; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - inertia[0] = buf[m++]; - inertia[1] = buf[m++]; - inertia[2] = buf[m++]; - bonus[j].ninteger = (int) ubuf(buf[m++]).i; - bonus[j].ndouble = (int) ubuf(buf[m++]).i; - // corresponding put() calls are in clear_bonus() - bonus[j].ivalue = icp->get(bonus[j].ninteger,bonus[j].iindex); - bonus[j].dvalue = dcp->get(bonus[j].ndouble,bonus[j].dindex); - m += bptr->unpack_border_body(&bonus[j],&buf[m]); - bonus[j].ilocal = i; - body[i] = j; - nghost_bonus++; - } - } return m; } @@ -968,24 +326,11 @@ int AtomVecBody::unpack_border_hybrid(int n, int first, double *buf) xyz must be 1st 3 values, so comm::exchange() can test on them ------------------------------------------------------------------------- */ -int AtomVecBody::pack_exchange(int i, double *buf) +int AtomVecBody::pack_exchange_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = angmom[i][0]; - buf[m++] = angmom[i][1]; - buf[m++] = angmom[i][2]; + int m = 0; + + int *body = atom->body; if (body[i] < 0) buf[m++] = ubuf(0).d; else { @@ -1009,40 +354,19 @@ int AtomVecBody::pack_exchange(int i, double *buf) m += bonus[j].ndouble; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- */ -int AtomVecBody::unpack_exchange(double *buf) +int AtomVecBody::unpack_exchange_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - angmom[nlocal][0] = buf[m++]; - angmom[nlocal][1] = buf[m++]; - angmom[nlocal][2] = buf[m++]; + int *body = atom->body; - body[nlocal] = (int) ubuf(buf[m++]).i; - if (body[nlocal] == 0) body[nlocal] = -1; + body[ilocal] = (int) ubuf(buf[m++]).i; + if (body[ilocal] == 0) body[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); double *quat = bonus[nlocal_bonus].quat; @@ -1069,42 +393,34 @@ int AtomVecBody::unpack_exchange(double *buf) bonus[nlocal_bonus].ndouble*sizeof(double)); m += bonus[nlocal_bonus].ndouble; - bonus[nlocal_bonus].ilocal = nlocal; - body[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + body[ilocal] = nlocal_bonus++; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; return m; } /* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes + unpack data for one atom from restart file including bonus data ------------------------------------------------------------------------- */ -int AtomVecBody::size_restart() +int AtomVecBody::size_restart_bonus() { int i; + int *body = atom->body; + int n = 0; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) + for (i = 0; i < nlocal; i++) { if (body[i] >= 0) { - n += 26; + n += size_restart_bonus_one; if (intdoubleratio == 1) n += bonus[body[i]].ninteger; else n += (bonus[body[i]].ninteger+1)/2; n += bonus[body[i]].ndouble; - } else n += 17; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + } + n++; + } return n; } @@ -1115,25 +431,11 @@ int AtomVecBody::size_restart() molecular types may be negative, but write as positive ------------------------------------------------------------------------- */ -int AtomVecBody::pack_restart(int i, double *buf) +int AtomVecBody::pack_restart_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; + int m = 0; - buf[m++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = angmom[i][0]; - buf[m++] = angmom[i][1]; - buf[m++] = angmom[i][2]; + int *body = atom->body; if (body[i] < 0) buf[m++] = ubuf(0).d; else { @@ -1157,47 +459,21 @@ int AtomVecBody::pack_restart(int i, double *buf) m += bonus[j].ndouble; } - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities + unpack data for one atom from restart file including bonus data ------------------------------------------------------------------------- */ -int AtomVecBody::unpack_restart(double *buf) +int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; + int *body = atom->body; - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - angmom[nlocal][0] = buf[m++]; - angmom[nlocal][1] = buf[m++]; - angmom[nlocal][2] = buf[m++]; - - body[nlocal] = (int) ubuf(buf[m++]).i; - if (body[nlocal] == 0) body[nlocal] = -1; + body[ilocal] = (int) ubuf(buf[m++]).i; + if (body[ilocal] == 0) body[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); double *quat = bonus[nlocal_bonus].quat; @@ -1222,17 +498,10 @@ int AtomVecBody::unpack_restart(double *buf) memcpy(bonus[nlocal_bonus].dvalue,&buf[m], bonus[nlocal_bonus].ndouble*sizeof(double)); m += bonus[nlocal_bonus].ndouble; - bonus[nlocal_bonus].ilocal = nlocal; - body[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + body[ilocal] = nlocal_bonus++; } - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; return m; } @@ -1241,92 +510,33 @@ int AtomVecBody::unpack_restart(double *buf) set other values to defaults ------------------------------------------------------------------------- */ -void AtomVecBody::create_atom(int itype, double *coord) +void AtomVecBody::create_atom_post(int ilocal) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - radius[nlocal] = 0.5; - rmass[nlocal] = 1.0; - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - body[nlocal] = -1; - - atom->nlocal++; + atom->radius[ilocal] = 0.5; + atom->rmass[ilocal] = 1.0; + atom->body[ilocal] = -1; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecBody::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecBody::data_atom_post(int ilocal) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + body_flag = atom->body[ilocal]; + if (body_flag == 0) body_flag = -1; + else if (body_flag == 1) body_flag = 0; + else error->one(FLERR,"Invalid body flag in Atoms section of data file"); + atom->body[ilocal] = body_flag; - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - body[nlocal] = utils::inumeric(FLERR,values[2],true,lmp); - if (body[nlocal] == 0) body[nlocal] = -1; - else if (body[nlocal] == 1) body[nlocal] = 0; - else error->one(FLERR,"Invalid bodyflag in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[3],true,lmp); - if (rmass[nlocal] <= 0.0) + if (atom->rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - radius[nlocal] = 0.5; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecBody::data_atom_hybrid(int nlocal, char **values) -{ - body[nlocal] = utils::inumeric(FLERR,values[0],true,lmp); - if (body[nlocal] == 0) body[nlocal] = -1; - else if (body[nlocal] == 1) body[nlocal] = 0; - else error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[1],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - return 2; + atom->radius[ilocal] = 0.5; + atom->angmom[ilocal][0] = 0.0; + atom->angmom[ilocal][1] = 0.0; + atom->angmom[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -1336,148 +546,52 @@ int AtomVecBody::data_atom_hybrid(int nlocal, char **values) void AtomVecBody::data_body(int m, int ninteger, int ndouble, int *ivalues, double *dvalues) { - if (body[m]) error->one(FLERR,"Assigning body parameters to non-body atom"); + if (atom->body[m]) + error->one(FLERR,"Assigning body parameters to non-body atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); bonus[nlocal_bonus].ilocal = m; bptr->data_body(nlocal_bonus,ninteger,ndouble,ivalues,dvalues); - body[m] = nlocal_bonus++; + atom->body[m] = nlocal_bonus++; } /* ---------------------------------------------------------------------- - unpack one tri from Velocities section of data file + return # of bytes of allocated memory ------------------------------------------------------------------------- */ -void AtomVecBody::data_vel(int m, char **values) +bigint AtomVecBody::memory_usage_bonus() { - v[m][0] = utils::numeric(FLERR,values[0],true,lmp); - v[m][1] = utils::numeric(FLERR,values[1],true,lmp); - v[m][2] = utils::numeric(FLERR,values[2],true,lmp); - angmom[m][0] = utils::numeric(FLERR,values[3],true,lmp); - angmom[m][1] = utils::numeric(FLERR,values[4],true,lmp); - angmom[m][2] = utils::numeric(FLERR,values[5],true,lmp); -} + bigint bytes = 0; + bytes += nmax_bonus*sizeof(Bonus); + bytes += icp->size + dcp->size; -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one body in Velocities section of data file -------------------------------------------------------------------------- */ - -int AtomVecBody::data_vel_hybrid(int m, char **values) -{ - angmom[m][0] = utils::numeric(FLERR,values[0],true,lmp); - angmom[m][1] = utils::numeric(FLERR,values[1],true,lmp); - angmom[m][2] = utils::numeric(FLERR,values[2],true,lmp); - return 3; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecBody::pack_data(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(type[i]).d; - if (body[i] < 0) buf[i][2] = ubuf(0).d; - else buf[i][2] = ubuf(1).d; - buf[i][3] = rmass[i]; - buf[i][4] = x[i][0]; - buf[i][5] = x[i][1]; - buf[i][6] = x[i][2]; - buf[i][7] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][8] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][9] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + int nall = nlocal_bonus + nghost_bonus; + for (int i = 0; i < nall; i++) { + bytes += bonus[i].ninteger * sizeof(int); + bytes += bonus[i].ndouble * sizeof(double); } + + return bytes; } /* ---------------------------------------------------------------------- - pack hybrid atom info for data file + modify values for AtomVec::pack_data() to pack ------------------------------------------------------------------------- */ -int AtomVecBody::pack_data_hybrid(int i, double *buf) -{ - if (body[i] < 0) buf[0] = ubuf(0).d; - else buf[0] = ubuf(1).d; - buf[1] = rmass[i]; - return 2; +void AtomVecBody::pack_data_pre(int ilocal) +{ + body_flag = atom->body[ilocal]; + + if (body_flag < 0) atom->body[ilocal] = 0; + else atom->body[ilocal] = 1; } /* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags + unmodify values packed by AtomVec::pack_data() ------------------------------------------------------------------------- */ -void AtomVecBody::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " %d %d %g %g %g %g %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i, - (int) ubuf(buf[i][2]).i, - buf[i][3],buf[i][4],buf[i][5],buf[i][6], - (int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i, - (int) ubuf(buf[i][9]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecBody::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %d %g",(int) ubuf(buf[0]).i,buf[1]); - return 2; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecBody::pack_vel(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = v[i][0]; - buf[i][2] = v[i][1]; - buf[i][3] = v[i][2]; - buf[i][4] = angmom[i][0]; - buf[i][5] = angmom[i][1]; - buf[i][6] = angmom[i][2]; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid velocity info for data file -------------------------------------------------------------------------- */ - -int AtomVecBody::pack_vel_hybrid(int i, double *buf) -{ - buf[0] = angmom[i][0]; - buf[1] = angmom[i][1]; - buf[2] = angmom[i][2]; - return 3; -} - -/* ---------------------------------------------------------------------- - write velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecBody::write_vel(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " %g %g %g %g %g %g\n", - (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3], - buf[i][4],buf[i][5],buf[i][6]); -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file -------------------------------------------------------------------------- */ - -int AtomVecBody::write_vel_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %g %g %g",buf[0],buf[1],buf[2]); - return 3; +void AtomVecBody::pack_data_post(int ilocal) +{ + atom->body[ilocal] = body_flag; } /* ---------------------------------------------------------------------- @@ -1497,47 +611,12 @@ double AtomVecBody::radius_body(int ninteger, int ndouble, void AtomVecBody::set_quat(int m, double *quat_external) { - if (body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom"); - double *quat = bonus[body[m]].quat; + if (atom->body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom"); + double *quat = bonus[atom->body[m]].quat; quat[0] = quat_external[0]; quat[1] = quat_external[1]; quat[2] = quat_external[2]; quat[3] = quat_external[3]; } -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecBody::memory_usage() -{ - bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - - if (atom->memcheck("radius")) bytes += memory->usage(radius,nmax); - if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); - if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3); - if (atom->memcheck("torque")) bytes += - memory->usage(torque,nmax*comm->nthreads,3); - if (atom->memcheck("body")) bytes += memory->usage(body,nmax); - - bytes += nmax_bonus*sizeof(Bonus); - bytes += icp->size + dcp->size; - - int nall = nlocal_bonus + nghost_bonus; - for (int i = 0; i < nall; i++) { - bytes += bonus[i].ninteger * sizeof(int); - bytes += bonus[i].ndouble * sizeof(double); - } - - return bytes; -} - /* ---------------------------------------------------------------------- debug method for sanity checking of own/bonus data pointers ------------------------------------------------------------------------- */ diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 38309648fb..183b4ea8ea 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -42,49 +42,26 @@ class AtomVecBody : public AtomVec { AtomVecBody(class LAMMPS *); ~AtomVecBody(); void process_args(int, char **); - void grow(int); - void grow_reset(); - void copy(int, int, int); - int pack_comm(int, int *, double *, int, int *); - int pack_comm_vel(int, int *, double *, int, int *); - int pack_comm_hybrid(int, int *, double *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_reverse(int, int, double *); - int pack_reverse_hybrid(int, int, double *); - void unpack_reverse(int, int *, double *); - int unpack_reverse_hybrid(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - void unpack_border(int, int, double *); - void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - int pack_exchange(int, double *); - int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void data_vel(int, char **); - int data_vel_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - void pack_vel(double **); - int pack_vel_hybrid(int, double *); - void write_vel(FILE *, int, double **); - int write_vel_hybrid(FILE *, double *); - bigint memory_usage(); - - // manipulate Bonus data structure for extra atom info + void copy_bonus(int, int, int); void clear_bonus(); + int pack_comm_bonus(int, int *, double *); + void unpack_comm_bonus(int, int, double *); + int pack_reverse_bonus(int, int, double *); + int pack_border_bonus(int, int *, double *); + int unpack_border_bonus(int, int, double *); + int pack_exchange_bonus(int, double *); + int unpack_exchange_bonus(int, double *); + int size_restart_bonus(); + int pack_restart_bonus(int, double *); + int unpack_restart_bonus(int, double *); void data_body(int, int, int, int *, double *); + bigint memory_usage_bonus(); + + void create_atom_post(int); + void data_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); // methods used by other classes to query/set body info @@ -94,23 +71,16 @@ class AtomVecBody : public AtomVec { int nlocal_bonus; private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *radius; - double *rmass; - double **angmom,**torque; - int *body; - int nghost_bonus,nmax_bonus; - int intdoubleratio; // sizeof(double) / sizeof(int) + int intdoubleratio; // sizeof(double) / sizeof(int) + int body_flag; MyPoolChunk *icp; MyPoolChunk *dcp; void grow_bonus(); - void copy_bonus(int, int); + void copy_bonus_all(int, int); + // check(int); }; } diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 5565b82a10..7ba26c1c34 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -19,8 +19,6 @@ #include #include "math_extra.h" #include "atom.h" -#include "comm.h" -#include "domain.h" #include "modify.h" #include "fix.h" #include "math_const.h" @@ -36,22 +34,38 @@ using namespace MathConst; AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; + bonus_flag = 1; - comm_x_only = comm_f_only = 0; - size_forward = 7; - size_reverse = 6; - size_border = 15; - size_velocity = 6; - size_data_atom = 7; - size_data_vel = 7; + size_forward_bonus = 4; + size_border_bonus = 8; + size_restart_bonus_one = 7; size_data_bonus = 8; - xcol_data = 5; atom->ellipsoid_flag = 1; atom->rmass_flag = atom->angmom_flag = atom->torque_flag = 1; nlocal_bonus = nghost_bonus = nmax_bonus = 0; bonus = NULL; + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file + + fields_grow = (char *) "rmass angmom torque ellipsoid"; + fields_copy = (char *) "rmass angmom"; + fields_comm = NULL; + fields_comm_vel = (char *) "angmom"; + fields_reverse = (char *) "torque"; + fields_border = (char *) "rmass"; + fields_border_vel = (char *) "rmass angmom"; + fields_exchange = (char *) "rmass angmom"; + fields_restart = (char *) "rmass angmom"; + fields_create = (char *) "rmass angmom ellipsoid"; + fields_data_atom = (char *) "id type ellipsoid rmass x"; + fields_data_vel = (char *) "angmom"; + + setup_fields(); } /* ---------------------------------------------------------------------- */ @@ -61,51 +75,6 @@ AtomVecEllipsoid::~AtomVecEllipsoid() memory->sfree(bonus); } -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR,"Per-processor system is too big"); - - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - rmass = memory->grow(atom->rmass,nmax,"atom:rmass"); - angmom = memory->grow(atom->angmom,nmax,3,"atom:angmom"); - torque = memory->grow(atom->torque,nmax*comm->nthreads,3,"atom:torque"); - ellipsoid = memory->grow(atom->ellipsoid,nmax,"atom:ellipsoid"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - rmass = atom->rmass; angmom = atom->angmom; torque = atom->torque; - ellipsoid = atom->ellipsoid; -} - /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -121,31 +90,17 @@ void AtomVecEllipsoid::grow_bonus() } /* ---------------------------------------------------------------------- - copy atom I info to atom J + copy atom I bonus info to atom J ------------------------------------------------------------------------- */ -void AtomVecEllipsoid::copy(int i, int j, int delflag) +void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag) { - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - rmass[j] = rmass[i]; - angmom[j][0] = angmom[i][0]; - angmom[j][1] = angmom[i][1]; - angmom[j][2] = angmom[i][2]; + int *ellipsoid = atom->ellipsoid; // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && ellipsoid[j] >= 0) { - copy_bonus(nlocal_bonus-1,ellipsoid[j]); + copy_bonus_all(nlocal_bonus-1,ellipsoid[j]); nlocal_bonus--; } @@ -154,10 +109,6 @@ void AtomVecEllipsoid::copy(int i, int j, int delflag) if (ellipsoid[i] >= 0 && i != j) bonus[ellipsoid[i]].ilocal = j; ellipsoid[j] = ellipsoid[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); } /* ---------------------------------------------------------------------- @@ -165,9 +116,9 @@ void AtomVecEllipsoid::copy(int i, int j, int delflag) also reset ellipsoid that points to I to now point to J ------------------------------------------------------------------------- */ -void AtomVecEllipsoid::copy_bonus(int i, int j) +void AtomVecEllipsoid::copy_bonus_all(int i, int j) { - ellipsoid[bonus[i].ilocal] = j; + atom->ellipsoid[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -179,195 +130,21 @@ void AtomVecEllipsoid::copy_bonus(int i, int j) void AtomVecEllipsoid::clear_bonus() { nghost_bonus = 0; -} -/* ---------------------------------------------------------------------- - set shape values in bonus data for particle I - oriented aligned with xyz axes - this may create or delete entry in bonus data -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::set_shape(int i, - double shapex, double shapey, double shapez) -{ - if (ellipsoid[i] < 0) { - if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) return; - if (nlocal_bonus == nmax_bonus) grow_bonus(); - double *shape = bonus[nlocal_bonus].shape; - double *quat = bonus[nlocal_bonus].quat; - shape[0] = shapex; - shape[1] = shapey; - shape[2] = shapez; - quat[0] = 1.0; - quat[1] = 0.0; - quat[2] = 0.0; - quat[3] = 0.0; - bonus[nlocal_bonus].ilocal = i; - ellipsoid[i] = nlocal_bonus++; - } else if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) { - copy_bonus(nlocal_bonus-1,ellipsoid[i]); - nlocal_bonus--; - ellipsoid[i] = -1; - } else { - double *shape = bonus[ellipsoid[i]].shape; - shape[0] = shapex; - shape[1] = shapey; - shape[2] = shapez; - } + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->clear_bonus(); } /* ---------------------------------------------------------------------- */ -int AtomVecEllipsoid::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - double *quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (ellipsoid[j] >= 0) { - quat = bonus[ellipsoid[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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; - if (ellipsoid[j] >= 0) { - quat = bonus[ellipsoid[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - double *quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (ellipsoid[j] >= 0) { - quat = bonus[ellipsoid[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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; - if (ellipsoid[j] >= 0) { - quat = bonus[ellipsoid[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - 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 (ellipsoid[j] >= 0) { - quat = bonus[ellipsoid[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - 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]; - } - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_comm_hybrid(int n, int *list, double *buf) +int AtomVecEllipsoid::pack_comm_bonus(int n, int *list, double *buf) { int i,j,m; double *quat; + int *ellipsoid = atom->ellipsoid; + m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -379,22 +156,22 @@ int AtomVecEllipsoid::pack_comm_hybrid(int n, int *list, double *buf) buf[m++] = quat[3]; } } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf) +void AtomVecEllipsoid::unpack_comm_bonus(int n, int first, double *buf) { int i,m,last; double *quat; + int *ellipsoid = atom->ellipsoid; + m = 0; last = first + n; for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; if (ellipsoid[i] >= 0) { quat = bonus[ellipsoid[i]].quat; quat[0] = buf[m++]; @@ -407,339 +184,17 @@ void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -void AtomVecEllipsoid::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - double *quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - if (ellipsoid[i] >= 0) { - quat = bonus[ellipsoid[i]].quat; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - double *quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (ellipsoid[i] >= 0) { - quat = bonus[ellipsoid[i]].quat; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_reverse_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEllipsoid::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::unpack_reverse_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) +int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf) { int i,j,m; double dx,dy,dz; double *shape,*quat; - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = rmass[j]; - if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - shape = bonus[ellipsoid[j]].shape; - quat = bonus[ellipsoid[j]].quat; - buf[m++] = shape[0]; - buf[m++] = shape[1]; - buf[m++] = shape[2]; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = rmass[j]; - if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - shape = bonus[ellipsoid[j]].shape; - quat = bonus[ellipsoid[j]].quat; - buf[m++] = shape[0]; - buf[m++] = shape[1]; - buf[m++] = shape[2]; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - double *shape,*quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = rmass[j]; - if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - shape = bonus[ellipsoid[j]].shape; - quat = bonus[ellipsoid[j]].quat; - buf[m++] = shape[0]; - buf[m++] = shape[1]; - buf[m++] = shape[2]; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = rmass[j]; - if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - shape = bonus[ellipsoid[j]].shape; - quat = bonus[ellipsoid[j]].quat; - buf[m++] = shape[0]; - buf[m++] = shape[1]; - buf[m++] = shape[2]; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - 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; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = rmass[j]; - if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - shape = bonus[ellipsoid[j]].shape; - quat = bonus[ellipsoid[j]].quat; - buf[m++] = shape[0]; - buf[m++] = shape[1]; - buf[m++] = shape[2]; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - 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]; - } - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_border_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - double *shape,*quat; + int *ellipsoid = atom->ellipsoid; m = 0; for (i = 0; i < n; i++) { j = list[i]; - buf[m++] = rmass[j]; if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -754,27 +209,22 @@ int AtomVecEllipsoid::pack_border_hybrid(int n, int *list, double *buf) buf[m++] = quat[3]; } } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecEllipsoid::unpack_border(int n, int first, double *buf) +int AtomVecEllipsoid::unpack_border_bonus(int n, int first, double *buf) { int i,j,m,last; double *shape,*quat; + int *ellipsoid = atom->ellipsoid; + m = 0; last = first + n; for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - rmass[i] = buf[m++]; ellipsoid[i] = (int) ubuf(buf[m++]).i; if (ellipsoid[i] == 0) ellipsoid[i] = -1; else { @@ -795,92 +245,6 @@ void AtomVecEllipsoid::unpack_border(int n, int first, double *buf) } } - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecEllipsoid::unpack_border_vel(int n, int first, double *buf) -{ - int i,j,m,last; - double *shape,*quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - rmass[i] = buf[m++]; - ellipsoid[i] = (int) ubuf(buf[m++]).i; - if (ellipsoid[i] == 0) ellipsoid[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - shape = bonus[j].shape; - quat = bonus[j].quat; - shape[0] = buf[m++]; - shape[1] = buf[m++]; - shape[2] = buf[m++]; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - bonus[j].ilocal = i; - ellipsoid[i] = j; - nghost_bonus++; - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecEllipsoid::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,j,m,last; - double *shape,*quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - rmass[i] = buf[m++]; - ellipsoid[i] = (int) ubuf(buf[m++]).i; - if (ellipsoid[i] == 0) ellipsoid[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - shape = bonus[j].shape; - quat = bonus[j].quat; - shape[0] = buf[m++]; - shape[1] = buf[m++]; - shape[2] = buf[m++]; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - bonus[j].ilocal = i; - ellipsoid[i] = j; - nghost_bonus++; - } - } return m; } @@ -889,24 +253,11 @@ int AtomVecEllipsoid::unpack_border_hybrid(int n, int first, double *buf) xyz must be 1st 3 values, so comm::exchange() can test on them ------------------------------------------------------------------------- */ -int AtomVecEllipsoid::pack_exchange(int i, double *buf) +int AtomVecEllipsoid::pack_exchange_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; + int m = 0; - buf[m++] = rmass[i]; - buf[m++] = angmom[i][0]; - buf[m++] = angmom[i][1]; - buf[m++] = angmom[i][2]; + int *ellipsoid = atom->ellipsoid; if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; else { @@ -923,40 +274,19 @@ int AtomVecEllipsoid::pack_exchange(int i, double *buf) buf[m++] = quat[3]; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- */ -int AtomVecEllipsoid::unpack_exchange(double *buf) +int AtomVecEllipsoid::unpack_exchange_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; + int *ellipsoid = atom->ellipsoid; - rmass[nlocal] = buf[m++]; - angmom[nlocal][0] = buf[m++]; - angmom[nlocal][1] = buf[m++]; - angmom[nlocal][2] = buf[m++]; - - ellipsoid[nlocal] = (int) ubuf(buf[m++]).i; - if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1; + ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; + if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); double *shape = bonus[nlocal_bonus].shape; @@ -968,16 +298,10 @@ int AtomVecEllipsoid::unpack_exchange(double *buf) quat[1] = buf[m++]; quat[2] = buf[m++]; quat[3] = buf[m++]; - bonus[nlocal_bonus].ilocal = nlocal; - ellipsoid[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + ellipsoid[ilocal] = nlocal_bonus++; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; return m; } @@ -986,20 +310,18 @@ int AtomVecEllipsoid::unpack_exchange(double *buf) include extra data stored by fixes ------------------------------------------------------------------------- */ -int AtomVecEllipsoid::size_restart() +int AtomVecEllipsoid::size_restart_bonus() { int i; + int *ellipsoid = atom->ellipsoid; + int n = 0; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) - if (ellipsoid[i] >= 0) n += 23; - else n += 16; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + for (i = 0; i < nlocal; i++) { + if (ellipsoid[i] >= 0) n += size_restart_bonus_one; + n++; + } return n; } @@ -1010,24 +332,11 @@ int AtomVecEllipsoid::size_restart() molecular types may be negative, but write as positive ------------------------------------------------------------------------- */ -int AtomVecEllipsoid::pack_restart(int i, double *buf) +int AtomVecEllipsoid::pack_restart_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; + int m = 0; - buf[m++] = rmass[i]; - buf[m++] = angmom[i][0]; - buf[m++] = angmom[i][1]; - buf[m++] = angmom[i][2]; + int *ellipsoid = atom->ellipsoid; if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; else { @@ -1042,11 +351,6 @@ int AtomVecEllipsoid::pack_restart(int i, double *buf) buf[m++] = bonus[j].quat[3]; } - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; return m; } @@ -1054,34 +358,14 @@ int AtomVecEllipsoid::pack_restart(int i, double *buf) unpack data for one atom from restart file including bonus data ------------------------------------------------------------------------- */ -int AtomVecEllipsoid::unpack_restart(double *buf) +int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; + int *ellipsoid = atom->ellipsoid; - rmass[nlocal] = buf[m++]; - angmom[nlocal][0] = buf[m++]; - angmom[nlocal][1] = buf[m++]; - angmom[nlocal][2] = buf[m++]; - - ellipsoid[nlocal] = (int) ubuf(buf[m++]).i; - if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1; + ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; + if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); double *shape = bonus[nlocal_bonus].shape; @@ -1093,118 +377,21 @@ int AtomVecEllipsoid::unpack_restart(double *buf) quat[1] = buf[m++]; quat[2] = buf[m++]; quat[3] = buf[m++]; - bonus[nlocal_bonus].ilocal = nlocal; - ellipsoid[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + ellipsoid[ilocal] = nlocal_bonus++; } - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; return m; } -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - rmass[nlocal] = 1.0; - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - ellipsoid[nlocal] = -1; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::data_atom(double *coord, imageint imagetmp, - char **values) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - ellipsoid[nlocal] = utils::inumeric(FLERR,values[2],true,lmp); - if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1; - else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0; - else error->one(FLERR,"Invalid ellipsoidflag in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[3],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecEllipsoid::data_atom_hybrid(int nlocal, char **values) -{ - ellipsoid[nlocal] = utils::inumeric(FLERR,values[0],true,lmp); - if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1; - else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0; - else error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[1],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - return 2; -} - /* ---------------------------------------------------------------------- unpack one line from Ellipsoids section of data file ------------------------------------------------------------------------- */ void AtomVecEllipsoid::data_atom_bonus(int m, char **values) { + int *ellipsoid = atom->ellipsoid; + if (ellipsoid[m]) error->one(FLERR,"Assigning ellipsoid parameters to non-ellipsoid atom"); @@ -1227,184 +414,113 @@ void AtomVecEllipsoid::data_atom_bonus(int m, char **values) // reset ellipsoid mass // previously stored density in rmass - rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; + atom->rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; bonus[nlocal_bonus].ilocal = m; ellipsoid[m] = nlocal_bonus++; } /* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file + return # of bytes of allocated bonus memory ------------------------------------------------------------------------- */ -void AtomVecEllipsoid::data_vel(int m, char **values) -{ - v[m][0] = utils::numeric(FLERR,values[0],true,lmp); - v[m][1] = utils::numeric(FLERR,values[1],true,lmp); - v[m][2] = utils::numeric(FLERR,values[2],true,lmp); - angmom[m][0] = utils::numeric(FLERR,values[3],true,lmp); - angmom[m][1] = utils::numeric(FLERR,values[4],true,lmp); - angmom[m][2] = utils::numeric(FLERR,values[5],true,lmp); -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Velocities section of data file -------------------------------------------------------------------------- */ - -int AtomVecEllipsoid::data_vel_hybrid(int m, char **values) -{ - angmom[m][0] = utils::numeric(FLERR,values[0],true,lmp); - angmom[m][1] = utils::numeric(FLERR,values[1],true,lmp); - angmom[m][2] = utils::numeric(FLERR,values[2],true,lmp); - return 3; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::pack_data(double **buf) -{ - double *shape; - - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(type[i]).d; - if (ellipsoid[i] < 0) buf[i][2] = ubuf(0).d; - else buf[i][2] = ubuf(1).d; - if (ellipsoid[i] < 0) buf[i][3] = rmass[i]; - else { - shape = bonus[ellipsoid[i]].shape; - buf[i][3] = rmass[i] / (4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]); - } - buf[i][4] = x[i][0]; - buf[i][5] = x[i][1]; - buf[i][6] = x[i][2]; - buf[i][7] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][8] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][9] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_data_hybrid(int i, double *buf) -{ - if (ellipsoid[i] < 0) buf[0] = ubuf(0).d; - else buf[0] = ubuf(1).d; - if (ellipsoid[i] < 0) buf[1] = rmass[i]; - else { - double *shape = bonus[ellipsoid[i]].shape; - buf[1] = rmass[i] / (4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]); - } - return 2; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT - " %d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i, - (int) ubuf(buf[i][2]).i, - buf[i][3],buf[i][4],buf[i][5],buf[i][6], - (int) ubuf(buf[i][7]).i,(int) ubuf(buf[i][8]).i, - (int) ubuf(buf[i][9]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecEllipsoid::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %d %-1.16e",(int) ubuf(buf[0]).i,buf[1]); - return 2; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::pack_vel(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = v[i][0]; - buf[i][2] = v[i][1]; - buf[i][3] = v[i][2]; - buf[i][4] = angmom[i][0]; - buf[i][5] = angmom[i][1]; - buf[i][6] = angmom[i][2]; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid velocity info for data file -------------------------------------------------------------------------- */ - -int AtomVecEllipsoid::pack_vel_hybrid(int i, double *buf) -{ - buf[0] = angmom[i][0]; - buf[1] = angmom[i][1]; - buf[2] = angmom[i][2]; - return 3; -} - -/* ---------------------------------------------------------------------- - write velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecEllipsoid::write_vel(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT - " %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e\n", - (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3], - buf[i][4],buf[i][5],buf[i][6]); -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file -------------------------------------------------------------------------- */ - -int AtomVecEllipsoid::write_vel_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2]); - return 3; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecEllipsoid::memory_usage() +bigint AtomVecEllipsoid::memory_usage_bonus() { bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - - if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); - if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3); - if (atom->memcheck("torque")) - bytes += memory->usage(torque,nmax*comm->nthreads,3); - if (atom->memcheck("ellipsoid")) bytes += memory->usage(ellipsoid,nmax); - bytes += nmax_bonus*sizeof(Bonus); - return bytes; } + +/* ---------------------------------------------------------------------- + initialize non-zero atom quantities +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid::create_atom_post(int ilocal) +{ + atom->rmass[ilocal] = 1.0; + atom->ellipsoid[ilocal] = -1; +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid::data_atom_post(int ilocal) +{ + ellipsoid_flag = atom->ellipsoid[ilocal]; + if (ellipsoid_flag == 0) ellipsoid_flag = -1; + else if (ellipsoid_flag == 1) ellipsoid_flag = 0; + else error->one(FLERR,"Invalid ellipsoid flag in Atoms section of data file"); + atom->ellipsoid[ilocal] = ellipsoid_flag; + + if (atom->rmass[ilocal] <= 0.0) + error->one(FLERR,"Invalid density in Atoms section of data file"); +} + +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_data() to pack +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid::pack_data_pre(int ilocal) +{ + double *shape; + + ellipsoid_flag = atom->ellipsoid[ilocal]; + rmass = atom->rmass[ilocal]; + + if (ellipsoid_flag < 0) atom->ellipsoid[ilocal] = 0; + else atom->ellipsoid[ilocal] = 1; + + if (ellipsoid_flag >= 0) { + shape = bonus[ellipsoid_flag].shape; + atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; + } +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_data() +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid::pack_data_post(int ilocal) +{ + atom->ellipsoid[ilocal] = ellipsoid_flag; + atom->rmass[ilocal] = rmass; +} + +/* ---------------------------------------------------------------------- + set shape values in bonus data for particle I + oriented aligned with xyz axes + this may create or delete entry in bonus data +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid:: +set_shape(int i, double shapex, double shapey, double shapez) +{ + int *ellipsoid = atom->ellipsoid; + + if (ellipsoid[i] < 0) { + if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) return; + if (nlocal_bonus == nmax_bonus) grow_bonus(); + double *shape = bonus[nlocal_bonus].shape; + double *quat = bonus[nlocal_bonus].quat; + shape[0] = shapex; + shape[1] = shapey; + shape[2] = shapez; + quat[0] = 1.0; + quat[1] = 0.0; + quat[2] = 0.0; + quat[3] = 0.0; + bonus[nlocal_bonus].ilocal = i; + ellipsoid[i] = nlocal_bonus++; + } else if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) { + copy_bonus_all(nlocal_bonus-1,ellipsoid[i]); + nlocal_bonus--; + ellipsoid[i] = -1; + } else { + double *shape = bonus[ellipsoid[i]].shape; + shape[0] = shapex; + shape[1] = shapey; + shape[2] = shapez; + } +} diff --git a/src/atom_vec_ellipsoid.h b/src/atom_vec_ellipsoid.h index d71859624e..70797c59d5 100644 --- a/src/atom_vec_ellipsoid.h +++ b/src/atom_vec_ellipsoid.h @@ -35,49 +35,26 @@ class AtomVecEllipsoid : public AtomVec { AtomVecEllipsoid(class LAMMPS *); ~AtomVecEllipsoid(); - void grow(int); - void grow_reset(); - void copy(int, int, int); - int pack_comm(int, int *, double *, int, int *); - int pack_comm_vel(int, int *, double *, int, int *); - int pack_comm_hybrid(int, int *, double *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_reverse(int, int, double *); - int pack_reverse_hybrid(int, int, double *); - void unpack_reverse(int, int *, double *); - int unpack_reverse_hybrid(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - void unpack_border(int, int, double *); - void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - int pack_exchange(int, double *); - int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void data_vel(int, char **); - int data_vel_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - void pack_vel(double **); - int pack_vel_hybrid(int, double *); - void write_vel(FILE *, int, double **); - int write_vel_hybrid(FILE *, double *); - bigint memory_usage(); - - // manipulate Bonus data structure for extra atom info + void copy_bonus(int, int, int); void clear_bonus(); + int pack_comm_bonus(int, int *, double *); + void unpack_comm_bonus(int, int, double *); + int pack_reverse_bonus(int, int, double *); + int pack_border_bonus(int, int *, double *); + int unpack_border_bonus(int, int, double *); + int pack_exchange_bonus(int, double *); + int unpack_exchange_bonus(int, double *); + int size_restart_bonus(); + int pack_restart_bonus(int, double *); + int unpack_restart_bonus(int, double *); void data_atom_bonus(int, char **); + bigint memory_usage_bonus(); + + void create_atom_post(int); + void data_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); // unique to AtomVecEllipsoid @@ -86,18 +63,12 @@ class AtomVecEllipsoid : public AtomVec { int nlocal_bonus; private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *rmass; - double **angmom,**torque; - int *ellipsoid; - int nghost_bonus,nmax_bonus; + int ellipsoid_flag; + double rmass; void grow_bonus(); - void copy_bonus(int, int); + void copy_bonus_all(int, int); }; } diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 695ced13fd..3b806c959e 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -15,7 +15,6 @@ #include #include #include "atom.h" -#include "comm.h" #include "domain.h" #include "modify.h" #include "fix.h" @@ -34,16 +33,12 @@ using namespace MathConst; AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; + bonus_flag = 1; - comm_x_only = comm_f_only = 0; - size_forward = 4; - size_reverse = 6; - size_border = 12; - size_velocity = 6; - size_data_atom = 8; - size_data_vel = 7; + size_forward_bonus = 1; + size_border_bonus = 3; + size_restart_bonus_one = 2; size_data_bonus = 5; - xcol_data = 6; atom->line_flag = 1; atom->molecule_flag = atom->rmass_flag = 1; @@ -52,6 +47,26 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) nlocal_bonus = nghost_bonus = nmax_bonus = 0; bonus = NULL; + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file + + fields_grow = (char *) "molecule radius rmass omega torque line"; + fields_copy = (char *) "molecule radius rmass omega"; + fields_comm = NULL; + fields_comm_vel = (char *) "omega"; + fields_reverse = (char *) "torque"; + fields_border = (char *) "molecule radius rmass"; + fields_border_vel = (char *) "molecule radius rmass omega"; + fields_exchange = (char *) "molecule radius rmass omega"; + fields_restart = (char *) "molecule radius rmass omega"; + fields_create = (char *) "molecule radius rmass omega line"; + fields_data_atom = (char *) "id molecule type line rmass x"; + fields_data_vel = (char *) "omega"; + + setup_fields(); } /* ---------------------------------------------------------------------- */ @@ -71,54 +86,6 @@ void AtomVecLine::init() error->all(FLERR,"Atom_style line can only be used in 2d simulations"); } -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecLine::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR,"Per-processor system is too big"); - - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); - rmass = memory->grow(atom->rmass,nmax,"atom:rmass"); - radius = memory->grow(atom->radius,nmax,"atom:radius"); - omega = memory->grow(atom->omega,nmax,3,"atom:omega"); - torque = memory->grow(atom->torque,nmax*comm->nthreads,3,"atom:torque"); - line = memory->grow(atom->line,nmax,"atom:line"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecLine::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - molecule = atom->molecule; rmass = atom->rmass; - radius = atom->radius; omega = atom->omega; torque = atom->torque; - line = atom->line; -} - /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -137,30 +104,14 @@ void AtomVecLine::grow_bonus() copy atom I info to atom J ------------------------------------------------------------------------- */ -void AtomVecLine::copy(int i, int j, int delflag) +void AtomVecLine::copy_bonus(int i, int j, int delflag) { - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - molecule[j] = molecule[i]; - rmass[j] = rmass[i]; - radius[j] = radius[i]; - omega[j][0] = omega[i][0]; - omega[j][1] = omega[i][1]; - omega[j][2] = omega[i][2]; + int *line = atom->line; // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && line[j] >= 0) { - copy_bonus(nlocal_bonus-1,line[j]); + copy_bonus_all(nlocal_bonus-1,line[j]); nlocal_bonus--; } @@ -169,10 +120,6 @@ void AtomVecLine::copy(int i, int j, int delflag) if (line[i] >= 0 && i != j) bonus[line[i]].ilocal = j; line[j] = line[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); } /* ---------------------------------------------------------------------- @@ -180,9 +127,9 @@ void AtomVecLine::copy(int i, int j, int delflag) also reset line that points to I to now point to J ------------------------------------------------------------------------- */ -void AtomVecLine::copy_bonus(int i, int j) +void AtomVecLine::copy_bonus_all(int i, int j) { - line[bonus[i].ilocal] = j; + atom->line[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -200,473 +147,49 @@ void AtomVecLine::clear_bonus() modify->fix[atom->extra_grow[iextra]]->clear_bonus(); } -/* ---------------------------------------------------------------------- - set length value in bonus data for particle I - oriented along x axis - this may create or delete entry in bonus data -------------------------------------------------------------------------- */ - -void AtomVecLine::set_length(int i, double value) -{ - if (line[i] < 0) { - if (value == 0.0) return; - if (nlocal_bonus == nmax_bonus) grow_bonus(); - bonus[nlocal_bonus].length = value; - bonus[nlocal_bonus].theta = 0.0; - bonus[nlocal_bonus].ilocal = i; - line[i] = nlocal_bonus++; - } else if (value == 0.0) { - copy_bonus(nlocal_bonus-1,line[i]); - nlocal_bonus--; - line[i] = -1; - } else bonus[line[i]].length = value; - - // also set radius = half of length - // unless value = 0.0, then set diameter = 1.0 - - radius[i] = 0.5 * value; - if (value == 0.0) radius[i] = 0.5; -} - /* ---------------------------------------------------------------------- */ -int AtomVecLine::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) +int AtomVecLine::pack_comm_bonus(int n, int *list, double *buf) { int i,j,m; - double dx,dy,dz; - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (line[j] >= 0) buf[m++] = bonus[line[j]].theta; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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; - if (line[j] >= 0) buf[m++] = bonus[line[j]].theta; - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (line[j] >= 0) buf[m++] = bonus[line[j]].theta; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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; - if (line[j] >= 0) buf[m++] = bonus[line[j]].theta; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[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 (line[j] >= 0) buf[m++] = bonus[line[j]].theta; - 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]; - } - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_comm_hybrid(int n, int *list, double *buf) -{ - int i,j,m; + int *line = atom->line; m = 0; for (i = 0; i < n; i++) { j = list[i]; if (line[j] >= 0) buf[m++] = bonus[line[j]].theta; } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecLine::unpack_comm(int n, int first, double *buf) +void AtomVecLine::unpack_comm_bonus(int n, int first, double *buf) { int i,m,last; + int *line = atom->line; + m = 0; last = first + n; for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; if (line[i] >= 0) bonus[line[i]].theta = buf[m++]; } } /* ---------------------------------------------------------------------- */ -void AtomVecLine::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - if (line[i] >= 0) bonus[line[i]].theta = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - if (line[i] >= 0) bonus[line[i]].theta = buf[m++]; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_reverse_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecLine::unpack_reverse(int n, int *list, double *buf) +int AtomVecLine::pack_border_bonus(int n, int *list, double *buf) { int i,j,m; + int *line = atom->line; + m = 0; for (i = 0; i < n; i++) { j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::unpack_reverse_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (line[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - buf[m++] = bonus[line[j]].length; - buf[m++] = bonus[line[j]].theta; - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (line[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - buf[m++] = bonus[line[j]].length; - buf[m++] = bonus[line[j]].theta; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (line[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - buf[m++] = bonus[line[j]].length; - buf[m++] = bonus[line[j]].theta; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (line[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - buf[m++] = bonus[line[j]].length; - buf[m++] = bonus[line[j]].theta; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (line[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - buf[m++] = bonus[line[j]].length; - buf[m++] = bonus[line[j]].theta; - } - 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]; - } - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::pack_border_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; if (line[j] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -674,28 +197,21 @@ int AtomVecLine::pack_border_hybrid(int n, int *list, double *buf) buf[m++] = bonus[line[j]].theta; } } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecLine::unpack_border(int n, int first, double *buf) +int AtomVecLine::unpack_border_bonus(int n, int first, double *buf) { int i,j,m,last; + int *line = atom->line; + m = 0; last = first + n; for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - molecule[i] = (tagint) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; line[i] = (int) ubuf(buf[m++]).i; if (line[i] == 0) line[i] = -1; else { @@ -709,80 +225,6 @@ void AtomVecLine::unpack_border(int n, int first, double *buf) } } - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecLine::unpack_border_vel(int n, int first, double *buf) -{ - int i,j,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - molecule[i] = (tagint) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - line[i] = (int) ubuf(buf[m++]).i; - if (line[i] == 0) line[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - bonus[j].length = buf[m++]; - bonus[j].theta = buf[m++]; - bonus[j].ilocal = i; - line[i] = j; - nghost_bonus++; - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecLine::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,j,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - molecule[i] = (tagint) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - line[i] = (int) ubuf(buf[m++]).i; - if (line[i] == 0) line[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - bonus[j].length = buf[m++]; - bonus[j].theta = buf[m++]; - bonus[j].ilocal = i; - line[i] = j; - nghost_bonus++; - } - } return m; } @@ -791,26 +233,11 @@ int AtomVecLine::unpack_border_hybrid(int n, int first, double *buf) xyz must be 1st 3 values, so comm::exchange() can test on them ------------------------------------------------------------------------- */ -int AtomVecLine::pack_exchange(int i, double *buf) +int AtomVecLine::pack_exchange_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; + int m = 0; - buf[m++] = ubuf(molecule[i]).d; - buf[m++] = rmass[i]; - buf[m++] = radius[i]; - buf[m++] = omega[i][0]; - buf[m++] = omega[i][1]; - buf[m++] = omega[i][2]; + int *line = atom->line; if (line[i] < 0) buf[m++] = ubuf(0).d; else { @@ -820,56 +247,27 @@ int AtomVecLine::pack_exchange(int i, double *buf) buf[m++] = bonus[j].theta; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- */ -int AtomVecLine::unpack_exchange(double *buf) +int AtomVecLine::unpack_exchange_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; + int *line = atom->line; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - rmass[nlocal] = buf[m++]; - radius[nlocal] = buf[m++]; - omega[nlocal][0] = buf[m++]; - omega[nlocal][1] = buf[m++]; - omega[nlocal][2] = buf[m++]; - - line[nlocal] = (int) ubuf(buf[m++]).i; - if (line[nlocal] == 0) line[nlocal] = -1; + line[ilocal] = (int) ubuf(buf[m++]).i; + if (line[ilocal] == 0) line[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); bonus[nlocal_bonus].length = buf[m++]; bonus[nlocal_bonus].theta = buf[m++]; - bonus[nlocal_bonus].ilocal = nlocal; - line[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + line[ilocal] = nlocal_bonus++; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; return m; } @@ -878,20 +276,18 @@ int AtomVecLine::unpack_exchange(double *buf) include extra data stored by fixes ------------------------------------------------------------------------- */ -int AtomVecLine::size_restart() +int AtomVecLine::size_restart_bonus() { int i; + int *line = atom->line; + int n = 0; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) - if (line[i] >= 0) n += 20; - else n += 18; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + for (i = 0; i < nlocal; i++) { + if (line[i] >= 0) n += size_restart_bonus_one; + n++; + } return n; } @@ -902,26 +298,11 @@ int AtomVecLine::size_restart() molecular types may be negative, but write as positive ------------------------------------------------------------------------- */ -int AtomVecLine::pack_restart(int i, double *buf) +int AtomVecLine::pack_restart_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; + int m = 0; - buf[m++] = ubuf(molecule[i]).d; - buf[m++] = rmass[i]; - buf[m++] = radius[i]; - buf[m++] = omega[i][0]; - buf[m++] = omega[i][1]; - buf[m++] = omega[i][2]; + int *line = atom->line; if (line[i] < 0) buf[m++] = ubuf(0).d; else { @@ -931,180 +312,40 @@ int AtomVecLine::pack_restart(int i, double *buf) buf[m++] = bonus[j].theta; } - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities + unpack data for one atom from restart file including bonus data ------------------------------------------------------------------------- */ -int AtomVecLine::unpack_restart(double *buf) +int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; + int *line = atom->line; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - rmass[nlocal] = buf[m++]; - radius[nlocal] = buf[m++]; - omega[nlocal][0] = buf[m++]; - omega[nlocal][1] = buf[m++]; - omega[nlocal][2] = buf[m++]; - - line[nlocal] = (int) ubuf(buf[m++]).i; - if (line[nlocal] == 0) line[nlocal] = -1; + line[ilocal] = (int) ubuf(buf[m++]).i; + if (line[ilocal] == 0) line[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); bonus[nlocal_bonus].length = buf[m++]; bonus[nlocal_bonus].theta = buf[m++]; - bonus[nlocal_bonus].ilocal = nlocal; - line[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + line[ilocal] = nlocal_bonus++; } - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; return m; } -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecLine::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - molecule[nlocal] = 0; - radius[nlocal] = 0.5; - rmass[nlocal] = 4.0*MY_PI/3.0 * radius[nlocal]*radius[nlocal]*radius[nlocal]; - omega[nlocal][0] = 0.0; - omega[nlocal][1] = 0.0; - omega[nlocal][2] = 0.0; - line[nlocal] = -1; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecLine::data_atom(double *coord, imageint imagetmp, char **values) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - molecule[nlocal] = utils::tnumeric(FLERR,values[1],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[2],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - line[nlocal] = utils::inumeric(FLERR,values[3],true,lmp); - if (line[nlocal] == 0) line[nlocal] = -1; - else if (line[nlocal] == 1) line[nlocal] = 0; - else error->one(FLERR,"Invalid lineflag in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[4],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - if (line[nlocal] < 0) { - radius[nlocal] = 0.5; - rmass[nlocal] *= 4.0*MY_PI/3.0 * - radius[nlocal]*radius[nlocal]*radius[nlocal]; - } else radius[nlocal] = 0.0; - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - omega[nlocal][0] = 0.0; - omega[nlocal][1] = 0.0; - omega[nlocal][2] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecLine::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - - line[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (line[nlocal] == 0) line[nlocal] = -1; - else if (line[nlocal] == 1) line[nlocal] = 0; - else error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - if (line[nlocal] < 0) { - radius[nlocal] = 0.5; - rmass[nlocal] *= 4.0*MY_PI/3.0 * - radius[nlocal]*radius[nlocal]*radius[nlocal]; - } else radius[nlocal] = 0.0; - - return 3; -} - /* ---------------------------------------------------------------------- unpack one line from Lines section of data file ------------------------------------------------------------------------- */ void AtomVecLine::data_atom_bonus(int m, char **values) { + int *line = atom->line; + if (line[m]) error->one(FLERR,"Assigning line parameters to non-line atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -1136,188 +377,122 @@ void AtomVecLine::data_atom_bonus(int m, char **values) // reset line radius and mass // rmass currently holds density - radius[m] = 0.5 * length; - rmass[m] *= length; + atom->radius[m] = 0.5 * length; + atom->rmass[m] *= length; bonus[nlocal_bonus].ilocal = m; line[m] = nlocal_bonus++; } /* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file + return # of bytes of allocated bonus memory ------------------------------------------------------------------------- */ -void AtomVecLine::data_vel(int m, char **values) -{ - v[m][0] = utils::numeric(FLERR,values[0],true,lmp); - v[m][1] = utils::numeric(FLERR,values[1],true,lmp); - v[m][2] = utils::numeric(FLERR,values[2],true,lmp); - omega[m][0] = utils::numeric(FLERR,values[3],true,lmp); - omega[m][1] = utils::numeric(FLERR,values[4],true,lmp); - omega[m][2] = utils::numeric(FLERR,values[5],true,lmp); -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Velocities section of data file -------------------------------------------------------------------------- */ - -int AtomVecLine::data_vel_hybrid(int m, char **values) -{ - omega[m][0] = utils::numeric(FLERR,values[0],true,lmp); - omega[m][1] = utils::numeric(FLERR,values[1],true,lmp); - omega[m][2] = utils::numeric(FLERR,values[2],true,lmp); - return 3; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecLine::pack_data(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(molecule[i]).d; - buf[i][2] = ubuf(type[i]).d; - if (line[i] < 0) buf[i][3] = ubuf(0).d; - else buf[i][3] = ubuf(1).d; - if (line[i] < 0) - buf[i][4] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[i]); - else buf[i][4] = rmass[i]/bonus[line[i]].length; - buf[i][5] = x[i][0]; - buf[i][6] = x[i][1]; - buf[i][7] = x[i][2]; - buf[i][8] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][9] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][10] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecLine::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - if (line[i] < 0) buf[1] = ubuf(0).d; - else buf[1] = ubuf(1).d; - if (line[i] < 0) - buf[2] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[i]); - else buf[2] = rmass[i]/bonus[line[i]].length; - return 3; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecLine::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i, - (int) ubuf(buf[i][2]).i,(int) ubuf(buf[i][3]).i, - buf[i][4],buf[i][5],buf[i][6],buf[i][7], - (int) ubuf(buf[i][8]).i,(int) ubuf(buf[i][9]).i, - (int) ubuf(buf[i][10]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecLine::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT " %d %-1.16e", - (tagint) ubuf(buf[0]).i,(int) ubuf(buf[1]).i,buf[2]); - return 3; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecLine::pack_vel(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = v[i][0]; - buf[i][2] = v[i][1]; - buf[i][3] = v[i][2]; - buf[i][4] = omega[i][0]; - buf[i][5] = omega[i][1]; - buf[i][6] = omega[i][2]; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid velocity info for data file -------------------------------------------------------------------------- */ - -int AtomVecLine::pack_vel_hybrid(int i, double *buf) -{ - buf[0] = omega[i][0]; - buf[1] = omega[i][1]; - buf[2] = omega[i][2]; - return 3; -} - -/* ---------------------------------------------------------------------- - write velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecLine::write_vel(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT - " %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e\n", - (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3], - buf[i][4],buf[i][5],buf[i][6]); -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file -------------------------------------------------------------------------- */ - -int AtomVecLine::write_vel_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2]); - return 3; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecLine::memory_usage() +bigint AtomVecLine::memory_usage_bonus() { bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - - if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); - if (atom->memcheck("radius")) bytes += memory->usage(radius,nmax); - if (atom->memcheck("omega")) bytes += memory->usage(omega,nmax,3); - if (atom->memcheck("torque")) - bytes += memory->usage(torque,nmax*comm->nthreads,3); - if (atom->memcheck("line")) bytes += memory->usage(line,nmax); - bytes += nmax_bonus*sizeof(Bonus); - return bytes; } +/* ---------------------------------------------------------------------- + create one atom of itype at coord + set other values to defaults +------------------------------------------------------------------------- */ + +void AtomVecLine::create_atom_post(int ilocal) +{ + double radius = 0.5; + atom->radius[ilocal] = radius; + atom->rmass[ilocal] = 4.0*MY_PI/3.0 * radius*radius*radius; + atom->line[ilocal] = -1; +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecLine::data_atom_post(int ilocal) +{ + line_flag = atom->line[ilocal]; + if (line_flag == 0) line_flag = -1; + else if (line_flag == 1) line_flag = 0; + else error->one(FLERR,"Invalid line flag in Atoms section of data file"); + atom->line[ilocal] = line_flag; + + if (atom->rmass[ilocal] <= 0.0) + error->one(FLERR,"Invalid density in Atoms section of data file"); + + if (line_flag < 0) { + double radius = 0.5; + atom->radius[ilocal] = radius; + atom->rmass[ilocal] *= 4.0*MY_PI/3.0 * radius*radius*radius; + } else atom->radius[ilocal] = 0.0; + + atom->omega[ilocal][0] = 0.0; + atom->omega[ilocal][1] = 0.0; + atom->omega[ilocal][2] = 0.0; +} + +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_data() to pack +------------------------------------------------------------------------- */ + +void AtomVecLine::pack_data_pre(int ilocal) +{ + line_flag = atom->line[ilocal]; + rmass = atom->rmass[ilocal]; + + if (line_flag < 0) atom->line[ilocal] = 0; + else atom->line[ilocal] = 1; + + if (line_flag < 0) { + double radius = atom->radius[ilocal]; + atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * radius*radius*radius; + } else atom->rmass[ilocal] /= bonus[line_flag].length; +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_data() +------------------------------------------------------------------------- */ + +void AtomVecLine::pack_data_post(int ilocal) +{ + atom->line[ilocal] = line_flag; + atom->rmass[ilocal] = rmass; +} + +/* ---------------------------------------------------------------------- + set length value in bonus data for particle I + oriented along x axis + this may create or delete entry in bonus data +------------------------------------------------------------------------- */ + +void AtomVecLine::set_length(int i, double value) +{ + int *line = atom->line; + + if (line[i] < 0) { + if (value == 0.0) return; + if (nlocal_bonus == nmax_bonus) grow_bonus(); + bonus[nlocal_bonus].length = value; + bonus[nlocal_bonus].theta = 0.0; + bonus[nlocal_bonus].ilocal = i; + line[i] = nlocal_bonus++; + } else if (value == 0.0) { + copy_bonus_all(nlocal_bonus-1,line[i]); + nlocal_bonus--; + line[i] = -1; + } else bonus[line[i]].length = value; + + // also set radius = half of length + // unless value = 0.0, then set diameter = 1.0 + + atom->radius[i] = 0.5 * value; + if (value == 0.0) atom->radius[i] = 0.5; +} + /* ---------------------------------------------------------------------- check consistency of internal Bonus data structure n = # of atoms in regular structure to check against diff --git a/src/atom_vec_line.h b/src/atom_vec_line.h index 6c8701cfc2..a8bc8fd1bc 100644 --- a/src/atom_vec_line.h +++ b/src/atom_vec_line.h @@ -35,49 +35,26 @@ class AtomVecLine : public AtomVec { AtomVecLine(class LAMMPS *); ~AtomVecLine(); void init(); - void grow(int); - void grow_reset(); - void copy(int, int, int); - int pack_comm(int, int *, double *, int, int *); - int pack_comm_vel(int, int *, double *, int, int *); - int pack_comm_hybrid(int, int *, double *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_reverse(int, int, double *); - int pack_reverse_hybrid(int, int, double *); - void unpack_reverse(int, int *, double *); - int unpack_reverse_hybrid(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - void unpack_border(int, int, double *); - void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - int pack_exchange(int, double *); - int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void data_vel(int, char **); - int data_vel_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - void pack_vel(double **); - int pack_vel_hybrid(int, double *); - void write_vel(FILE *, int, double **); - int write_vel_hybrid(FILE *, double *); - bigint memory_usage(); - - // manipulate Bonus data structure for extra atom info + void copy_bonus(int, int, int); void clear_bonus(); + int pack_comm_bonus(int, int *, double *); + void unpack_comm_bonus(int, int, double *); + int pack_reverse_bonus(int, int, double *); + int pack_border_bonus(int, int *, double *); + int unpack_border_bonus(int, int, double *); + int pack_exchange_bonus(int, double *); + int unpack_exchange_bonus(int, double *); + int size_restart_bonus(); + int pack_restart_bonus(int, double *); + int unpack_restart_bonus(int, double *); void data_atom_bonus(int, char **); + bigint memory_usage_bonus(); + + void create_atom_post(int); + void data_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); // unique to AtomVecLine @@ -86,19 +63,12 @@ class AtomVecLine : public AtomVec { int nlocal_bonus; private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - tagint *molecule; - double *rmass,*radius; - double **omega,**torque; - int *line; - int nghost_bonus,nmax_bonus; + int line_flag; + double rmass; void grow_bonus(); - void copy_bonus(int, int); + void copy_bonus_all(int, int); // void consistency_check(int, char *); }; diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index b44aa69035..5ae4c0ca21 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -94,7 +94,7 @@ void AtomVecSphere::init() } /* ---------------------------------------------------------------------- - initialize other atom quantities + initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecSphere::create_atom_post(int ilocal) @@ -117,7 +117,7 @@ void AtomVecSphere::data_atom_post(int ilocal) 4.0*MY_PI/3.0 * radius*radius*radius * atom->rmass[ilocal]; if (atom->rmass[ilocal] <= 0.0) - error->one(FLERR,"Invalid mass in Atoms section of data file"); + error->one(FLERR,"Invalid density in Atoms section of data file"); } /* ---------------------------------------------------------------------- diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 3b7bfe5377..6da0ef7015 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -16,7 +16,6 @@ #include #include "math_extra.h" #include "atom.h" -#include "comm.h" #include "domain.h" #include "modify.h" #include "fix.h" @@ -35,16 +34,12 @@ using namespace MathConst; AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; + bonus_flag = 1; - comm_x_only = comm_f_only = 0; - size_forward = 7; - size_reverse = 6; - size_border = 26; - size_velocity = 9; - size_data_atom = 8; - size_data_vel = 7; + size_forward_bonus = 4; + size_border_bonus = 17; + size_restart_bonus_one = 16; size_data_bonus = 10; - xcol_data = 6; atom->tri_flag = 1; atom->molecule_flag = atom->rmass_flag = 1; @@ -55,8 +50,25 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) nlocal_bonus = nghost_bonus = nmax_bonus = 0; bonus = NULL; - if (domain->dimension != 3) - error->all(FLERR,"Atom_style tri can only be used in 3d simulations"); + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in the string does not matter + // except fields_data_atom and fields_data_vel which must match data file + + fields_grow = (char *) "molecule radius rmass omega angmom torque tri"; + fields_copy = (char *) "molecule radius rmass omega angmom"; + fields_comm = NULL; + fields_comm_vel = (char *) "omega angmom"; + fields_reverse = (char *) "torque"; + fields_border = (char *) "molecule radius rmass"; + fields_border_vel = (char *) "molecule radius rmass omega"; + fields_exchange = (char *) "molecule radius rmass omega angmom"; + fields_restart = (char *) "molecule radius rmass omega angmom"; + fields_create = (char *) "molecule radius rmass omega angmom line"; + fields_data_atom = (char *) "id molecule type tri rmass x"; + fields_data_vel = (char *) "omega angmom"; + + setup_fields(); } /* ---------------------------------------------------------------------- */ @@ -76,56 +88,6 @@ void AtomVecTri::init() error->all(FLERR,"Atom_style tri can only be used in 3d simulations"); } -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecTri::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR,"Per-processor system is too big"); - - tag = memory->grow(atom->tag,nmax,"atom:tag"); - type = memory->grow(atom->type,nmax,"atom:type"); - mask = memory->grow(atom->mask,nmax,"atom:mask"); - image = memory->grow(atom->image,nmax,"atom:image"); - x = memory->grow(atom->x,nmax,3,"atom:x"); - v = memory->grow(atom->v,nmax,3,"atom:v"); - f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); - - molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); - rmass = memory->grow(atom->rmass,nmax,"atom:rmass"); - radius = memory->grow(atom->radius,nmax,"atom:radius"); - omega = memory->grow(atom->omega,nmax,3,"atom:omega"); - angmom = memory->grow(atom->angmom,nmax,3,"atom:angmom"); - torque = memory->grow(atom->torque,nmax*comm->nthreads,3,"atom:torque"); - tri = memory->grow(atom->tri,nmax,"atom:tri"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); -} - -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVecTri::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - molecule = atom->molecule; rmass = atom->rmass; - radius = atom->radius; omega = atom->omega; - angmom = atom->angmom; torque = atom->torque; - tri = atom->tri; -} - /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -145,33 +107,14 @@ void AtomVecTri::grow_bonus() if delflag and atom J has bonus data, then delete it ------------------------------------------------------------------------- */ -void AtomVecTri::copy(int i, int j, int delflag) +void AtomVecTri::copy_bonus(int i, int j, int delflag) { - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - molecule[j] = molecule[i]; - rmass[j] = rmass[i]; - radius[j] = radius[i]; - omega[j][0] = omega[i][0]; - omega[j][1] = omega[i][1]; - omega[j][2] = omega[i][2]; - angmom[j][0] = angmom[i][0]; - angmom[j][1] = angmom[i][1]; - angmom[j][2] = angmom[i][2]; + int *tri = atom->tri; // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && tri[j] >= 0) { - copy_bonus(nlocal_bonus-1,tri[j]); + copy_bonus_all(nlocal_bonus-1,tri[j]); nlocal_bonus--; } @@ -180,10 +123,6 @@ void AtomVecTri::copy(int i, int j, int delflag) if (tri[i] >= 0 && i != j) bonus[tri[i]].ilocal = j; tri[j] = tri[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); } /* ---------------------------------------------------------------------- @@ -191,9 +130,9 @@ void AtomVecTri::copy(int i, int j, int delflag) also reset tri that points to I to now point to J ------------------------------------------------------------------------- */ -void AtomVecTri::copy_bonus(int i, int j) +void AtomVecTri::copy_bonus_all(int i, int j) { - tri[bonus[i].ilocal] = j; + atom->tri[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -211,233 +150,15 @@ void AtomVecTri::clear_bonus() modify->fix[atom->extra_grow[iextra]]->clear_bonus(); } -/* ---------------------------------------------------------------------- - set equilateral tri of size in bonus data for particle I - oriented symmetrically in xy plane - this may create or delete entry in bonus data -------------------------------------------------------------------------- */ - -void AtomVecTri::set_equilateral(int i, double size) -{ - // also set radius = distance from center to corner-pt = len(c1) - // unless size = 0.0, then set diameter = 1.0 - - if (tri[i] < 0) { - if (size == 0.0) return; - if (nlocal_bonus == nmax_bonus) grow_bonus(); - double *quat = bonus[nlocal_bonus].quat; - double *c1 = bonus[nlocal_bonus].c1; - double *c2 = bonus[nlocal_bonus].c2; - double *c3 = bonus[nlocal_bonus].c3; - double *inertia = bonus[nlocal_bonus].inertia; - quat[0] = 1.0; - quat[1] = 0.0; - quat[2] = 0.0; - quat[3] = 0.0; - c1[0] = -size/2.0; - c1[1] = -sqrt(3.0)/2.0 * size / 3.0; - c1[2] = 0.0; - c2[0] = size/2.0; - c2[1] = -sqrt(3.0)/2.0 * size / 3.0; - c2[2] = 0.0; - c3[0] = 0.0; - c3[1] = sqrt(3.0)/2.0 * size * 2.0/3.0; - c3[2] = 0.0; - inertia[0] = sqrt(3.0)/96.0 * size*size*size*size; - inertia[1] = sqrt(3.0)/96.0 * size*size*size*size; - inertia[2] = sqrt(3.0)/48.0 * size*size*size*size; - radius[i] = MathExtra::len3(c1); - bonus[nlocal_bonus].ilocal = i; - tri[i] = nlocal_bonus++; - } else if (size == 0.0) { - radius[i] = 0.5; - copy_bonus(nlocal_bonus-1,tri[i]); - nlocal_bonus--; - tri[i] = -1; - } else { - double *c1 = bonus[tri[i]].c1; - double *c2 = bonus[tri[i]].c2; - double *c3 = bonus[tri[i]].c3; - double *inertia = bonus[tri[i]].inertia; - c1[0] = -size/2.0; - c1[1] = -sqrt(3.0)/2.0 * size / 3.0; - c1[2] = 0.0; - c2[0] = size/2.0; - c2[1] = -sqrt(3.0)/2.0 * size / 3.0; - c2[2] = 0.0; - c3[0] = 0.0; - c3[1] = sqrt(3.0)/2.0 * size * 2.0/3.0; - c3[2] = 0.0; - inertia[0] = sqrt(3.0)/96.0 * size*size*size*size; - inertia[1] = sqrt(3.0)/96.0 * size*size*size*size; - inertia[2] = sqrt(3.0)/48.0 * size*size*size*size; - radius[i] = MathExtra::len3(c1); - } -} - /* ---------------------------------------------------------------------- */ -int AtomVecTri::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - double *quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (tri[j] >= 0) { - quat = bonus[tri[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - 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; - if (tri[j] >= 0) { - quat = bonus[tri[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - double *quat; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - if (tri[j] >= 0) { - quat = bonus[tri[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; - dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; - dz = pbc[2]*domain->zprd; - } - 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; - if (tri[j] >= 0) { - quat = bonus[tri[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - 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 (tri[j] >= 0) { - quat = bonus[tri[j]].quat; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - } - 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]; - } - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_comm_hybrid(int n, int *list, double *buf) +int AtomVecTri::pack_comm_bonus(int n, int *list, double *buf) { int i,j,m; double *quat; + int *tri = atom->tri; + m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -449,22 +170,22 @@ int AtomVecTri::pack_comm_hybrid(int n, int *list, double *buf) buf[m++] = quat[3]; } } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecTri::unpack_comm(int n, int first, double *buf) +void AtomVecTri::unpack_comm_bonus(int n, int first, double *buf) { int i,m,last; double *quat; + int *tri = atom->tri; + m = 0; last = first + n; for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; if (tri[i] >= 0) { quat = bonus[tri[i]].quat; quat[0] = buf[m++]; @@ -477,422 +198,16 @@ void AtomVecTri::unpack_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -void AtomVecTri::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - double *quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - if (tri[i] >= 0) { - quat = bonus[tri[i]].quat; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - double *quat; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - if (tri[i] >= 0) { - quat = bonus[tri[i]].quat; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_reverse_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = torque[i][0]; - buf[m++] = torque[i][1]; - buf[m++] = torque[i][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTri::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::unpack_reverse_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - torque[j][0] += buf[m++]; - torque[j][1] += buf[m++]; - torque[j][2] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - double *quat,*c1,*c2,*c3,*inertia; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (tri[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[tri[j]].quat; - c1 = bonus[tri[j]].c1; - c2 = bonus[tri[j]].c2; - c3 = bonus[tri[j]].c3; - inertia = bonus[tri[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = c1[0]; - buf[m++] = c1[1]; - buf[m++] = c1[2]; - buf[m++] = c2[0]; - buf[m++] = c2[1]; - buf[m++] = c2[2]; - buf[m++] = c3[0]; - buf[m++] = c3[1]; - buf[m++] = c3[2]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - } - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - 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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (tri[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[tri[j]].quat; - c1 = bonus[tri[j]].c1; - c2 = bonus[tri[j]].c2; - c3 = bonus[tri[j]].c3; - inertia = bonus[tri[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = c1[0]; - buf[m++] = c1[1]; - buf[m++] = c1[2]; - buf[m++] = c2[0]; - buf[m++] = c2[1]; - buf[m++] = c2[2]; - buf[m++] = c3[0]; - buf[m++] = c3[1]; - buf[m++] = c3[2]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz,dvx,dvy,dvz; - double *quat,*c1,*c2,*c3,*inertia; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (tri[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[tri[j]].quat; - c1 = bonus[tri[j]].c1; - c2 = bonus[tri[j]].c2; - c3 = bonus[tri[j]].c3; - inertia = bonus[tri[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = c1[0]; - buf[m++] = c1[1]; - buf[m++] = c1[2]; - buf[m++] = c2[0]; - buf[m++] = c2[1]; - buf[m++] = c2[2]; - buf[m++] = c3[0]; - buf[m++] = c3[1]; - buf[m++] = c3[2]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0]*domain->xprd; - dy = pbc[1]*domain->yprd; - dz = pbc[2]*domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[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++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (tri[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[tri[j]].quat; - c1 = bonus[tri[j]].c1; - c2 = bonus[tri[j]].c2; - c3 = bonus[tri[j]].c3; - inertia = bonus[tri[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = c1[0]; - buf[m++] = c1[1]; - buf[m++] = c1[2]; - buf[m++] = c2[0]; - buf[m++] = c2[1]; - buf[m++] = c2[2]; - buf[m++] = c3[0]; - buf[m++] = c3[1]; - buf[m++] = c3[2]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - } - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - 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; - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - if (tri[j] < 0) buf[m++] = ubuf(0).d; - else { - buf[m++] = ubuf(1).d; - quat = bonus[tri[j]].quat; - c1 = bonus[tri[j]].c1; - c2 = bonus[tri[j]].c2; - c3 = bonus[tri[j]].c3; - inertia = bonus[tri[j]].inertia; - buf[m++] = quat[0]; - buf[m++] = quat[1]; - buf[m++] = quat[2]; - buf[m++] = quat[3]; - buf[m++] = c1[0]; - buf[m++] = c1[1]; - buf[m++] = c1[2]; - buf[m++] = c2[0]; - buf[m++] = c2[1]; - buf[m++] = c2[2]; - buf[m++] = c3[0]; - buf[m++] = c3[1]; - buf[m++] = c3[2]; - buf[m++] = inertia[0]; - buf[m++] = inertia[1]; - buf[m++] = inertia[2]; - } - 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]; - } - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::pack_border_hybrid(int n, int *list, double *buf) +int AtomVecTri::pack_border_bonus(int n, int *list, double *buf) { int i,j,m; double *quat,*c1,*c2,*c3,*inertia; + int *tri = atom->tri; + m = 0; for (i = 0; i < n; i++) { j = list[i]; - buf[m++] = ubuf(molecule[j]).d; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; if (tri[j] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -919,29 +234,22 @@ int AtomVecTri::pack_border_hybrid(int n, int *list, double *buf) buf[m++] = inertia[2]; } } + return m; } /* ---------------------------------------------------------------------- */ -void AtomVecTri::unpack_border(int n, int first, double *buf) +int AtomVecTri::unpack_border_bonus(int n, int first, double *buf) { int i,j,m,last; double *quat,*c1,*c2,*c3,*inertia; + int *tri = atom->tri; + m = 0; last = first + n; for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - molecule[i] = (tagint) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; tri[i] = (int) ubuf(buf[m++]).i; if (tri[i] == 0) tri[i] = -1; else { @@ -974,123 +282,6 @@ void AtomVecTri::unpack_border(int n, int first, double *buf) } } - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTri::unpack_border_vel(int n, int first, double *buf) -{ - int i,j,m,last; - double *quat,*c1,*c2,*c3,*inertia; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - molecule[i] = (tagint) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - tri[i] = (int) ubuf(buf[m++]).i; - if (tri[i] == 0) tri[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - quat = bonus[j].quat; - c1 = bonus[j].c1; - c2 = bonus[j].c2; - c3 = bonus[j].c3; - inertia = bonus[j].inertia; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - c1[0] = buf[m++]; - c1[1] = buf[m++]; - c1[2] = buf[m++]; - c2[0] = buf[m++]; - c2[1] = buf[m++]; - c2[2] = buf[m++]; - c3[0] = buf[m++]; - c3[1] = buf[m++]; - c3[2] = buf[m++]; - inertia[0] = buf[m++]; - inertia[1] = buf[m++]; - inertia[2] = buf[m++]; - bonus[j].ilocal = i; - tri[i] = j; - nghost_bonus++; - } - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]-> - unpack_border(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTri::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,j,m,last; - double *quat,*c1,*c2,*c3,*inertia; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - molecule[i] = (tagint) ubuf(buf[m++]).i; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - tri[i] = (int) ubuf(buf[m++]).i; - if (tri[i] == 0) tri[i] = -1; - else { - j = nlocal_bonus + nghost_bonus; - if (j == nmax_bonus) grow_bonus(); - quat = bonus[j].quat; - c1 = bonus[j].c1; - c2 = bonus[j].c2; - c3 = bonus[j].c3; - inertia = bonus[j].inertia; - quat[0] = buf[m++]; - quat[1] = buf[m++]; - quat[2] = buf[m++]; - quat[3] = buf[m++]; - c1[0] = buf[m++]; - c1[1] = buf[m++]; - c1[2] = buf[m++]; - c2[0] = buf[m++]; - c2[1] = buf[m++]; - c2[2] = buf[m++]; - c3[0] = buf[m++]; - c3[1] = buf[m++]; - c3[2] = buf[m++]; - inertia[0] = buf[m++]; - inertia[1] = buf[m++]; - inertia[2] = buf[m++]; - bonus[j].ilocal = i; - tri[i] = j; - nghost_bonus++; - } - } return m; } @@ -1099,29 +290,11 @@ int AtomVecTri::unpack_border_hybrid(int n, int first, double *buf) xyz must be 1st 3 values, so comm::exchange() can test on them ------------------------------------------------------------------------- */ -int AtomVecTri::pack_exchange(int i, double *buf) +int AtomVecTri::pack_exchange_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; + int m = 0; - buf[m++] = ubuf(molecule[i]).d; - buf[m++] = rmass[i]; - buf[m++] = radius[i]; - buf[m++] = omega[i][0]; - buf[m++] = omega[i][1]; - buf[m++] = omega[i][2]; - buf[m++] = angmom[i][0]; - buf[m++] = angmom[i][1]; - buf[m++] = angmom[i][2]; + int *tri = atom->tri; if (tri[i] < 0) buf[m++] = ubuf(0).d; else { @@ -1150,45 +323,19 @@ int AtomVecTri::pack_exchange(int i, double *buf) buf[m++] = inertia[2]; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- */ -int AtomVecTri::unpack_exchange(double *buf) +int AtomVecTri::unpack_exchange_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; + int *tri = atom->tri; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - rmass[nlocal] = buf[m++]; - radius[nlocal] = buf[m++]; - omega[nlocal][0] = buf[m++]; - omega[nlocal][1] = buf[m++]; - omega[nlocal][2] = buf[m++]; - angmom[nlocal][0] = buf[m++]; - angmom[nlocal][1] = buf[m++]; - angmom[nlocal][2] = buf[m++]; - - tri[nlocal] = (int) ubuf(buf[m++]).i; - if (tri[nlocal] == 0) tri[nlocal] = -1; + tri[ilocal] = (int) ubuf(buf[m++]).i; + if (tri[ilocal] == 0) tri[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); double *quat = bonus[nlocal_bonus].quat; @@ -1212,16 +359,10 @@ int AtomVecTri::unpack_exchange(double *buf) inertia[0] = buf[m++]; inertia[1] = buf[m++]; inertia[2] = buf[m++]; - bonus[nlocal_bonus].ilocal = nlocal; - tri[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + tri[ilocal] = nlocal_bonus++; } - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]-> - unpack_exchange(nlocal,&buf[m]); - - atom->nlocal++; return m; } @@ -1230,53 +371,31 @@ int AtomVecTri::unpack_exchange(double *buf) include extra data stored by fixes ------------------------------------------------------------------------- */ -int AtomVecTri::size_restart() +int AtomVecTri::size_restart_bonus() { int i; + int *tri = atom->tri; + int n = 0; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) - if (tri[i] >= 0) n += 37; - else n += 21; - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + for (i = 0; i < nlocal; i++) { + if (tri[i] >= 0) n += size_restart_bonus_one; + n++; + } return n; } /* ---------------------------------------------------------------------- - pack atom I's data for restart file including extra quantities - xyz must be 1st 3 values, so that read_restart can test on them - molecular types may be negative, but write as positive + unpack data for one atom from restart file including bonus data ------------------------------------------------------------------------- */ -int AtomVecTri::pack_restart(int i, double *buf) +int AtomVecTri::pack_restart_bonus(int i, double *buf) { - int m = 1; - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; + int m = 0; - buf[m++] = ubuf(molecule[i]).d; - buf[m++] = rmass[i]; - buf[m++] = radius[i]; - buf[m++] = omega[i][0]; - buf[m++] = omega[i][1]; - buf[m++] = omega[i][2]; - buf[m++] = angmom[i][0]; - buf[m++] = angmom[i][1]; - buf[m++] = angmom[i][2]; + int *tri = atom->tri; if (tri[i] < 0) buf[m++] = ubuf(0).d; else { @@ -1305,51 +424,21 @@ int AtomVecTri::pack_restart(int i, double *buf) buf[m++] = inertia[2]; } - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); - - buf[0] = m; return m; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities + unpack data for one atom from restart file including bonus data ------------------------------------------------------------------------- */ -int AtomVecTri::unpack_restart(double *buf) +int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); - } + int m = 0; - int m = 1; - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; + int *tri = atom->tri; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - rmass[nlocal] = buf[m++]; - radius[nlocal] = buf[m++]; - omega[nlocal][0] = buf[m++]; - omega[nlocal][1] = buf[m++]; - omega[nlocal][2] = buf[m++]; - angmom[nlocal][0] = buf[m++]; - angmom[nlocal][1] = buf[m++]; - angmom[nlocal][2] = buf[m++]; - - tri[nlocal] = (int) ubuf(buf[m++]).i; - if (tri[nlocal] == 0) tri[nlocal] = -1; + tri[ilocal] = (int) ubuf(buf[m++]).i; + if (tri[ilocal] == 0) tri[ilocal] = -1; else { if (nlocal_bonus == nmax_bonus) grow_bonus(); double *quat = bonus[nlocal_bonus].quat; @@ -1373,140 +462,21 @@ int AtomVecTri::unpack_restart(double *buf) inertia[0] = buf[m++]; inertia[1] = buf[m++]; inertia[2] = buf[m++]; - bonus[nlocal_bonus].ilocal = nlocal; - tri[nlocal] = nlocal_bonus++; + bonus[nlocal_bonus].ilocal = ilocal; + tri[ilocal] = nlocal_bonus++; } - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast (buf[0]) - m; - for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; return m; } -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults -------------------------------------------------------------------------- */ - -void AtomVecTri::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | - ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - molecule[nlocal] = 0; - radius[nlocal] = 0.5; - rmass[nlocal] = 4.0*MY_PI/3.0 * radius[nlocal]*radius[nlocal]*radius[nlocal]; - omega[nlocal][0] = 0.0; - omega[nlocal][1] = 0.0; - omega[nlocal][2] = 0.0; - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - tri[nlocal] = -1; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecTri::data_atom(double *coord, imageint imagetmp, char **values) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - molecule[nlocal] = utils::tnumeric(FLERR,values[1],true,lmp); - type[nlocal] = utils::inumeric(FLERR,values[2],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - tri[nlocal] = utils::inumeric(FLERR,values[3],true,lmp); - if (tri[nlocal] == 0) tri[nlocal] = -1; - else if (tri[nlocal] == 1) tri[nlocal] = 0; - else error->one(FLERR,"Invalid triflag in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[4],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - if (tri[nlocal] < 0) { - radius[nlocal] = 0.5; - rmass[nlocal] *= 4.0*MY_PI/3.0 * - radius[nlocal]*radius[nlocal]*radius[nlocal]; - } else radius[nlocal] = 0.0; - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - omega[nlocal][0] = 0.0; - omega[nlocal][1] = 0.0; - omega[nlocal][2] = 0.0; - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one tri in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecTri::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - - tri[nlocal] = utils::inumeric(FLERR,values[1],true,lmp); - if (tri[nlocal] == 0) tri[nlocal] = -1; - else if (tri[nlocal] == 1) tri[nlocal] = 0; - else error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - if (rmass[nlocal] <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - if (tri[nlocal] < 0) { - radius[nlocal] = 0.5; - rmass[nlocal] *= 4.0*MY_PI/3.0 * - radius[nlocal]*radius[nlocal]*radius[nlocal]; - } else radius[nlocal] = 0.0; - - return 3; -} - /* ---------------------------------------------------------------------- unpack one line from Tris section of data file ------------------------------------------------------------------------- */ void AtomVecTri::data_atom_bonus(int m, char **values) { + int *tri = atom->tri; + if (tri[m]) error->one(FLERR,"Assigning tri parameters to non-tri atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -1553,9 +523,9 @@ void AtomVecTri::data_atom_bonus(int m, char **values) if (delta/size > EPSILON) error->one(FLERR,"Inconsistent triangle in data file"); - x[m][0] = centroid[0]; - x[m][1] = centroid[1]; - x[m][2] = centroid[2]; + atom->x[m][0] = centroid[0]; + atom->x[m][1] = centroid[1]; + atom->x[m][2] = centroid[2]; // reset tri radius and mass // rmass currently holds density @@ -1563,22 +533,22 @@ void AtomVecTri::data_atom_bonus(int m, char **values) double c4[3]; MathExtra::sub3(c1,centroid,c4); - radius[m] = MathExtra::lensq3(c4); + atom->radius[m] = MathExtra::lensq3(c4); MathExtra::sub3(c2,centroid,c4); - radius[m] = MAX(radius[m],MathExtra::lensq3(c4)); + atom->radius[m] = MAX(atom->radius[m],MathExtra::lensq3(c4)); MathExtra::sub3(c3,centroid,c4); - radius[m] = MAX(radius[m],MathExtra::lensq3(c4)); - radius[m] = sqrt(radius[m]); + atom->radius[m] = MAX(atom->radius[m],MathExtra::lensq3(c4)); + atom->radius[m] = sqrt(atom->radius[m]); double norm[3]; MathExtra::cross3(c2mc1,c3mc1,norm); double area = 0.5 * MathExtra::len3(norm); - rmass[m] *= area; + atom->rmass[m] *= area; // inertia = inertia tensor of triangle as 6-vector in Voigt notation double inertia[6]; - MathExtra::inertia_triangle(c1,c2,c3,rmass[m],inertia); + MathExtra::inertia_triangle(c1,c2,c3,atom->rmass[m],inertia); // diagonalize inertia tensor via Jacobi rotations // bonus[].inertia = 3 eigenvalues = principal moments of inertia @@ -1635,207 +605,156 @@ void AtomVecTri::data_atom_bonus(int m, char **values) } /* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file + return # of bytes of allocated bonus memory ------------------------------------------------------------------------- */ -void AtomVecTri::data_vel(int m, char **values) -{ - v[m][0] = utils::numeric(FLERR,values[0],true,lmp); - v[m][1] = utils::numeric(FLERR,values[1],true,lmp); - v[m][2] = utils::numeric(FLERR,values[2],true,lmp); - omega[m][0] = utils::numeric(FLERR,values[3],true,lmp); - omega[m][1] = utils::numeric(FLERR,values[4],true,lmp); - omega[m][2] = utils::numeric(FLERR,values[5],true,lmp); - angmom[m][0] = utils::numeric(FLERR,values[6],true,lmp); - angmom[m][1] = utils::numeric(FLERR,values[7],true,lmp); - angmom[m][2] = utils::numeric(FLERR,values[8],true,lmp); -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Velocities section of data file -------------------------------------------------------------------------- */ - -int AtomVecTri::data_vel_hybrid(int m, char **values) -{ - omega[m][0] = utils::numeric(FLERR,values[0],true,lmp); - omega[m][1] = utils::numeric(FLERR,values[1],true,lmp); - omega[m][2] = utils::numeric(FLERR,values[2],true,lmp); - angmom[m][0] = utils::numeric(FLERR,values[3],true,lmp); - angmom[m][1] = utils::numeric(FLERR,values[4],true,lmp); - angmom[m][2] = utils::numeric(FLERR,values[5],true,lmp); - return 6; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecTri::pack_data(double **buf) -{ - double c2mc1[3],c3mc1[3],norm[3]; - double area; - - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(molecule[i]).d; - buf[i][2] = ubuf(type[i]).d; - if (tri[i] < 0) buf[i][3] = ubuf(0).d; - else buf[i][3] = ubuf(1).d; - if (tri[i] < 0) - buf[i][4] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[i]); - else { - MathExtra::sub3(bonus[tri[i]].c2,bonus[tri[i]].c1,c2mc1); - MathExtra::sub3(bonus[tri[i]].c3,bonus[tri[i]].c1,c3mc1); - MathExtra::cross3(c2mc1,c3mc1,norm); - area = 0.5 * MathExtra::len3(norm); - buf[i][4] = rmass[i]/area; - } - buf[i][5] = x[i][0]; - buf[i][6] = x[i][1]; - buf[i][7] = x[i][2]; - buf[i][8] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][9] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][10] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecTri::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - if (tri[i] < 0) buf[1] = ubuf(0).d; - else buf[1] = ubuf(1).d; - if (tri[i] < 0) - buf[2] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[i]); - else { - double c2mc1[3],c3mc1[3],norm[3]; - MathExtra::sub3(bonus[tri[i]].c2,bonus[tri[i]].c1,c2mc1); - MathExtra::sub3(bonus[tri[i]].c3,bonus[tri[i]].c1,c3mc1); - MathExtra::cross3(c2mc1,c3mc1,norm); - double area = 0.5 * MathExtra::len3(norm); - buf[2] = rmass[i]/area; - } - return 3; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecTri::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %d %-1.16e %-1.16e %-1.16e %-1.16e %d %d %d\n", - (tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i, - (int) ubuf(buf[i][2]).i,(int) ubuf(buf[i][3]).i, - buf[i][4],buf[i][5],buf[i][6],buf[i][7], - (int) ubuf(buf[i][8]).i,(int) ubuf(buf[i][9]).i, - (int) ubuf(buf[i][10]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecTri::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT " %d %-1.16e", - (tagint) ubuf(buf[0]).i,(int) ubuf(buf[1]).i,buf[2]); - return 3; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecTri::pack_vel(double **buf) -{ - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = v[i][0]; - buf[i][2] = v[i][1]; - buf[i][3] = v[i][2]; - buf[i][4] = omega[i][0]; - buf[i][5] = omega[i][1]; - buf[i][6] = omega[i][2]; - buf[i][7] = angmom[i][0]; - buf[i][8] = angmom[i][1]; - buf[i][9] = angmom[i][2]; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid velocity info for data file -------------------------------------------------------------------------- */ - -int AtomVecTri::pack_vel_hybrid(int i, double *buf) -{ - buf[0] = omega[i][0]; - buf[1] = omega[i][1]; - buf[2] = omega[i][2]; - buf[3] = angmom[i][0]; - buf[4] = angmom[i][1]; - buf[5] = angmom[i][2]; - return 6; -} - -/* ---------------------------------------------------------------------- - write velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecTri::write_vel(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT - " %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e " - "%-1.16e %-1.16e %-1.16e\n", - (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]); -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file -------------------------------------------------------------------------- */ - -int AtomVecTri::write_vel_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e", - buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]); - return 6; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecTri::memory_usage() +bigint AtomVecTri::memory_usage_bonus() { bigint bytes = 0; - - if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); - if (atom->memcheck("type")) bytes += memory->usage(type,nmax); - if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); - if (atom->memcheck("image")) bytes += memory->usage(image,nmax); - if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); - if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); - if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); - - if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); - if (atom->memcheck("radius")) bytes += memory->usage(radius,nmax); - if (atom->memcheck("omega")) bytes += memory->usage(omega,nmax,3); - if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3); - if (atom->memcheck("torque")) bytes += - memory->usage(torque,nmax*comm->nthreads,3); - if (atom->memcheck("tri")) bytes += memory->usage(tri,nmax); - bytes += nmax_bonus*sizeof(Bonus); - return bytes; } + +/* ---------------------------------------------------------------------- + create one atom of itype at coord + set other values to defaults +------------------------------------------------------------------------- */ + +void AtomVecTri::create_atom_post(int ilocal) +{ + double radius = 0.5; + atom->radius[ilocal] = radius; + atom->rmass[ilocal] = 4.0*MY_PI/3.0 * radius*radius*radius; + atom->tri[ilocal] = -1; +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecTri::data_atom_post(int ilocal) +{ + tri_flag = atom->tri[ilocal]; + if (tri_flag == 0) tri_flag = -1; + else if (tri_flag == 1) tri_flag = 0; + else error->one(FLERR,"Invalid tri flag in Atoms section of data file"); + atom->tri[ilocal] = tri_flag; + + if (atom->rmass[ilocal] <= 0.0) + error->one(FLERR,"Invalid density in Atoms section of data file"); + + if (tri_flag < 0) { + double radius = 0.5; + atom->radius[ilocal] = radius; + atom->rmass[ilocal] *= 4.0*MY_PI/3.0 * radius*radius*radius; + } else atom->radius[ilocal] = 0.0; + + atom->omega[ilocal][0] = 0.0; + atom->omega[ilocal][1] = 0.0; + atom->omega[ilocal][2] = 0.0; + atom->angmom[ilocal][0] = 0.0; + atom->angmom[ilocal][1] = 0.0; + atom->angmom[ilocal][2] = 0.0; +} + +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_data() to pack +------------------------------------------------------------------------- */ + +void AtomVecTri::pack_data_pre(int ilocal) +{ + tri_flag = atom->tri[ilocal]; + rmass = atom->rmass[ilocal]; + + if (tri_flag < 0) atom->tri[ilocal] = 0; + else atom->tri[ilocal] = 1; + + if (tri_flag < 0) { + double radius = atom->radius[ilocal]; + atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * radius*radius*radius; + } else { + double c2mc1[3],c3mc1[3],norm[3]; + MathExtra::sub3(bonus[tri_flag].c2,bonus[tri_flag].c1,c2mc1); + MathExtra::sub3(bonus[tri_flag].c3,bonus[tri_flag].c1,c3mc1); + MathExtra::cross3(c2mc1,c3mc1,norm); + double area = 0.5 * MathExtra::len3(norm); + atom->rmass[ilocal] /= area; + } +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_data() +------------------------------------------------------------------------- */ + +void AtomVecTri::pack_data_post(int ilocal) +{ + atom->tri[ilocal] = tri_flag; + atom->rmass[ilocal] = rmass; +} + +/* ---------------------------------------------------------------------- + set equilateral tri of size in bonus data for particle I + oriented symmetrically in xy plane + this may create or delete entry in bonus data +------------------------------------------------------------------------- */ + +void AtomVecTri::set_equilateral(int i, double size) +{ + // also set radius = distance from center to corner-pt = len(c1) + // unless size = 0.0, then set diameter = 1.0 + + int *tri = atom->tri; + + if (tri[i] < 0) { + if (size == 0.0) return; + if (nlocal_bonus == nmax_bonus) grow_bonus(); + double *quat = bonus[nlocal_bonus].quat; + double *c1 = bonus[nlocal_bonus].c1; + double *c2 = bonus[nlocal_bonus].c2; + double *c3 = bonus[nlocal_bonus].c3; + double *inertia = bonus[nlocal_bonus].inertia; + quat[0] = 1.0; + quat[1] = 0.0; + quat[2] = 0.0; + quat[3] = 0.0; + c1[0] = -size/2.0; + c1[1] = -sqrt(3.0)/2.0 * size / 3.0; + c1[2] = 0.0; + c2[0] = size/2.0; + c2[1] = -sqrt(3.0)/2.0 * size / 3.0; + c2[2] = 0.0; + c3[0] = 0.0; + c3[1] = sqrt(3.0)/2.0 * size * 2.0/3.0; + c3[2] = 0.0; + inertia[0] = sqrt(3.0)/96.0 * size*size*size*size; + inertia[1] = sqrt(3.0)/96.0 * size*size*size*size; + inertia[2] = sqrt(3.0)/48.0 * size*size*size*size; + atom->radius[i] = MathExtra::len3(c1); + bonus[nlocal_bonus].ilocal = i; + tri[i] = nlocal_bonus++; + } else if (size == 0.0) { + atom->radius[i] = 0.5; + copy_bonus_all(nlocal_bonus-1,tri[i]); + nlocal_bonus--; + tri[i] = -1; + } else { + double *c1 = bonus[tri[i]].c1; + double *c2 = bonus[tri[i]].c2; + double *c3 = bonus[tri[i]].c3; + double *inertia = bonus[tri[i]].inertia; + c1[0] = -size/2.0; + c1[1] = -sqrt(3.0)/2.0 * size / 3.0; + c1[2] = 0.0; + c2[0] = size/2.0; + c2[1] = -sqrt(3.0)/2.0 * size / 3.0; + c2[2] = 0.0; + c3[0] = 0.0; + c3[1] = sqrt(3.0)/2.0 * size * 2.0/3.0; + c3[2] = 0.0; + inertia[0] = sqrt(3.0)/96.0 * size*size*size*size; + inertia[1] = sqrt(3.0)/96.0 * size*size*size*size; + inertia[2] = sqrt(3.0)/48.0 * size*size*size*size; + atom->radius[i] = MathExtra::len3(c1); + } +} diff --git a/src/atom_vec_tri.h b/src/atom_vec_tri.h index 81b4c1ada9..3c701067b2 100644 --- a/src/atom_vec_tri.h +++ b/src/atom_vec_tri.h @@ -37,49 +37,26 @@ class AtomVecTri : public AtomVec { AtomVecTri(class LAMMPS *); ~AtomVecTri(); void init(); - void grow(int); - void grow_reset(); - void copy(int, int, int); - int pack_comm(int, int *, double *, int, int *); - int pack_comm_vel(int, int *, double *, int, int *); - int pack_comm_hybrid(int, int *, double *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_reverse(int, int, double *); - int pack_reverse_hybrid(int, int, double *); - void unpack_reverse(int, int *, double *); - int unpack_reverse_hybrid(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *); - void unpack_border(int, int, double *); - void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *); - int pack_exchange(int, double *); - int unpack_exchange(double *); - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); - int data_atom_hybrid(int, char **); - void data_vel(int, char **); - int data_vel_hybrid(int, char **); - void pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - void pack_vel(double **); - int pack_vel_hybrid(int, double *); - void write_vel(FILE *, int, double **); - int write_vel_hybrid(FILE *, double *); - bigint memory_usage(); - - // manipulate Bonus data structure for extra atom info + void copy_bonus(int, int, int); void clear_bonus(); + int pack_comm_bonus(int, int *, double *); + void unpack_comm_bonus(int, int, double *); + int pack_reverse_bonus(int, int, double *); + int pack_border_bonus(int, int *, double *); + int unpack_border_bonus(int, int, double *); + int pack_exchange_bonus(int, double *); + int unpack_exchange_bonus(int, double *); + int size_restart_bonus(); + int pack_restart_bonus(int, double *); + int unpack_restart_bonus(int, double *); void data_atom_bonus(int, char **); + bigint memory_usage_bonus(); + + void create_atom_post(int); + void data_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); // unique to AtomVecTri @@ -88,19 +65,12 @@ class AtomVecTri : public AtomVec { int nlocal_bonus; private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - tagint *molecule; - double *rmass,*radius; - double **omega,**angmom,**torque; - int *tri; - int nghost_bonus,nmax_bonus; + int tri_flag; + double rmass; void grow_bonus(); - void copy_bonus(int, int); + void copy_bonus_all(int, int); }; } diff --git a/src/read_data.cpp b/src/read_data.cpp index d558b87633..aa4e758744 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -568,7 +568,7 @@ void ReadData::command(int narg, char **arg) if (!avec_body) error->all(FLERR,"Invalid data file section: Bodies"); if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bodies"); - bodies(firstpass); + bodies(firstpass,(AtomVec *) avec_body); } else if (strcmp(keyword,"Masses") == 0) { if (firstpass) mass(); @@ -1686,7 +1686,7 @@ void ReadData::bonus(bigint nbonus, AtomVec *ptr, const char *type) if not firstpass, just read past data, but no processing of data ------------------------------------------------------------------------- */ -void ReadData::bodies(int firstpass) +void ReadData::bodies(int firstpass, AtomVec *ptr) { int m,nchunk,nline,nmax,ninteger,ndouble,nword,ncount,onebody,tmp,rv; char *eof; @@ -1770,7 +1770,7 @@ void ReadData::bodies(int firstpass) MPI_Bcast(&m,1,MPI_INT,0,world); MPI_Bcast(buffer,m,MPI_CHAR,0,world); - if (firstpass) atom->data_bodies(nchunk,buffer,avec_body,id_offset); + if (firstpass) atom->data_bodies(nchunk,buffer,ptr,id_offset); nread += nchunk; } diff --git a/src/read_data.h b/src/read_data.h index 98de607f6b..aee54ef3ed 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -97,7 +97,7 @@ class ReadData : protected Pointers { void impropers(int); void bonus(bigint, class AtomVec *, const char *); - void bodies(int); + void bodies(int, class AtomVec *); void mass(); void paircoeffs();