From 3736af0aaf5f1522e1e48ceb5fceeaada30cb3e2 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 26 Nov 2019 13:42:32 -0700 Subject: [PATCH 01/42] initial refactoring on AtomVec class --- src/DIPOLE/atom_vec_dipole.cpp | 888 +---------- src/DIPOLE/atom_vec_dipole.h | 45 - src/MOLECULE/atom_vec_angle.cpp | 956 ++---------- src/MOLECULE/atom_vec_angle.h | 53 +- src/MOLECULE/atom_vec_bond.cpp | 865 +---------- src/MOLECULE/atom_vec_bond.h | 47 +- src/MOLECULE/atom_vec_full.cpp | 1191 ++------------- src/MOLECULE/atom_vec_full.h | 60 +- src/MOLECULE/atom_vec_molecular.cpp | 1171 ++------------- src/MOLECULE/atom_vec_molecular.h | 56 +- src/MOLECULE/atom_vec_template.cpp | 804 +--------- src/MOLECULE/atom_vec_template.h | 50 +- src/PERI/atom_vec_peri.cpp | 905 +----------- src/PERI/atom_vec_peri.h | 48 - src/SPIN/atom_vec_spin.cpp | 928 +----------- src/SPIN/atom_vec_spin.h | 54 - src/atom.cpp | 220 ++- src/atom.h | 160 +- src/atom_vec.cpp | 2112 ++++++++++++++++++++++++++- src/atom_vec.h | 143 +- src/atom_vec_atomic.cpp | 677 +-------- src/atom_vec_atomic.h | 40 +- src/atom_vec_charge.cpp | 764 +--------- src/atom_vec_charge.h | 45 - src/atom_vec_sphere.cpp | 1153 +-------------- src/atom_vec_sphere.h | 52 - 26 files changed, 3191 insertions(+), 10296 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 0b6a27888f..dc3279227d 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -31,880 +31,40 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) molecular = 0; mass_type = 1; - comm_x_only = 0; - comm_f_only = 1; - size_forward = 6; - size_reverse = 3; - size_border = 11; - size_velocity = 3; - size_data_atom = 9; - size_data_vel = 4; - xcol_data = 4; - atom->q_flag = atom->mu_flag = 1; -} -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecDipole::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"); - - q = memory->grow(atom->q,nmax,"atom:q"); - mu = memory->grow(atom->mu,nmax,4,"atom:mu"); - - 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 AtomVecDipole::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; mu = atom->mu; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecDipole::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]; - mu[j][0] = mu[i][0]; - mu[j][1] = mu[i][1]; - mu[j][2] = mu[i][2]; - mu[j][3] = mu[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); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDipole::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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[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; - } - 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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDipole::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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - 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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - 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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][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]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDipole::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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDipole::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++]; - mu[i][0] = buf[m++]; - mu[i][1] = buf[m++]; - mu[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDipole::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++]; - mu[i][0] = buf[m++]; - mu[i][1] = buf[m++]; - mu[i][2] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDipole::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - mu[i][0] = buf[m++]; - mu[i][1] = buf[m++]; - mu[i][2] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecDipole::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 AtomVecDipole::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 AtomVecDipole::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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - buf[m++] = mu[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++] = q[j]; - buf[m++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - buf[m++] = mu[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 AtomVecDipole::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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - buf[m++] = mu[j][3]; - 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 (!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++] = q[j]; - buf[m++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - buf[m++] = mu[j][3]; - 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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - buf[m++] = mu[j][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]; - } - } - } - } - - 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 AtomVecDipole::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++] = mu[j][0]; - buf[m++] = mu[j][1]; - buf[m++] = mu[j][2]; - buf[m++] = mu[j][3]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecDipole::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++]; - mu[i][0] = buf[m++]; - mu[i][1] = buf[m++]; - mu[i][2] = buf[m++]; - mu[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 AtomVecDipole::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++]; - mu[i][0] = buf[m++]; - mu[i][1] = buf[m++]; - mu[i][2] = buf[m++]; - mu[i][3] = 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 AtomVecDipole::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++]; - mu[i][0] = buf[m++]; - mu[i][1] = buf[m++]; - mu[i][2] = buf[m++]; - mu[i][3] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- - pack all atom quantities for shipping to another proc - xyz must be 1st 3 values, so that comm::exchange can test on them -------------------------------------------------------------------------- */ - -int AtomVecDipole::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++] = q[i]; - buf[m++] = mu[i][0]; - buf[m++] = mu[i][1]; - buf[m++] = mu[i][2]; - buf[m++] = mu[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 AtomVecDipole::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++]; - mu[nlocal][0] = buf[m++]; - mu[nlocal][1] = buf[m++]; - mu[nlocal][2] = buf[m++]; - mu[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; -} - -/* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes -------------------------------------------------------------------------- */ - -int AtomVecDipole::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 16 * nlocal; - - 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 AtomVecDipole::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++] = mu[i][0]; - buf[m++] = mu[i][1]; - buf[m++] = mu[i][2]; - buf[m++] = mu[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 AtomVecDipole::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++]; - mu[nlocal][0] = buf[m++]; - mu[nlocal][1] = buf[m++]; - mu[nlocal][2] = buf[m++]; - mu[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 AtomVecDipole::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; - mu[nlocal][0] = 0.0; - mu[nlocal][1] = 0.0; - mu[nlocal][2] = 0.0; - mu[nlocal][3] = 0.0; - - atom->nlocal++; + // 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 *) "q mu"; + fields_copy = (char *) "q mu"; + fields_comm = (char *) "mu3"; + fields_comm_vel = (char *) "mu3"; + fields_reverse = NULL; + fields_border = (char *) "q mu"; + fields_border_vel = (char *) "q mu"; + fields_exchange = (char *) "q mu"; + fields_restart = (char *) "q mu"; + fields_create = (char *) "q mu"; + fields_data_atom = (char *) "id type q x mu3"; + fields_data_vel = NULL; + + setup_fields(); } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what the default AtomVec::data_atom() just initialized ------------------------------------------------------------------------- */ void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); - 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); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - mu[nlocal][0] = utils::numeric(FLERR,values[6],true,lmp); - mu[nlocal][1] = utils::numeric(FLERR,values[7],true,lmp); - mu[nlocal][2] = utils::numeric(FLERR,values[8],true,lmp); - mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] + - mu[nlocal][1]*mu[nlocal][1] + - mu[nlocal][2]*mu[nlocal][2]); - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - - atom->nlocal++; + int ilocal = atom->nlocal-1; + double mu = atom->mu[ilocal]; + mu[3] = sqrt(mu[0]*mu[0] + mu[1]*mu[1] + mu[2]*mu[2]); } -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecDipole::data_atom_hybrid(int nlocal, char **values) -{ - q[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - mu[nlocal][0] = utils::numeric(FLERR,values[1],true,lmp); - mu[nlocal][1] = utils::numeric(FLERR,values[2],true,lmp); - mu[nlocal][2] = utils::numeric(FLERR,values[3],true,lmp); - mu[nlocal][3] = sqrt(mu[nlocal][0]*mu[nlocal][0] + - mu[nlocal][1]*mu[nlocal][1] + - mu[nlocal][2]*mu[nlocal][2]); - return 4; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecDipole::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] = x[i][0]; - buf[i][4] = x[i][1]; - buf[i][5] = x[i][2]; - buf[i][6] = mu[i][0]; - buf[i][7] = mu[i][1]; - buf[i][8] = mu[i][2]; - buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecDipole::pack_data_hybrid(int i, double *buf) -{ - buf[0] = q[i]; - buf[1] = mu[i][0]; - buf[2] = mu[i][1]; - buf[3] = mu[i][2]; - return 4; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecDipole::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 %-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],buf[i][7],buf[i][8], - (int) ubuf(buf[i][9]).i,(int) ubuf(buf[i][10]).i, - (int) ubuf(buf[i][11]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecDipole::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2],buf[3]); - return 4; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecDipole::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("mu")) bytes += memory->usage(mu,nmax,4); - - return bytes; -} diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index c6ee23def1..6abcb4e2ea 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -27,43 +27,7 @@ namespace LAMMPS_NS { class AtomVecDipole : public AtomVec { public: AtomVecDipole(class LAMMPS *); - 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 *); - void unpack_reverse(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 pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - bigint memory_usage(); - - private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *q,**mu; }; } @@ -73,13 +37,4 @@ class AtomVecDipole : 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. - */ diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 4eba471b8f..79f5a7853e 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -13,13 +13,6 @@ #include "atom_vec_angle.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; @@ -31,895 +24,140 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) bonds_allow = angles_allow = 1; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 7; - size_velocity = 3; - size_data_atom = 6; - size_data_vel = 4; - xcol_data = 4; - atom->molecule_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 *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; + fields_copy = (char *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = (char *) "molecule"; + fields_border_vel = (char *) "molecule"; + fields_exchange = (char *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; + fields_restart = (char *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3"; + fields_create = (char *) "molecule num_bond num_angle nspecial"; + fields_data_atom = (char *) "id molecule type x"; + fields_data_vel = NULL; + + setup_fields(); + + bond_per_atom = angle_per_atom = 0; + bond_negative = angle_negative = NULL; +} + +/* ---------------------------------------------------------------------- */ + +AtomVecAngle::~AtomVecAngle() +{ + delete [] bond_negative; + delete [] angle_negative; } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + pack atom I's data for restart file + modify/unmodify values for default AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecAngle::grow(int n) +int AtomVecAngle::pack_restart(int i, double *buf) { - 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"); + // insure negative vectors are needed length - 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"); - - nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); - special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); - - num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); - bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, - "atom:bond_type"); - bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, - "atom:bond_atom"); - - num_angle = memory->grow(atom->num_angle,nmax,"atom:num_angle"); - angle_type = memory->grow(atom->angle_type,nmax,atom->angle_per_atom, - "atom:angle_type"); - angle_atom1 = memory->grow(atom->angle_atom1,nmax,atom->angle_per_atom, - "atom:angle_atom1"); - angle_atom2 = memory->grow(atom->angle_atom2,nmax,atom->angle_per_atom, - "atom:angle_atom2"); - angle_atom3 = memory->grow(atom->angle_atom3,nmax,atom->angle_per_atom, - "atom:angle_atom3"); - - 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 AtomVecAngle::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; - nspecial = atom->nspecial; special = atom->special; - num_bond = atom->num_bond; bond_type = atom->bond_type; - bond_atom = atom->bond_atom; - num_angle = atom->num_angle; angle_type = atom->angle_type; - angle_atom1 = atom->angle_atom1; angle_atom2 = atom->angle_atom2; - angle_atom3 = atom->angle_atom3; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecAngle::copy(int i, int j, int delflag) -{ - int k; - - 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]; - - num_bond[j] = num_bond[i]; - for (k = 0; k < num_bond[j]; k++) { - bond_type[j][k] = bond_type[i][k]; - bond_atom[j][k] = bond_atom[i][k]; + if (bond_per_atom < atom->bond_per_atom) { + delete [] bond_negative; + bond_per_atom = atom->bond_per_atom; + bond_negative = new int[bond_per_atom]; + } + if (angle_per_atom < atom->angle_per_atom) { + delete [] angle_negative; + angle_per_atom = atom->angle_per_atom; + angle_negative = new int[angle_per_atom]; } - num_angle[j] = num_angle[i]; - for (k = 0; k < num_angle[j]; k++) { - angle_type[j][k] = angle_type[i][k]; - angle_atom1[j][k] = angle_atom1[i][k]; - angle_atom2[j][k] = angle_atom2[i][k]; - angle_atom3[j][k] = angle_atom3[i][k]; + // flip any negative types to positive and flag which ones + + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + int *num_angle = atom->num_angle; + int **angle_type = atom->angle_type; + + int any_bond_negative = 0; + for (int m = 0; m < num_bond[i]; m++) { + if (bond_type[i][m] < 0) { + bond_negative[m] = 1; + bond_type[i][m] = -bond_type[i][m]; + any_bond_negative = 1; + } else bond_negative[m] = 0; } - nspecial[j][0] = nspecial[i][0]; - nspecial[j][1] = nspecial[i][1]; - nspecial[j][2] = nspecial[i][2]; - for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; - - 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 AtomVecAngle::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecAngle::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecAngle::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecAngle::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecAngle::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 AtomVecAngle::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 AtomVecAngle::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; - } - } 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; - } + int any_angle_negative = 0; + for (int m = 0; m < num_angle[i]; m++) { + if (angle_type[i][m] < 0) { + angle_negative[m] = 1; + angle_type[i][m] = -angle_type[i][m]; + any_angle_negative = 1; + } else angle_negative[m] = 0; } - 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]); + // perform the pack with adjusted values - return m; -} + int n = AtomVec::pack_restart(i,buf); -/* ---------------------------------------------------------------------- */ + // restore the flagged types to their negative values -int AtomVecAngle::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++] = 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 (!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++] = 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++] = ubuf(molecule[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]; - } - } - } + if (any_bond_negative) { + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][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 AtomVecAngle::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; + if (any_angle_negative) { + for (int m = 0; m < num_angle[i]; m++) + if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecAngle::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - } - - 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 AtomVecAngle::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - 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 AtomVecAngle::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - molecule[i] = (tagint) ubuf(buf[m++]).i; - 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 AtomVecAngle::pack_exchange(int i, double *buf) -{ - int k; - - 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++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(bond_type[i][k]).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(angle_type[i][k]).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(nspecial[i][0]).d; - buf[m++] = ubuf(nspecial[i][1]).d; - buf[m++] = ubuf(nspecial[i][2]).d; - for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; - - 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 AtomVecAngle::unpack_exchange(double *buf) -{ - int k; - - 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; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; - for (k = 0; k < nspecial[nlocal][2]; k++) - special[nlocal][k] = (tagint) ubuf(buf[m++]).i; - - 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 AtomVecAngle::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 0; - for (i = 0; i < nlocal; i++) - n += 14 + 2*num_bond[i] + 4*num_angle[i]; - - 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 AtomVecAngle::pack_restart(int i, double *buf) -{ - int k; - - 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++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(MAX(angle_type[i][k],-angle_type[i][k])).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - 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 + initialize other atom quantities ------------------------------------------------------------------------- */ int AtomVecAngle::unpack_restart(double *buf) { - int k; + AtomVec::unpack_restart(buf); + int ilocal = atom->nlocal-1; - 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++]; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 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 AtomVecAngle::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; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; - - atom->nlocal++; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ void AtomVecAngle::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); - - 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; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecAngle::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - - return 1; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecAngle::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; - 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 AtomVecAngle::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - return 1; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecAngle::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %-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, - 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 AtomVecAngle::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT,(tagint) ubuf(buf[0]).i); - return 1; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecAngle::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("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); - if (atom->memcheck("special")) - bytes += memory->usage(special,nmax,atom->maxspecial); - - if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); - if (atom->memcheck("bond_type")) - bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); - if (atom->memcheck("bond_atom")) - bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - - if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); - if (atom->memcheck("angle_type")) - bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom1")) - bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom2")) - bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom3")) - bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); - - return bytes; + atom->num_bond[ilocal] = 0; + atom->num_angle[ilocal] = 0; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_angle.h b/src/MOLECULE/atom_vec_angle.h index 9030cce0d8..6511b517ee 100644 --- a/src/MOLECULE/atom_vec_angle.h +++ b/src/MOLECULE/atom_vec_angle.h @@ -27,50 +27,14 @@ namespace LAMMPS_NS { class AtomVecAngle : public AtomVec { public: AtomVecAngle(class LAMMPS *); - virtual ~AtomVecAngle() {} - 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 *); - 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 *); - 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(); + ~AtomVecAngle(); 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(); - protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - tagint *molecule; - int **nspecial; - tagint **special; - int *num_bond; - int **bond_type; - tagint **bond_atom; - int *num_angle; - int **angle_type; - tagint **angle_atom1,**angle_atom2,**angle_atom3; + private: + int bond_per_atom,angle_per_atom; + int *bond_negative,*angle_negative; }; } @@ -80,13 +44,4 @@ class AtomVecAngle : 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. - */ diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 0bcd614f94..20cdfdd65a 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -13,13 +13,6 @@ #include "atom_vec_bond.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; @@ -31,829 +24,113 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) bonds_allow = 1; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 7; - size_velocity = 3; - size_data_atom = 6; - size_data_vel = 4; - xcol_data = 4; - atom->molecule_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 *) + "molecule num_bond bond_type bond_atom nspecial special"; + fields_copy = (char *) + "molecule num_bond bond_type bond_atom nspecial special"; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = (char *) "molecule"; + fields_border_vel = (char *) "molecule"; + fields_exchange = (char *) + "molecule num_bond bond_type bond_atom nspecial special"; + fields_restart = (char *) "molecule num_bond bond_type bond_atom"; + fields_create = (char *) "molecule num_bond nspecial"; + fields_data_atom = (char *) "id molecule type x"; + fields_data_vel = NULL; + + setup_fields(); + + bond_per_atom = 0; + bond_negative = NULL; +} + +/* ---------------------------------------------------------------------- */ + +AtomVecBond::~AtomVecBond() +{ + delete [] bond_negative; } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + pack atom I's data for restart file + modify/unmodify values for default AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecBond::grow(int n) +int AtomVecBond::pack_restart(int i, double *buf) { - 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"); + // insure bond_negative vector is needed length - 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"); - - nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); - special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); - - num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); - bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, - "atom:bond_type"); - bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, - "atom:bond_atom"); - - 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 AtomVecBond::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; - nspecial = atom->nspecial; special = atom->special; - num_bond = atom->num_bond; bond_type = atom->bond_type; - bond_atom = atom->bond_atom; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecBond::copy(int i, int j, int delflag) -{ - int k; - - 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]; - - num_bond[j] = num_bond[i]; - for (k = 0; k < num_bond[j]; k++) { - bond_type[j][k] = bond_type[i][k]; - bond_atom[j][k] = bond_atom[i][k]; + if (bond_per_atom < atom->bond_per_atom) { + delete [] bond_negative; + bond_per_atom = atom->bond_per_atom; + bond_negative = new int[bond_per_atom]; } - nspecial[j][0] = nspecial[i][0]; - nspecial[j][1] = nspecial[i][1]; - nspecial[j][2] = nspecial[i][2]; - for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; + // flip any negative types to positive and flag which ones - 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 *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; -/* ---------------------------------------------------------------------- */ - -int AtomVecBond::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBond::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecBond::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecBond::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecBond::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 AtomVecBond::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 AtomVecBond::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; - } - } 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; - } + int any_bond_negative = 0; + for (int m = 0; m < num_bond[i]; m++) { + if (bond_type[i][m] < 0) { + bond_negative[m] = 1; + bond_type[i][m] = -bond_type[i][m]; + any_bond_negative = 1; + } else bond_negative[m] = 0; } - 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]); + // perform the pack with adjusted values - return m; -} + int n = AtomVec::pack_restart(i,buf); -/* ---------------------------------------------------------------------- */ + // restore the flagged types to their negative values -int AtomVecBond::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++] = 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 (!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++] = 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++] = ubuf(molecule[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]; - } - } - } + if (any_bond_negative) { + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][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 AtomVecBond::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; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecBond::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - } - - 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 AtomVecBond::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - 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 AtomVecBond::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - molecule[i] = (tagint) ubuf(buf[m++]).i; - 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 AtomVecBond::pack_exchange(int i, double *buf) -{ - int k; - - 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++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(bond_type[i][k]).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(nspecial[i][0]).d; - buf[m++] = ubuf(nspecial[i][1]).d; - buf[m++] = ubuf(nspecial[i][2]).d; - for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; - - 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 AtomVecBond::unpack_exchange(double *buf) -{ - int k; - - 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; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; - for (k = 0; k < nspecial[nlocal][2]; k++) - special[nlocal][k] = (tagint) ubuf(buf[m++]).i; - - 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 AtomVecBond::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 0; - for (i = 0; i < nlocal; i++) - n += 13 + 2*num_bond[i]; - - 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 AtomVecBond::pack_restart(int i, double *buf) -{ - int k; - - 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++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - 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 + initialize other atom quantities ------------------------------------------------------------------------- */ int AtomVecBond::unpack_restart(double *buf) { - int k; + AtomVec::unpack_restart(buf); + int ilocal = atom->nlocal-1; - 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++]; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 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 AtomVecBond::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; - num_bond[nlocal] = 0; - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; - - atom->nlocal++; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ void AtomVecBond::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); - - 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; - num_bond[nlocal] = 0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecBond::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - - num_bond[nlocal] = 0; - - return 1; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecBond::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; - 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 AtomVecBond::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - return 1; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecBond::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %-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, - 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 AtomVecBond::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT,(tagint) ubuf(buf[0]).i); - return 1; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecBond::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("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); - if (atom->memcheck("special")) - bytes += memory->usage(special,nmax,atom->maxspecial); - - if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); - if (atom->memcheck("bond_type")) - bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); - if (atom->memcheck("bond_atom")) - bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - - return bytes; + atom->num_bond[ilocal] = 0; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index d7370d4659..9245bc317a 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -27,46 +27,14 @@ namespace LAMMPS_NS { class AtomVecBond : public AtomVec { public: AtomVecBond(class LAMMPS *); - 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 *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int pack_reverse(int, int, double *); - void unpack_reverse(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(); + ~AtomVecBond(); 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(); private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - tagint *molecule; - int **nspecial; - tagint **special; - int *num_bond; - int **bond_type; - tagint **bond_atom; + int bond_per_atom; + int *bond_negative; }; } @@ -76,13 +44,4 @@ class AtomVecBond : 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. - */ diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index 76c60ba121..826d5fea4e 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -13,13 +13,6 @@ #include "atom_vec_full.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; @@ -31,1078 +24,204 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 8; - size_velocity = 3; - size_data_atom = 7; - size_data_vel = 4; - xcol_data = 5; - atom->molecule_flag = atom->q_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 *) + "q molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4 " + "nspecial special"; + fields_copy = (char *) + "q molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4 " + "nspecial special"; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = (char *) "q molecule"; + fields_border_vel = (char *) "q molecule"; + fields_exchange = (char *) + "q molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4 " + "nspecial special"; + fields_restart = (char *) + "q molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4"; + fields_create = (char *) + "q molecule num_bond num_angle num_dihedral num_improper nspecial"; + fields_data_atom = (char *) "id molecule type q x"; + fields_data_vel = NULL; + + setup_fields(); + + bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; + bond_negative = angle_negative = dihedral_negative = improper_negative = NULL; +} + +/* ---------------------------------------------------------------------- */ + +AtomVecFull::~AtomVecFull() +{ + delete [] bond_negative; + delete [] angle_negative; + delete [] dihedral_negative; + delete [] improper_negative; } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + pack atom I's data for restart file + modify/unmodify values for default AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecFull::grow(int n) +int AtomVecFull::pack_restart(int i, double *buf) { - 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"); + // insure negative vectors are needed length - 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"); - molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); - - nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); - special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); - - num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); - bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, - "atom:bond_type"); - bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, - "atom:bond_atom"); - - num_angle = memory->grow(atom->num_angle,nmax,"atom:num_angle"); - angle_type = memory->grow(atom->angle_type,nmax,atom->angle_per_atom, - "atom:angle_type"); - angle_atom1 = memory->grow(atom->angle_atom1,nmax,atom->angle_per_atom, - "atom:angle_atom1"); - angle_atom2 = memory->grow(atom->angle_atom2,nmax,atom->angle_per_atom, - "atom:angle_atom2"); - angle_atom3 = memory->grow(atom->angle_atom3,nmax,atom->angle_per_atom, - "atom:angle_atom3"); - - num_dihedral = memory->grow(atom->num_dihedral,nmax,"atom:num_dihedral"); - dihedral_type = memory->grow(atom->dihedral_type,nmax, - atom->dihedral_per_atom,"atom:dihedral_type"); - dihedral_atom1 = - memory->grow(atom->dihedral_atom1,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom1"); - dihedral_atom2 = - memory->grow(atom->dihedral_atom2,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom2"); - dihedral_atom3 = - memory->grow(atom->dihedral_atom3,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom3"); - dihedral_atom4 = - memory->grow(atom->dihedral_atom4,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom4"); - - num_improper = memory->grow(atom->num_improper,nmax,"atom:num_improper"); - improper_type = - memory->grow(atom->improper_type,nmax,atom->improper_per_atom, - "atom:improper_type"); - improper_atom1 = - memory->grow(atom->improper_atom1,nmax,atom->improper_per_atom, - "atom:improper_atom1"); - improper_atom2 = - memory->grow(atom->improper_atom2,nmax,atom->improper_per_atom, - "atom:improper_atom2"); - improper_atom3 = - memory->grow(atom->improper_atom3,nmax,atom->improper_per_atom, - "atom:improper_atom3"); - improper_atom4 = - memory->grow(atom->improper_atom4,nmax,atom->improper_per_atom, - "atom:improper_atom4"); - - 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 AtomVecFull::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; molecule = atom->molecule; - nspecial = atom->nspecial; special = atom->special; - num_bond = atom->num_bond; bond_type = atom->bond_type; - bond_atom = atom->bond_atom; - num_angle = atom->num_angle; angle_type = atom->angle_type; - angle_atom1 = atom->angle_atom1; angle_atom2 = atom->angle_atom2; - angle_atom3 = atom->angle_atom3; - num_dihedral = atom->num_dihedral; dihedral_type = atom->dihedral_type; - dihedral_atom1 = atom->dihedral_atom1; dihedral_atom2 = atom->dihedral_atom2; - dihedral_atom3 = atom->dihedral_atom3; dihedral_atom4 = atom->dihedral_atom4; - num_improper = atom->num_improper; improper_type = atom->improper_type; - improper_atom1 = atom->improper_atom1; improper_atom2 = atom->improper_atom2; - improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecFull::copy(int i, int j, int delflag) -{ - int k; - - 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]; - molecule[j] = molecule[i]; - - num_bond[j] = num_bond[i]; - for (k = 0; k < num_bond[j]; k++) { - bond_type[j][k] = bond_type[i][k]; - bond_atom[j][k] = bond_atom[i][k]; + if (bond_per_atom < atom->bond_per_atom) { + delete [] bond_negative; + bond_per_atom = atom->bond_per_atom; + bond_negative = new int[bond_per_atom]; + } + if (angle_per_atom < atom->angle_per_atom) { + delete [] angle_negative; + angle_per_atom = atom->angle_per_atom; + angle_negative = new int[angle_per_atom]; + } + if (dihedral_per_atom < atom->dihedral_per_atom) { + delete [] dihedral_negative; + dihedral_per_atom = atom->dihedral_per_atom; + dihedral_negative = new int[dihedral_per_atom]; + } + if (improper_per_atom < atom->improper_per_atom) { + delete [] improper_negative; + improper_per_atom = atom->improper_per_atom; + improper_negative = new int[improper_per_atom]; } - num_angle[j] = num_angle[i]; - for (k = 0; k < num_angle[j]; k++) { - angle_type[j][k] = angle_type[i][k]; - angle_atom1[j][k] = angle_atom1[i][k]; - angle_atom2[j][k] = angle_atom2[i][k]; - angle_atom3[j][k] = angle_atom3[i][k]; + // flip any negative types to positive and flag which ones + + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + int *num_angle = atom->num_angle; + int **angle_type = atom->angle_type; + int *num_dihedral = atom->num_dihedral; + int **dihedral_type = atom->dihedral_type; + int *num_improper = atom->num_improper; + int **improper_type = atom->improper_type; + + int any_bond_negative = 0; + for (int m = 0; m < num_bond[i]; m++) { + if (bond_type[i][m] < 0) { + bond_negative[m] = 1; + bond_type[i][m] = -bond_type[i][m]; + any_bond_negative = 1; + } else bond_negative[m] = 0; } - num_dihedral[j] = num_dihedral[i]; - for (k = 0; k < num_dihedral[j]; k++) { - dihedral_type[j][k] = dihedral_type[i][k]; - dihedral_atom1[j][k] = dihedral_atom1[i][k]; - dihedral_atom2[j][k] = dihedral_atom2[i][k]; - dihedral_atom3[j][k] = dihedral_atom3[i][k]; - dihedral_atom4[j][k] = dihedral_atom4[i][k]; + int any_angle_negative = 0; + for (int m = 0; m < num_angle[i]; m++) { + if (angle_type[i][m] < 0) { + angle_negative[m] = 1; + angle_type[i][m] = -angle_type[i][m]; + any_angle_negative = 1; + } else angle_negative[m] = 0; } - num_improper[j] = num_improper[i]; - for (k = 0; k < num_improper[j]; k++) { - improper_type[j][k] = improper_type[i][k]; - improper_atom1[j][k] = improper_atom1[i][k]; - improper_atom2[j][k] = improper_atom2[i][k]; - improper_atom3[j][k] = improper_atom3[i][k]; - improper_atom4[j][k] = improper_atom4[i][k]; + int any_dihedral_negative = 0; + for (int m = 0; m < num_dihedral[i]; m++) { + if (dihedral_type[i][m] < 0) { + dihedral_negative[m] = 1; + dihedral_type[i][m] = -dihedral_type[i][m]; + any_dihedral_negative = 1; + } else dihedral_negative[m] = 0; } - nspecial[j][0] = nspecial[i][0]; - nspecial[j][1] = nspecial[i][1]; - nspecial[j][2] = nspecial[i][2]; - for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; - - 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 AtomVecFull::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFull::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFull::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFull::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecFull::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 AtomVecFull::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 AtomVecFull::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(molecule[j]).d; - } - } 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(molecule[j]).d; - } + int any_improper_negative = 0; + for (int m = 0; m < num_improper[i]; m++) { + if (improper_type[i][m] < 0) { + improper_negative[m] = 1; + improper_type[i][m] = -improper_type[i][m]; + any_improper_negative = 1; + } else improper_negative[m] = 0; } - 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]); + // perform the pack with adjusted values - return m; -} + int n = AtomVec::pack_restart(i,buf); -/* ---------------------------------------------------------------------- */ + // restore the flagged types to their negative values -int AtomVecFull::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(molecule[j]).d; - 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 (!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++] = q[j]; - buf[m++] = ubuf(molecule[j]).d; - 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(molecule[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]; - } - } - } + if (any_bond_negative) { + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][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 AtomVecFull::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(molecule[j]).d; + if (any_angle_negative) { + for (int m = 0; m < num_angle[i]; m++) + if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecFull::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++]; - molecule[i] = (tagint) ubuf(buf[m++]).i; + if (any_dihedral_negative) { + for (int m = 0; m < num_dihedral[i]; m++) + if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][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 AtomVecFull::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++]; - molecule[i] = (tagint) ubuf(buf[m++]).i; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; + if (any_improper_negative) { + for (int m = 0; m < num_improper[i]; m++) + if (improper_negative[m]) improper_type[i][m] = -improper_type[i][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 AtomVecFull::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++]; - molecule[i] = (tagint) ubuf(buf[m++]).i; - } - 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 AtomVecFull::pack_exchange(int i, double *buf) -{ - int k; - - 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(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(bond_type[i][k]).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(angle_type[i][k]).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(num_dihedral[i]).d; - for (k = 0; k < num_dihedral[i]; k++) { - buf[m++] = ubuf(dihedral_type[i][k]).d; - buf[m++] = ubuf(dihedral_atom1[i][k]).d; - buf[m++] = ubuf(dihedral_atom2[i][k]).d; - buf[m++] = ubuf(dihedral_atom3[i][k]).d; - buf[m++] = ubuf(dihedral_atom4[i][k]).d; - } - - buf[m++] = ubuf(num_improper[i]).d; - for (k = 0; k < num_improper[i]; k++) { - buf[m++] = ubuf(improper_type[i][k]).d; - buf[m++] = ubuf(improper_atom1[i][k]).d; - buf[m++] = ubuf(improper_atom2[i][k]).d; - buf[m++] = ubuf(improper_atom3[i][k]).d; - buf[m++] = ubuf(improper_atom4[i][k]).d; - } - - buf[m++] = ubuf(nspecial[i][0]).d; - buf[m++] = ubuf(nspecial[i][1]).d; - buf[m++] = ubuf(nspecial[i][2]).d; - for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; - - 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 AtomVecFull::unpack_exchange(double *buf) -{ - int k; - - 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++]; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_dihedral[nlocal]; k++) { - dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; - dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_improper[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_improper[nlocal]; k++) { - improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; - improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; - for (k = 0; k < nspecial[nlocal][2]; k++) - special[nlocal][k] = (tagint) ubuf(buf[m++]).i; - - 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 AtomVecFull::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 0; - for (i = 0; i < nlocal; i++) - n += 17 + 2*num_bond[i] + 4*num_angle[i] + - 5*num_dihedral[i] + 5*num_improper[i]; - - 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 AtomVecFull::pack_restart(int i, double *buf) -{ - int k; - - 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(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(MAX(angle_type[i][k],-angle_type[i][k])).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(num_dihedral[i]).d; - for (k = 0; k < num_dihedral[i]; k++) { - buf[m++] = ubuf(MAX(dihedral_type[i][k],-dihedral_type[i][k])).d; - buf[m++] = ubuf(dihedral_atom1[i][k]).d; - buf[m++] = ubuf(dihedral_atom2[i][k]).d; - buf[m++] = ubuf(dihedral_atom3[i][k]).d; - buf[m++] = ubuf(dihedral_atom4[i][k]).d; - } - - buf[m++] = ubuf(num_improper[i]).d; - for (k = 0; k < num_improper[i]; k++) { - buf[m++] = ubuf(MAX(improper_type[i][k],-improper_type[i][k])).d; - buf[m++] = ubuf(improper_atom1[i][k]).d; - buf[m++] = ubuf(improper_atom2[i][k]).d; - buf[m++] = ubuf(improper_atom3[i][k]).d; - buf[m++] = ubuf(improper_atom4[i][k]).d; - } - - 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 + initialize other atom quantities ------------------------------------------------------------------------- */ int AtomVecFull::unpack_restart(double *buf) { - int k; + AtomVec::unpack_restart(buf); + int ilocal = atom->nlocal-1; - 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++]; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_dihedral[nlocal]; k++) { - dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; - dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_improper[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_improper[nlocal]; k++) { - improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; - improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 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 AtomVecFull::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; - molecule[nlocal] = 0; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; - - atom->nlocal++; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ void AtomVecFull::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); - - q[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; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecFull::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - q[nlocal] = utils::numeric(FLERR,values[1],true,lmp); - - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - - return 2; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecFull::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; - buf[i][3] = q[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; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecFull::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - buf[1] = q[i]; - return 2; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecFull::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %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, - 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 AtomVecFull::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT " %-1.16e",(tagint) ubuf(buf[0]).i,buf[1]); - return 2; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecFull::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("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); - if (atom->memcheck("special")) - bytes += memory->usage(special,nmax,atom->maxspecial); - - if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); - if (atom->memcheck("bond_type")) - bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); - if (atom->memcheck("bond_atom")) - bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - - if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); - if (atom->memcheck("angle_type")) - bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom1")) - bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom2")) - bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom3")) - bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); - - if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); - if (atom->memcheck("dihedral_type")) - bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom1")) - bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom2")) - bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom3")) - bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom4")) - bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); - - if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); - if (atom->memcheck("improper_type")) - bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom1")) - bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom2")) - bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom3")) - bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom4")) - bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); - - return bytes; + atom->num_bond[ilocal] = 0; + atom->num_angle[ilocal] = 0; + atom->num_dihedral[ilocal] = 0; + atom->num_improper[ilocal] = 0; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_full.h b/src/MOLECULE/atom_vec_full.h index abaf570b17..b194a86994 100644 --- a/src/MOLECULE/atom_vec_full.h +++ b/src/MOLECULE/atom_vec_full.h @@ -27,57 +27,14 @@ namespace LAMMPS_NS { class AtomVecFull : public AtomVec { public: AtomVecFull(class LAMMPS *); - virtual ~AtomVecFull() {} - 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 *); - 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 *); - 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(); + ~AtomVecFull(); 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(); - protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *q; - tagint *molecule; - int **nspecial; - tagint **special; - int *num_bond; - int **bond_type; - tagint **bond_atom; - int *num_angle; - int **angle_type; - tagint **angle_atom1,**angle_atom2,**angle_atom3; - int *num_dihedral; - int **dihedral_type; - tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; - int *num_improper; - int **improper_type; - tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; + private: + int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; + int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative; }; } @@ -87,13 +44,4 @@ class AtomVecFull : 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. - */ diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index 73cec70456..dad7c5cea6 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -13,13 +13,6 @@ #include "atom_vec_molecular.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; @@ -31,1056 +24,204 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 7; - size_velocity = 3; - size_data_atom = 6; - size_data_vel = 4; - xcol_data = 4; - atom->molecule_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 *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4 " + "nspecial special"; + fields_copy = (char *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4 " + "nspecial special"; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = (char *) "molecule"; + fields_border_vel = (char *) "molecule"; + fields_exchange = (char *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4 " + "nspecial special"; + fields_restart = (char *) + "molecule num_bond bond_type bond_atom " + "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " + "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " + "dihedral_atom3 dihedral_atom4 " + "num_improper improper_type improper_atom1 improper_atom2 " + "improper_atom3 improper_atom4"; + fields_create = (char *) + "molecule num_bond num_angle num_dihedral num_improper nspecial"; + fields_data_atom = (char *) "id molecule type x"; + fields_data_vel = NULL; + + setup_fields(); + + bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; + bond_negative = angle_negative = dihedral_negative = improper_negative = NULL; +} + +/* ---------------------------------------------------------------------- */ + +AtomVecMolecular::~AtomVecMolecular() +{ + delete [] bond_negative; + delete [] angle_negative; + delete [] dihedral_negative; + delete [] improper_negative; } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + pack atom I's data for restart file + modify/unmodify values for default AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecMolecular::grow(int n) +int AtomVecMolecular::pack_restart(int i, double *buf) { - 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"); + // insure negative vectors are needed length - 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"); - - nspecial = memory->grow(atom->nspecial,nmax,3,"atom:nspecial"); - special = memory->grow(atom->special,nmax,atom->maxspecial,"atom:special"); - - num_bond = memory->grow(atom->num_bond,nmax,"atom:num_bond"); - bond_type = memory->grow(atom->bond_type,nmax,atom->bond_per_atom, - "atom:bond_type"); - bond_atom = memory->grow(atom->bond_atom,nmax,atom->bond_per_atom, - "atom:bond_atom"); - - num_angle = memory->grow(atom->num_angle,nmax,"atom:num_angle"); - angle_type = memory->grow(atom->angle_type,nmax,atom->angle_per_atom, - "atom:angle_type"); - angle_atom1 = memory->grow(atom->angle_atom1,nmax,atom->angle_per_atom, - "atom:angle_atom1"); - angle_atom2 = memory->grow(atom->angle_atom2,nmax,atom->angle_per_atom, - "atom:angle_atom2"); - angle_atom3 = memory->grow(atom->angle_atom3,nmax,atom->angle_per_atom, - "atom:angle_atom3"); - - num_dihedral = memory->grow(atom->num_dihedral,nmax,"atom:num_dihedral"); - dihedral_type = memory->grow(atom->dihedral_type,nmax, - atom->dihedral_per_atom,"atom:dihedral_type"); - dihedral_atom1 = - memory->grow(atom->dihedral_atom1,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom1"); - dihedral_atom2 = - memory->grow(atom->dihedral_atom2,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom2"); - dihedral_atom3 = - memory->grow(atom->dihedral_atom3,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom3"); - dihedral_atom4 = - memory->grow(atom->dihedral_atom4,nmax,atom->dihedral_per_atom, - "atom:dihedral_atom4"); - - num_improper = memory->grow(atom->num_improper,nmax,"atom:num_improper"); - improper_type = - memory->grow(atom->improper_type,nmax,atom->improper_per_atom, - "atom:improper_type"); - improper_atom1 = - memory->grow(atom->improper_atom1,nmax,atom->improper_per_atom, - "atom:improper_atom1"); - improper_atom2 = - memory->grow(atom->improper_atom2,nmax,atom->improper_per_atom, - "atom:improper_atom2"); - improper_atom3 = - memory->grow(atom->improper_atom3,nmax,atom->improper_per_atom, - "atom:improper_atom3"); - improper_atom4 = - memory->grow(atom->improper_atom4,nmax,atom->improper_per_atom, - "atom:improper_atom4"); - - 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 AtomVecMolecular::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; - nspecial = atom->nspecial; special = atom->special; - num_bond = atom->num_bond; bond_type = atom->bond_type; - bond_atom = atom->bond_atom; - num_angle = atom->num_angle; angle_type = atom->angle_type; - angle_atom1 = atom->angle_atom1; angle_atom2 = atom->angle_atom2; - angle_atom3 = atom->angle_atom3; - num_dihedral = atom->num_dihedral; dihedral_type = atom->dihedral_type; - dihedral_atom1 = atom->dihedral_atom1; dihedral_atom2 = atom->dihedral_atom2; - dihedral_atom3 = atom->dihedral_atom3; dihedral_atom4 = atom->dihedral_atom4; - num_improper = atom->num_improper; improper_type = atom->improper_type; - improper_atom1 = atom->improper_atom1; improper_atom2 = atom->improper_atom2; - improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecMolecular::copy(int i, int j, int delflag) -{ - int k; - - 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]; - - num_bond[j] = num_bond[i]; - for (k = 0; k < num_bond[j]; k++) { - bond_type[j][k] = bond_type[i][k]; - bond_atom[j][k] = bond_atom[i][k]; + if (bond_per_atom < atom->bond_per_atom) { + delete [] bond_negative; + bond_per_atom = atom->bond_per_atom; + bond_negative = new int[bond_per_atom]; + } + if (angle_per_atom < atom->angle_per_atom) { + delete [] angle_negative; + angle_per_atom = atom->angle_per_atom; + angle_negative = new int[angle_per_atom]; + } + if (dihedral_per_atom < atom->dihedral_per_atom) { + delete [] dihedral_negative; + dihedral_per_atom = atom->dihedral_per_atom; + dihedral_negative = new int[dihedral_per_atom]; + } + if (improper_per_atom < atom->improper_per_atom) { + delete [] improper_negative; + improper_per_atom = atom->improper_per_atom; + improper_negative = new int[improper_per_atom]; } - num_angle[j] = num_angle[i]; - for (k = 0; k < num_angle[j]; k++) { - angle_type[j][k] = angle_type[i][k]; - angle_atom1[j][k] = angle_atom1[i][k]; - angle_atom2[j][k] = angle_atom2[i][k]; - angle_atom3[j][k] = angle_atom3[i][k]; + // flip any negative types to positive and flag which ones + + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + int *num_angle = atom->num_angle; + int **angle_type = atom->angle_type; + int *num_dihedral = atom->num_dihedral; + int **dihedral_type = atom->dihedral_type; + int *num_improper = atom->num_improper; + int **improper_type = atom->improper_type; + + int any_bond_negative = 0; + for (int m = 0; m < num_bond[i]; m++) { + if (bond_type[i][m] < 0) { + bond_negative[m] = 1; + bond_type[i][m] = -bond_type[i][m]; + any_bond_negative = 1; + } else bond_negative[m] = 0; } - num_dihedral[j] = num_dihedral[i]; - for (k = 0; k < num_dihedral[j]; k++) { - dihedral_type[j][k] = dihedral_type[i][k]; - dihedral_atom1[j][k] = dihedral_atom1[i][k]; - dihedral_atom2[j][k] = dihedral_atom2[i][k]; - dihedral_atom3[j][k] = dihedral_atom3[i][k]; - dihedral_atom4[j][k] = dihedral_atom4[i][k]; + int any_angle_negative = 0; + for (int m = 0; m < num_angle[i]; m++) { + if (angle_type[i][m] < 0) { + angle_negative[m] = 1; + angle_type[i][m] = -angle_type[i][m]; + any_angle_negative = 1; + } else angle_negative[m] = 0; } - num_improper[j] = num_improper[i]; - for (k = 0; k < num_improper[j]; k++) { - improper_type[j][k] = improper_type[i][k]; - improper_atom1[j][k] = improper_atom1[i][k]; - improper_atom2[j][k] = improper_atom2[i][k]; - improper_atom3[j][k] = improper_atom3[i][k]; - improper_atom4[j][k] = improper_atom4[i][k]; + int any_dihedral_negative = 0; + for (int m = 0; m < num_dihedral[i]; m++) { + if (dihedral_type[i][m] < 0) { + dihedral_negative[m] = 1; + dihedral_type[i][m] = -dihedral_type[i][m]; + any_dihedral_negative = 1; + } else dihedral_negative[m] = 0; } - nspecial[j][0] = nspecial[i][0]; - nspecial[j][1] = nspecial[i][1]; - nspecial[j][2] = nspecial[i][2]; - for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k]; - - 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 AtomVecMolecular::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMolecular::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMolecular::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMolecular::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMolecular::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 AtomVecMolecular::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 AtomVecMolecular::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; - } - } 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; - } + int any_improper_negative = 0; + for (int m = 0; m < num_improper[i]; m++) { + if (improper_type[i][m] < 0) { + improper_negative[m] = 1; + improper_type[i][m] = -improper_type[i][m]; + any_improper_negative = 1; + } else improper_negative[m] = 0; } - 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]); + // perform the pack with adjusted values - return m; -} + int n = AtomVec::pack_restart(i,buf); -/* ---------------------------------------------------------------------- */ + // restore the flagged types to their negative values -int AtomVecMolecular::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++] = 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 (!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++] = 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++] = ubuf(molecule[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]; - } - } - } + if (any_bond_negative) { + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][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 AtomVecMolecular::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; + if (any_angle_negative) { + for (int m = 0; m < num_angle[i]; m++) + if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMolecular::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; + if (any_dihedral_negative) { + for (int m = 0; m < num_dihedral[i]; m++) + if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][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 AtomVecMolecular::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; + if (any_improper_negative) { + for (int m = 0; m < num_improper[i]; m++) + if (improper_negative[m]) improper_type[i][m] = -improper_type[i][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 AtomVecMolecular::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - molecule[i] = (tagint) ubuf(buf[m++]).i; - 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 AtomVecMolecular::pack_exchange(int i, double *buf) -{ - int k; - - 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++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(bond_type[i][k]).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(angle_type[i][k]).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(num_dihedral[i]).d; - for (k = 0; k < num_dihedral[i]; k++) { - buf[m++] = ubuf(dihedral_type[i][k]).d; - buf[m++] = ubuf(dihedral_atom1[i][k]).d; - buf[m++] = ubuf(dihedral_atom2[i][k]).d; - buf[m++] = ubuf(dihedral_atom3[i][k]).d; - buf[m++] = ubuf(dihedral_atom4[i][k]).d; - } - - buf[m++] = ubuf(num_improper[i]).d; - for (k = 0; k < num_improper[i]; k++) { - buf[m++] = ubuf(improper_type[i][k]).d; - buf[m++] = ubuf(improper_atom1[i][k]).d; - buf[m++] = ubuf(improper_atom2[i][k]).d; - buf[m++] = ubuf(improper_atom3[i][k]).d; - buf[m++] = ubuf(improper_atom4[i][k]).d; - } - - buf[m++] = ubuf(nspecial[i][0]).d; - buf[m++] = ubuf(nspecial[i][1]).d; - buf[m++] = ubuf(nspecial[i][2]).d; - for (k = 0; k < nspecial[i][2]; k++) buf[m++] = ubuf(special[i][k]).d; - - 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 AtomVecMolecular::unpack_exchange(double *buf) -{ - int k; - - 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; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_dihedral[nlocal]; k++) { - dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; - dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_improper[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_improper[nlocal]; k++) { - improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; - improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][1] = (int) ubuf(buf[m++]).i; - nspecial[nlocal][2] = (int) ubuf(buf[m++]).i; - for (k = 0; k < nspecial[nlocal][2]; k++) - special[nlocal][k] = (int) ubuf(buf[m++]).i; - - 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 AtomVecMolecular::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 0; - for (i = 0; i < nlocal; i++) - n += 16 + 2*num_bond[i] + 4*num_angle[i] + - 5*num_dihedral[i] + 5*num_improper[i]; - - 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 AtomVecMolecular::pack_restart(int i, double *buf) -{ - int k; - - 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++] = ubuf(molecule[i]).d; - - buf[m++] = ubuf(num_bond[i]).d; - for (k = 0; k < num_bond[i]; k++) { - buf[m++] = ubuf(MAX(bond_type[i][k],-bond_type[i][k])).d; - buf[m++] = ubuf(bond_atom[i][k]).d; - } - - buf[m++] = ubuf(num_angle[i]).d; - for (k = 0; k < num_angle[i]; k++) { - buf[m++] = ubuf(MAX(angle_type[i][k],-angle_type[i][k])).d; - buf[m++] = ubuf(angle_atom1[i][k]).d; - buf[m++] = ubuf(angle_atom2[i][k]).d; - buf[m++] = ubuf(angle_atom3[i][k]).d; - } - - buf[m++] = ubuf(num_dihedral[i]).d; - for (k = 0; k < num_dihedral[i]; k++) { - buf[m++] = ubuf(MAX(dihedral_type[i][k],-dihedral_type[i][k])).d; - buf[m++] = ubuf(dihedral_atom1[i][k]).d; - buf[m++] = ubuf(dihedral_atom2[i][k]).d; - buf[m++] = ubuf(dihedral_atom3[i][k]).d; - buf[m++] = ubuf(dihedral_atom4[i][k]).d; - } - - buf[m++] = ubuf(num_improper[i]).d; - for (k = 0; k < num_improper[i]; k++) { - buf[m++] = ubuf(MAX(improper_type[i][k],-improper_type[i][k])).d; - buf[m++] = ubuf(improper_atom1[i][k]).d; - buf[m++] = ubuf(improper_atom2[i][k]).d; - buf[m++] = ubuf(improper_atom3[i][k]).d; - buf[m++] = ubuf(improper_atom4[i][k]).d; - } - - 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 + initialize other atom quantities ------------------------------------------------------------------------- */ int AtomVecMolecular::unpack_restart(double *buf) { - int k; + AtomVec::unpack_restart(buf); + int ilocal = atom->nlocal-1; - 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++]; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - - num_bond[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_bond[nlocal]; k++) { - bond_type[nlocal][k] = (int) ubuf(buf[m++]).i; - bond_atom[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_angle[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_angle[nlocal]; k++) { - angle_type[nlocal][k] = (int) ubuf(buf[m++]).i; - angle_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - angle_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_dihedral[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_dihedral[nlocal]; k++) { - dihedral_type[nlocal][k] = (int) ubuf(buf[m++]).i; - dihedral_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - dihedral_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - num_improper[nlocal] = (int) ubuf(buf[m++]).i; - for (k = 0; k < num_improper[nlocal]; k++) { - improper_type[nlocal][k] = (int) ubuf(buf[m++]).i; - improper_atom1[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom2[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom3[nlocal][k] = (tagint) ubuf(buf[m++]).i; - improper_atom4[nlocal][k] = (tagint) ubuf(buf[m++]).i; - } - - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 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 AtomVecMolecular::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; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; - - atom->nlocal++; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecMolecular::data_atom(double *coord, imageint imagetmp, - char **values) +void AtomVecMolecular::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); - - 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; - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecMolecular::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - - num_bond[nlocal] = 0; - num_angle[nlocal] = 0; - num_dihedral[nlocal] = 0; - num_improper[nlocal] = 0; - - return 1; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecMolecular::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; - 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 AtomVecMolecular::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - return 1; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecMolecular::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %-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, - 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 AtomVecMolecular::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT,(tagint) ubuf(buf[0]).i); - return 1; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecMolecular::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("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("nspecial")) bytes += memory->usage(nspecial,nmax,3); - if (atom->memcheck("special")) - bytes += memory->usage(special,nmax,atom->maxspecial); - - if (atom->memcheck("num_bond")) bytes += memory->usage(num_bond,nmax); - if (atom->memcheck("bond_type")) - bytes += memory->usage(bond_type,nmax,atom->bond_per_atom); - if (atom->memcheck("bond_atom")) - bytes += memory->usage(bond_atom,nmax,atom->bond_per_atom); - - if (atom->memcheck("num_angle")) bytes += memory->usage(num_angle,nmax); - if (atom->memcheck("angle_type")) - bytes += memory->usage(angle_type,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom1")) - bytes += memory->usage(angle_atom1,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom2")) - bytes += memory->usage(angle_atom2,nmax,atom->angle_per_atom); - if (atom->memcheck("angle_atom3")) - bytes += memory->usage(angle_atom3,nmax,atom->angle_per_atom); - - if (atom->memcheck("num_dihedral")) bytes += memory->usage(num_dihedral,nmax); - if (atom->memcheck("dihedral_type")) - bytes += memory->usage(dihedral_type,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom1")) - bytes += memory->usage(dihedral_atom1,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom2")) - bytes += memory->usage(dihedral_atom2,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom3")) - bytes += memory->usage(dihedral_atom3,nmax,atom->dihedral_per_atom); - if (atom->memcheck("dihedral_atom4")) - bytes += memory->usage(dihedral_atom4,nmax,atom->dihedral_per_atom); - - if (atom->memcheck("num_improper")) bytes += memory->usage(num_improper,nmax); - if (atom->memcheck("improper_type")) - bytes += memory->usage(improper_type,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom1")) - bytes += memory->usage(improper_atom1,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom2")) - bytes += memory->usage(improper_atom2,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom3")) - bytes += memory->usage(improper_atom3,nmax,atom->improper_per_atom); - if (atom->memcheck("improper_atom4")) - bytes += memory->usage(improper_atom4,nmax,atom->improper_per_atom); - - return bytes; + atom->num_bond[ilocal] = 0; + atom->num_angle[ilocal] = 0; + atom->num_dihedral[ilocal] = 0; + atom->num_improper[ilocal] = 0; + atom->nspecial[ilocal][0] = 0; + atom->nspecial[ilocal][1] = 0; + atom->nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_molecular.h b/src/MOLECULE/atom_vec_molecular.h index 19104c3987..cba6d1b480 100644 --- a/src/MOLECULE/atom_vec_molecular.h +++ b/src/MOLECULE/atom_vec_molecular.h @@ -27,55 +27,14 @@ namespace LAMMPS_NS { class AtomVecMolecular : public AtomVec { public: AtomVecMolecular(class LAMMPS *); - 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 *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int pack_reverse(int, int, double *); - void unpack_reverse(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(); + ~AtomVecMolecular(); 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(); private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - tagint *molecule; - int **nspecial; - tagint **special; - int *num_bond; - int **bond_type; - tagint **bond_atom; - int *num_angle; - int **angle_type; - tagint **angle_atom1,**angle_atom2,**angle_atom3; - int *num_dihedral; - int **dihedral_type; - tagint **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; - int *num_improper; - int **improper_type; - tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; + int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; + int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative; }; } @@ -85,13 +44,4 @@ class AtomVecMolecular : 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. - */ diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index c9ccfc6d2b..31d9af4caf 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -31,16 +31,27 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp) molecular = 2; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 9; - size_velocity = 3; - size_data_atom = 8; - size_data_vel = 4; - xcol_data = 6; - atom->molecule_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 *) "molecule molindex molatom"; + fields_copy = (char *) "molecule molindex molatom"; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = (char *) "molecule molindex molatom"; + fields_border_vel = (char *) "molecule molindex molatom"; + fields_exchange = (char *) "molecule molindex molatom"; + fields_restart = (char *) "molecule molindex molatom"; + fields_create = (char *) "molecule molindex molatom"; + fields_data_atom = (char *) "id molecule molindex molatom type x"; + fields_data_vel = NULL; + + setup_fields(); } /* ---------------------------------------------------------------------- @@ -85,786 +96,35 @@ void AtomVecTemplate::process_args(int narg, char **arg) } } -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecTemplate::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"); - molindex = memory->grow(atom->molindex,nmax,"atom:molindex"); - molatom = memory->grow(atom->molatom,nmax,"atom:molatom"); - - 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 AtomVecTemplate::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; - molindex = atom->molindex; molatom = atom->molatom; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecTemplate::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]; - - molecule[j] = molecule[i]; - molindex[j] = molindex[i]; - molatom[j] = molatom[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 AtomVecTemplate::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTemplate::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTemplate::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTemplate::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTemplate::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 AtomVecTemplate::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 AtomVecTemplate::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++] = ubuf(molindex[j]).d; - buf[m++] = ubuf(molatom[j]).d; - } - } 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++] = ubuf(molindex[j]).d; - buf[m++] = ubuf(molatom[j]).d; - } - } - - 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 AtomVecTemplate::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++] = ubuf(molindex[j]).d; - buf[m++] = ubuf(molatom[j]).d; - 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 (!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++] = ubuf(molindex[j]).d; - buf[m++] = ubuf(molatom[j]).d; - 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++] = ubuf(molecule[j]).d; - buf[m++] = ubuf(molindex[j]).d; - buf[m++] = ubuf(molatom[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]; - } - } - } - } - - 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 AtomVecTemplate::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++] = ubuf(molindex[j]).d; - buf[m++] = ubuf(molatom[j]).d; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTemplate::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - molindex[i] = (int) ubuf(buf[m++]).i; - molatom[i] = (int) ubuf(buf[m++]).i; - } - - 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 AtomVecTemplate::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; - molecule[i] = (tagint) ubuf(buf[m++]).i; - molindex[i] = (int) ubuf(buf[m++]).i; - molatom[i] = (int) ubuf(buf[m++]).i; - 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 AtomVecTemplate::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - molecule[i] = (tagint) ubuf(buf[m++]).i; - molindex[i] = (int) ubuf(buf[m++]).i; - molatom[i] = (int) ubuf(buf[m++]).i; - } - 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 AtomVecTemplate::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++] = ubuf(molecule[i]).d; - buf[m++] = ubuf(molindex[i]).d; - buf[m++] = ubuf(molatom[i]).d; - - 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 AtomVecTemplate::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; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - molindex[nlocal] = (int) ubuf(buf[m++]).i; - molatom[nlocal] = (int) ubuf(buf[m++]).i; - - 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 AtomVecTemplate::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 14 * nlocal; - - 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 AtomVecTemplate::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++] = ubuf(molecule[i]).d; - buf[m++] = ubuf(molindex[i]).d; - buf[m++] = ubuf(molatom[i]).d; - - 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 AtomVecTemplate::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++]; - - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; - molindex[nlocal] = (int) ubuf(buf[m++]).i; - molatom[nlocal] = (int) ubuf(buf[m++]).i; - - 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 + modify what default AtomVec::create_atom() just created ------------------------------------------------------------------------- */ void AtomVecTemplate::create_atom(int itype, double *coord) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::create_atom(itype,coord); - 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; - molindex[nlocal] = -1; - molatom[nlocal] = -1; - - atom->nlocal++; + int ilocal = atom->nlocal-1; + atom->molindex[ilocal] = -1; + atom->molatom[ilocal] = -1; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + error check what default AtomVec::data_atom() just unpacked ------------------------------------------------------------------------- */ void AtomVecTemplate::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); - tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - if (tag[nlocal] <= 0) - error->one(FLERR,"Invalid atom ID in Atoms section of data file"); + int ilocal = atom->nlocal-1; + int molindex = atom->molindex[ilocal]; + int molatom = atom->molatom[ilocal]; - molecule[nlocal] = utils::tnumeric(FLERR,values[1],true,lmp); - molindex[nlocal] = utils::inumeric(FLERR,values[2],true,lmp) - 1; - molatom[nlocal] = utils::inumeric(FLERR,values[3],true,lmp) - 1; - - if (molindex[nlocal] < 0 || molindex[nlocal] >= nset) + if (molindex < 0 || molindex >= nset) error->one(FLERR,"Invalid template index in Atoms section of data file"); - if (molatom[nlocal] < 0 || - molatom[nlocal] >= onemols[molindex[nlocal]]->natoms) + if (molatom < 0 || molatom >= onemols[molindex]->natoms) error->one(FLERR,"Invalid template atom in Atoms section of data file"); - - type[nlocal] = utils::inumeric(FLERR,values[4],true,lmp); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type 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; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecTemplate::data_atom_hybrid(int nlocal, char **values) -{ - molecule[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp); - molindex[nlocal] = utils::inumeric(FLERR,values[1],true,lmp) - 1; - molatom[nlocal] = utils::inumeric(FLERR,values[2],true,lmp) - 1; - return 3; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecTemplate::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(molindex[i]+1).d; - buf[i][3] = ubuf(molatom[i]+1).d; - buf[i][4] = ubuf(type[i]).d; - 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 AtomVecTemplate::pack_data_hybrid(int i, double *buf) -{ - buf[0] = ubuf(molecule[i]).d; - buf[1] = ubuf(molindex[i]+1).d; - buf[2] = ubuf(molatom[i]+1).d; - return 3; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecTemplate::write_data(FILE *fp, int n, double **buf) -{ - for (int i = 0; i < n; i++) - fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT - " %d %d %d %-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, - (int) ubuf(buf[i][4]).i, - 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 AtomVecTemplate::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," " TAGINT_FORMAT " %d %d", - (tagint) ubuf(buf[0]).i,(int) ubuf(buf[1]).i,(int) ubuf(buf[2]).i); - return 3; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecTemplate::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("molecule")) bytes += memory->usage(molecule,nmax); - if (atom->memcheck("molindex")) bytes += memory->usage(molindex,nmax); - if (atom->memcheck("molatom")) bytes += memory->usage(molatom,nmax); - - return bytes; } diff --git a/src/MOLECULE/atom_vec_template.h b/src/MOLECULE/atom_vec_template.h index eee7fa9723..59a1386f2d 100644 --- a/src/MOLECULE/atom_vec_template.h +++ b/src/MOLECULE/atom_vec_template.h @@ -27,44 +27,9 @@ namespace LAMMPS_NS { class AtomVecTemplate : public AtomVec { public: AtomVecTemplate(class LAMMPS *); - virtual ~AtomVecTemplate() {} void process_args(int, char **); - 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 *); - 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 *); - 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 *, tagint, 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(); - - protected: - tagint *tag; - int *type,*mask; - tagint *image; - double **x,**v,**f; - tagint *molecule; - int *molindex,*molatom; + void data_atom(double *, imageint, char **); }; } @@ -88,15 +53,6 @@ E: Atom style template molecule must have atom types The defined molecule(s) does not specify atom types. -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 ID in Atoms section of data file - -Atom IDs must be positive integers. - E: Invalid template index in Atoms section of data file The template indices must be between 1 to N, where N is the number of @@ -107,8 +63,4 @@ E: Invalid template atom in Atoms section of data file The atom indices must be between 1 to N, where N is the number of atoms in the template molecule the atom belongs to. -E: Invalid atom type in Atoms section of data file - -Atom types must range from 1 to specified # of types. - */ diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 3e3312bf01..29c4cb0d83 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -19,14 +19,9 @@ #include #include #include "atom.h" -#include "comm.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" #include "citeme.h" #include "memory.h" #include "error.h" -#include "utils.h" using namespace LAMMPS_NS; @@ -49,859 +44,67 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) molecular = 0; - comm_x_only = 0; - comm_f_only = 1; - size_forward = 4; - size_reverse = 3; - size_border = 12; - size_velocity = 3; - size_data_atom = 7; - size_data_vel = 4; - xcol_data = 5; - + atom->rmass_flag = 1; atom->peri_flag = 1; - atom->vfrac_flag = atom->rmass_flag = 1; -} - -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecPeri::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"); - - vfrac = memory->grow(atom->vfrac,nmax,"atom:vfrac"); - rmass = memory->grow(atom->rmass,nmax,"atom:rmass"); - s0 = memory->grow(atom->s0,nmax,"atom:s0"); - x0 = memory->grow(atom->x0,nmax,3,"atom:x0"); - - 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 AtomVecPeri::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - vfrac = atom->vfrac; rmass = atom->rmass; - s0 = atom->s0; x0 = atom->x0; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecPeri::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]; - - vfrac[j] = vfrac[i]; - rmass[j] = rmass[i]; - s0[j] = s0[i]; - x0[j][0] = x0[i][0]; - x0[j][1] = x0[i][1]; - x0[j][2] = x0[i][2]; - - 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 AtomVecPeri::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++] = s0[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++] = s0[j]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecPeri::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++] = s0[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++] = s0[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++] = s0[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 AtomVecPeri::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++] = s0[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecPeri::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++]; - s0[i] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecPeri::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++]; - s0[i] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecPeri::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - s0[i] = buf[m++]; - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecPeri::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 AtomVecPeri::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 AtomVecPeri::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++] = vfrac[j]; - buf[m++] = rmass[j]; - buf[m++] = s0[j]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[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]; - } - 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++] = vfrac[j]; - buf[m++] = rmass[j]; - buf[m++] = s0[j]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[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 AtomVecPeri::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++] = vfrac[j]; - buf[m++] = rmass[j]; - buf[m++] = s0[j]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; - 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 (!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++] = vfrac[j]; - buf[m++] = rmass[j]; - buf[m++] = s0[j]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; - 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++] = vfrac[j]; - buf[m++] = rmass[j]; - buf[m++] = s0[j]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][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]; - } - } - } - } - - 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 AtomVecPeri::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++] = vfrac[j]; - buf[m++] = rmass[j]; - buf[m++] = s0[j]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecPeri::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; - vfrac[i] = buf[m++]; - rmass[i] = buf[m++]; - s0[i] = buf[m++]; - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[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]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecPeri::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; - vfrac[i] = buf[m++]; - rmass[i] = buf[m++]; - s0[i] = buf[m++]; - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = 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 AtomVecPeri::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - vfrac[i] = buf[m++]; - rmass[i] = buf[m++]; - s0[i] = buf[m++]; - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = 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 AtomVecPeri::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++] = vfrac[i]; - buf[m++] = rmass[i]; - buf[m++] = s0[i]; - buf[m++] = x0[i][0]; - buf[m++] = x0[i][1]; - buf[m++] = x0[i][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 AtomVecPeri::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; - - vfrac[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - s0[nlocal] = buf[m++]; - x0[nlocal][0] = buf[m++]; - x0[nlocal][1] = buf[m++]; - x0[nlocal][2] = 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 AtomVecPeri::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 17 * nlocal; - - 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 AtomVecPeri::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++] = vfrac[i]; - buf[m++] = rmass[i]; - buf[m++] = s0[i]; - buf[m++] = x0[i][0]; - buf[m++] = x0[i][1]; - buf[m++] = x0[i][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 -------------------------------------------------------------------------- */ - -int AtomVecPeri::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++]; - - vfrac[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - s0[nlocal] = buf[m++]; - x0[nlocal][0] = buf[m++]; - x0[nlocal][1] = buf[m++]; - x0[nlocal][2] = 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; + atom->vfrac_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 *) "rmass vfrac s0 x0"; + fields_copy = (char *) "rmass vfrac s0 x0"; + fields_comm = (char *) "s0"; + fields_comm_vel = (char *) "s0"; + fields_reverse = NULL; + fields_border = (char *) "rmass vfrac s0 x0"; + fields_border_vel = (char *) "rmass vfrac s0 x0"; + fields_exchange = (char *) "rmass vfrac s0 x0"; + fields_restart = (char *) "rmass vfrac s0 x0"; + fields_create = (char *) "rmass vfrac s0 x0"; + fields_data_atom = (char *) "id type vfrac rmass x"; + fields_data_vel = (char *) "omega"; + + setup_fields(); } /* ---------------------------------------------------------------------- create one atom of itype at coord - set other values to defaults + modify what default AtomVec::create_atom() just created ------------------------------------------------------------------------- */ void AtomVecPeri::create_atom(int itype, double *coord) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::create_atom(itype,coord); + int ilocal = atom->nlocal-1; - 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; - - vfrac[nlocal] = 1.0; - rmass[nlocal] = 1.0; - s0[nlocal] = DBL_MAX; - x0[nlocal][0] = coord[0]; - x0[nlocal][1] = coord[1]; - x0[nlocal][2] = coord[2]; - - atom->nlocal++; + 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]; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ void AtomVecPeri::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); + atom->s0[ilocal] = DBL_MAX; + atom->x0[ilocal][0] = coord[0]; + atom->x0[ilocal][1] = coord[1]; + atom->x0[ilocal][2] = coord[2]; - vfrac[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - rmass[nlocal] = utils::numeric(FLERR,values[3],true,lmp); - if (rmass[nlocal] <= 0.0) error->one(FLERR,"Invalid mass value"); - - 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; - - s0[nlocal] = DBL_MAX; - x0[nlocal][0] = coord[0]; - x0[nlocal][1] = coord[1]; - x0[nlocal][2] = coord[2]; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecPeri::data_atom_hybrid(int nlocal, char **values) -{ - vfrac[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - rmass[nlocal] = utils::numeric(FLERR,values[1],true,lmp); - if (rmass[nlocal] <= 0.0) error->one(FLERR,"Invalid mass value"); - - s0[nlocal] = DBL_MAX; - x0[nlocal][0] = x[nlocal][0]; - x0[nlocal][1] = x[nlocal][1]; - x0[nlocal][2] = x[nlocal][2]; - - return 2; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecPeri::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] = vfrac[i]; - 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; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecPeri::pack_data_hybrid(int i, double *buf) -{ - buf[0] = vfrac[i]; - buf[1] = rmass[i]; - return 2; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecPeri::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); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecPeri::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e",buf[0],buf[1]); - return 2; + if (atom->rmass[ilocal] <= 0.0) + error->one(FLERR,"Invalid mass in Atoms section of data file"); } /* ---------------------------------------------------------------------- @@ -929,12 +132,14 @@ void AtomVecPeri::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { + double *vfrac = atom->vfrac; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = vfrac[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { + double *s0 = atom->s0; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = s0[i]; else buf[n] = 0.0; @@ -942,27 +147,3 @@ void AtomVecPeri::pack_property_atom(int index, double *buf, } } } - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecPeri::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("vfrac")) bytes += memory->usage(vfrac,nmax); - if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); - if (atom->memcheck("s0")) bytes += memory->usage(s0,nmax); - if (atom->memcheck("x0")) bytes += memory->usage(x0,nmax,3); - - return bytes; -} diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 0fc30d6dc2..12ef650348 100644 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -27,45 +27,10 @@ namespace LAMMPS_NS { class AtomVecPeri : public AtomVec { public: AtomVecPeri(class LAMMPS *); - 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 *); - void unpack_reverse(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 pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); 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; - double *vfrac,*rmass,*s0,**x0; }; } @@ -75,17 +40,4 @@ class AtomVecPeri : 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: Invalid mass value - -Self-explanatory. - */ diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index ad1384ffd2..135f8936a1 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -27,13 +27,6 @@ #include #include #include "atom.h" -#include "comm.h" -#include "domain.h" -#include "error.h" -#include "fix.h" -#include "memory.h" -#include "modify.h" -#include "utils.h" using namespace LAMMPS_NS; @@ -45,908 +38,45 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) mass_type = 1; forceclearflag = 1; - comm_x_only = 0; - comm_f_only = 0; - size_forward = 7; - size_reverse = 9; - size_border = 10; - size_velocity = 3; - size_data_atom = 9; - size_data_vel = 4; - xcol_data = 4; - atom->sp_flag = 1; -} -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecSpin::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"); - - // allocating mech. quantities - - 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"); - - // allocating mag. quantities - - sp = memory->grow(atom->sp,nmax,4,"atom:sp"); - fm = memory->grow(atom->fm,nmax*comm->nthreads,3,"atom:fm"); - fm_long = memory->grow(atom->fm_long,nmax*comm->nthreads,3,"atom:fm_long"); - - 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 AtomVecSpin::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - sp = atom->sp; fm = atom->fm; fm_long = atom->fm_long; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecSpin::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]; - - sp[j][0] = sp[i][0]; - sp[j][1] = sp[i][1]; - sp[j][2] = sp[i][2]; - sp[j][3] = sp[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); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSpin::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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][3]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSpin::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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][3]; - 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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][3]; - 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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][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]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSpin::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++] = sp[j][3]; - buf[m++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSpin::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++]; - sp[i][0] = buf[m++]; - sp[i][1] = buf[m++]; - sp[i][2] = buf[m++]; - sp[i][3] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSpin::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++]; - sp[i][0] = buf[m++]; - sp[i][1] = buf[m++]; - sp[i][2] = buf[m++]; - sp[i][3] = buf[m++]; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSpin::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - sp[i][3] = buf[m++]; - sp[i][0] = buf[m++]; - sp[i][1] = buf[m++]; - sp[i][2] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSpin::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++] = fm[i][0]; - buf[m++] = fm[i][1]; - buf[m++] = fm[i][2]; - buf[m++] = fm_long[i][0]; - buf[m++] = fm_long[i][1]; - buf[m++] = fm_long[i][2]; - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSpin::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++]; - fm[j][0] += buf[m++]; - fm[j][1] += buf[m++]; - fm[j][2] += buf[m++]; - fm_long[j][0] += buf[m++]; - fm_long[j][1] += buf[m++]; - fm_long[j][2] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSpin::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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[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 AtomVecSpin::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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][3]; - 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 (!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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][3]; - 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++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - buf[m++] = sp[j][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]; - } - } - } - } - - 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 AtomVecSpin::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++] = sp[j][3]; - buf[m++] = sp[j][0]; - buf[m++] = sp[j][1]; - buf[m++] = sp[j][2]; - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSpin::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; - sp[i][0] = buf[m++]; - sp[i][1] = buf[m++]; - sp[i][2] = buf[m++]; - sp[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 AtomVecSpin::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; - sp[i][0] = buf[m++]; - sp[i][1] = buf[m++]; - sp[i][2] = buf[m++]; - sp[i][3] = 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 AtomVecSpin::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - sp[i][3] = buf[m++]; - sp[i][0] = buf[m++]; - sp[i][1] = buf[m++]; - sp[i][2] = buf[m++]; - } - - return m; -} - -/* ---------------------------------------------------------------------- - pack all atom quantities for shipping to another proc - xyz must be 1st 3 values, so that comm::exchange can test on them -------------------------------------------------------------------------- */ - -int AtomVecSpin::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++] = sp[i][0]; - buf[m++] = sp[i][1]; - buf[m++] = sp[i][2]; - buf[m++] = sp[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 AtomVecSpin::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; - - sp[nlocal][0] = buf[m++]; - sp[nlocal][1] = buf[m++]; - sp[nlocal][2] = buf[m++]; - sp[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; -} - -/* ---------------------------------------------------------------------- - size of restart data for all atoms owned by this proc - include extra data stored by fixes -------------------------------------------------------------------------- */ - -int AtomVecSpin::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 15 * nlocal; - - 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 AtomVecSpin::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++] = sp[i][0]; - buf[m++] = sp[i][1]; - buf[m++] = sp[i][2]; - buf[m++] = sp[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 AtomVecSpin::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++]; - - sp[nlocal][0] = buf[m++]; - sp[nlocal][1] = buf[m++]; - sp[nlocal][2] = buf[m++]; - sp[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 AtomVecSpin::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; - - sp[nlocal][0] = 0.0; - sp[nlocal][1] = 0.0; - sp[nlocal][2] = 0.0; - sp[nlocal][3] = 0.0; - - atom->nlocal++; + // 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 *) "sp fm fm_long"; + fields_copy = (char *) "sp"; + fields_comm = (char *) "sp"; + fields_comm_vel = (char *) "sp"; + fields_reverse = (char *) "fm fm_long"; + fields_border = (char *) "sp"; + fields_border_vel = (char *) "sp"; + fields_exchange = (char *) "sp"; + fields_restart = (char *) "sp"; + fields_create = (char *) "sp"; + fields_data_atom = (char *) "id type x sp"; + fields_data_vel = (char *) "omega"; + + setup_fields(); } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ void AtomVecSpin::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - sp[nlocal][3] = utils::numeric(FLERR,values[2],true,lmp); - sp[nlocal][0] = utils::numeric(FLERR,values[6],true,lmp); - sp[nlocal][1] = utils::numeric(FLERR,values[7],true,lmp); - sp[nlocal][2] = utils::numeric(FLERR,values[8],true,lmp); - double inorm = 1.0/sqrt(sp[nlocal][0]*sp[nlocal][0] + - sp[nlocal][1]*sp[nlocal][1] + - sp[nlocal][2]*sp[nlocal][2]); - sp[nlocal][0] *= inorm; - sp[nlocal][1] *= inorm; - sp[nlocal][2] *= inorm; - - image[nlocal] = imagetmp; - - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[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 AtomVecSpin::data_atom_hybrid(int nlocal, char **values) -{ - - sp[nlocal][0] = utils::numeric(FLERR,values[0],true,lmp); - sp[nlocal][1] = utils::numeric(FLERR,values[1],true,lmp); - sp[nlocal][2] = utils::numeric(FLERR,values[2],true,lmp); - double inorm = 1.0/sqrt(sp[nlocal][0]*sp[nlocal][0] + - sp[nlocal][1]*sp[nlocal][1] + - sp[nlocal][2]*sp[nlocal][2]); - sp[nlocal][0] *= inorm; - sp[nlocal][1] *= inorm; - sp[nlocal][2] *= inorm; - sp[nlocal][3] = utils::numeric(FLERR,values[3],true,lmp); - - return 4; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecSpin::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] = sp[i][3]; - buf[i][3] = x[i][0]; - buf[i][4] = x[i][1]; - buf[i][5] = x[i][2]; - buf[i][6] = sp[i][0]; - buf[i][7] = sp[i][1]; - buf[i][8] = sp[i][2]; - buf[i][9] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][10] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][11] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecSpin::pack_data_hybrid(int i, double *buf) -{ - buf[0] = sp[i][3]; - buf[1] = sp[i][0]; - buf[2] = sp[i][1]; - buf[3] = sp[i][2]; - return 4; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecSpin::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 %-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],buf[i][7],buf[i][8], - (int) ubuf(buf[i][9]).i,(int) ubuf(buf[i][10]).i, - (int) ubuf(buf[i][11]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecSpin::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2],buf[3]); - return 4; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecSpin::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("sp")) bytes += memory->usage(sp,nmax,4); - if (atom->memcheck("fm")) bytes += memory->usage(fm,nmax*comm->nthreads,3); - if (atom->memcheck("fm_long")) bytes += memory->usage(fm_long,nmax*comm->nthreads,3); - - return bytes; + double *sp = atom->sp[ilocal]; + double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]); + sp[0] *= inorm; + sp[1] *= inorm; + sp[2] *= inorm; } /* ---------------------------------------------------------------------- @@ -959,5 +89,3 @@ void AtomVecSpin::force_clear(int /*n*/, size_t nbytes) memset(&atom->fm[0][0],0,3*nbytes); memset(&atom->fm_long[0][0],0,3*nbytes); } - - diff --git a/src/SPIN/atom_vec_spin.h b/src/SPIN/atom_vec_spin.h index 6ce2c9dc7d..ca92cccc2e 100644 --- a/src/SPIN/atom_vec_spin.h +++ b/src/SPIN/atom_vec_spin.h @@ -27,53 +27,8 @@ namespace LAMMPS_NS { class AtomVecSpin : public AtomVec { public: AtomVecSpin(class LAMMPS *); - 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 *); - void unpack_reverse(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 pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); - bigint memory_usage(); - - // clear magnetic and mechanic forces - void force_clear(int, size_t); - - - private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; // lattice quantities - - // spin quantities - double **sp; // sp[i][0-2] direction of the spin i - // sp[i][3] atomic magnetic moment of the spin i - double **fm; // fm[i][0-2] direction of magnetic precession - double **fm_long; // storage of long-range spin prec. components }; } @@ -83,13 +38,4 @@ class AtomVecSpin : 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. - */ diff --git a/src/atom.cpp b/src/atom.cpp index de5d30930a..7f1a5a6022 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -44,9 +44,11 @@ using namespace LAMMPS_NS; using namespace MathConst; #define DELTA 1 -#define DELTA_MEMSTR 1024 +#define DELTA_PERATOM 64 #define EPSILON 1.0e-6 +enum{DOUBLE,INT,BIGINT}; + /* ---------------------------------------------------------------------- */ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) @@ -66,6 +68,11 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) binhead = NULL; next = permute = NULL; + // data structure with info on per-atom vectors/arrays + + nperatom = maxperatom = 0; + peratom = NULL; + // initialize atom arrays // customize by adding new array @@ -193,6 +200,10 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) pdscale = 1.0; + // initialize peratom data structure + + peratom_create(); + // ntype-length arrays mass = NULL; @@ -245,6 +256,12 @@ Atom::~Atom() memory->destroy(next); memory->destroy(permute); + // delete peratom data struct + + for (int i = 0; i < nperatom; i++) + delete [] peratom[i].name; + memory->sfree(peratom); + // delete atom arrays // customize by adding new array @@ -403,6 +420,175 @@ void Atom::settings(Atom *old) } } +/* ---------------------------------------------------------------------- + one-time creation of peratom data structure +------------------------------------------------------------------------- */ + +void Atom::peratom_create() +{ + for (int i = 0; i < nperatom; i++) + delete [] peratom[i].name; + memory->sfree(peratom); + + peratom = NULL; + nperatom = maxperatom = 0; + + // customize: add new peratom variables here, order does not matter + // register tagint & imageint variables as INT or BIGINT + + int tagintsize = INT; + if (sizeof(tagint) == 8) tagintsize = BIGINT; + int imageintsize = INT; + if (sizeof(imageint) == 8) imageintsize = BIGINT; + + add_peratom("id",&tag,tagintsize,0); + add_peratom("type",&type,INT,0); + add_peratom("mask",&mask,INT,0); + add_peratom("image",&image,imageintsize,0); + + add_peratom("x",&x,DOUBLE,3); + add_peratom("v",&v,DOUBLE,3); + add_peratom("f",&f,DOUBLE,3,1); // set per-thread flag + + add_peratom("rmass",&rmass,DOUBLE,0); + add_peratom("q",&q,DOUBLE,0); + add_peratom("mu",&mu,DOUBLE,4); + add_peratom("mu3",&mu,DOUBLE,3); // just first 3 values of mu[4] + + // finite size particles + + 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("ellipsoid",&ellipsoid,INT,0); + add_peratom("line",&line,INT,0); + add_peratom("tri",&tri,INT,0); + add_peratom("body",&body,INT,0); + + // MOLECULE package + + add_peratom("molecule",&molecule,tagintsize,0); + add_peratom("molindex",&molindex,INT,0); + add_peratom("molatom",&molatom,INT,0); + + add_peratom("nspecial",&nspecial,INT,3); + add_peratom_vary("special",&special,tagintsize,&maxspecial,&nspecial,3); + + add_peratom("num_bond",&num_bond,INT,0); + add_peratom_vary("bond_type",&bond_type,INT,&bond_per_atom,&num_bond); + add_peratom_vary("bond_atom",&bond_atom,tagintsize,&bond_per_atom,&num_bond); + + add_peratom("num_angle",&num_angle,INT,0); + add_peratom_vary("angle_type",&angle_type,INT,&angle_per_atom,&num_angle); + add_peratom_vary("angle_atom1",&angle_atom1,tagintsize, + &angle_per_atom,&num_angle); + add_peratom_vary("angle_atom2",&angle_atom2,tagintsize, + &angle_per_atom,&num_angle); + add_peratom_vary("angle_atom3",&angle_atom3,tagintsize, + &angle_per_atom,&num_angle); + + add_peratom("num_dihedral",&num_dihedral,INT,0); + add_peratom_vary("dihedral_type",&dihedral_type,INT, + &dihedral_per_atom,&num_dihedral); + add_peratom_vary("dihedral_atom1",&dihedral_atom1,tagintsize, + &dihedral_per_atom,&num_dihedral); + add_peratom_vary("dihedral_atom2",&dihedral_atom2,tagintsize, + &dihedral_per_atom,&num_dihedral); + add_peratom_vary("dihedral_atom3",&dihedral_atom3,tagintsize, + &dihedral_per_atom,&num_dihedral); + add_peratom_vary("dihedral_atom4",&dihedral_atom4,tagintsize, + &dihedral_per_atom,&num_dihedral); + + add_peratom("num_improper",&num_improper,INT,0); + add_peratom_vary("improper_type",&improper_type,INT, + &improper_per_atom,&num_improper); + add_peratom_vary("improper_atom1",&improper_atom1,tagintsize, + &improper_per_atom,&num_improper); + add_peratom_vary("improper_atom2",&improper_atom2,tagintsize, + &improper_per_atom,&num_improper); + add_peratom_vary("improper_atom3",&improper_atom3,tagintsize, + &improper_per_atom,&num_improper); + add_peratom_vary("improper_atom4",&improper_atom4,tagintsize, + &improper_per_atom,&num_improper); + + // PERI package + + add_peratom("vfrac",&vfrac,DOUBLE,0); + add_peratom("s0",&s0,DOUBLE,0); + add_peratom("x0",&x0,DOUBLE,3); + + // SPIN package + + add_peratom("sp",&sp,DOUBLE,4); + add_peratom("fm",&fm,DOUBLE,3,1); + add_peratom("fm_long",&fm_long,DOUBLE,3,1); +} + +/* ---------------------------------------------------------------------- + add info for a single per-atom vector/array to PerAtom data struct + cols = 0: per-atom vector + cols = N: static per-atom array with N columns + use add_peratom_vary() when column count varies per atom +------------------------------------------------------------------------- */ + +void Atom::add_peratom(const char *name, void *address, + int datatype, int cols, int threadflag) +{ + if (nperatom == maxperatom) { + maxperatom += DELTA_PERATOM; + peratom = (PerAtom *) + memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom"); + } + + int n = strlen(name) + 1; + peratom[nperatom].name = new char[n]; + strcpy(peratom[nperatom].name,name); + peratom[nperatom].address = address; + peratom[nperatom].datatype = datatype; + peratom[nperatom].cols = cols; + peratom[nperatom].threadflag = threadflag; + peratom[nperatom].address_length = NULL; + + nperatom++; +} + +/* ---------------------------------------------------------------------- + add info for a single per-atom array to PerAtom data struct + cols = address of int variable with max columns per atom + for collength = 0: + length = address of peratom vector with column count per atom + e.g. num_bond + for collength = N: + length = address of peratom array with column count per atom + collength = index of column (1 to N) in peratom array with count + e.g. nspecial +------------------------------------------------------------------------- */ + +void Atom::add_peratom_vary(const char *name, void *address, + int datatype, int *cols, void *length, int collength) +{ + if (nperatom == maxperatom) { + maxperatom += DELTA_PERATOM; + peratom = (PerAtom *) + memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom"); + } + + int n = strlen(name) + 1; + peratom[nperatom].name = new char[n]; + strcpy(peratom[nperatom].name,name); + peratom[nperatom].address = address; + peratom[nperatom].datatype = datatype; + peratom[nperatom].cols = -1; + peratom[nperatom].threadflag = 0; + peratom[nperatom].address_maxcols = cols; + peratom[nperatom].address_length = length; + peratom[nperatom].collength = collength; + + nperatom++; +} + /* ---------------------------------------------------------------------- create an AtomVec style called from lammps.cpp, input script, restart file, replicate @@ -2296,11 +2482,7 @@ void *Atom::extract(char *name) bigint Atom::memory_usage() { - memlength = DELTA_MEMSTR; - memory->create(memstr,memlength,"atom:memstr"); - memstr[0] = '\0'; bigint bytes = avec->memory_usage(); - memory->destroy(memstr); bytes += max_same*sizeof(int); if (map_style == 1) @@ -2316,31 +2498,3 @@ bigint Atom::memory_usage() return bytes; } - -/* ---------------------------------------------------------------------- - accumulate per-atom vec names in memstr, padded by spaces - return 1 if padded str is not already in memlist, else 0 -------------------------------------------------------------------------- */ - -int Atom::memcheck(const char *str) -{ - int n = strlen(str) + 3; - char *padded = new char[n]; - strcpy(padded," "); - strcat(padded,str); - strcat(padded," "); - - if (strstr(memstr,padded)) { - delete [] padded; - return 0; - } - - if ((int)strlen(memstr) + n >= memlength) { - memlength += DELTA_MEMSTR; - memory->grow(memstr,memlength,"atom:memstr"); - } - - strcat(memstr,padded); - delete [] padded; - return 1; -} diff --git a/src/atom.h b/src/atom.h index 81f643c007..6cc5dff72a 100644 --- a/src/atom.h +++ b/src/atom.h @@ -38,6 +38,8 @@ class Atom : protected Pointers { bigint nlines; // number of lines bigint ntris; // number of triangles bigint nbodies; // number of bodies + + // system properties bigint nbonds,nangles,ndihedrals,nimpropers; int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; @@ -49,69 +51,28 @@ class Atom : protected Pointers { int nfirst; // # of atoms in first group on this proc char *firstgroupname; // group-ID to store first, NULL if unset - // per-atom arrays - // customize by adding new array + // -------------------------------------------------------------------- + // 1st customization section: customize by adding new per-atom variable + // per-atom vectors and arrays tagint *tag; int *type,*mask; imageint *image; double **x,**v,**f; - tagint *molecule; - int *molindex,*molatom; - + double *rmass; double *q,**mu; + + // finite-size particles + + double *radius; double **omega,**angmom,**torque; - double *radius,*rmass; int *ellipsoid,*line,*tri,*body; - // SPIN package + // MOLECULE package - double **sp; - double **fm; - double **fm_long; - - // PERI package - - double *vfrac,*s0; - double **x0; - - // USER-EFF and USER-AWPMD packages - - int *spin; - double *eradius,*ervel,*erforce,*ervelforce; - double *cs,*csforce,*vforce; - int *etag; - - // USER-SPH package - - double *rho,*drho,*e,*de,*cv; - double **vest; - - // USER-SMD package - - double *contact_radius; - double **smd_data_9; - double **smd_stress; - double *eff_plastic_strain; - double *eff_plastic_strain_rate; - double *damage; - - // USER-DPD package - - double *uCond,*uMech,*uChem,*uCGnew,*uCG; - double *duChem; - double *dpdTheta; - int nspecies_dpd; - - // USER-MESO package - - double **cc, **cc_flux; // cc = chemical concentration - double *edpd_temp,*edpd_flux; // temperature and heat flux - double *edpd_cv; // heat capacity - int cc_species; - - // molecular info + tagint *molecule; + int *molindex,*molatom; int **nspecial; // 0,1,2 = cumulative # of 1-2,1-3,1-4 neighs tagint **special; // IDs of 1-2,1-3,1-4 neighs of each atom @@ -133,15 +94,56 @@ class Atom : protected Pointers { int **improper_type; tagint **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; - // custom arrays used by fix property/atom + // PERI package - int **ivector; - double **dvector; - char **iname,**dname; - int nivector,ndvector; + double *vfrac,*s0; + double **x0; - // atom style and per-atom array existence flags - // customize by adding new flag + // SPIN package + + double **sp; + double **fm; + double **fm_long; + + // USER-AWPMD and USER_EFF packages + + int *spin; + double *eradius,*ervel,*erforce,*ervelforce; + double *cs,*csforce,*vforce; + int *etag; + + // USER-DPD package + + double *uCond,*uMech,*uChem,*uCGnew,*uCG; + double *duChem; + double *dpdTheta; + int nspecies_dpd; + + // USER-MESO package + + double **cc, **cc_flux; // cc = chemical concentration + double *edpd_temp,*edpd_flux; // temperature and heat flux + double *edpd_cv; // heat capacity + int cc_species; + + // USER-SMD package + + double *contact_radius; + double **smd_data_9; + double **smd_stress; + double *eff_plastic_strain; + double *eff_plastic_strain_rate; + double *damage; + + // USER-SPH package + + double *rho,*drho,*e,*de,*cv; + double **vest; + + // -------------------------------------------------------------------- + // 1st customization section: customize by adding new flag + // 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; @@ -156,7 +158,7 @@ class Atom : protected Pointers { int rho_flag,e_flag,cv_flag,vest_flag; int dpd_flag,edpd_flag,tdpd_flag; - //USER-SPIN package + // USER-SPIN package int sp_flag; @@ -175,6 +177,32 @@ class Atom : protected Pointers { double pdscale; + // end of 2 customization sections + // -------------------------------------------------------------------- + + // per-atom data struct describing all per-atom vectors/arrays + + struct PerAtom { + char *name; + void *address; + void *address_length; + int *address_maxcols; + int datatype; + int cols; + int collength; + int threadflag; + }; + + PerAtom *peratom; + int nperatom,maxperatom; + + // custom arrays used by fix property/atom + + int **ivector; + double **dvector; + char **iname,**dname; + int nivector,ndvector; + // molecule templates // each template can be a set of consecutive molecules // each with same ID (stored in molecules) @@ -221,12 +249,17 @@ class Atom : protected Pointers { typedef std::map AtomVecCreatorMap; AtomVecCreatorMap *avec_map; + // -------------------------------------------------------------------- // functions Atom(class LAMMPS *); ~Atom(); void settings(class Atom *); + void peratom_create(); + void add_peratom(const char *, void *, int, int, int threadflag=0); + void add_peratom_vary(const char *, void *, int, int *, + void *, int collength=0); void create_avec(const char *, int, char **, int); virtual class AtomVec *new_avec(const char *, int, int &); void init(); @@ -289,8 +322,10 @@ class Atom : protected Pointers { inline int get_map_size() {return map_tag_max+1;}; inline int get_map_maxarray() {return map_maxarray+1;}; + // NOTE: placeholder method until AtomVec is refactored + int memcheck(const char *) {return 1;} + bigint memory_usage(); - int memcheck(const char *); // functions for global to local ID mapping // map lookup function inlined for efficiency @@ -343,9 +378,6 @@ class Atom : protected Pointers { double bininvx,bininvy,bininvz; // inverse actual bin sizes double bboxlo[3],bboxhi[3]; // bounding box of my sub-domain - int memlength; // allocated size of memstr - char *memstr; // string of array names already counted - void setup_sort_bins(); int next_prime(int); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index bc94e36e7a..428117f0db 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -12,18 +12,27 @@ ------------------------------------------------------------------------- */ #include "atom_vec.h" +#include #include #include "atom.h" -#include "force.h" +#include "comm.h" #include "domain.h" +#include "force.h" +#include "modify.h" +#include "fix.h" +#include "math_const.h" +#include "memory.h" #include "error.h" #include "utils.h" using namespace LAMMPS_NS; +using namespace MathConst; #define DELTA 16384 #define DELTA_BONUS 8192 +enum{DOUBLE,INT,BIGINT}; + /* ---------------------------------------------------------------------- */ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) @@ -39,6 +48,40 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) nargcopy = 0; argcopy = NULL; + + nthreads = comm->nthreads; + + // peratom variables auto-included in corresponding child style fields string + // these fields cannot be specified in the fields string + // leading/trailing whitespace just facilitates matching in process_args() + + default_grow = " id type mask image x v f "; + default_copy = " id type mask image x v "; + default_comm = " x "; + default_comm_vel = " x v "; + default_reverse = " f "; + default_border = " id type mask x "; + default_border_vel = " id type mask x v "; + default_exchange = " id type mask image x v "; + default_restart = " id type mask image x v "; + default_create = " id type mask image x v "; + default_data_atom = ""; + default_data_vel = " v "; + + // initializations + + init_method(&mgrow); + init_method(&mcopy); + init_method(&mcomm); + init_method(&mcomm_vel); + init_method(&mreverse); + init_method(&mborder); + init_method(&mborder_vel); + init_method(&mexchange); + init_method(&mrestart); + init_method(&mcreate); + init_method(&mdata_atom); + init_method(&mdata_vel); } /* ---------------------------------------------------------------------- */ @@ -47,6 +90,21 @@ AtomVec::~AtomVec() { for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; delete [] argcopy; + + destroy_method(&mgrow); + destroy_method(&mcopy); + destroy_method(&mcomm); + destroy_method(&mcomm_vel); + destroy_method(&mreverse); + destroy_method(&mborder); + destroy_method(&mborder_vel); + destroy_method(&mexchange); + destroy_method(&mrestart); + destroy_method(&mcreate); + destroy_method(&mdata_atom); + destroy_method(&mdata_vel); + + delete [] threads; } /* ---------------------------------------------------------------------- @@ -87,6 +145,223 @@ void AtomVec::init() error->all(FLERR,"KOKKOS package requires a kokkos enabled atom_style"); } +/* ---------------------------------------------------------------------- + process field strings to initialize data structs for all other methods +------------------------------------------------------------------------- */ + +void AtomVec::setup_fields() +{ + int n,cols; + + if (!fields_data_atom) + error->all(FLERR,"Atom style requires fields_data_atom"); + + // process field strings + // return # of fields and matching index into atom->peratom (in Method struct) + + ngrow = process_fields(fields_grow,default_grow,&mgrow); + ncopy = process_fields(fields_copy,default_copy,&mcopy); + ncomm = process_fields(fields_comm,default_comm,&mcomm); + ncomm_vel = process_fields(fields_comm_vel,default_comm_vel,&mcomm_vel); + nreverse = process_fields(fields_reverse,default_reverse,&mreverse); + nborder = process_fields(fields_border,default_border,&mborder); + nborder_vel = process_fields(fields_border_vel,default_border_vel,&mborder_vel); + nexchange = process_fields(fields_exchange,default_exchange,&mexchange); + nrestart = process_fields(fields_restart,default_restart,&mrestart); + ncreate = process_fields(fields_create,default_create,&mcreate); + ndata_atom = process_fields(fields_data_atom,default_data_atom,&mdata_atom); + ndata_vel = process_fields(fields_data_vel,default_data_vel,&mdata_vel); + + // populate field-based data struct for each method to use + + create_method(ngrow,&mgrow); + create_method(ncopy,&mcopy); + create_method(ncomm,&mcomm); + create_method(ncomm_vel,&mcomm_vel); + create_method(nreverse,&mreverse); + create_method(nborder,&mborder); + create_method(nborder_vel,&mborder_vel); + create_method(nexchange,&mexchange); + create_method(nrestart,&mrestart); + create_method(ncreate,&mcreate); + create_method(ndata_atom,&mdata_atom); + create_method(ndata_vel,&mdata_vel); + + // create threads data struct for grow and memory_usage to use + + threads = new int[ngrow]; + for (int i = 0; i < ngrow; i++) { + Atom::PerAtom *field = &atom->peratom[mgrow.index[i]]; + if (field->threadflag) threads[i] = nthreads; + else threads[i] = 1; + } + + // set style-specific variables + // NOTE: check for others vars in atom_vec.cpp/h ?? + + if (ncomm == 0) comm_x_only = 1; + else comm_x_only = 0; + + if (nreverse == 0) comm_f_only = 1; + else comm_f_only = 0; + + size_forward = 3; + for (n = 0; n < ncomm; n++) { + cols = mcomm.cols[n]; + if (cols == 0) size_forward++; + else size_forward += cols; + } + + size_reverse = 3; + for (n = 0; n < nreverse; n++) { + cols = mreverse.cols[n]; + if (cols == 0) size_reverse++; + else size_reverse += cols; + } + + size_border = 6; + for (n = 0; n < nborder; n++) { + cols = mborder.cols[n]; + if (cols == 0) size_border++; + else size_border += cols; + } + + size_velocity = 3; + for (n = 0; n < ncomm_vel; n++) { + cols = mcomm_vel.cols[n]; + if (cols == 0) size_velocity++; + else size_velocity += cols; + } + + size_data_atom = 0; + for (n = 0; n < ndata_atom; n++) { + cols = mdata_atom.cols[n]; + if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0) + xcol_data = size_data_atom + 1; + if (cols == 0) size_data_atom++; + else size_data_atom += cols; + } + + size_data_vel = 4; + for (n = 0; n < ndata_vel; n++) { + cols = mdata_vel.cols[n]; + if (cols == 0) size_data_vel++; + else size_data_vel += cols; + } +} + +/* ---------------------------------------------------------------------- + process a single field string +------------------------------------------------------------------------- */ + +int AtomVec::process_fields(char *list, const char *default_list, Method *method) +{ + int i,n; + char match[128]; + + if (list == NULL) { + method->index = NULL; + return 0; + } + + // make copy of list of fields so can tokenize it + + n = strlen(list) + 1; + char *copy = new char[n]; + strcpy(copy,list); + + int nfield = atom->count_words(copy); + int *index = new int[nfield]; + + Atom::PerAtom *peratom = atom->peratom; + int nperatom = atom->nperatom; + + nfield = 0; + char *field = strtok(copy," "); + while (field) { + + // find field in master Atom::peratom list + + 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"); + index[nfield++] = i; + + // error if field is in default list or appears multiple times + + sprintf(match," %s ",field); + if (strstr(default_list,match)) + error->all(FLERR,"Atom_style repeat of default peratom field"); + + for (i = 0; i < nfield-1; i++) + if (index[i] == index[nfield-1]) + error->all(FLERR,"Atom_style duplicated peratom field"); + + field = strtok(NULL," "); + } + + delete [] copy; + + method->index = index; + return nfield; +} + +/* ---------------------------------------------------------------------- + create a method data structs for processing fields +------------------------------------------------------------------------- */ + +void AtomVec::create_method(int nfield, Method *method) +{ + method->pdata = new void*[nfield]; + method->datatype = new int[nfield]; + method->cols = new int[nfield]; + method->maxcols = new int*[nfield]; + method->collength = new int[nfield]; + method->plength = new void*[nfield]; + + for (int i = 0; i < nfield; i++) { + Atom::PerAtom *field = &atom->peratom[method->index[i]]; + method->pdata[i] = (void *) field->address; + method->datatype[i] = field->datatype; + method->cols[i] = field->cols; + if (method->cols[i] < 0) { + method->maxcols[i] = field->address_maxcols; + method->collength[i] = field->collength; + method->plength[i] = field->address_length; + } + } +} + +/* ---------------------------------------------------------------------- + free memory in a method data structs +------------------------------------------------------------------------- */ + +void AtomVec::init_method(Method *method) +{ + method->pdata = NULL; + method->datatype = NULL; + method->cols = NULL; + method->maxcols = NULL; + method->collength = NULL; + method->plength = NULL; + method->index = NULL; +} + +/* ---------------------------------------------------------------------- + free memory in a method data structs +------------------------------------------------------------------------- */ + +void AtomVec::destroy_method(Method *method) +{ + delete [] method->pdata; + delete [] method->datatype; + delete [] method->cols; + delete [] method->maxcols; + delete [] method->collength; + delete [] method->plength; + delete [] method->index; +} + /* ---------------------------------------------------------------------- grow nmax so it is a multiple of DELTA ------------------------------------------------------------------------- */ @@ -108,16 +383,1700 @@ int AtomVec::grow_nmax_bonus(int nmax_bonus) return nmax_bonus; } +/* ---------------------------------------------------------------------- + grow atom arrays + n = 0 grows arrays by a chunk + n > 0 allocates arrays to size n +------------------------------------------------------------------------- */ + +void AtomVec::grow(int n) +{ + int i,datatype,cols,maxcols; + void *pdata,*plength; + + 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*nthreads,3,"atom:f"); + + for (i = 0; i < ngrow; i++) { + pdata = mgrow.pdata[i]; + datatype = mgrow.datatype[i]; + cols = mgrow.cols[i]; + if (datatype == DOUBLE) { + if (cols == 0) + memory->grow(*((double **) pdata),nmax*threads[i],"atom:dvec"); + else if (cols > 0) + memory->grow(*((double ***) pdata),nmax*threads[i],cols,"atom:darray"); + else { + maxcols = *(mgrow.maxcols[i]); + memory->grow(*((double ***) pdata),nmax*threads[i],maxcols,"atom:darray"); + } + } else if (datatype == INT) { + if (cols == 0) + memory->grow(*((int **) pdata),nmax*threads[i],"atom:ivec"); + else if (cols > 0) + memory->grow(*((int ***) pdata),nmax*threads[i],cols,"atom:iarray"); + else { + maxcols = *(mgrow.maxcols[i]); + memory->grow(*((int ***) pdata),nmax*threads[i],maxcols,"atom:iarray"); + } + } else if (datatype == BIGINT) { + if (cols == 0) + memory->grow(*((bigint **) pdata),nmax*threads[i],"atom:bvec"); + else if (cols > 0) + memory->grow(*((bigint ***) pdata),nmax*threads[i],cols,"atom:barray"); + else { + maxcols = *(mgrow.maxcols[i]); + memory->grow(*((int ***) pdata),nmax*threads[i],maxcols,"atom:barray"); + } + } + } + + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); +} + +/* ---------------------------------------------------------------------- + reset local array ptrs +------------------------------------------------------------------------- */ + +void AtomVec::grow_reset() +{ + // NOTE: is this method needed anymore + tag = atom->tag; type = atom->type; + mask = atom->mask; image = atom->image; + x = atom->x; v = atom->v; f = atom->f; +} + +/* ---------------------------------------------------------------------- + copy atom I info to atom J +------------------------------------------------------------------------- */ + +void AtomVec::copy(int i, int j, int delflag) +{ + int m,n,datatype,cols,collength,ncols; + void *pdata,*plength; + + 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]; + + if (ncopy) { + for (n = 0; n < ncopy; n++) { + pdata = mcopy.pdata[n]; + datatype = mcopy.datatype[n]; + cols = mcopy.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[j] = vec[i]; + } else if (cols > 0) { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + array[j][m] = array[i][m]; + } else { + double **array = *((double ***) pdata); + collength = mcopy.collength[n]; + plength = mcopy.plength[n]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (m = 0; m < ncols; m++) + array[j][m] = array[i][m]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[j] = vec[i]; + } else if (cols > 0) { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + array[j][m] = array[i][m]; + } else { + int **array = *((int ***) pdata); + collength = mcopy.collength[n]; + plength = mcopy.plength[n]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (m = 0; m < ncols; m++) + array[j][m] = array[i][m]; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[j] = vec[i]; + } else if (cols > 0) { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + array[j][m] = array[i][m]; + } else { + bigint **array = *((bigint ***) pdata); + collength = mcopy.collength[n]; + plength = mcopy.plength[n]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (m = 0; m < ncols; m++) + array[j][m] = array[i][m]; + } + } + } + } + + 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 AtomVec::pack_comm(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m,mm,nn,datatype,cols; + double dx,dy,dz; + void *pdata; + + 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]; + } + } 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 (comm) { + for (nn = 0; nn < ncomm; nn++) { + pdata = mcomm.pdata[nn]; + datatype = mcomm.datatype[nn]; + cols = mcomm.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = vec[j]; + } + } else { + double **array = *((double ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = array[j][mm]; + } + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + int **array = *((int ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + bigint **array = *((bigint ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } + } + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVec::pack_comm_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m,mm,nn,datatype,cols; + double dx,dy,dz,dvx,dvy,dvz; + void *pdata; + + 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]; + } + } 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]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + + if (ncomm_vel) { + for (nn = 0; nn < ncomm_vel; nn++) { + pdata = mcomm_vel.pdata[nn]; + datatype = mcomm_vel.datatype[nn]; + cols = mcomm_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = vec[j]; + } + } else { + double **array = *((double ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = array[j][mm]; + } + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + int **array = *((int ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + bigint **array = *((bigint ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } + } + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVec::unpack_comm(int n, int first, double *buf) +{ + int i,m,last,mm,nn,datatype,cols; + void *pdata; + + 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 (ncomm) { + for (nn = 0; nn < ncomm; nn++) { + pdata = mcomm.pdata[nn]; + datatype = mcomm.datatype[nn]; + cols = mcomm.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = first; i < last; i++) + vec[i] = buf[m++]; + } else { + double **array = *((double ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = buf[m++]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = first; i < last; i++) + vec[i] = ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (int) ubuf(buf[m++]).i; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = first; i < last; i++) + vec[i] = (bigint) ubuf(buf[m++]).i; + } else { + bigint **array = *((bigint ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (bigint) ubuf(buf[m++]).i; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void AtomVec::unpack_comm_vel(int n, int first, double *buf) +{ + int i,m,last,mm,nn,datatype,cols; + void *pdata; + + 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++]; + } + + if (ncomm_vel) { + for (nn = 0; nn < ncomm_vel; nn++) { + pdata = mcomm_vel.pdata[nn]; + datatype = mcomm_vel.datatype[nn]; + cols = mcomm_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = first; i < last; i++) + vec[i] = buf[m++]; + } else { + double **array = *((double ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = buf[m++]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = first; i < last; i++) + vec[i] = ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (int) ubuf(buf[m++]).i; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = first; i < last; i++) + vec[i] = (bigint) ubuf(buf[m++]).i; + } else { + bigint **array = *((bigint ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (bigint) ubuf(buf[m++]).i; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVec::pack_reverse(int n, int first, double *buf) +{ + int i,m,last,mm,nn,datatype,cols; + void *pdata; + + 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]; + } + + if (nreverse) { + for (nn = 0; nn < nreverse; nn++) { + pdata = mreverse.pdata[nn]; + datatype = mreverse.datatype[nn]; + cols = mreverse.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = first; i < last; i++) { + buf[m++] = vec[i]; + } + } else { + double **array = *((double ***) pdata); + for (i = first; i < last; i++) { + for (mm = 0; mm < cols; mm++) + buf[m++] = array[i][mm]; + } + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = first; i < last; i++) { + buf[m++] = ubuf(vec[i]).d; + } + } else { + int **array = *((int ***) pdata); + for (i = first; i < last; i++) { + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = first; i < last; i++) { + buf[m++] = ubuf(vec[i]).d; + } + } else { + bigint **array = *((bigint ***) pdata); + for (i = first; i < last; i++) { + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } + } + } + } + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVec::unpack_reverse(int n, int *list, double *buf) +{ + int i,j,m,mm,nn,datatype,cols; + void *pdata; + + 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++]; + } + + if (nreverse) { + for (nn = 0; nn < nreverse; nn++) { + pdata = mreverse.pdata[nn]; + datatype = mreverse.datatype[nn]; + cols = mreverse.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + vec[j] += buf[m++]; + } + } else { + double **array = *((double ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + array[j][mm] += buf[m++]; + } + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + vec[j] += buf[m++]; + } + } else { + int **array = *((int ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + array[j][mm] += buf[m++]; + } + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + vec[j] += buf[m++]; + } + } else { + bigint **array = *((bigint ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + array[j][mm] += buf[m++]; + } + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVec::pack_border(int n, int *list, double *buf, int pbc_flag, int *pbc) +{ + int i,j,m,mm,nn,datatype,cols; + double dx,dy,dz; + void *pdata; + + 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; + } + } 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; + } + } + + if (nborder) { + for (nn = 0; nn < nborder; nn++) { + pdata = mborder.pdata[nn]; + datatype = mborder.datatype[nn]; + cols = mborder.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = vec[j]; + } + } else { + double **array = *((double ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = array[j][mm]; + } + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + int **array = *((int ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + bigint **array = *((bigint ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } + } + } + + 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 AtomVec::pack_border_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m,mm,nn,datatype,cols; + double dx,dy,dz,dvx,dvy,dvz; + void *pdata; + + 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]; + } + } 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]; + } + } 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]; + } + } + } + } + + if (nborder_vel) { + for (nn = 0; nn < nborder_vel; nn++) { + pdata = mborder_vel.pdata[nn]; + datatype = mborder_vel.datatype[nn]; + cols = mborder_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = vec[j]; + } + } else { + double **array = *((double ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = array[j][mm]; + } + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + int **array = *((int ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(vec[j]).d; + } + } else { + bigint **array = *((bigint ***) pdata); + for (i = 0; i < n; i++) { + j = list[i]; + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[j][mm]).d; + } + } + } + } + } + + 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 AtomVec::unpack_border(int n, int first, double *buf) +{ + int i,m,last,mm,nn,datatype,cols; + void *pdata; + + 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; + } + + if (nborder) { + for (nn = 0; nn < nborder; nn++) { + pdata = mborder.pdata[nn]; + datatype = mborder.datatype[nn]; + cols = mborder.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = first; i < last; i++) + vec[i] = buf[m++]; + } else { + double **array = *((double ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = buf[m++]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = first; i < last; i++) + vec[i] = ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (int) ubuf(buf[m++]).i; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = first; i < last; i++) + vec[i] = (bigint) ubuf(buf[m++]).i; + } else { + bigint **array = *((bigint ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (bigint) ubuf(buf[m++]).i; + } + } + } + } + + 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 AtomVec::unpack_border_vel(int n, int first, double *buf) +{ + int i,m,last,mm,nn,datatype,cols; + void *pdata; + + 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++]; + } + + if (nborder_vel) { + for (nn = 0; nn < nborder_vel; nn++) { + pdata = mborder_vel.pdata[nn]; + datatype = mborder_vel.datatype[nn]; + cols = mborder_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + for (i = first; i < last; i++) + vec[i] = buf[m++]; + } else { + double **array = *((double ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = buf[m++]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + for (i = first; i < last; i++) + vec[i] = ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (int) ubuf(buf[m++]).i; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + for (i = first; i < last; i++) + vec[i] = (bigint) ubuf(buf[m++]).i; + } else { + bigint **array = *((bigint ***) pdata); + for (i = first; i < last; i++) + for (mm = 0; mm < cols; mm++) + array[i][mm] = (bigint) ubuf(buf[m++]).i; + } + } + } + } + + 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]); +} + +/* ---------------------------------------------------------------------- + pack data for atom I for sending to another proc + xyz must be 1st 3 values, so comm::exchange() can test on them +------------------------------------------------------------------------- */ + +int AtomVec::pack_exchange(int i, double *buf) +{ + int mm,nn,datatype,cols,collength,ncols; + void *pdata,*plength; + + 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; + + if (nexchange) { + for (nn = 0; nn < nexchange; nn++) { + pdata = mexchange.pdata[nn]; + datatype = mexchange.datatype[nn]; + cols = mexchange.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + buf[m++] = vec[i]; + } else if (cols > 0) { + double **array = *((double ***) pdata); + for (mm = 0; mm < cols; mm++) + buf[m++] = array[i][mm]; + } else { + double **array = *((double ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (mm = 0; mm < ncols; mm++) + buf[m++] = array[i][mm]; + } + } if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + buf[m++] = ubuf(vec[i]).d; + } else if (cols > 0) { + int **array = *((int ***) pdata); + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } else { + int **array = *((int ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (mm = 0; mm < ncols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } + } if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + buf[m++] = ubuf(vec[i]).d; + } else if (cols > 0) { + bigint **array = *((bigint ***) pdata); + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } else { + bigint **array = *((bigint ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (mm = 0; mm < ncols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } + } + } + } + + 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 AtomVec::unpack_exchange(double *buf) +{ + int mm,nn,datatype,cols,collength,ncols; + void *pdata,*plength; + + 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; + + if (nexchange) { + for (nn = 0; nn < nexchange; nn++) { + pdata = mexchange.pdata[nn]; + datatype = mexchange.datatype[nn]; + cols = mexchange.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[nlocal] = buf[m++]; + } else if (cols > 0) { + double **array = *((double ***) pdata); + for (mm = 0; mm < cols; mm++) + array[nlocal][mm] = buf[m++]; + } else { + double **array = *((double ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + for (mm = 0; mm < ncols; mm++) + array[nlocal][mm] = buf[m++]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[nlocal] = ubuf(buf[m++]).i; + } else if (cols > 0) { + int **array = *((int ***) pdata); + for (mm = 0; mm < cols; mm++) + array[nlocal][mm] = (int) ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + for (mm = 0; mm < ncols; mm++) + array[nlocal][mm] = (int) ubuf(buf[m++]).i; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[nlocal] = (bigint) ubuf(buf[m++]).i; + } else if (cols > 0) { + bigint **array = *((bigint ***) pdata); + for (mm = 0; mm < cols; mm++) + array[nlocal][mm] = (bigint) ubuf(buf[m++]).i; + } else { + bigint **array = *((bigint ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + for (mm = 0; mm < ncols; mm++) + array[nlocal][mm] = (bigint) ubuf(buf[m++]).i; + } + } + } + } + + 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 AtomVec::size_restart() +{ + int i,nn,cols,collength,ncols; + void *plength; + + // NOTE: need to worry about overflow of returned int ?? + + int nlocal = atom->nlocal; + + // 11 = length storage + id,type,mask,image,x,v + + int n = 11 * nlocal; + + if (nrestart) { + for (nn = 0; nn < nrestart; nn++) { + cols = mrestart.cols[i]; + if (cols == 0) n += nlocal; + else if (cols > 0) n += cols*nlocal; + else { + collength = mrestart.collength[nn]; + plength = mrestart.plength[nn]; + for (i = 0; i < nlocal; i++) { + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + n += ncols; + } + } + } + } + + 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 AtomVec::pack_restart(int i, double *buf) +{ + int mm,nn,datatype,cols,collength,ncols; + void *pdata,*plength; + + 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]; + + for (nn = 0; nn < nrestart; nn++) { + pdata = mrestart.pdata[nn]; + datatype = mrestart.datatype[nn]; + cols = mrestart.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + buf[m++] = vec[i]; + } else if (ncols > 0) { + double **array = *((double ***) pdata); + for (mm = 0; mm < cols; mm++) + buf[m++] = array[i][mm]; + } else { + double **array = *((double ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (mm = 0; mm < ncols; mm++) + buf[m++] = array[i][mm]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + buf[m++] = ubuf(vec[i]).d; + } else if (cols > 0) { + int **array = *((int ***) pdata); + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } else { + int **array = *((int ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (mm = 0; mm < ncols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + buf[m++] = ubuf(vec[i]).d; + } else if (ncols > 0) { + bigint **array = *((bigint ***) pdata); + for (mm = 0; mm < cols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } else { + bigint **array = *((bigint ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; + for (mm = 0; mm < ncols; mm++) + buf[m++] = ubuf(array[i][mm]).d; + } + } + } + + 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 AtomVec::unpack_restart(double *buf) +{ + int mm,nn,datatype,cols,collength,ncols; + void *pdata,*plength; + + 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++]; + + for (nn = 0; nn < nrestart; nn++) { + pdata = mrestart.pdata[nn]; + datatype = mrestart.datatype[nn]; + cols = mrestart.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[nlocal] = buf[m++]; + } else if (cols > 0) { + double **array = *((double ***) pdata); + for (mm = 0; mm < cols; mm++) + array[nlocal][mm] = buf[m++]; + } else { + double **array = *((double ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + for (mm = 0; mm < ncols; mm++) + array[nlocal][mm] = buf[m++]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[nlocal] = ubuf(buf[m++]).i; + } else if (cols > 0) { + int **array = *((int ***) pdata); + for (mm = 0; mm < cols; mm++) + array[nlocal][mm] = (int) ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + for (mm = 0; mm < ncols; mm++) + array[nlocal][mm] = (int) ubuf(buf[m++]).i; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[nlocal] = (bigint) ubuf(buf[m++]).i; + } else if (cols > 0) { + bigint **array = *((bigint ***) pdata); + for (mm = 0; mm < cols; mm++) + array[nlocal][mm] = (bigint) ubuf(buf[m++]).i; + } else { + int **array = *((int ***) pdata); + collength = mexchange.collength[nn]; + plength = mexchange.plength[nn]; + if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; + else ncols = (*((int **) plength))[nlocal]; + for (mm = 0; mm < ncols; mm++) + array[nlocal][mm] = (bigint) ubuf(buf[m++]).i; + } + } + } + + 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 AtomVec::create_atom(int itype, double *coord) +{ + int m,n,datatype,cols; + void *pdata; + + 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; + + // special-case initialization for some fields + + for (n = 0; n < ncreate; n++) { + pdata = mcreate.pdata[n]; + datatype = mcreate.datatype[n]; + cols = mcreate.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[nlocal] = 0.0; + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + array[nlocal][m] = 0.0; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[nlocal] = 0; + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + array[nlocal][m] = 0; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[nlocal] = 0; + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + array[nlocal][m] = 0; + } + } + } + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack one line from Atoms section of data file + initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVec::data_atom(double *coord, imageint imagetmp, char **values) +{ + int m,n,datatype,cols; + void *pdata; + + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + mask[nlocal] = 1; + image[nlocal] = imagetmp; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + + int ivalue = 0; + for (n = 0; n < ndata_atom; n++) { + pdata = mdata_atom.pdata[n]; + datatype = mdata_atom.datatype[n]; + cols = mdata_atom.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[nlocal] = utils::numeric(FLERR,values[ivalue++],true,lmp); + } else { + double **array = *((double ***) pdata); + if (array == atom->x) { // already set by coord arg + ivalue += cols; + continue; + } + for (m = 0; m < cols; m++) + array[nlocal][m] = utils::numeric(FLERR,values[ivalue++],true,lmp); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[nlocal] = utils::inumeric(FLERR,values[ivalue++],true,lmp); + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + array[nlocal][m] = utils::inumeric(FLERR,values[ivalue++],true,lmp); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[nlocal] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + array[nlocal][m] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + } + } + } + + // error checks applicable to all styles + + if (atom->tag[nlocal] <= 0) + error->one(FLERR,"Invalid atom ID in Atoms section of data file"); + if (atom->type[nlocal] <= 0 || atom->type[nlocal] > atom->ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + pack atom info for data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVec::pack_data(double **buf) +{ + int i,j,m,n,datatype,cols; + void *pdata; + + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + j = 0; + for (n = 0; n < ndata_atom; n++) { + pdata = mdata_atom.pdata[n]; + datatype = mdata_atom.datatype[n]; + cols = mdata_atom.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + buf[i][j++] = vec[i]; + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = array[i][m]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + buf[i][j++] = ubuf(vec[i]).d; + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = ubuf(array[i][m]).d; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + buf[i][j++] = ubuf(vec[i]).d; + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = ubuf(array[i][m]).d; + } + } + } + + buf[i][j++] = ubuf((image[i] & IMGMASK) - IMGMAX).d; + buf[i][j++] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; + buf[i][j++] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + } +} + +/* ---------------------------------------------------------------------- + write atom info to data file + id is first field, 3 image flags are final fields +------------------------------------------------------------------------- */ + +void AtomVec::write_data(FILE *fp, int n, double **buf) +{ + int i,j,m,nn,datatype,cols; + void *pdata; + + for (i = 0; i < n; i++) { + fprintf(fp,TAGINT_FORMAT,(tagint) ubuf(buf[i][0]).i); + + j = 1; + for (nn = 1; nn < ndata_atom; nn++) { + pdata = mdata_atom.pdata[nn]; + datatype = mdata_atom.datatype[nn]; + cols = mdata_atom.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + fprintf(fp," %-1.16e",buf[i][j++]); + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," %-1.16e",buf[i][j++]); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } + } + } + + fprintf(fp," %d %d %d\n", + (int) ubuf(buf[i][j]).i, + (int) ubuf(buf[i][j+1]).i, + (int) ubuf(buf[i][j+2]).i); + } +} + /* ---------------------------------------------------------------------- unpack one line from Velocities section of data file ------------------------------------------------------------------------- */ -void AtomVec::data_vel(int m, char **values) +void AtomVec::data_vel(int ilocal, char **values) { + int m,n,datatype,cols; + void *pdata; + double **v = atom->v; - 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); + v[ilocal][0] = utils::numeric(FLERR,values[0],true,lmp); + v[ilocal][1] = utils::numeric(FLERR,values[1],true,lmp); + v[ilocal][2] = utils::numeric(FLERR,values[2],true,lmp); + + int ivalue = 3; + for (n = 0; n < ndata_vel; n++) { + pdata = mdata_vel.pdata[n]; + datatype = mdata_vel.datatype[n]; + cols = mdata_vel.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[ilocal] = utils::numeric(FLERR,values[ivalue++],true,lmp); + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + array[ilocal][m] = utils::numeric(FLERR,values[ivalue++],true,lmp); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[ilocal] = utils::inumeric(FLERR,values[ivalue++],true,lmp); + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + array[ilocal][m] = utils::inumeric(FLERR,values[ivalue++],true,lmp); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[ilocal] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + array[ilocal][m] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + } + } + } } /* ---------------------------------------------------------------------- @@ -126,27 +2085,109 @@ void AtomVec::data_vel(int m, char **values) void AtomVec::pack_vel(double **buf) { + int i,j,m,n,datatype,cols; + void *pdata; + double **v = atom->v; tagint *tag = atom->tag; int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { + for (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]; + + j = 4; + if (ndata_vel) { + for (n = 0; n < ndata_vel; n++) { + pdata = mdata_vel.pdata[n]; + datatype = mdata_vel.datatype[n]; + cols = mdata_vel.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + buf[i][j++] = vec[i]; + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = array[i][m]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + buf[i][j++] = ubuf(vec[i]).d; + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = ubuf(array[i][m]).d; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + buf[i][j++] = ubuf(vec[i]).d; + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = ubuf(array[i][m]).d; + } + } + } + } } } /* ---------------------------------------------------------------------- write velocity info to data file + id and velocity vector are first 4 fields ------------------------------------------------------------------------- */ void AtomVec::write_vel(FILE *fp, int n, double **buf) { - for (int i = 0; i < n; i++) + int i,j,m,nn,datatype,cols; + void *pdata; + + for (i = 0; i < n; i++) { fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e\n", (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]); + + j = 4; + for (nn = 0; nn < ndata_vel; nn++) { + pdata = mdata_vel.pdata[nn]; + datatype = mdata_vel.datatype[nn]; + cols = mdata_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + fprintf(fp," %-1.16e",buf[i][j++]); + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," %-1.16e",buf[i][j++]); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } + } + } + + fprintf(fp,"\n"); + } } /* ---------------------------------------------------------------------- @@ -395,3 +2436,60 @@ void AtomVec::write_improper(FILE *fp, int n, tagint **buf, int index) index++; } } + +/* ---------------------------------------------------------------------- + return # of bytes of allocated memory +------------------------------------------------------------------------- */ + +bigint AtomVec::memory_usage() +{ + int datatype,cols,index,maxcols; + void *pdata; + + bigint bytes = 0; + + bytes += memory->usage(tag,nmax); + bytes += memory->usage(type,nmax); + bytes += memory->usage(mask,nmax); + bytes += memory->usage(image,nmax); + bytes += memory->usage(x,nmax,3); + bytes += memory->usage(v,nmax,3); + bytes += memory->usage(f,nmax*nthreads,3); + + for (int i = 0; i < ngrow; i++) { + pdata = mgrow.pdata[i]; + datatype = mgrow.datatype[i]; + cols = mgrow.cols[i]; + index = mgrow.index[i]; + if (datatype == DOUBLE) { + if (cols == 0) { + bytes += memory->usage(*((double **) pdata),nmax*threads[i]); + } else if (cols > 0) { + bytes += memory->usage(*((double ***) pdata),nmax*threads[i],cols); + } else { + maxcols = *(mgrow.maxcols[i]); + bytes += memory->usage(*((double ***) pdata),nmax*threads[i],maxcols); + } + } else if (datatype == INT) { + if (cols == 0) { + bytes += memory->usage(*((int **) pdata),nmax*threads[i]); + } else if (cols > 0) { + bytes += memory->usage(*((int ***) pdata),nmax*threads[i],cols); + } else { + maxcols = *(mgrow.maxcols[i]); + bytes += memory->usage(*((int ***) pdata),nmax*threads[i],maxcols); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bytes += memory->usage(*((bigint **) pdata),nmax*threads[i]); + } else if (cols > 0) { + bytes += memory->usage(*((bigint ***) pdata),nmax*threads[i],cols); + } else { + maxcols = *(mgrow.maxcols[i]); + bytes += memory->usage(*((bigint ***) pdata),nmax*threads[i],maxcols); + } + } + } + + return bytes; +} diff --git a/src/atom_vec.h b/src/atom_vec.h index 2b57238c3b..c3551b541d 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -55,54 +55,54 @@ class AtomVec : protected Pointers { virtual void process_args(int, char **); virtual void init(); - virtual void grow(int) = 0; - virtual void grow_reset() = 0; - virtual void copy(int, int, int) = 0; - virtual void clear_bonus() {} - virtual void force_clear(int, size_t) {} + void grow(int); + void grow_reset(); + void copy(int, int, int); + void clear_bonus() {} + void force_clear(int, size_t) {} - virtual int pack_comm(int, int *, double *, int, int *) = 0; - virtual int pack_comm_vel(int, int *, double *, int, int *) = 0; - virtual int pack_comm_hybrid(int, int *, double *) {return 0;} - virtual void unpack_comm(int, int, double *) = 0; - virtual void unpack_comm_vel(int, int, double *) = 0; - virtual int unpack_comm_hybrid(int, int, double *) {return 0;} + int pack_comm(int, int *, double *, int, int *); + int pack_comm_vel(int, int *, double *, int, int *); + int pack_comm_hybrid(int, int *, double *) {return 0;} + void unpack_comm(int, int, double *); + void unpack_comm_vel(int, int, double *); + int unpack_comm_hybrid(int, int, double *) {return 0;} - virtual int pack_reverse(int, int, double *) = 0; - virtual int pack_reverse_hybrid(int, int, double *) {return 0;} - virtual void unpack_reverse(int, int *, double *) = 0; - virtual int unpack_reverse_hybrid(int, int *, double *) {return 0;} + int pack_reverse(int, int, double *); + int pack_reverse_hybrid(int, int, double *) {return 0;} + void unpack_reverse(int, int *, double *); + int unpack_reverse_hybrid(int, int *, double *) {return 0;} - virtual int pack_border(int, int *, double *, int, int *) = 0; - virtual int pack_border_vel(int, int *, double *, int, int *) = 0; - virtual int pack_border_hybrid(int, int *, double *) {return 0;} - virtual void unpack_border(int, int, double *) = 0; - virtual void unpack_border_vel(int, int, double *) = 0; - virtual int unpack_border_hybrid(int, int, double *) {return 0;} + int pack_border(int, int *, double *, int, int *); + int pack_border_vel(int, int *, double *, int, int *); + int pack_border_hybrid(int, int *, double *) {return 0;} + void unpack_border(int, int, double *); + void unpack_border_vel(int, int, double *); + int unpack_border_hybrid(int, int, double *) {return 0;} - virtual int pack_exchange(int, double *) = 0; - virtual int unpack_exchange(double *) = 0; + int pack_exchange(int, double *); + int unpack_exchange(double *); - virtual int size_restart() = 0; - virtual int pack_restart(int, double *) = 0; - virtual int unpack_restart(double *) = 0; + int size_restart(); + virtual int pack_restart(int, double *); + virtual int unpack_restart(double *); - virtual void create_atom(int, double *) = 0; + virtual void create_atom(int, double *); - virtual void data_atom(double *, imageint, char **) = 0; - virtual void data_atom_bonus(int, char **) {} - virtual int data_atom_hybrid(int, char **) {return 0;} - virtual void data_vel(int, char **); - virtual int data_vel_hybrid(int, char **) {return 0;} + virtual void data_atom(double *, imageint, char **); + void data_atom_bonus(int, char **) {} + int data_atom_hybrid(int, char **) {return 0;} + void data_vel(int, char **); + int data_vel_hybrid(int, char **) {return 0;} - virtual void pack_data(double **) = 0; - virtual int pack_data_hybrid(int, double *) {return 0;} - virtual void write_data(FILE *, int, double **) = 0; - virtual int write_data_hybrid(FILE *, double *) {return 0;} - virtual void pack_vel(double **); - virtual int pack_vel_hybrid(int, double *) {return 0;} - virtual void write_vel(FILE *, int, double **); - virtual int write_vel_hybrid(FILE *, double *) {return 0;} + void pack_data(double **); + int pack_data_hybrid(int, double *) {return 0;} + void write_data(FILE *, int, double **); + int write_data_hybrid(FILE *, double *) {return 0;} + void pack_vel(double **); + int pack_vel_hybrid(int, double *) {return 0;} + void write_vel(FILE *, int, double **); + int write_vel_hybrid(FILE *, double *) {return 0;} int pack_bond(tagint **); void write_bond(FILE *, int, tagint **, int); @@ -113,10 +113,10 @@ class AtomVec : protected Pointers { int pack_improper(tagint **); void write_improper(FILE *, int, tagint **, int); - virtual int property_atom(char *) {return -1;} - virtual void pack_property_atom(int, double *, int, int) {} + int property_atom(char *) {return -1;} + void pack_property_atom(int, double *, int, int) {} - virtual bigint memory_usage() = 0; + bigint memory_usage(); protected: int nmax; // local copy of atom->nmax @@ -124,6 +124,47 @@ class AtomVec : protected Pointers { int deform_groupbit; double *h_rate; + tagint *tag; // peratom fields common to all styles + int *type,*mask; + imageint *image; + double **x,**v,**f; + + const char *default_grow,*default_copy; + const char *default_comm,*default_comm_vel,*default_reverse; + const char *default_border,*default_border_vel; + const char *default_exchange,*default_restart; + const char *default_create,*default_data_atom,*default_data_vel; + + char *fields_grow,*fields_copy; + char *fields_comm,*fields_comm_vel,*fields_reverse; + char *fields_border,*fields_border_vel; + char *fields_exchange,*fields_restart; + char *fields_create,*fields_data_atom,*fields_data_vel; + + struct Method { + void **pdata; + int *datatype; + int *cols; + int **maxcols; + int *collength; + void **plength; + int *index; + }; + + Method mgrow,mcopy; + Method mcomm,mcomm_vel,mreverse,mborder,mborder_vel,mexchange,mrestart; + Method mcreate,mdata_atom,mdata_vel; + + int ngrow,ncopy; + int ncomm,ncomm_vel,nreverse,nborder,nborder_vel,nexchange,nrestart; + int ncreate,ndata_atom,ndata_vel; + + // thread info for fields that are duplicated over threads + // used by fields in grow() and memory_usage() + + int nthreads; + int *threads; + // union data struct for packing 32-bit and 64-bit ints into double bufs // this avoids aliasing issues by having 2 pointers (double,int) // to same buf memory @@ -143,8 +184,15 @@ class AtomVec : protected Pointers { ubuf(int arg) : i(arg) {} }; + // local methods + void grow_nmax(); int grow_nmax_bonus(int); + void setup_fields(); + int process_fields(char *, const char *, Method *); + void create_method(int, Method *); + void init_method(Method *); + void destroy_method(Method *); }; } @@ -161,4 +209,13 @@ E: KOKKOS package requires a kokkos enabled atom_style Self-explanatory. +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. + */ diff --git a/src/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index 25a28f1668..a283e99081 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -12,14 +12,6 @@ ------------------------------------------------------------------------- */ #include "atom_vec_atomic.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; @@ -30,654 +22,23 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp) molecular = 0; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 6; - size_velocity = 3; - size_data_atom = 5; - size_data_vel = 4; - xcol_data = 3; -} - -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecAtomic::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"); - - 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 AtomVecAtomic::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecAtomic::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]; - - 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 AtomVecAtomic::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecAtomic::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecAtomic::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecAtomic::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecAtomic::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 AtomVecAtomic::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 AtomVecAtomic::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; - } - } 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; - } - } - - 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 AtomVecAtomic::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]; - } - } 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]; - } - } 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]; - } - } - } - } - - 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 AtomVecAtomic::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; - } - - 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 AtomVecAtomic::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++]; - } - - 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]); -} - -/* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - xyz must be 1st 3 values, so comm::exchange() can test on them -------------------------------------------------------------------------- */ - -int AtomVecAtomic::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; - - 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 AtomVecAtomic::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; - - 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 AtomVecAtomic::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 11 * nlocal; - - 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 AtomVecAtomic::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]; - - 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 AtomVecAtomic::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++]; - - 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 AtomVecAtomic::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; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecAtomic::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"); - - 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; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecAtomic::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] = x[i][0]; - buf[i][3] = x[i][1]; - buf[i][4] = x[i][2]; - buf[i][5] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][6] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][7] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecAtomic::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 %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], - (int) ubuf(buf[i][5]).i,(int) ubuf(buf[i][6]).i, - (int) ubuf(buf[i][7]).i); -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecAtomic::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); - - return bytes; + // 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 = NULL; + fields_copy = NULL; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = NULL; + fields_border_vel = NULL; + fields_exchange = NULL; + fields_restart = NULL; + fields_create = NULL; + fields_data_atom = (char *) "id type x"; + fields_data_vel = NULL; + + setup_fields(); } diff --git a/src/atom_vec_atomic.h b/src/atom_vec_atomic.h index afcede89b1..3caf1a5a94 100644 --- a/src/atom_vec_atomic.h +++ b/src/atom_vec_atomic.h @@ -27,36 +27,7 @@ namespace LAMMPS_NS { class AtomVecAtomic : public AtomVec { public: AtomVecAtomic(class LAMMPS *); - virtual ~AtomVecAtomic() {} - 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 *); - 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; + ~AtomVecAtomic() {} }; } @@ -66,13 +37,4 @@ class AtomVecAtomic : 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. - */ diff --git a/src/atom_vec_charge.cpp b/src/atom_vec_charge.cpp index 9f35d16ff0..9c8f18a846 100644 --- a/src/atom_vec_charge.cpp +++ b/src/atom_vec_charge.cpp @@ -13,13 +13,6 @@ #include "atom_vec_charge.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; @@ -30,742 +23,25 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp) molecular = 0; mass_type = 1; - comm_x_only = comm_f_only = 1; - size_forward = 3; - size_reverse = 3; - size_border = 7; - size_velocity = 3; - size_data_atom = 6; - size_data_vel = 4; - xcol_data = 4; - atom->q_flag = 1; -} - -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecCharge::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"); - - q = memory->grow(atom->q,nmax,"atom:q"); - - 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 AtomVecCharge::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; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecCharge::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]; - - 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 AtomVecCharge::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]; - } - } 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; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecCharge::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]; - } - } 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]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecCharge::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecCharge::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++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecCharge::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 AtomVecCharge::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 AtomVecCharge::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]; - } - } 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]; - } - } - - 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 AtomVecCharge::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++] = 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 (!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++] = q[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]; - 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 AtomVecCharge::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]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecCharge::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++]; - } - - 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 AtomVecCharge::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++]; - 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 AtomVecCharge::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++]; - 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 AtomVecCharge::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++] = q[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 AtomVecCharge::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++]; - - 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 AtomVecCharge::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 12 * nlocal; - - 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 AtomVecCharge::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]; - - 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 AtomVecCharge::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++]; - - 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 AtomVecCharge::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; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecCharge::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); - - 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; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style -------------------------------------------------------------------------- */ - -int AtomVecCharge::data_atom_hybrid(int nlocal, char **values) -{ - q[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - - return 1; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecCharge::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] = 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 AtomVecCharge::pack_data_hybrid(int i, double *buf) -{ - buf[0] = q[i]; - return 1; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecCharge::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 AtomVecCharge::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e",buf[0]); - return 1; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecCharge::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); - - return bytes; + + // 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 *) "q"; + fields_copy = (char *) "q"; + fields_comm = NULL; + fields_comm_vel = NULL; + fields_reverse = NULL; + fields_border = (char *) "q"; + fields_border_vel = (char *) "q"; + fields_exchange = (char *) "q"; + fields_restart = (char *) "q"; + fields_create = (char *) "q"; + fields_data_atom = (char *) "id type q x"; + fields_data_vel = NULL; + + setup_fields(); } diff --git a/src/atom_vec_charge.h b/src/atom_vec_charge.h index 10f1d8d141..d52b4a068a 100644 --- a/src/atom_vec_charge.h +++ b/src/atom_vec_charge.h @@ -27,42 +27,6 @@ namespace LAMMPS_NS { class AtomVecCharge : public AtomVec { public: AtomVecCharge(class LAMMPS *); - virtual ~AtomVecCharge() {} - 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 *); - 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 *); - 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(); - - protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *q; }; } @@ -72,13 +36,4 @@ class AtomVecCharge : 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. - */ diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 75136503ea..7a14ea26e6 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -5,7 +5,7 @@ Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributead under the GNU General Public License. See the README file in the top-level LAMMPS directory. @@ -14,15 +14,11 @@ #include "atom_vec_sphere.h" #include #include "atom.h" -#include "comm.h" -#include "domain.h" #include "modify.h" #include "fix.h" #include "fix_adapt.h" #include "math_const.h" -#include "memory.h" #include "error.h" -#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -33,19 +29,29 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; - comm_x_only = 1; - comm_f_only = 0; - size_forward = 3; - size_reverse = 6; - size_border = 8; - size_velocity = 6; - size_data_atom = 7; - size_data_vel = 7; - xcol_data = 5; - atom->sphere_flag = 1; atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_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 *) "radius rmass omega torque"; + fields_copy = (char *) "radius rmass omega"; + fields_comm = NULL; + fields_comm_vel = (char *) "omega"; + fields_reverse = (char *) "torque"; + fields_border = (char *) "radius rmass"; + fields_border_vel = (char *) "radius rmass omega"; + fields_exchange = (char *) "radius rmass omega"; + fields_restart = (char *) "radius rmass omega"; + fields_create = (char *) "radius rmass omega"; + fields_data_atom = (char *) "id type radius rmass x"; + fields_data_vel = (char *) "omega"; + + setup_fields(); } /* ---------------------------------------------------------------------- */ @@ -55,10 +61,11 @@ void AtomVecSphere::init() AtomVec::init(); // set radvary if particle diameters are time-varying due to fix adapt + // NOTE: change this to a atom_style sphere optional arg radvary = 0; - comm_x_only = 1; - size_forward = 3; + //comm_x_only = 1; + //size_forward = 3; for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"adapt") == 0) { @@ -69,1118 +76,42 @@ void AtomVecSphere::init() size_forward = 5; } } -} -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecSphere::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"); - omega = memory->grow(atom->omega,nmax,3,"atom:omega"); - torque = memory->grow(atom->torque,nmax*comm->nthreads,3,"atom:torque"); - - 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 AtomVecSphere::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; - omega = atom->omega; torque = atom->torque; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecSphere::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]; - - radius[j] = radius[i]; - rmass[j] = rmass[i]; - omega[j][0] = omega[i][0]; - omega[j][1] = omega[i][1]; - omega[j][2] = omega[i][2]; - - 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 AtomVecSphere::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,m; - double dx,dy,dz; - - if (radvary == 0) { - 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]; - } - } 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; - } - } - - } else { - 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++] = radius[j]; - buf[m++] = rmass[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++] = radius[j]; - buf[m++] = rmass[j]; - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSphere::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; - - if (radvary == 0) { - 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++] = 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; - 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 (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]; - } - } - } - - } else { - 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++] = radius[j]; - buf[m++] = rmass[j]; - 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; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - 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++] = radius[j]; - buf[m++] = rmass[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]; - } - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSphere::pack_comm_hybrid(int n, int *list, double *buf) -{ - int i,j,m; - - if (radvary == 0) return 0; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSphere::unpack_comm(int n, int first, double *buf) -{ - int i,m,last; - - if (radvary == 0) { - 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++]; - } - } else { - 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++]; - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - } - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSphere::unpack_comm_vel(int n, int first, double *buf) -{ - int i,m,last; - - if (radvary == 0) { - 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++]; - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - } - } else { - 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++]; - radius[i] = buf[m++]; - rmass[i] = 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 AtomVecSphere::unpack_comm_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - if (radvary == 0) return 0; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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++] = radius[j]; - buf[m++] = rmass[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++] = radius[j]; - buf[m++] = rmass[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 AtomVecSphere::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++] = radius[j]; - buf[m++] = rmass[j]; - 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++] = radius[j]; - buf[m++] = rmass[j]; - 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++] = radius[j]; - buf[m++] = rmass[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]; - } - 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 AtomVecSphere::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++] = radius[j]; - buf[m++] = rmass[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSphere::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; - radius[i] = buf[m++]; - rmass[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 AtomVecSphere::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; - radius[i] = buf[m++]; - rmass[i] = 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++]; - } - - 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 AtomVecSphere::unpack_border_hybrid(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - radius[i] = buf[m++]; - rmass[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 AtomVecSphere::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++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = omega[i][0]; - buf[m++] = omega[i][1]; - buf[m++] = omega[i][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 AtomVecSphere::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; - - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - omega[nlocal][0] = buf[m++]; - omega[nlocal][1] = buf[m++]; - omega[nlocal][2] = 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 AtomVecSphere::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = 16 * nlocal; - - 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 AtomVecSphere::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++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = omega[i][0]; - buf[m++] = omega[i][1]; - buf[m++] = omega[i][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 -------------------------------------------------------------------------- */ - -int AtomVecSphere::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++]; - - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - omega[nlocal][0] = buf[m++]; - omega[nlocal][1] = buf[m++]; - omega[nlocal][2] = 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; + //fields_comm = (char *) "radius rmass"; + //fields_comm_vel = (char *) "radius rmass"; } /* ---------------------------------------------------------------------- create one atom of itype at coord - set other values to defaults + modify what default AtomVec::create_atom() just created ------------------------------------------------------------------------- */ void AtomVecSphere::create_atom(int itype, double *coord) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::create_atom(itype,coord); + int ilocal = atom->nlocal-1; - 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] = 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; - - atom->nlocal++; + atom->radius[ilocal] = 0.5; + atom->rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + modify what default AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ void AtomVecSphere::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); + AtomVec::data_atom(coord,imagetmp,values); + int ilocal = atom->nlocal-1; - 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"); + double radius = 0.5 * atom->radius[ilocal]; + atom->radius[ilocal] = radius; + if (radius > 0.0) + atom->rmass[ilocal] = + 4.0*MY_PI/3.0 * radius*radius*radius * atom->rmass[ilocal]; - radius[nlocal] = 0.5 * utils::numeric(FLERR,values[2],true,lmp); - if (radius[nlocal] < 0.0) - error->one(FLERR,"Invalid radius in Atoms section of data file"); - - double density = utils::numeric(FLERR,values[3],true,lmp); - if (density <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - if (radius[nlocal] == 0.0) rmass[nlocal] = density; - else - rmass[nlocal] = 4.0*MY_PI/3.0 * - radius[nlocal]*radius[nlocal]*radius[nlocal] * density; - - 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 AtomVecSphere::data_atom_hybrid(int nlocal, char **values) -{ - radius[nlocal] = 0.5 * utils::numeric(FLERR,values[0],true,lmp); - if (radius[nlocal] < 0.0) - error->one(FLERR,"Invalid radius in Atoms section of data file"); - - double density = utils::numeric(FLERR,values[1],true,lmp); - if (density <= 0.0) - error->one(FLERR,"Invalid density in Atoms section of data file"); - - if (radius[nlocal] == 0.0) rmass[nlocal] = density; - else - rmass[nlocal] = 4.0*MY_PI/3.0 * - radius[nlocal]*radius[nlocal]*radius[nlocal] * density; - - return 2; -} - -/* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file -------------------------------------------------------------------------- */ - -void AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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] = 2.0*radius[i]; - if (radius[i] == 0.0) buf[i][3] = rmass[i]; - else - buf[i][3] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[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; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecSphere::pack_data_hybrid(int i, double *buf) -{ - buf[0] = 2.0*radius[i]; - if (radius[i] == 0.0) buf[1] = rmass[i]; - else buf[1] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[i]); - return 2; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecSphere::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); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecSphere::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e",buf[0],buf[1]); - return 2; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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 AtomVecSphere::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("omega")) bytes += memory->usage(omega,nmax,3); - if (atom->memcheck("torque")) - bytes += memory->usage(torque,nmax*comm->nthreads,3); - - return bytes; + if (atom->rmass[ilocal] <= 0.0) + error->one(FLERR,"Invalid mass in Atoms section of data file"); } diff --git a/src/atom_vec_sphere.h b/src/atom_vec_sphere.h index 28b1198d59..98762dba49 100644 --- a/src/atom_vec_sphere.h +++ b/src/atom_vec_sphere.h @@ -27,54 +27,11 @@ namespace LAMMPS_NS { class AtomVecSphere : public AtomVec { public: AtomVecSphere(class LAMMPS *); - ~AtomVecSphere() {} 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(); private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *radius,*rmass; - double **omega,**torque; int radvary; }; @@ -85,15 +42,6 @@ class AtomVecSphere : 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: Invalid radius in Atoms section of data file Radius must be >= 0.0. From 6c18e366d7d2972a1bf79e6e5f5bd0dd7c0bb6af Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 26 Nov 2019 18:34:51 -0700 Subject: [PATCH 02/42] changes to start to make atom style hybrid work --- src/DIPOLE/atom_vec_dipole.cpp | 12 +- src/DIPOLE/atom_vec_dipole.h | 2 +- src/MOLECULE/atom_vec_angle.cpp | 59 +- src/MOLECULE/atom_vec_angle.h | 8 +- src/MOLECULE/atom_vec_bond.cpp | 50 +- src/MOLECULE/atom_vec_bond.h | 8 +- src/MOLECULE/atom_vec_full.cpp | 81 +-- src/MOLECULE/atom_vec_full.h | 9 +- src/MOLECULE/atom_vec_molecular.cpp | 81 +-- src/MOLECULE/atom_vec_molecular.h | 9 +- src/MOLECULE/atom_vec_template.cpp | 17 +- src/MOLECULE/atom_vec_template.h | 4 +- src/PERI/atom_vec_peri.cpp | 14 +- src/PERI/atom_vec_peri.h | 2 +- src/SPIN/atom_vec_spin.cpp | 34 +- src/SPIN/atom_vec_spin.h | 2 +- src/atom.cpp | 1 + src/atom_vec.cpp | 490 +++++++------- src/atom_vec.h | 51 +- src/atom_vec_hybrid.cpp | 959 ++-------------------------- src/atom_vec_hybrid.h | 36 +- src/atom_vec_sphere.cpp | 80 ++- src/atom_vec_sphere.h | 8 +- src/special.cpp | 1 - 24 files changed, 586 insertions(+), 1432 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index dc3279227d..650bc14d8f 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -55,16 +55,12 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what the default AtomVec::data_atom() just initialized + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecDipole::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - - int ilocal = atom->nlocal-1; - double mu = atom->mu[ilocal]; + double *mu = atom->mu[ilocal]; mu[3] = sqrt(mu[0]*mu[0] + mu[1]*mu[1] + mu[2]*mu[2]); } - diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index 6abcb4e2ea..45f33d109d 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class AtomVecDipole : public AtomVec { public: AtomVecDipole(class LAMMPS *); - void data_atom(double *, imageint, char **); + void data_atom_post(int); }; } diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 79f5a7853e..df48c4b2a0 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -67,11 +67,10 @@ AtomVecAngle::~AtomVecAngle() } /* ---------------------------------------------------------------------- - pack atom I's data for restart file - modify/unmodify values for default AtomVec::pack_restart() to pack + modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -int AtomVecAngle::pack_restart(int i, double *buf) +void AtomVecAngle::pack_restart_pre(int i) { // insure negative vectors are needed length @@ -110,51 +109,49 @@ int AtomVecAngle::pack_restart(int i, double *buf) any_angle_negative = 1; } else angle_negative[m] = 0; } - - // perform the pack with adjusted values - - int n = AtomVec::pack_restart(i,buf); - - // restore the flagged types to their negative values - - if (any_bond_negative) { - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; - } - if (any_angle_negative) { - for (int m = 0; m < num_angle[i]; m++) - if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; - } - - return n; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities - initialize other atom quantities + unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -int AtomVecAngle::unpack_restart(double *buf) +void AtomVecAngle::pack_restart_post(int i) { - AtomVec::unpack_restart(buf); - int ilocal = atom->nlocal-1; + // restore the flagged types to their negative values + if (any_bond_negative) { + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + } + + if (any_angle_negative) { + int *num_angle = atom->num_angle; + int **angle_type = atom->angle_type; + for (int m = 0; m < num_angle[i]; m++) + if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; + } +} + +/* ---------------------------------------------------------------------- + initialize other atom quantities after AtomVec::unpack_restart() +------------------------------------------------------------------------- */ + +void AtomVecAngle::unpack_restart_init(int ilocal) +{ atom->nspecial[ilocal][0] = 0; atom->nspecial[ilocal][1] = 0; atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecAngle::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecAngle::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - atom->num_bond[ilocal] = 0; atom->num_angle[ilocal] = 0; atom->nspecial[ilocal][0] = 0; diff --git a/src/MOLECULE/atom_vec_angle.h b/src/MOLECULE/atom_vec_angle.h index 6511b517ee..48e55b0988 100644 --- a/src/MOLECULE/atom_vec_angle.h +++ b/src/MOLECULE/atom_vec_angle.h @@ -28,11 +28,13 @@ class AtomVecAngle : public AtomVec { public: AtomVecAngle(class LAMMPS *); ~AtomVecAngle(); - int pack_restart(int, double *); - int unpack_restart(double *); - void data_atom(double *, imageint, char **); + void pack_restart_pre(int); + void pack_restart_post(int); + void unpack_restart_init(int); + void data_atom_post(int); private: + int any_bond_negative,any_angle_negative; int bond_per_atom,angle_per_atom; int *bond_negative,*angle_negative; }; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 20cdfdd65a..fd3f08979d 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -61,11 +61,10 @@ AtomVecBond::~AtomVecBond() } /* ---------------------------------------------------------------------- - pack atom I's data for restart file - modify/unmodify values for default AtomVec::pack_restart() to pack + modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -int AtomVecBond::pack_restart(int i, double *buf) +void AtomVecBond::pack_restart_pre(int i) { // insure bond_negative vector is needed length @@ -80,7 +79,7 @@ int AtomVecBond::pack_restart(int i, double *buf) int *num_bond = atom->num_bond; int **bond_type = atom->bond_type; - int any_bond_negative = 0; + any_bond_negative = 0; for (int m = 0; m < num_bond[i]; m++) { if (bond_type[i][m] < 0) { bond_negative[m] = 1; @@ -88,47 +87,42 @@ int AtomVecBond::pack_restart(int i, double *buf) any_bond_negative = 1; } else bond_negative[m] = 0; } - - // perform the pack with adjusted values - - int n = AtomVec::pack_restart(i,buf); - - // restore the flagged types to their negative values - - if (any_bond_negative) { - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; - } - - return n; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities - initialize other atom quantities + unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -int AtomVecBond::unpack_restart(double *buf) +void AtomVecBond::pack_restart_post(int i) { - AtomVec::unpack_restart(buf); - int ilocal = atom->nlocal-1; + // restore the flagged types to their negative values + if (any_bond_negative) { + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + } +} + +/* ---------------------------------------------------------------------- + initialize other atom quantities after AtomVec::unpack_restart() +------------------------------------------------------------------------- */ + +void AtomVecBond::unpack_restart_init(int ilocal) +{ atom->nspecial[ilocal][0] = 0; atom->nspecial[ilocal][1] = 0; atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecBond::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecBond::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - atom->num_bond[ilocal] = 0; atom->nspecial[ilocal][0] = 0; atom->nspecial[ilocal][1] = 0; diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index 9245bc317a..c2bf7d6680 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -28,11 +28,13 @@ class AtomVecBond : public AtomVec { public: AtomVecBond(class LAMMPS *); ~AtomVecBond(); - int pack_restart(int, double *); - int unpack_restart(double *); - void data_atom(double *, imageint, char **); + void pack_restart_pre(int); + void pack_restart_post(int); + void unpack_restart_init(int); + void data_atom_post(int); private: + int any_bond_negative; int bond_per_atom; int *bond_negative; }; diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index 826d5fea4e..ed838aa0e3 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -89,11 +89,10 @@ AtomVecFull::~AtomVecFull() } /* ---------------------------------------------------------------------- - pack atom I's data for restart file - modify/unmodify values for default AtomVec::pack_restart() to pack + modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -int AtomVecFull::pack_restart(int i, double *buf) +void AtomVecFull::pack_restart_pre(int i) { // insure negative vectors are needed length @@ -164,59 +163,63 @@ int AtomVecFull::pack_restart(int i, double *buf) any_improper_negative = 1; } else improper_negative[m] = 0; } - - // perform the pack with adjusted values - - int n = AtomVec::pack_restart(i,buf); - - // restore the flagged types to their negative values - - if (any_bond_negative) { - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; - } - if (any_angle_negative) { - for (int m = 0; m < num_angle[i]; m++) - if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; - } - if (any_dihedral_negative) { - for (int m = 0; m < num_dihedral[i]; m++) - if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m]; - } - if (any_improper_negative) { - for (int m = 0; m < num_improper[i]; m++) - if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m]; - } - - return n; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities - initialize other atom quantities + unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -int AtomVecFull::unpack_restart(double *buf) +void AtomVecFull::pack_restart_post(int i) { - AtomVec::unpack_restart(buf); - int ilocal = atom->nlocal-1; + // restore the flagged types to their negative values + if (any_bond_negative) { + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + } + + if (any_angle_negative) { + int *num_angle = atom->num_angle; + int **angle_type = atom->angle_type; + for (int m = 0; m < num_angle[i]; m++) + if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; + } + + if (any_dihedral_negative) { + int *num_dihedral = atom->num_dihedral; + int **dihedral_type = atom->dihedral_type; + for (int m = 0; m < num_dihedral[i]; m++) + if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m]; + } + + if (any_improper_negative) { + int *num_improper = atom->num_improper; + int **improper_type = atom->improper_type; + for (int m = 0; m < num_improper[i]; m++) + if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m]; + } +} + +/* ---------------------------------------------------------------------- + initialize other atom quantities after AtomVec::unpack_restart() +------------------------------------------------------------------------- */ + +void AtomVecFull::unpack_restart_init(int ilocal) +{ atom->nspecial[ilocal][0] = 0; atom->nspecial[ilocal][1] = 0; atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecFull::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecFull::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - atom->num_bond[ilocal] = 0; atom->num_angle[ilocal] = 0; atom->num_dihedral[ilocal] = 0; diff --git a/src/MOLECULE/atom_vec_full.h b/src/MOLECULE/atom_vec_full.h index b194a86994..455bbd0d5e 100644 --- a/src/MOLECULE/atom_vec_full.h +++ b/src/MOLECULE/atom_vec_full.h @@ -28,11 +28,14 @@ class AtomVecFull : public AtomVec { public: AtomVecFull(class LAMMPS *); ~AtomVecFull(); - int pack_restart(int, double *); - int unpack_restart(double *); - void data_atom(double *, imageint, char **); + void pack_restart_pre(int); + void pack_restart_post(int); + void unpack_restart_init(int); + void data_atom_post(int); private: + int any_bond_negative,any_angle_negative, + any_dihedral_negative,any_improper_negative; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative; }; diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index dad7c5cea6..77aec2cf50 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -89,11 +89,10 @@ AtomVecMolecular::~AtomVecMolecular() } /* ---------------------------------------------------------------------- - pack atom I's data for restart file - modify/unmodify values for default AtomVec::pack_restart() to pack + modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -int AtomVecMolecular::pack_restart(int i, double *buf) +void AtomVecMolecular::pack_restart_pre(int i) { // insure negative vectors are needed length @@ -164,59 +163,63 @@ int AtomVecMolecular::pack_restart(int i, double *buf) any_improper_negative = 1; } else improper_negative[m] = 0; } - - // perform the pack with adjusted values - - int n = AtomVec::pack_restart(i,buf); - - // restore the flagged types to their negative values - - if (any_bond_negative) { - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; - } - if (any_angle_negative) { - for (int m = 0; m < num_angle[i]; m++) - if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; - } - if (any_dihedral_negative) { - for (int m = 0; m < num_dihedral[i]; m++) - if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m]; - } - if (any_improper_negative) { - for (int m = 0; m < num_improper[i]; m++) - if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m]; - } - - return n; } /* ---------------------------------------------------------------------- - unpack data for one atom from restart file including extra quantities - initialize other atom quantities + unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -int AtomVecMolecular::unpack_restart(double *buf) +void AtomVecMolecular::pack_restart_post(int i) { - AtomVec::unpack_restart(buf); - int ilocal = atom->nlocal-1; + // restore the flagged types to their negative values + if (any_bond_negative) { + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + for (int m = 0; m < num_bond[i]; m++) + if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + } + + if (any_angle_negative) { + int *num_angle = atom->num_angle; + int **angle_type = atom->angle_type; + for (int m = 0; m < num_angle[i]; m++) + if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; + } + + if (any_dihedral_negative) { + int *num_dihedral = atom->num_dihedral; + int **dihedral_type = atom->dihedral_type; + for (int m = 0; m < num_dihedral[i]; m++) + if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m]; + } + + if (any_improper_negative) { + int *num_improper = atom->num_improper; + int **improper_type = atom->improper_type; + for (int m = 0; m < num_improper[i]; m++) + if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m]; + } +} + +/* ---------------------------------------------------------------------- + initialize other atom quantities after AtomVec::unpack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMolecular::unpack_restart_init(int ilocal) +{ atom->nspecial[ilocal][0] = 0; atom->nspecial[ilocal][1] = 0; atom->nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecMolecular::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecMolecular::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - atom->num_bond[ilocal] = 0; atom->num_angle[ilocal] = 0; atom->num_dihedral[ilocal] = 0; diff --git a/src/MOLECULE/atom_vec_molecular.h b/src/MOLECULE/atom_vec_molecular.h index cba6d1b480..5b79f8b5c6 100644 --- a/src/MOLECULE/atom_vec_molecular.h +++ b/src/MOLECULE/atom_vec_molecular.h @@ -28,11 +28,14 @@ class AtomVecMolecular : public AtomVec { public: AtomVecMolecular(class LAMMPS *); ~AtomVecMolecular(); - int pack_restart(int, double *); - int unpack_restart(double *); - void data_atom(double *, imageint, char **); + void pack_restart_pre(int); + void pack_restart_post(int); + void unpack_restart_init(int); + void data_atom_post(int); private: + int any_bond_negative,any_angle_negative, + any_dihedral_negative,any_improper_negative; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative; }; diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index 31d9af4caf..d22e9abfb3 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -97,29 +97,22 @@ void AtomVecTemplate::process_args(int narg, char **arg) } /* ---------------------------------------------------------------------- - create one atom of itype at coord - modify what default AtomVec::create_atom() just created + initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecTemplate::create_atom(int itype, double *coord) +void AtomVecTemplate::create_atom_post(int ilocal) { - AtomVec::create_atom(itype,coord); - - int ilocal = atom->nlocal-1; atom->molindex[ilocal] = -1; atom->molatom[ilocal] = -1; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - error check what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecTemplate::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecTemplate::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - - int ilocal = atom->nlocal-1; int molindex = atom->molindex[ilocal]; int molatom = atom->molatom[ilocal]; diff --git a/src/MOLECULE/atom_vec_template.h b/src/MOLECULE/atom_vec_template.h index 59a1386f2d..52ef5e70e1 100644 --- a/src/MOLECULE/atom_vec_template.h +++ b/src/MOLECULE/atom_vec_template.h @@ -28,8 +28,8 @@ class AtomVecTemplate : public AtomVec { public: AtomVecTemplate(class LAMMPS *); void process_args(int, char **); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); + void create_atom_post(int); + void data_atom_post(int); }; } diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 29c4cb0d83..5450b23293 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -88,20 +88,16 @@ void AtomVecPeri::create_atom(int itype, double *coord) } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecPeri::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecPeri::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - 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]; if (atom->rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid mass in Atoms section of data file"); diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 12ef650348..3b41950a6f 100644 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -28,7 +28,7 @@ class AtomVecPeri : public AtomVec { public: AtomVecPeri(class LAMMPS *); void create_atom(int, double *); - void data_atom(double *, imageint, char **); + void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); }; diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 135f8936a1..6c88fb1a9e 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -62,25 +62,7 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked - or initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecSpin::data_atom(double *coord, imageint imagetmp, char **values) -{ - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - - double *sp = atom->sp[ilocal]; - double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]); - sp[0] *= inorm; - sp[1] *= inorm; - sp[2] *= inorm; -} - -/* ---------------------------------------------------------------------- - clear all forces (mech and mag) + clear all forces (mechanical and magnetic) ------------------------------------------------------------------------- */ void AtomVecSpin::force_clear(int /*n*/, size_t nbytes) @@ -89,3 +71,17 @@ void AtomVecSpin::force_clear(int /*n*/, size_t nbytes) memset(&atom->fm[0][0],0,3*nbytes); memset(&atom->fm_long[0][0],0,3*nbytes); } + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecSpin::data_atom_post(int ilocal) +{ + double *sp = atom->sp[ilocal]; + double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]); + sp[0] *= inorm; + sp[1] *= inorm; + sp[2] *= inorm; +} diff --git a/src/SPIN/atom_vec_spin.h b/src/SPIN/atom_vec_spin.h index ca92cccc2e..c68f3a0419 100644 --- a/src/SPIN/atom_vec_spin.h +++ b/src/SPIN/atom_vec_spin.h @@ -27,8 +27,8 @@ namespace LAMMPS_NS { class AtomVecSpin : public AtomVec { public: AtomVecSpin(class LAMMPS *); - void data_atom(double *, imageint, char **); void force_clear(int, size_t); + void data_atom_post(int); }; } diff --git a/src/atom.cpp b/src/atom.cpp index 7f1a5a6022..e1736e321c 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -2498,3 +2498,4 @@ bigint Atom::memory_usage() return bytes; } + diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 428117f0db..776d7a4619 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -145,223 +145,6 @@ void AtomVec::init() error->all(FLERR,"KOKKOS package requires a kokkos enabled atom_style"); } -/* ---------------------------------------------------------------------- - process field strings to initialize data structs for all other methods -------------------------------------------------------------------------- */ - -void AtomVec::setup_fields() -{ - int n,cols; - - if (!fields_data_atom) - error->all(FLERR,"Atom style requires fields_data_atom"); - - // process field strings - // return # of fields and matching index into atom->peratom (in Method struct) - - ngrow = process_fields(fields_grow,default_grow,&mgrow); - ncopy = process_fields(fields_copy,default_copy,&mcopy); - ncomm = process_fields(fields_comm,default_comm,&mcomm); - ncomm_vel = process_fields(fields_comm_vel,default_comm_vel,&mcomm_vel); - nreverse = process_fields(fields_reverse,default_reverse,&mreverse); - nborder = process_fields(fields_border,default_border,&mborder); - nborder_vel = process_fields(fields_border_vel,default_border_vel,&mborder_vel); - nexchange = process_fields(fields_exchange,default_exchange,&mexchange); - nrestart = process_fields(fields_restart,default_restart,&mrestart); - ncreate = process_fields(fields_create,default_create,&mcreate); - ndata_atom = process_fields(fields_data_atom,default_data_atom,&mdata_atom); - ndata_vel = process_fields(fields_data_vel,default_data_vel,&mdata_vel); - - // populate field-based data struct for each method to use - - create_method(ngrow,&mgrow); - create_method(ncopy,&mcopy); - create_method(ncomm,&mcomm); - create_method(ncomm_vel,&mcomm_vel); - create_method(nreverse,&mreverse); - create_method(nborder,&mborder); - create_method(nborder_vel,&mborder_vel); - create_method(nexchange,&mexchange); - create_method(nrestart,&mrestart); - create_method(ncreate,&mcreate); - create_method(ndata_atom,&mdata_atom); - create_method(ndata_vel,&mdata_vel); - - // create threads data struct for grow and memory_usage to use - - threads = new int[ngrow]; - for (int i = 0; i < ngrow; i++) { - Atom::PerAtom *field = &atom->peratom[mgrow.index[i]]; - if (field->threadflag) threads[i] = nthreads; - else threads[i] = 1; - } - - // set style-specific variables - // NOTE: check for others vars in atom_vec.cpp/h ?? - - if (ncomm == 0) comm_x_only = 1; - else comm_x_only = 0; - - if (nreverse == 0) comm_f_only = 1; - else comm_f_only = 0; - - size_forward = 3; - for (n = 0; n < ncomm; n++) { - cols = mcomm.cols[n]; - if (cols == 0) size_forward++; - else size_forward += cols; - } - - size_reverse = 3; - for (n = 0; n < nreverse; n++) { - cols = mreverse.cols[n]; - if (cols == 0) size_reverse++; - else size_reverse += cols; - } - - size_border = 6; - for (n = 0; n < nborder; n++) { - cols = mborder.cols[n]; - if (cols == 0) size_border++; - else size_border += cols; - } - - size_velocity = 3; - for (n = 0; n < ncomm_vel; n++) { - cols = mcomm_vel.cols[n]; - if (cols == 0) size_velocity++; - else size_velocity += cols; - } - - size_data_atom = 0; - for (n = 0; n < ndata_atom; n++) { - cols = mdata_atom.cols[n]; - if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0) - xcol_data = size_data_atom + 1; - if (cols == 0) size_data_atom++; - else size_data_atom += cols; - } - - size_data_vel = 4; - for (n = 0; n < ndata_vel; n++) { - cols = mdata_vel.cols[n]; - if (cols == 0) size_data_vel++; - else size_data_vel += cols; - } -} - -/* ---------------------------------------------------------------------- - process a single field string -------------------------------------------------------------------------- */ - -int AtomVec::process_fields(char *list, const char *default_list, Method *method) -{ - int i,n; - char match[128]; - - if (list == NULL) { - method->index = NULL; - return 0; - } - - // make copy of list of fields so can tokenize it - - n = strlen(list) + 1; - char *copy = new char[n]; - strcpy(copy,list); - - int nfield = atom->count_words(copy); - int *index = new int[nfield]; - - Atom::PerAtom *peratom = atom->peratom; - int nperatom = atom->nperatom; - - nfield = 0; - char *field = strtok(copy," "); - while (field) { - - // find field in master Atom::peratom list - - 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"); - index[nfield++] = i; - - // error if field is in default list or appears multiple times - - sprintf(match," %s ",field); - if (strstr(default_list,match)) - error->all(FLERR,"Atom_style repeat of default peratom field"); - - for (i = 0; i < nfield-1; i++) - if (index[i] == index[nfield-1]) - error->all(FLERR,"Atom_style duplicated peratom field"); - - field = strtok(NULL," "); - } - - delete [] copy; - - method->index = index; - return nfield; -} - -/* ---------------------------------------------------------------------- - create a method data structs for processing fields -------------------------------------------------------------------------- */ - -void AtomVec::create_method(int nfield, Method *method) -{ - method->pdata = new void*[nfield]; - method->datatype = new int[nfield]; - method->cols = new int[nfield]; - method->maxcols = new int*[nfield]; - method->collength = new int[nfield]; - method->plength = new void*[nfield]; - - for (int i = 0; i < nfield; i++) { - Atom::PerAtom *field = &atom->peratom[method->index[i]]; - method->pdata[i] = (void *) field->address; - method->datatype[i] = field->datatype; - method->cols[i] = field->cols; - if (method->cols[i] < 0) { - method->maxcols[i] = field->address_maxcols; - method->collength[i] = field->collength; - method->plength[i] = field->address_length; - } - } -} - -/* ---------------------------------------------------------------------- - free memory in a method data structs -------------------------------------------------------------------------- */ - -void AtomVec::init_method(Method *method) -{ - method->pdata = NULL; - method->datatype = NULL; - method->cols = NULL; - method->maxcols = NULL; - method->collength = NULL; - method->plength = NULL; - method->index = NULL; -} - -/* ---------------------------------------------------------------------- - free memory in a method data structs -------------------------------------------------------------------------- */ - -void AtomVec::destroy_method(Method *method) -{ - delete [] method->pdata; - delete [] method->datatype; - delete [] method->cols; - delete [] method->maxcols; - delete [] method->collength; - delete [] method->plength; - delete [] method->index; -} - /* ---------------------------------------------------------------------- grow nmax so it is a multiple of DELTA ------------------------------------------------------------------------- */ @@ -446,18 +229,6 @@ void AtomVec::grow(int n) modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); } -/* ---------------------------------------------------------------------- - reset local array ptrs -------------------------------------------------------------------------- */ - -void AtomVec::grow_reset() -{ - // NOTE: is this method needed anymore - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; -} - /* ---------------------------------------------------------------------- copy atom I info to atom J ------------------------------------------------------------------------- */ @@ -1614,6 +1385,10 @@ int AtomVec::pack_restart(int i, double *buf) int mm,nn,datatype,cols,collength,ncols; void *pdata,*plength; + // if needed, change values before packing + + pack_restart_pre(i); + int m = 1; buf[m++] = x[i][0]; buf[m++] = x[i][1]; @@ -1684,6 +1459,12 @@ int AtomVec::pack_restart(int i, double *buf) } } + // if needed, restore values after packing + + pack_restart_post(i); + + // invoke fixes which store peratom restart info + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); @@ -1777,6 +1558,12 @@ int AtomVec::unpack_restart(double *buf) } } + // if needed, initialize other peratom values + + unpack_restart_init(nlocal); + + // store extra restart info which fixes can unpack when instantiated + double **extra = atom->extra; if (atom->nextra_store) { int size = static_cast (buf[0]) - m; @@ -1812,7 +1599,7 @@ void AtomVec::create_atom(int itype, double *coord) v[nlocal][1] = 0.0; v[nlocal][2] = 0.0; - // special-case initialization for some fields + // initialization additional fields for (n = 0; n < ncreate; n++) { pdata = mcreate.pdata[n]; @@ -1848,12 +1635,16 @@ void AtomVec::create_atom(int itype, double *coord) } } + // if needed, initialize other peratom values + + create_atom_post(nlocal); + atom->nlocal++; } /* ---------------------------------------------------------------------- unpack one line from Atoms section of data file - initialize other atom quantities + initialize other peratom quantities ------------------------------------------------------------------------- */ void AtomVec::data_atom(double *coord, imageint imagetmp, char **values) @@ -1919,6 +1710,10 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, char **values) if (atom->type[nlocal] <= 0 || atom->type[nlocal] > atom->ntypes) error->one(FLERR,"Invalid atom type in Atoms section of data file"); + // if needed, modify unpacked values or initialize other peratom values + + data_atom_post(nlocal); + atom->nlocal++; } @@ -1933,6 +1728,11 @@ void AtomVec::pack_data(double **buf) int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { + + // if needed, change values before packing + + pack_data_pre(i); + j = 0; for (n = 0; n < ndata_atom; n++) { pdata = mdata_atom.pdata[n]; @@ -1971,6 +1771,10 @@ void AtomVec::pack_data(double **buf) buf[i][j++] = ubuf((image[i] & IMGMASK) - IMGMAX).d; buf[i][j++] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; buf[i][j++] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + + // if needed, restore values after packing + + pack_data_post(i); } } @@ -2493,3 +2297,227 @@ bigint AtomVec::memory_usage() return bytes; } + +// ---------------------------------------------------------------------- +// internal methods +// ---------------------------------------------------------------------- + +/* ---------------------------------------------------------------------- + process field strings to initialize data structs for all other methods +------------------------------------------------------------------------- */ + +void AtomVec::setup_fields() +{ + int n,cols; + + if (!fields_data_atom) + error->all(FLERR,"Atom style requires fields_data_atom"); + if (strstr(fields_data_atom,"id ") != fields_data_atom) + error->all(FLERR,"Atom style fields_data_atom must have id as first field"); + + // process field strings + // return # of fields and matching index into atom->peratom (in Method struct) + + ngrow = process_fields(fields_grow,default_grow,&mgrow); + ncopy = process_fields(fields_copy,default_copy,&mcopy); + ncomm = process_fields(fields_comm,default_comm,&mcomm); + ncomm_vel = process_fields(fields_comm_vel,default_comm_vel,&mcomm_vel); + nreverse = process_fields(fields_reverse,default_reverse,&mreverse); + nborder = process_fields(fields_border,default_border,&mborder); + nborder_vel = process_fields(fields_border_vel,default_border_vel,&mborder_vel); + nexchange = process_fields(fields_exchange,default_exchange,&mexchange); + nrestart = process_fields(fields_restart,default_restart,&mrestart); + ncreate = process_fields(fields_create,default_create,&mcreate); + ndata_atom = process_fields(fields_data_atom,default_data_atom,&mdata_atom); + ndata_vel = process_fields(fields_data_vel,default_data_vel,&mdata_vel); + + // populate field-based data struct for each method to use + + create_method(ngrow,&mgrow); + create_method(ncopy,&mcopy); + create_method(ncomm,&mcomm); + create_method(ncomm_vel,&mcomm_vel); + create_method(nreverse,&mreverse); + create_method(nborder,&mborder); + create_method(nborder_vel,&mborder_vel); + create_method(nexchange,&mexchange); + create_method(nrestart,&mrestart); + create_method(ncreate,&mcreate); + create_method(ndata_atom,&mdata_atom); + create_method(ndata_vel,&mdata_vel); + + // create threads data struct for grow and memory_usage to use + + threads = new int[ngrow]; + for (int i = 0; i < ngrow; i++) { + Atom::PerAtom *field = &atom->peratom[mgrow.index[i]]; + if (field->threadflag) threads[i] = nthreads; + else threads[i] = 1; + } + + // set style-specific variables + // 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; + + if (nreverse == 0) comm_f_only = 1; + else comm_f_only = 0; + + size_forward = 3; + for (n = 0; n < ncomm; n++) { + cols = mcomm.cols[n]; + if (cols == 0) size_forward++; + else size_forward += cols; + } + + size_reverse = 3; + for (n = 0; n < nreverse; n++) { + cols = mreverse.cols[n]; + if (cols == 0) size_reverse++; + else size_reverse += cols; + } + + size_border = 6; + for (n = 0; n < nborder; n++) { + cols = mborder.cols[n]; + if (cols == 0) size_border++; + else size_border += cols; + } + + size_velocity = 3; + for (n = 0; n < ncomm_vel; n++) { + cols = mcomm_vel.cols[n]; + if (cols == 0) size_velocity++; + else size_velocity += cols; + } + + size_data_atom = 0; + for (n = 0; n < ndata_atom; n++) { + cols = mdata_atom.cols[n]; + if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0) + xcol_data = size_data_atom + 1; + if (cols == 0) size_data_atom++; + else size_data_atom += cols; + } + + size_data_vel = 4; + for (n = 0; n < ndata_vel; n++) { + cols = mdata_vel.cols[n]; + if (cols == 0) size_data_vel++; + else size_data_vel += cols; + } +} + +/* ---------------------------------------------------------------------- + process a single field string +------------------------------------------------------------------------- */ + +int AtomVec::process_fields(char *list, const char *default_list, Method *method) +{ + int i,n; + char match[128]; + + if (list == NULL) { + method->index = NULL; + return 0; + } + + // make copy of list of fields so can tokenize it + + n = strlen(list) + 1; + char *copy = new char[n]; + strcpy(copy,list); + + int nfield = atom->count_words(copy); + int *index = new int[nfield]; + + Atom::PerAtom *peratom = atom->peratom; + int nperatom = atom->nperatom; + + nfield = 0; + char *field = strtok(copy," "); + while (field) { + + // find field in master Atom::peratom list + + 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"); + index[nfield++] = i; + + // error if field is in default list or appears multiple times + + sprintf(match," %s ",field); + if (strstr(default_list,match)) + error->all(FLERR,"Atom_style repeat of default peratom field"); + + for (i = 0; i < nfield-1; i++) + if (index[i] == index[nfield-1]) + error->all(FLERR,"Atom_style duplicated peratom field"); + + field = strtok(NULL," "); + } + + delete [] copy; + + method->index = index; + return nfield; +} + +/* ---------------------------------------------------------------------- + create a method data structs for processing fields +------------------------------------------------------------------------- */ + +void AtomVec::create_method(int nfield, Method *method) +{ + method->pdata = new void*[nfield]; + method->datatype = new int[nfield]; + method->cols = new int[nfield]; + method->maxcols = new int*[nfield]; + method->collength = new int[nfield]; + method->plength = new void*[nfield]; + + for (int i = 0; i < nfield; i++) { + Atom::PerAtom *field = &atom->peratom[method->index[i]]; + method->pdata[i] = (void *) field->address; + method->datatype[i] = field->datatype; + method->cols[i] = field->cols; + if (method->cols[i] < 0) { + method->maxcols[i] = field->address_maxcols; + method->collength[i] = field->collength; + method->plength[i] = field->address_length; + } + } +} + +/* ---------------------------------------------------------------------- + free memory in a method data structs +------------------------------------------------------------------------- */ + +void AtomVec::init_method(Method *method) +{ + method->pdata = NULL; + method->datatype = NULL; + method->cols = NULL; + method->maxcols = NULL; + method->collength = NULL; + method->plength = NULL; + method->index = NULL; +} + +/* ---------------------------------------------------------------------- + free memory in a method data structs +------------------------------------------------------------------------- */ + +void AtomVec::destroy_method(Method *method) +{ + delete [] method->pdata; + delete [] method->datatype; + delete [] method->cols; + delete [] method->maxcols; + delete [] method->collength; + delete [] method->plength; + delete [] method->index; +} diff --git a/src/atom_vec.h b/src/atom_vec.h index c3551b541d..8ed6fff35f 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -49,60 +49,68 @@ class AtomVec : protected Pointers { int nargcopy; // copy of command-line args for atom_style command char **argcopy; // used when AtomVec is realloced (restart,replicate) + // additional list of peratom fields operated on by different methods + // set by child styles + + char *fields_grow,*fields_copy; + char *fields_comm,*fields_comm_vel,*fields_reverse; + char *fields_border,*fields_border_vel; + char *fields_exchange,*fields_restart; + char *fields_create,*fields_data_atom,*fields_data_vel; + + // methods + AtomVec(class LAMMPS *); virtual ~AtomVec(); void store_args(int, char **); virtual void process_args(int, char **); virtual void init(); + virtual void force_clear(int, size_t) {} + void grow(int); - void grow_reset(); void copy(int, int, int); void clear_bonus() {} - 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 *) {return 0;} void unpack_comm(int, int, double *); void unpack_comm_vel(int, int, double *); - int unpack_comm_hybrid(int, int, double *) {return 0;} int pack_reverse(int, int, double *); - int pack_reverse_hybrid(int, int, double *) {return 0;} void unpack_reverse(int, int *, double *); - int unpack_reverse_hybrid(int, int *, double *) {return 0;} int pack_border(int, int *, double *, int, int *); int pack_border_vel(int, int *, double *, int, int *); - int pack_border_hybrid(int, int *, double *) {return 0;} void unpack_border(int, int, double *); void unpack_border_vel(int, int, double *); - int unpack_border_hybrid(int, int, double *) {return 0;} int pack_exchange(int, double *); int unpack_exchange(double *); int size_restart(); - virtual int pack_restart(int, double *); - virtual int unpack_restart(double *); + virtual void pack_restart_pre(int) {} + int pack_restart(int, double *); + virtual void pack_restart_post(int) {} + int unpack_restart(double *); + virtual void unpack_restart_init(int) {} - virtual void create_atom(int, double *); + void create_atom(int, double *); + virtual void create_atom_post(int) {} + + void data_atom(double *, imageint, char **); + virtual void data_atom_post(int) {} - virtual void data_atom(double *, imageint, char **); void data_atom_bonus(int, char **) {} - int data_atom_hybrid(int, char **) {return 0;} void data_vel(int, char **); - int data_vel_hybrid(int, char **) {return 0;} + 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 **); - int write_data_hybrid(FILE *, double *) {return 0;} void pack_vel(double **); - int pack_vel_hybrid(int, double *) {return 0;} void write_vel(FILE *, int, double **); - int write_vel_hybrid(FILE *, double *) {return 0;} int pack_bond(tagint **); void write_bond(FILE *, int, tagint **, int); @@ -129,18 +137,15 @@ class AtomVec : protected Pointers { imageint *image; double **x,**v,**f; + // standard list of peratom fields always operated on by different methods + // common to all styles, so not listed in field strings + const char *default_grow,*default_copy; const char *default_comm,*default_comm_vel,*default_reverse; const char *default_border,*default_border_vel; const char *default_exchange,*default_restart; const char *default_create,*default_data_atom,*default_data_vel; - char *fields_grow,*fields_copy; - char *fields_comm,*fields_comm_vel,*fields_reverse; - char *fields_border,*fields_border_vel; - char *fields_exchange,*fields_restart; - char *fields_create,*fields_data_atom,*fields_data_vel; - struct Method { void **pdata; int *datatype; diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 4ca0dfbba5..d96494544c 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -35,6 +35,15 @@ AtomVecHybrid::~AtomVecHybrid() delete [] styles; for (int k = 0; k < nstyles; k++) delete [] keywords[k]; delete [] keywords; + + // these strings will be concatenated from sub-style strings + // fields_data_atom must start with fields common to all styles + + fields_grow = fields_copy = fields_comm = fields_comm_vel = NULL; + fields_reverse = fields_border = fields_border_vel = NULL; + fields_exchange = fields_restart = fields_create = NULL; + fields_data_atom = (char *) "id type x"; + fields_data_vel = NULL; } /* ---------------------------------------------------------------------- @@ -81,51 +90,49 @@ void AtomVecHybrid::process_args(int narg, char **arg) for (int i = 0; i < nallstyles; i++) delete [] allstyles[i]; delete [] allstyles; - // hybrid settings are MAX or MIN of sub-style settings - // hybrid sizes are minimal values plus extra values for each sub-style + // concatenate field strings from all sub-styles - molecular = 0; - comm_x_only = comm_f_only = 1; + concatenate_fields(); - size_forward = 3; - size_reverse = 3; - size_border = 6; - size_data_atom = 5; - size_data_vel = 4; - xcol_data = 3; - maxexchange = 0; + // parent AtomVec will now operate on concatenated fields + setup_fields(); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::concatenate_fields() +{ for (int k = 0; k < nstyles; k++) { - if ((styles[k]->molecular == 1 && molecular == 2) || - (styles[k]->molecular == 2 && molecular == 1)) - error->all(FLERR,"Cannot mix molecular and molecule template " - "atom styles"); - molecular = MAX(molecular,styles[k]->molecular); - - bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow); - angles_allow = MAX(angles_allow,styles[k]->angles_allow); - dihedrals_allow = MAX(dihedrals_allow,styles[k]->dihedrals_allow); - impropers_allow = MAX(impropers_allow,styles[k]->impropers_allow); - mass_type = MAX(mass_type,styles[k]->mass_type); - dipole_type = MAX(dipole_type,styles[k]->dipole_type); - forceclearflag = MAX(forceclearflag,styles[k]->forceclearflag); - - if (styles[k]->molecular == 2) onemols = styles[k]->onemols; - - comm_x_only = MIN(comm_x_only,styles[k]->comm_x_only); - comm_f_only = MIN(comm_f_only,styles[k]->comm_f_only); - size_forward += styles[k]->size_forward - 3; - size_reverse += styles[k]->size_reverse - 3; - size_border += styles[k]->size_border - 6; - size_data_atom += styles[k]->size_data_atom - 5; - size_data_vel += styles[k]->size_data_vel - 4; - - maxexchange += styles[k]->maxexchange; + concatenate(fields_grow,styles[k]->fields_grow); + concatenate(fields_copy,styles[k]->fields_copy); + concatenate(fields_comm,styles[k]->fields_comm); + concatenate(fields_comm_vel,styles[k]->fields_comm_vel); + concatenate(fields_reverse,styles[k]->fields_reverse); + concatenate(fields_border,styles[k]->fields_border); + concatenate(fields_border_vel,styles[k]->fields_border_vel); + concatenate(fields_exchange,styles[k]->fields_exchange); + concatenate(fields_restart,styles[k]->fields_restart); + concatenate(fields_create,styles[k]->fields_create); + concatenate(fields_data_atom,styles[k]->fields_data_atom); + concatenate(fields_data_vel,styles[k]->fields_data_vel); } +} - size_velocity = 3; - if (atom->omega_flag) size_velocity += 3; - if (atom->angmom_flag) size_velocity += 3; +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::concatenate(char *&root, char *add) +{ + /* + char **rootwords,**addwords; + int nroot = parse(root,rootwords); + int nadd = parse(add,addwords); + + for (int iadd = 0; iadd < nadd; iadd++) { + if (check(addwords[iadd],nroot,rootwords)) continue; + addone(addwords[iadd],nroot,rootwords); + } + */ } /* ---------------------------------------------------------------------- */ @@ -136,76 +143,6 @@ void AtomVecHybrid::init() for (int k = 0; k < nstyles; k++) styles[k]->init(); } -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n -------------------------------------------------------------------------- */ - -void AtomVecHybrid::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"); - - // sub-styles perform all reallocation - // turn off nextra_grow so hybrid can do that once below - - int tmp = atom->nextra_grow; - atom->nextra_grow = 0; - for (int k = 0; k < nstyles; k++) styles[k]->grow(nmax); - atom->nextra_grow = tmp; - - // insure hybrid local ptrs and sub-style ptrs are up to date - // for sub-styles, do this in case - // multiple sub-style reallocs of same array occurred - - grow_reset(); - - 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 AtomVecHybrid::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - omega = atom->omega; angmom = atom->angmom; - - for (int k = 0; k < nstyles; k++) styles[k]->grow_reset(); -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J for all sub-styles -------------------------------------------------------------------------- */ - -void AtomVecHybrid::copy(int i, int j, int delflag) -{ - int tmp = atom->nextra_grow; - atom->nextra_grow = 0; - for (int k = 0; k < nstyles; k++) styles[k]->copy(i,j,delflag); - atom->nextra_grow = tmp; - - 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 AtomVecHybrid::clear_bonus() -{ - for (int k = 0; k < nstyles; k++) styles[k]->clear_bonus(); -} - /* ---------------------------------------------------------------------- */ void AtomVecHybrid::force_clear(int n, size_t nbytes) @@ -214,799 +151,6 @@ void AtomVecHybrid::force_clear(int n, size_t nbytes) if (styles[k]->forceclearflag) styles[k]->force_clear(n,nbytes); } -/* ---------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,k,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]; - } - } 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; - } - } - - // pack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_comm_hybrid(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,k,m; - double dx,dy,dz,dvx,dvy,dvz; - int omega_flag = atom->omega_flag; - int angmom_flag = atom->angmom_flag; - - 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]; - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } 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]; - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - } - - // pack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_comm_hybrid(n,list,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecHybrid::unpack_comm(int n, int first, double *buf) -{ - int i,k,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++]; - } - - // unpack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->unpack_comm_hybrid(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecHybrid::unpack_comm_vel(int n, int first, double *buf) -{ - int i,k,m,last; - int omega_flag = atom->omega_flag; - int angmom_flag = atom->angmom_flag; - - 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++]; - if (omega_flag) { - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - } - if (angmom_flag) { - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } - } - - // unpack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->unpack_comm_hybrid(n,first,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_reverse(int n, int first, double *buf) -{ - int i,k,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]; - } - - // pack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_reverse_hybrid(n,first,&buf[m]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf) -{ - int i,j,k,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++]; - } - - // unpack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->unpack_reverse_hybrid(n,list,&buf[m]); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_border(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,k,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; - } - } 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; - } - } - - // pack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_border_hybrid(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]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_border_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,k,m; - double dx,dy,dz,dvx,dvy,dvz; - int omega_flag = atom->omega_flag; - int angmom_flag = atom->angmom_flag; - - 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]; - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } 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]; - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } 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]; - } - if (omega_flag) { - buf[m++] = omega[j][0]; - buf[m++] = omega[j][1]; - buf[m++] = omega[j][2]; - } - if (angmom_flag) { - buf[m++] = angmom[j][0]; - buf[m++] = angmom[j][1]; - buf[m++] = angmom[j][2]; - } - } - } - } - - // pack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_border_hybrid(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]); - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecHybrid::unpack_border(int n, int first, double *buf) -{ - int i,k,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; - } - - // unpack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->unpack_border_hybrid(n,first,&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 AtomVecHybrid::unpack_border_vel(int n, int first, double *buf) -{ - int i,k,m,last; - int omega_flag = atom->omega_flag; - int angmom_flag = atom->angmom_flag; - - 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++]; - if (omega_flag) { - omega[i][0] = buf[m++]; - omega[i][1] = buf[m++]; - omega[i][2] = buf[m++]; - } - if (angmom_flag) { - angmom[i][0] = buf[m++]; - angmom[i][1] = buf[m++]; - angmom[i][2] = buf[m++]; - } - } - - // unpack sub-style contributions as contiguous chunks - - for (k = 0; k < nstyles; k++) - m += styles[k]->unpack_border_hybrid(n,first,&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]); -} - -/* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - pack each sub-style one after the other -------------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_exchange(int i, double *buf) -{ - int k,m; - - int tmp = atom->nextra_grow; - atom->nextra_grow = 0; - - m = 0; - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_exchange(i,&buf[m]); - - atom->nextra_grow = tmp; - - 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; -} - -/* ---------------------------------------------------------------------- - unpack data for single atom received from another proc - unpack each sub-style one after the other - grow() occurs here so arrays for all sub-styles are grown -------------------------------------------------------------------------- */ - -int AtomVecHybrid::unpack_exchange(double *buf) -{ - int k,m; - - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - int tmp = atom->nextra_grow; - atom->nextra_grow = 0; - - m = 0; - for (k = 0; k < nstyles; k++) { - m += styles[k]->unpack_exchange(&buf[m]); - atom->nlocal--; - } - - atom->nextra_grow = tmp; - - 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 AtomVecHybrid::size_restart() -{ - int tmp = atom->nextra_restart; - atom->nextra_restart = 0; - - int n = 0; - for (int k = 0; k < nstyles; k++) - n += styles[k]->size_restart(); - - atom->nextra_restart = tmp; - - int nlocal = atom->nlocal; - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (int 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 - pack each sub-style one after the other -------------------------------------------------------------------------- */ - -int AtomVecHybrid::pack_restart(int i, double *buf) -{ - int tmp = atom->nextra_restart; - atom->nextra_restart = 0; - - int m = 0; - for (int k = 0; k < nstyles; k++) - m += styles[k]->pack_restart(i,&buf[m]); - - atom->nextra_restart = tmp; - - 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 each sub-style one after the other - grow() occurs here so arrays for all sub-styles are grown -------------------------------------------------------------------------- */ - -int AtomVecHybrid::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 tmp = atom->nextra_store; - atom->nextra_store = 0; - - int m = 0; - for (int k = 0; k < nstyles; k++) { - m += styles[k]->unpack_restart(&buf[m]); - atom->nlocal--; - } - atom->nextra_store = tmp; - - 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 - create each sub-style one after the other - grow() occurs here so arrays for all sub-styles are grown -------------------------------------------------------------------------- */ - -void AtomVecHybrid::create_atom(int itype, double *coord) -{ - int nlocal = atom->nlocal; - if (nlocal == nmax) grow(0); - - for (int k = 0; k < nstyles; k++) { - styles[k]->create_atom(itype,coord); - atom->nlocal--; - } - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - grow() occurs here so arrays for all sub-styles are grown -------------------------------------------------------------------------- */ - -void AtomVecHybrid::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"); - - 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; - if (atom->omega_flag) { - omega[nlocal][0] = 0.0; - omega[nlocal][1] = 0.0; - omega[nlocal][2] = 0.0; - } - if (atom->angmom_flag) { - angmom[nlocal][0] = 0.0; - angmom[nlocal][1] = 0.0; - angmom[nlocal][2] = 0.0; - } - - // each sub-style parses sub-style specific values - - int m = 5; - for (int k = 0; k < nstyles; k++) - m += styles[k]->data_atom_hybrid(nlocal,&values[m]); - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file -------------------------------------------------------------------------- */ - -void AtomVecHybrid::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); - - // each sub-style parses sub-style specific values - - int n = 3; - for (int k = 0; k < nstyles; k++) - n += styles[k]->data_vel_hybrid(m,&values[n]); -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecHybrid::pack_data(double **buf) -{ - int k,m; - - 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] = x[i][0]; - buf[i][3] = x[i][1]; - buf[i][4] = x[i][2]; - - m = 5; - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_data_hybrid(i,&buf[i][m]); - - buf[i][m] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][m+1] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][m+2] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecHybrid::write_data(FILE *fp, int n, double **buf) -{ - int k,m; - - for (int i = 0; i < n; i++) { - fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i, - buf[i][2],buf[i][3],buf[i][4]); - - m = 5; - for (k = 0; k < nstyles; k++) - m += styles[k]->write_data_hybrid(fp,&buf[i][m]); - - fprintf(fp," %d %d %d\n", - (int) ubuf(buf[i][m]).i,(int) ubuf(buf[i][m+1]).i, - (int) ubuf(buf[i][m+2]).i); - } -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecHybrid::pack_vel(double **buf) -{ - int k,m; - - 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]; - - m = 4; - for (k = 0; k < nstyles; k++) - m += styles[k]->pack_vel_hybrid(i,&buf[i][m]); - } -} - -/* ---------------------------------------------------------------------- - write velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecHybrid::write_vel(FILE *fp, int n, double **buf) -{ - int k,m; - - for (int i = 0; i < n; i++) { - fprintf(fp,TAGINT_FORMAT " %g %g %g", - (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]); - - m = 4; - for (k = 0; k < nstyles; k++) - m += styles[k]->write_vel_hybrid(fp,&buf[i][m]); - - fprintf(fp,"\n"); - } -} - /* ---------------------------------------------------------------------- assign an index to named atom property and return index returned value encodes which sub-style and index returned by sub-style @@ -1073,14 +217,3 @@ int AtomVecHybrid::known_style(char *str) if (strcmp(str,allstyles[i]) == 0) return 1; return 0; } - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecHybrid::memory_usage() -{ - bigint bytes = 0; - for (int k = 0; k < nstyles; k++) bytes += styles[k]->memory_usage(); - return bytes; -} diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 8129baccba..41067d44f2 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -34,48 +34,16 @@ class AtomVecHybrid : public AtomVec { ~AtomVecHybrid(); void process_args(int, char **); void init(); - void grow(int); - void grow_reset(); - void copy(int, int, int); - void clear_bonus(); void force_clear(int, size_t); - 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 *); - int pack_reverse(int, int, double *); - void unpack_reverse(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - void unpack_border(int, int, double *); - void unpack_border_vel(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 **) {return 0;} - void data_vel(int, char **); - void pack_data(double **); - void write_data(FILE *, int, double **); - void pack_vel(double **); - void write_vel(FILE *, int, double **); 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; - double **omega,**angmom; - int nallstyles; char **allstyles; + void concatenate_fields(); + void concatenate(char *&, char *); void build_styles(); int known_style(char *); }; diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 7a14ea26e6..b44aa69035 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -19,6 +19,7 @@ #include "fix_adapt.h" #include "math_const.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -54,58 +55,61 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + process sub-style args + optional arg = 0/1 for static/dynamic particle radii +------------------------------------------------------------------------- */ + +void AtomVecSphere::process_args(int narg, char **arg) +{ + if (narg == 0) return; + if (narg != 1) error->all(FLERR,"Illegal atom_style sphere command"); + + radvary = utils::numeric(FLERR,arg[0],true,lmp); + if (radvary < 0 || radvary > 1) + error->all(FLERR,"Illegal atom_style sphere command"); + if (radvary == 0) return; + + // dynamic particle radius and mass must be communicated every step + + fields_comm = (char *) "radius rmass"; + fields_comm_vel = (char *) "radius rmass omega"; +} + /* ---------------------------------------------------------------------- */ void AtomVecSphere::init() { AtomVec::init(); - // set radvary if particle diameters are time-varying due to fix adapt - // NOTE: change this to a atom_style sphere optional arg - - radvary = 0; - //comm_x_only = 1; - //size_forward = 3; + // check if optional radvary setting should have been set to 1 for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"adapt") == 0) { FixAdapt *fix = (FixAdapt *) modify->fix[i]; - if (fix->diamflag) { - radvary = 1; - comm_x_only = 0; - size_forward = 5; - } + if (fix->diamflag && radvary == 0) + error->all(FLERR,"Fix adapt changes particle radii " + "but atom_style sphere is not dynamic"); } - - //fields_comm = (char *) "radius rmass"; - //fields_comm_vel = (char *) "radius rmass"; } /* ---------------------------------------------------------------------- - create one atom of itype at coord - modify what default AtomVec::create_atom() just created + initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecSphere::create_atom(int itype, double *coord) +void AtomVecSphere::create_atom_post(int ilocal) { - AtomVec::create_atom(itype,coord); - int ilocal = atom->nlocal-1; - atom->radius[ilocal] = 0.5; atom->rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5; } /* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - modify what default AtomVec::data_atom() just unpacked + modify what AtomVec::data_atom() just unpacked or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecSphere::data_atom(double *coord, imageint imagetmp, char **values) +void AtomVecSphere::data_atom_post(int ilocal) { - AtomVec::data_atom(coord,imagetmp,values); - int ilocal = atom->nlocal-1; - double radius = 0.5 * atom->radius[ilocal]; atom->radius[ilocal] = radius; if (radius > 0.0) @@ -115,3 +119,27 @@ void AtomVecSphere::data_atom(double *coord, imageint imagetmp, char **values) if (atom->rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid mass in Atoms section of data file"); } + +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_data() to pack +------------------------------------------------------------------------- */ + +void AtomVecSphere::pack_data_pre(int ilocal) +{ + radius = atom->radius[ilocal]; + rmass = atom->rmass[ilocal]; + + atom->radius[ilocal] *= 2.0; + if (radius == 0.0) + atom->rmass[ilocal] = rmass / (4.0*MY_PI/3.0 * radius*radius*radius); +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_data() +------------------------------------------------------------------------- */ + +void AtomVecSphere::pack_data_post(int ilocal) +{ + atom->radius[ilocal] = radius; + atom->rmass[ilocal] = rmass; +} diff --git a/src/atom_vec_sphere.h b/src/atom_vec_sphere.h index 98762dba49..c205ba43de 100644 --- a/src/atom_vec_sphere.h +++ b/src/atom_vec_sphere.h @@ -27,12 +27,16 @@ namespace LAMMPS_NS { class AtomVecSphere : public AtomVec { public: AtomVecSphere(class LAMMPS *); + void process_args(int, char **); void init(); - void create_atom(int, double *); - void data_atom(double *, imageint, char **); + void create_atom_post(int); + void data_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); private: int radvary; + double radius,rmass; }; } diff --git a/src/special.cpp b/src/special.cpp index 3dd817bc7f..f859f4ff53 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -715,7 +715,6 @@ void Special::combine() memory->create(atom->special,atom->nmax,atom->maxspecial,"atom:special"); } - atom->avec->grow_reset(); tagint **special = atom->special; // ---------------------------------------------------- From 4f6cb135920c7788b8501b96155678430740172e Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 27 Nov 2019 16:03:50 -0700 Subject: [PATCH 03/42] added atom styles with bonus data, also a few USER packages --- src/MOLECULE/atom_vec_template.cpp | 2 +- src/PERI/atom_vec_peri.cpp | 14 +- src/PERI/atom_vec_peri.h | 2 +- src/USER-DPD/atom_vec_dpd.cpp | 929 +---------------- src/USER-DPD/atom_vec_dpd.h | 51 +- src/USER-EFF/atom_vec_electron.cpp | 954 +---------------- src/USER-EFF/atom_vec_electron.h | 49 +- src/USER-MESO/atom_vec_edpd.cpp | 819 +-------------- src/USER-MESO/atom_vec_edpd.h | 34 +- src/atom.cpp | 30 +- src/atom.h | 15 +- src/atom_vec.cpp | 50 +- src/atom_vec.h | 41 +- src/atom_vec_body.cpp | 1185 +++------------------ src/atom_vec_body.h | 72 +- src/atom_vec_ellipsoid.cpp | 1228 ++++------------------ src/atom_vec_ellipsoid.h | 69 +- src/atom_vec_line.cpp | 1173 ++++----------------- src/atom_vec_line.h | 70 +- src/atom_vec_sphere.cpp | 4 +- src/atom_vec_tri.cpp | 1537 +++++----------------------- src/atom_vec_tri.h | 70 +- src/read_data.cpp | 6 +- src/read_data.h | 2 +- 24 files changed, 1022 insertions(+), 7384 deletions(-) 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(); From ccca80a6a5e5ba9b3d42a5aebaa11552fbd123fe Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 2 Dec 2019 15:39:54 -0700 Subject: [PATCH 04/42] changes to enable atom_style hybrid to work --- src/DIPOLE/atom_vec_dipole.cpp | 8 +- src/MOLECULE/atom_vec_angle.cpp | 36 +-- src/MOLECULE/atom_vec_bond.cpp | 26 +- src/MOLECULE/atom_vec_full.cpp | 58 ++-- src/MOLECULE/atom_vec_molecular.cpp | 58 ++-- src/MOLECULE/atom_vec_template.cpp | 8 +- src/PERI/atom_vec_peri.cpp | 8 +- src/SPIN/atom_vec_spin.cpp | 6 +- src/USER-DPD/atom_vec_dpd.cpp | 8 +- src/USER-EFF/atom_vec_electron.cpp | 6 +- src/USER-MESO/atom_vec_edpd.cpp | 6 +- src/atom_vec.cpp | 323 +++++++++++--------- src/atom_vec.h | 3 +- src/atom_vec_atomic.cpp | 26 +- src/atom_vec_body.cpp | 8 +- src/atom_vec_body.h | 1 - src/atom_vec_charge.cpp | 14 +- src/atom_vec_ellipsoid.cpp | 8 +- src/atom_vec_ellipsoid.h | 1 - src/atom_vec_hybrid.cpp | 444 ++++++++++++++++++++++++---- src/atom_vec_hybrid.h | 38 ++- src/atom_vec_line.cpp | 8 +- src/atom_vec_line.h | 1 - src/atom_vec_sphere.cpp | 8 +- src/atom_vec_tri.cpp | 8 +- src/atom_vec_tri.h | 1 - 26 files changed, 763 insertions(+), 357 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 650bc14d8f..5cdbab1b33 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -35,21 +35,21 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "q mu"; fields_copy = (char *) "q mu"; fields_comm = (char *) "mu3"; fields_comm_vel = (char *) "mu3"; - fields_reverse = NULL; + fields_reverse = (char *) ""; fields_border = (char *) "q mu"; fields_border_vel = (char *) "q mu"; fields_exchange = (char *) "q mu"; fields_restart = (char *) "q mu"; fields_create = (char *) "q mu"; fields_data_atom = (char *) "id type q x mu3"; - fields_data_vel = NULL; + fields_data_vel = (char *) "id v"; setup_fields(); } diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index df48c4b2a0..1bd6f9a071 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -28,8 +28,8 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "molecule num_bond bond_type bond_atom " @@ -37,9 +37,9 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) fields_copy = (char *) "molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; fields_border = (char *) "molecule"; fields_border_vel = (char *) "molecule"; fields_exchange = (char *) @@ -50,7 +50,7 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) "num_angle angle_type angle_atom1 angle_atom2 angle_atom3"; fields_create = (char *) "molecule num_bond num_angle nspecial"; fields_data_atom = (char *) "id molecule type x"; - fields_data_vel = NULL; + fields_data_vel = (char *) "id v"; setup_fields(); @@ -70,7 +70,7 @@ AtomVecAngle::~AtomVecAngle() modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecAngle::pack_restart_pre(int i) +void AtomVecAngle::pack_restart_pre(int ilocal) { // insure negative vectors are needed length @@ -93,19 +93,19 @@ void AtomVecAngle::pack_restart_pre(int i) int **angle_type = atom->angle_type; int any_bond_negative = 0; - for (int m = 0; m < num_bond[i]; m++) { - if (bond_type[i][m] < 0) { + for (int m = 0; m < num_bond[ilocal]; m++) { + if (bond_type[ilocal][m] < 0) { bond_negative[m] = 1; - bond_type[i][m] = -bond_type[i][m]; + bond_type[ilocal][m] = -bond_type[ilocal][m]; any_bond_negative = 1; } else bond_negative[m] = 0; } int any_angle_negative = 0; - for (int m = 0; m < num_angle[i]; m++) { - if (angle_type[i][m] < 0) { + for (int m = 0; m < num_angle[ilocal]; m++) { + if (angle_type[ilocal][m] < 0) { angle_negative[m] = 1; - angle_type[i][m] = -angle_type[i][m]; + angle_type[ilocal][m] = -angle_type[ilocal][m]; any_angle_negative = 1; } else angle_negative[m] = 0; } @@ -115,22 +115,22 @@ void AtomVecAngle::pack_restart_pre(int i) unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -void AtomVecAngle::pack_restart_post(int i) +void AtomVecAngle::pack_restart_post(int ilocal) { // restore the flagged types to their negative values if (any_bond_negative) { int *num_bond = atom->num_bond; int **bond_type = atom->bond_type; - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + for (int m = 0; m < num_bond[ilocal]; m++) + if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { int *num_angle = atom->num_angle; int **angle_type = atom->angle_type; - for (int m = 0; m < num_angle[i]; m++) - if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; + for (int m = 0; m < num_angle[ilocal]; m++) + if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } } diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index fd3f08979d..30ad7d83e1 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -28,16 +28,16 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "molecule num_bond bond_type bond_atom nspecial special"; fields_copy = (char *) "molecule num_bond bond_type bond_atom nspecial special"; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; fields_border = (char *) "molecule"; fields_border_vel = (char *) "molecule"; fields_exchange = (char *) @@ -45,7 +45,7 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) fields_restart = (char *) "molecule num_bond bond_type bond_atom"; fields_create = (char *) "molecule num_bond nspecial"; fields_data_atom = (char *) "id molecule type x"; - fields_data_vel = NULL; + fields_data_vel = (char *) "id v"; setup_fields(); @@ -64,7 +64,7 @@ AtomVecBond::~AtomVecBond() modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecBond::pack_restart_pre(int i) +void AtomVecBond::pack_restart_pre(int ilocal) { // insure bond_negative vector is needed length @@ -80,10 +80,10 @@ void AtomVecBond::pack_restart_pre(int i) int **bond_type = atom->bond_type; any_bond_negative = 0; - for (int m = 0; m < num_bond[i]; m++) { - if (bond_type[i][m] < 0) { + for (int m = 0; m < num_bond[ilocal]; m++) { + if (bond_type[ilocal][m] < 0) { bond_negative[m] = 1; - bond_type[i][m] = -bond_type[i][m]; + bond_type[ilocal][m] = -bond_type[ilocal][m]; any_bond_negative = 1; } else bond_negative[m] = 0; } @@ -93,15 +93,15 @@ void AtomVecBond::pack_restart_pre(int i) unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -void AtomVecBond::pack_restart_post(int i) +void AtomVecBond::pack_restart_post(int ilocal) { // restore the flagged types to their negative values if (any_bond_negative) { int *num_bond = atom->num_bond; int **bond_type = atom->bond_type; - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + for (int m = 0; m < num_bond[ilocal]; m++) + if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } } diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index ed838aa0e3..9ab0a296e0 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -28,8 +28,8 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "q molecule num_bond bond_type bond_atom " @@ -47,9 +47,9 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) "num_improper improper_type improper_atom1 improper_atom2 " "improper_atom3 improper_atom4 " "nspecial special"; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; fields_border = (char *) "q molecule"; fields_border_vel = (char *) "q molecule"; fields_exchange = (char *) @@ -70,7 +70,7 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) fields_create = (char *) "q molecule num_bond num_angle num_dihedral num_improper nspecial"; fields_data_atom = (char *) "id molecule type q x"; - fields_data_vel = NULL; + fields_data_vel = (char *) "id v"; setup_fields(); @@ -92,7 +92,7 @@ AtomVecFull::~AtomVecFull() modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecFull::pack_restart_pre(int i) +void AtomVecFull::pack_restart_pre(int ilocal) { // insure negative vectors are needed length @@ -129,37 +129,37 @@ void AtomVecFull::pack_restart_pre(int i) int **improper_type = atom->improper_type; int any_bond_negative = 0; - for (int m = 0; m < num_bond[i]; m++) { - if (bond_type[i][m] < 0) { + for (int m = 0; m < num_bond[ilocal]; m++) { + if (bond_type[ilocal][m] < 0) { bond_negative[m] = 1; - bond_type[i][m] = -bond_type[i][m]; + bond_type[ilocal][m] = -bond_type[ilocal][m]; any_bond_negative = 1; } else bond_negative[m] = 0; } int any_angle_negative = 0; - for (int m = 0; m < num_angle[i]; m++) { - if (angle_type[i][m] < 0) { + for (int m = 0; m < num_angle[ilocal]; m++) { + if (angle_type[ilocal][m] < 0) { angle_negative[m] = 1; - angle_type[i][m] = -angle_type[i][m]; + angle_type[ilocal][m] = -angle_type[ilocal][m]; any_angle_negative = 1; } else angle_negative[m] = 0; } int any_dihedral_negative = 0; - for (int m = 0; m < num_dihedral[i]; m++) { - if (dihedral_type[i][m] < 0) { + for (int m = 0; m < num_dihedral[ilocal]; m++) { + if (dihedral_type[ilocal][m] < 0) { dihedral_negative[m] = 1; - dihedral_type[i][m] = -dihedral_type[i][m]; + dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; any_dihedral_negative = 1; } else dihedral_negative[m] = 0; } int any_improper_negative = 0; - for (int m = 0; m < num_improper[i]; m++) { - if (improper_type[i][m] < 0) { + for (int m = 0; m < num_improper[ilocal]; m++) { + if (improper_type[ilocal][m] < 0) { improper_negative[m] = 1; - improper_type[i][m] = -improper_type[i][m]; + improper_type[ilocal][m] = -improper_type[ilocal][m]; any_improper_negative = 1; } else improper_negative[m] = 0; } @@ -169,36 +169,38 @@ void AtomVecFull::pack_restart_pre(int i) unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -void AtomVecFull::pack_restart_post(int i) +void AtomVecFull::pack_restart_post(int ilocal) { // restore the flagged types to their negative values if (any_bond_negative) { int *num_bond = atom->num_bond; int **bond_type = atom->bond_type; - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + for (int m = 0; m < num_bond[ilocal]; m++) + if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { int *num_angle = atom->num_angle; int **angle_type = atom->angle_type; - for (int m = 0; m < num_angle[i]; m++) - if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; + for (int m = 0; m < num_angle[ilocal]; m++) + if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } if (any_dihedral_negative) { int *num_dihedral = atom->num_dihedral; int **dihedral_type = atom->dihedral_type; - for (int m = 0; m < num_dihedral[i]; m++) - if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m]; + for (int m = 0; m < num_dihedral[ilocal]; m++) + if (dihedral_negative[m]) + dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { int *num_improper = atom->num_improper; int **improper_type = atom->improper_type; - for (int m = 0; m < num_improper[i]; m++) - if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m]; + for (int m = 0; m < num_improper[ilocal]; m++) + if (improper_negative[m]) + improper_type[ilocal][m] = -improper_type[ilocal][m]; } } diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index 77aec2cf50..52947ceb71 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -28,8 +28,8 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "molecule num_bond bond_type bond_atom " @@ -47,9 +47,9 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) "num_improper improper_type improper_atom1 improper_atom2 " "improper_atom3 improper_atom4 " "nspecial special"; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; fields_border = (char *) "molecule"; fields_border_vel = (char *) "molecule"; fields_exchange = (char *) @@ -70,7 +70,7 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) fields_create = (char *) "molecule num_bond num_angle num_dihedral num_improper nspecial"; fields_data_atom = (char *) "id molecule type x"; - fields_data_vel = NULL; + fields_data_vel = (char *) "id v"; setup_fields(); @@ -92,7 +92,7 @@ AtomVecMolecular::~AtomVecMolecular() modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ -void AtomVecMolecular::pack_restart_pre(int i) +void AtomVecMolecular::pack_restart_pre(int ilocal) { // insure negative vectors are needed length @@ -129,37 +129,37 @@ void AtomVecMolecular::pack_restart_pre(int i) int **improper_type = atom->improper_type; int any_bond_negative = 0; - for (int m = 0; m < num_bond[i]; m++) { - if (bond_type[i][m] < 0) { + for (int m = 0; m < num_bond[ilocal]; m++) { + if (bond_type[ilocal][m] < 0) { bond_negative[m] = 1; - bond_type[i][m] = -bond_type[i][m]; + bond_type[ilocal][m] = -bond_type[ilocal][m]; any_bond_negative = 1; } else bond_negative[m] = 0; } int any_angle_negative = 0; - for (int m = 0; m < num_angle[i]; m++) { - if (angle_type[i][m] < 0) { + for (int m = 0; m < num_angle[ilocal]; m++) { + if (angle_type[ilocal][m] < 0) { angle_negative[m] = 1; - angle_type[i][m] = -angle_type[i][m]; + angle_type[ilocal][m] = -angle_type[ilocal][m]; any_angle_negative = 1; } else angle_negative[m] = 0; } int any_dihedral_negative = 0; - for (int m = 0; m < num_dihedral[i]; m++) { - if (dihedral_type[i][m] < 0) { + for (int m = 0; m < num_dihedral[ilocal]; m++) { + if (dihedral_type[ilocal][m] < 0) { dihedral_negative[m] = 1; - dihedral_type[i][m] = -dihedral_type[i][m]; + dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; any_dihedral_negative = 1; } else dihedral_negative[m] = 0; } int any_improper_negative = 0; - for (int m = 0; m < num_improper[i]; m++) { - if (improper_type[i][m] < 0) { + for (int m = 0; m < num_improper[ilocal]; m++) { + if (improper_type[ilocal][m] < 0) { improper_negative[m] = 1; - improper_type[i][m] = -improper_type[i][m]; + improper_type[ilocal][m] = -improper_type[ilocal][m]; any_improper_negative = 1; } else improper_negative[m] = 0; } @@ -169,36 +169,38 @@ void AtomVecMolecular::pack_restart_pre(int i) unmodify values packed by AtomVec::pack_restart() ------------------------------------------------------------------------- */ -void AtomVecMolecular::pack_restart_post(int i) +void AtomVecMolecular::pack_restart_post(int ilocal) { // restore the flagged types to their negative values if (any_bond_negative) { int *num_bond = atom->num_bond; int **bond_type = atom->bond_type; - for (int m = 0; m < num_bond[i]; m++) - if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m]; + for (int m = 0; m < num_bond[ilocal]; m++) + if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { int *num_angle = atom->num_angle; int **angle_type = atom->angle_type; - for (int m = 0; m < num_angle[i]; m++) - if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m]; + for (int m = 0; m < num_angle[ilocal]; m++) + if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } if (any_dihedral_negative) { int *num_dihedral = atom->num_dihedral; int **dihedral_type = atom->dihedral_type; - for (int m = 0; m < num_dihedral[i]; m++) - if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m]; + for (int m = 0; m < num_dihedral[ilocal]; m++) + if (dihedral_negative[m]) + dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { int *num_improper = atom->num_improper; int **improper_type = atom->improper_type; - for (int m = 0; m < num_improper[i]; m++) - if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m]; + for (int m = 0; m < num_improper[ilocal]; m++) + if (improper_negative[m]) + improper_type[ilocal][m] = -improper_type[ilocal][m]; } } diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index f8f99ae8a8..546c19da12 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -40,16 +40,16 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp) fields_grow = (char *) "molecule molindex molatom"; fields_copy = (char *) "molecule molindex molatom"; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; fields_border = (char *) "molecule molindex molatom"; fields_border_vel = (char *) "molecule molindex molatom"; fields_exchange = (char *) "molecule molindex molatom"; fields_restart = (char *) "molecule molindex molatom"; fields_create = (char *) "molecule molindex molatom"; fields_data_atom = (char *) "id molecule molindex molatom type x"; - fields_data_vel = NULL; + fields_data_vel = (char *) ""; setup_fields(); } diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 4fcebc2f84..58ff9c54d9 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -50,21 +50,21 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "rmass vfrac s0 x0"; fields_copy = (char *) "rmass vfrac s0 x0"; fields_comm = (char *) "s0"; fields_comm_vel = (char *) "s0"; - fields_reverse = NULL; + fields_reverse = (char *) ""; fields_border = (char *) "rmass vfrac s0 x0"; fields_border_vel = (char *) "rmass vfrac s0 x0"; fields_exchange = (char *) "rmass vfrac s0 x0"; fields_restart = (char *) "rmass vfrac s0 x0"; fields_create = (char *) "rmass vfrac s0 x0"; fields_data_atom = (char *) "id type vfrac rmass x"; - fields_data_vel = (char *) "omega"; + fields_data_vel = (char *) "id v omega"; setup_fields(); } diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 6c88fb1a9e..a8ff15492a 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -42,8 +42,8 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "sp fm fm_long"; fields_copy = (char *) "sp"; @@ -56,7 +56,7 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) fields_restart = (char *) "sp"; fields_create = (char *) "sp"; fields_data_atom = (char *) "id type x sp"; - fields_data_vel = (char *) "omega"; + fields_data_vel = (char *) "id v omega"; setup_fields(); } diff --git a/src/USER-DPD/atom_vec_dpd.cpp b/src/USER-DPD/atom_vec_dpd.cpp index 27e0f70a20..ce35178d8d 100644 --- a/src/USER-DPD/atom_vec_dpd.cpp +++ b/src/USER-DPD/atom_vec_dpd.cpp @@ -33,21 +33,21 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel 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_reverse = (char *) ""; 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"; + fields_data_vel = (char *) "id v omega"; setup_fields(); } diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index fc73bf4dd5..0bad0f115f 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -56,8 +56,8 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "q spin eradius ervel erforce"; fields_copy = (char *) "q spin eradius ervel"; @@ -70,7 +70,7 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) 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"; + fields_data_vel = (char *) "id v ervel"; setup_fields(); } diff --git a/src/USER-MESO/atom_vec_edpd.cpp b/src/USER-MESO/atom_vec_edpd.cpp index 59cee397b5..b4602c760c 100644 --- a/src/USER-MESO/atom_vec_edpd.cpp +++ b/src/USER-MESO/atom_vec_edpd.cpp @@ -41,8 +41,8 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "edpd_cv edpd_temp edpd_flux vest"; fields_copy = (char *) "edpd_cv edpd_temp edpd_flux vest"; @@ -55,7 +55,7 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp) 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; + fields_data_vel = (char *) "id v"; setup_fields(); } diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index ed56151d33..cfbc8b12a6 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -55,20 +55,19 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) // peratom variables auto-included in corresponding child style fields string // these fields cannot be specified in the fields string - // leading/trailing whitespace just facilitates matching in process_args() - default_grow = " id type mask image x v f "; - default_copy = " id type mask image x v "; - default_comm = " x "; - default_comm_vel = " x v "; - default_reverse = " f "; - default_border = " id type mask x "; - default_border_vel = " id type mask x v "; - default_exchange = " id type mask image x v "; - default_restart = " id type mask image x v "; - default_create = " id type mask image x v "; + default_grow = "id type mask image x v f"; + default_copy = "id type mask image x v"; + default_comm = "x"; + default_comm_vel = "x v"; + default_reverse = "f"; + default_border = "id type mask x"; + default_border_vel = "id type mask x v"; + default_exchange = "id type mask image x v"; + default_restart = "id type mask image x v"; + default_create = "id type mask image x v"; default_data_atom = ""; - default_data_vel = " v "; + default_data_vel = ""; // initializations @@ -1757,6 +1756,7 @@ void AtomVec::pack_data(double **buf) void *pdata; int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { // if needed, change values before packing @@ -1877,37 +1877,39 @@ void AtomVec::data_vel(int ilocal, char **values) v[ilocal][1] = utils::numeric(FLERR,values[1],true,lmp); v[ilocal][2] = utils::numeric(FLERR,values[2],true,lmp); - int ivalue = 3; - for (n = 0; n < ndata_vel; n++) { - pdata = mdata_vel.pdata[n]; - datatype = mdata_vel.datatype[n]; - cols = mdata_vel.cols[n]; - if (datatype == DOUBLE) { - if (cols == 0) { - double *vec = *((double **) pdata); - vec[ilocal] = utils::numeric(FLERR,values[ivalue++],true,lmp); - } else { - double **array = *((double ***) pdata); - for (m = 0; m < cols; m++) - array[ilocal][m] = utils::numeric(FLERR,values[ivalue++],true,lmp); - } - } else if (datatype == INT) { - if (cols == 0) { - int *vec = *((int **) pdata); - vec[ilocal] = utils::inumeric(FLERR,values[ivalue++],true,lmp); - } else { - int **array = *((int ***) pdata); - for (m = 0; m < cols; m++) - array[ilocal][m] = utils::inumeric(FLERR,values[ivalue++],true,lmp); - } - } else if (datatype == BIGINT) { - if (cols == 0) { - bigint *vec = *((bigint **) pdata); - vec[ilocal] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); - } else { - bigint **array = *((bigint ***) pdata); - for (m = 0; m < cols; m++) - array[ilocal][m] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + if (ndata_vel) { + int ivalue = 3; + for (n = 0; n < ndata_vel; n++) { + pdata = mdata_vel.pdata[n]; + datatype = mdata_vel.datatype[n]; + cols = mdata_vel.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + vec[ilocal] = utils::numeric(FLERR,values[ivalue++],true,lmp); + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + array[ilocal][m] = utils::numeric(FLERR,values[ivalue++],true,lmp); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + vec[ilocal] = utils::inumeric(FLERR,values[ivalue++],true,lmp); + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + array[ilocal][m] = utils::inumeric(FLERR,values[ivalue++],true,lmp); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + vec[ilocal] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + array[ilocal][m] = utils::bnumeric(FLERR,values[ivalue++],true,lmp); + } } } } @@ -1922,49 +1924,40 @@ void AtomVec::pack_vel(double **buf) int i,j,m,n,datatype,cols; void *pdata; - double **v = atom->v; - tagint *tag = atom->tag; int nlocal = atom->nlocal; for (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]; - - j = 4; - if (ndata_vel) { - for (n = 0; n < ndata_vel; n++) { - pdata = mdata_vel.pdata[n]; - datatype = mdata_vel.datatype[n]; - cols = mdata_vel.cols[n]; - if (datatype == DOUBLE) { - if (cols == 0) { - double *vec = *((double **) pdata); - buf[i][j++] = vec[i]; - } else { - double **array = *((double ***) pdata); - for (m = 0; m < cols; m++) - buf[i][j++] = array[i][m]; - } - } else if (datatype == INT) { - if (cols == 0) { - int *vec = *((int **) pdata); - buf[i][j++] = ubuf(vec[i]).d; - } else { - int **array = *((int ***) pdata); - for (m = 0; m < cols; m++) - buf[i][j++] = ubuf(array[i][m]).d; - } - } else if (datatype == BIGINT) { - if (cols == 0) { - bigint *vec = *((bigint **) pdata); - buf[i][j++] = ubuf(vec[i]).d; - } else { - bigint **array = *((bigint ***) pdata); - for (m = 0; m < cols; m++) - buf[i][j++] = ubuf(array[i][m]).d; - } + j = 0; + for (n = 0; n < ndata_vel; n++) { + pdata = mdata_vel.pdata[n]; + datatype = mdata_vel.datatype[n]; + cols = mdata_vel.cols[n]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + buf[i][j++] = vec[i]; + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = array[i][m]; + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + buf[i][j++] = ubuf(vec[i]).d; + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = ubuf(array[i][m]).d; + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + buf[i][j++] = ubuf(vec[i]).d; + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + buf[i][j++] = ubuf(array[i][m]).d; } } } @@ -1985,37 +1978,39 @@ void AtomVec::write_vel(FILE *fp, int n, double **buf) fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e\n", (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]); - j = 4; - for (nn = 0; nn < ndata_vel; nn++) { - pdata = mdata_vel.pdata[nn]; - datatype = mdata_vel.datatype[nn]; - cols = mdata_vel.cols[nn]; - if (datatype == DOUBLE) { - if (cols == 0) { - double *vec = *((double **) pdata); - fprintf(fp," %-1.16e",buf[i][j++]); - } else { - double **array = *((double ***) pdata); - for (m = 0; m < cols; m++) + if (ndata_vel) { + j = 4; + for (nn = 0; nn < ndata_vel; nn++) { + pdata = mdata_vel.pdata[nn]; + datatype = mdata_vel.datatype[nn]; + cols = mdata_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); fprintf(fp," %-1.16e",buf[i][j++]); - } - } else if (datatype == INT) { - if (cols == 0) { - int *vec = *((int **) pdata); - fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); - } else { - int **array = *((int ***) pdata); - for (m = 0; m < cols; m++) + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," %-1.16e",buf[i][j++]); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); - } - } else if (datatype == BIGINT) { - if (cols == 0) { - bigint *vec = *((bigint **) pdata); - fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); - } else { - bigint **array = *((bigint ***) pdata); - for (m = 0; m < cols; m++) + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) + fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } } } } @@ -2342,10 +2337,11 @@ void AtomVec::setup_fields() { int n,cols; - if (!fields_data_atom) - error->all(FLERR,"Atom style requires fields_data_atom"); if (strstr(fields_data_atom,"id ") != fields_data_atom) error->all(FLERR,"Atom style fields_data_atom must have id as first field"); + if (strstr(fields_data_vel,"id v") != fields_data_vel) + error->all(FLERR,"Atom style fields_data_vel must have " + "'id v' as first fields"); // process field strings // return # of fields and matching index into atom->peratom (in Method struct) @@ -2387,7 +2383,7 @@ void AtomVec::setup_fields() else threads[i] = 1; } - // set style-specific variables + // set style-specific sizes // NOTE: check for others vars in atom_vec.cpp/h ?? // NOTE: need to set maxexchange, e.g for style hybrid? @@ -2437,7 +2433,7 @@ void AtomVec::setup_fields() else size_data_atom += cols; } - size_data_vel = 4; + size_data_vel = 0; for (n = 0; n < ndata_vel; n++) { cols = mdata_vel.cols[n]; if (cols == 0) size_data_vel++; @@ -2449,61 +2445,96 @@ void AtomVec::setup_fields() process a single field string ------------------------------------------------------------------------- */ -int AtomVec::process_fields(char *list, const char *default_list, Method *method) +int AtomVec::process_fields(char *str, const char *default_str, Method *method) { - int i,n; - char match[128]; - - if (list == NULL) { + if (str == NULL) { method->index = NULL; return 0; } - // make copy of list of fields so can tokenize it + // tokenize words in both strings - n = strlen(list) + 1; - char *copy = new char[n]; - strcpy(copy,list); - - int nfield = atom->count_words(copy); - int *index = new int[nfield]; + char *copy1,*copy2; + char **words,**defwords; + int nfield = tokenize(str,words,copy1); + int ndef = tokenize((char *) default_str,defwords,copy2); + // process fields one by one, add to index vector + Atom::PerAtom *peratom = atom->peratom; int nperatom = atom->nperatom; - - nfield = 0; - char *field = strtok(copy," "); - while (field) { + + int *index = new int[nfield]; + int match; + + for (int i = 0; i < nfield; i++) { // find field in master Atom::peratom list - for (i = 0; i < nperatom; i++) - if (strcmp(field,peratom[i].name) == 0) break; - if (i == nperatom) { - printf("FIELD %s\n",field); - error->all(FLERR,"Atom_style unrecognized peratom field"); + for (match = 0; match < nperatom; match++) + if (strcmp(words[i],peratom[match].name) == 0) break; + if (match == nperatom) { + char str[128]; + sprintf(str,"Peratom field %s not recognized",words[i]); + error->all(FLERR,str); } - index[nfield++] = i; + index[i] = match; - // error if field is in default list or appears multiple times + // error if field appears multiple times - sprintf(match," %s ",field); - if (strstr(default_list,match)) - error->all(FLERR,"Atom_style repeat of default peratom field"); + for (match = 0; match < i; match++) + if (index[i] == index[match]) { + char str[128]; + sprintf(str,"Peratom field %s is repeated",words[i]); + error->all(FLERR,str); + } - for (i = 0; i < nfield-1; i++) - if (index[i] == index[nfield-1]) - error->all(FLERR,"Atom_style duplicated peratom field"); + // error if field is in default str + + for (match = 0; match < ndef; match++) + if (strcmp(words[i],defwords[match]) == 0) { + char str[128]; + sprintf(str,"Peratom field %s is a default",words[i]); + error->all(FLERR,str); + } - field = strtok(NULL," "); } - delete [] copy; + delete [] copy1; + delete [] copy2; + delete [] words; + delete [] defwords; method->index = index; return nfield; } +/* ---------------------------------------------------------------------- + tokenize str into white-space separated words + return nwords = number of words + return words = vector of ptrs to each word + also return copystr since words points into it, caller will delete copystr +------------------------------------------------------------------------- */ + +int AtomVec::tokenize(char *str, char **&words, char *©str) +{ + int n = strlen(str) + 1; + copystr = new char[n]; + strcpy(copystr,str); + + int nword = atom->count_words(copystr); + words = new char*[nword]; + + nword = 0; + char *word = strtok(copystr," "); + while (word) { + words[nword++] = word; + word = strtok(NULL," "); + } + + return nword; +} + /* ---------------------------------------------------------------------- create a method data structs for processing fields ------------------------------------------------------------------------- */ diff --git a/src/atom_vec.h b/src/atom_vec.h index 33bf4a3ccd..69ea1d51ab 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -55,7 +55,7 @@ class AtomVec : protected Pointers { char **argcopy; // used when AtomVec is realloced (restart,replicate) // additional list of peratom fields operated on by different methods - // set by child styles + // set or created by child styles char *fields_grow,*fields_copy; char *fields_comm,*fields_comm_vel,*fields_reverse; @@ -220,6 +220,7 @@ class AtomVec : protected Pointers { int grow_nmax_bonus(int); void setup_fields(); int process_fields(char *, const char *, Method *); + int tokenize(char *, char **&, char *&); void create_method(int, Method *); void init_method(Method *); void destroy_method(Method *); diff --git a/src/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index a283e99081..eb8dfc1b7e 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -24,21 +24,21 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file - fields_grow = NULL; - fields_copy = NULL; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; - fields_border = NULL; - fields_border_vel = NULL; - fields_exchange = NULL; - fields_restart = NULL; - fields_create = NULL; + fields_grow = (char *) ""; + fields_copy = (char *) ""; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; + fields_border = (char *) ""; + fields_border_vel = (char *) ""; + fields_exchange = (char *) ""; + fields_restart = (char *) ""; + fields_create = (char *) ""; fields_data_atom = (char *) "id type x"; - fields_data_vel = NULL; + fields_data_vel = (char *) "id v"; setup_fields(); } diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 1a8c2defd9..19ac69cef3 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -60,12 +60,12 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "radius rmass angmom torque body"; fields_copy = (char *) "radius rmass angmom"; - fields_comm = NULL; + fields_comm = (char *) ""; fields_comm_vel = (char *) "angmom"; fields_reverse = (char *) "torque"; fields_border = (char *) "radius rmass"; @@ -74,7 +74,7 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) 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"; + fields_data_vel = (char *) "id v angmom"; setup_fields(); } diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 183b4ea8ea..939b01878d 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -47,7 +47,6 @@ class AtomVecBody : public AtomVec { 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 *); diff --git a/src/atom_vec_charge.cpp b/src/atom_vec_charge.cpp index 9c8f18a846..5957ef5215 100644 --- a/src/atom_vec_charge.cpp +++ b/src/atom_vec_charge.cpp @@ -27,21 +27,21 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "q"; fields_copy = (char *) "q"; - fields_comm = NULL; - fields_comm_vel = NULL; - fields_reverse = NULL; + fields_comm = (char *) ""; + fields_comm_vel = (char *) ""; + fields_reverse = (char *) ""; fields_border = (char *) "q"; fields_border_vel = (char *) "q"; fields_exchange = (char *) "q"; fields_restart = (char *) "q"; fields_create = (char *) "q"; - fields_data_atom = (char *) "id type q x"; - fields_data_vel = NULL; + fields_data_atom = (char *) "id type q x"; + fields_data_vel = (char *) "id v"; setup_fields(); } diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 7ba26c1c34..9166293384 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -49,12 +49,12 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "rmass angmom torque ellipsoid"; fields_copy = (char *) "rmass angmom"; - fields_comm = NULL; + fields_comm = (char *) ""; fields_comm_vel = (char *) "angmom"; fields_reverse = (char *) "torque"; fields_border = (char *) "rmass"; @@ -63,7 +63,7 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp) 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"; + fields_data_vel = (char *) "id v angmom"; setup_fields(); } diff --git a/src/atom_vec_ellipsoid.h b/src/atom_vec_ellipsoid.h index 70797c59d5..79d17a2206 100644 --- a/src/atom_vec_ellipsoid.h +++ b/src/atom_vec_ellipsoid.h @@ -40,7 +40,6 @@ class AtomVecEllipsoid : public AtomVec { 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 *); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index d96494544c..9a79f66972 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -14,18 +14,39 @@ #include "atom_vec_hybrid.h" #include #include "atom.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" +#include "comm.h" #include "memory.h" #include "error.h" -#include "utils.h" using namespace LAMMPS_NS; +#define NFIELDSTRINGS 12 // # of field strings + /* ---------------------------------------------------------------------- */ -AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) {} +AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) +{ + nstyles = 0; + styles = NULL; + keywords = NULL; + fieldstrings = NULL; + + nstyles_bonus = 0; + styles_bonus = NULL; + + // NOTE: set bonus_flag if any substyle does + // set nstyles_bonus, styles_bonus + // NOTE: call method in each sub-style to set q_flag ?? + + // these strings will be concatenated from sub-style strings + // fields_data_atom & fields_data_vel start with fields common to all styles + + fields_grow = fields_copy = fields_comm = fields_comm_vel = (char *) ""; + fields_reverse = fields_border = fields_border_vel = (char *) ""; + fields_exchange = fields_restart = fields_create = (char *) ""; + fields_data_atom = (char *) "id type x"; + fields_data_vel = (char *) "id v"; +} /* ---------------------------------------------------------------------- */ @@ -36,14 +57,23 @@ AtomVecHybrid::~AtomVecHybrid() for (int k = 0; k < nstyles; k++) delete [] keywords[k]; delete [] keywords; - // these strings will be concatenated from sub-style strings - // fields_data_atom must start with fields common to all styles + // NOTE: need to check these have actually been allocated - fields_grow = fields_copy = fields_comm = fields_comm_vel = NULL; - fields_reverse = fields_border = fields_border_vel = NULL; - fields_exchange = fields_restart = fields_create = NULL; - fields_data_atom = (char *) "id type x"; - fields_data_vel = NULL; + delete [] fields_grow; + delete [] fields_copy; + delete [] fields_comm; + delete [] fields_comm_vel; + delete [] fields_reverse; + delete [] fields_border; + delete [] fields_border_vel; + delete [] fields_exchange; + delete [] fields_restart; + delete [] fields_create; + delete [] fields_data_atom; + delete [] fields_data_vel; + + for (int k = 0; k < nstyles; k++) delete [] fieldstrings[k].fstr; + delete [] fieldstrings; } /* ---------------------------------------------------------------------- @@ -52,7 +82,7 @@ AtomVecHybrid::~AtomVecHybrid() void AtomVecHybrid::process_args(int narg, char **arg) { - // build list of all known atom styles + // create list of all known atom styles build_styles(); @@ -85,58 +115,120 @@ void AtomVecHybrid::process_args(int narg, char **arg) nstyles++; } + // hybrid settings are MAX or MIN of sub-style settings + // check for both mass_type = 0 and 1, so can warn + + molecular = 0; + maxexchange = 0; + + for (int k = 0; k < nstyles; k++) { + if ((styles[k]->molecular == 1 && molecular == 2) || + (styles[k]->molecular == 2 && molecular == 1)) + error->all(FLERR,"Cannot mix molecular and molecule template " + "atom styles"); + molecular = MAX(molecular,styles[k]->molecular); + + bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow); + angles_allow = MAX(angles_allow,styles[k]->angles_allow); + dihedrals_allow = MAX(dihedrals_allow,styles[k]->dihedrals_allow); + impropers_allow = MAX(impropers_allow,styles[k]->impropers_allow); + mass_type = MAX(mass_type,styles[k]->mass_type); + dipole_type = MAX(dipole_type,styles[k]->dipole_type); + forceclearflag = MAX(forceclearflag,styles[k]->forceclearflag); + + if (styles[k]->molecular == 2) onemols = styles[k]->onemols; + + // NOTE: need to sum this one? + maxexchange += styles[k]->maxexchange; + } + + // issue a warning if both per-type mass and per-atom rmass are defined + + int mass_pertype = 0; + int mass_peratom = 0; + + for (int k = 0; k < nstyles; k++) { + if (styles[k]->mass_type == 0) mass_peratom = 1; + if (styles[k]->mass_type == 1) mass_pertype = 1; + } + + if (mass_pertype && mass_peratom && comm->me == 0) + error->warning(FLERR, + "Atom_style hybrid defines both pertype and peratom masses " + "- both must be set, only peratom masses will be used"); + // free allstyles created by build_styles() for (int i = 0; i < nallstyles; i++) delete [] allstyles[i]; delete [] allstyles; - // concatenate field strings from all sub-styles + // set field strings from all substyles - concatenate_fields(); + fieldstrings = new FieldStrings[nstyles]; - // parent AtomVec will now operate on concatenated fields + for (int k = 0; k < nstyles; k++) { + fieldstrings[k].fstr = new char*[NFIELDSTRINGS]; + fieldstrings[k].fstr[0] = styles[k]->fields_grow; + fieldstrings[k].fstr[1] = styles[k]->fields_copy; + fieldstrings[k].fstr[2] = styles[k]->fields_comm; + fieldstrings[k].fstr[3] = styles[k]->fields_comm_vel; + fieldstrings[k].fstr[4] = styles[k]->fields_reverse; + fieldstrings[k].fstr[5] = styles[k]->fields_border; + fieldstrings[k].fstr[6] = styles[k]->fields_border_vel; + fieldstrings[k].fstr[7] = styles[k]->fields_exchange; + fieldstrings[k].fstr[8] = styles[k]->fields_restart; + fieldstrings[k].fstr[9] = styles[k]->fields_create; + fieldstrings[k].fstr[10] = styles[k]->fields_data_atom; + fieldstrings[k].fstr[11] = styles[k]->fields_data_vel; + } + + // merge field strings from all sub-styles + // save concat_grow to check for duplicates of special-case fields + + char *concat_grow;; + char *null = NULL; + + fields_grow = merge_fields(0,fields_grow,1,concat_grow); + fields_copy = merge_fields(1,fields_copy,0,null); + fields_comm = merge_fields(2,fields_comm,0,null); + fields_comm_vel = merge_fields(3,fields_comm_vel,0,null); + fields_reverse = merge_fields(4,fields_reverse,0,null); + fields_border = merge_fields(5,fields_border,0,null); + fields_border_vel = merge_fields(6,fields_border_vel,0,null); + fields_exchange = merge_fields(7,fields_exchange,0,null); + fields_restart = merge_fields(8,fields_restart,0,null); + fields_create = merge_fields(9,fields_create,0,null); + fields_data_atom = merge_fields(10,fields_data_atom,0,null); + fields_data_vel = merge_fields(11,fields_data_vel,0,null); + + // check concat_grow for multiple special-case fields + // may cause issues with style-specific create_atom() and data_atom() methods + // issue warnings if appear in multiple sub-styles + + const char *dupfield[] = {"radius","rmass"}; + int ndupfield = 2; + char *ptr; + + for (int idup = 0; idup < ndupfield; idup++) { + char *dup = (char *) dupfield[idup]; + ptr = strstr(concat_grow,dup); + if (strstr(ptr+1,dup)) { + char str[128]; + sprintf(str,"Peratom %s is in multiple sub-styles - " + "must be used consistently",dup); + if (comm->me == 0) error->warning(FLERR,str); + } + } + + delete [] concat_grow; + + // parent AtomVec can now operate on merged fields setup_fields(); } /* ---------------------------------------------------------------------- */ -void AtomVecHybrid::concatenate_fields() -{ - for (int k = 0; k < nstyles; k++) { - concatenate(fields_grow,styles[k]->fields_grow); - concatenate(fields_copy,styles[k]->fields_copy); - concatenate(fields_comm,styles[k]->fields_comm); - concatenate(fields_comm_vel,styles[k]->fields_comm_vel); - concatenate(fields_reverse,styles[k]->fields_reverse); - concatenate(fields_border,styles[k]->fields_border); - concatenate(fields_border_vel,styles[k]->fields_border_vel); - concatenate(fields_exchange,styles[k]->fields_exchange); - concatenate(fields_restart,styles[k]->fields_restart); - concatenate(fields_create,styles[k]->fields_create); - concatenate(fields_data_atom,styles[k]->fields_data_atom); - concatenate(fields_data_vel,styles[k]->fields_data_vel); - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecHybrid::concatenate(char *&root, char *add) -{ - /* - char **rootwords,**addwords; - int nroot = parse(root,rootwords); - int nadd = parse(add,addwords); - - for (int iadd = 0; iadd < nadd; iadd++) { - if (check(addwords[iadd],nroot,rootwords)) continue; - addone(addwords[iadd],nroot,rootwords); - } - */ -} - -/* ---------------------------------------------------------------------- */ - void AtomVecHybrid::init() { AtomVec::init(); @@ -151,6 +243,185 @@ void AtomVecHybrid::force_clear(int n, size_t nbytes) if (styles[k]->forceclearflag) styles[k]->force_clear(n,nbytes); } +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_restart() to pack +------------------------------------------------------------------------- */ + +void AtomVecHybrid::pack_restart_pre(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->pack_restart_pre(ilocal); +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecHybrid::pack_restart_post(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->pack_restart_post(ilocal); +} + +/* ---------------------------------------------------------------------- + initialize other atom quantities after AtomVec::unpack_restart() +------------------------------------------------------------------------- */ + +void AtomVecHybrid::unpack_restart_init(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->unpack_restart_init(ilocal); +} + +/* ---------------------------------------------------------------------- + initialize non-zero atom quantities +------------------------------------------------------------------------- */ + +void AtomVecHybrid::create_atom_post(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->create_atom_post(ilocal); +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecHybrid::data_atom_post(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->data_atom_post(ilocal); +} + +/* ---------------------------------------------------------------------- + modify values for AtomVec::pack_data() to pack +------------------------------------------------------------------------- */ + +void AtomVecHybrid::pack_data_pre(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->pack_data_pre(ilocal); +} + +/* ---------------------------------------------------------------------- + unmodify values packed by AtomVec::pack_data() +------------------------------------------------------------------------- */ + +void AtomVecHybrid::pack_data_post(int ilocal) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->pack_data_post(ilocal); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::copy_bonus(int i, int j, int delflag) +{ + for (int k = 0; k < nstyles_bonus; k++) + styles_bonus[k]->copy_bonus(i,j,delflag); +} + +// NOTE: need a clear_bonus() ? + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->pack_comm_bonus(n,list,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf) +{ + for (int k = 0; k < nstyles_bonus; k++) + styles_bonus[k]->unpack_comm_bonus(n,first,buf); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->pack_border_bonus(n,list,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->unpack_border_bonus(n,first,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::pack_exchange_bonus(int i, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->pack_exchange_bonus(i,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->unpack_exchange_bonus(ilocal,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::size_restart_bonus() +{ + int n = 0; + for (int k = 0; k < nstyles_bonus; k++) + n += styles_bonus[k]->size_restart_bonus(); + return n; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::pack_restart_bonus(int i, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->pack_restart_bonus(i,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf) +{ + int m = 0; + for (int k = 0; k < nstyles_bonus; k++) + m += styles_bonus[k]->unpack_restart_bonus(ilocal,buf); + return m; +} + +/* ---------------------------------------------------------------------- */ + +bigint AtomVecHybrid::memory_usage_bonus() +{ + bigint bytes = 0; + for (int k = 0; k < nstyles_bonus; k++) + bytes += styles_bonus[k]->memory_usage_bonus(); + return bytes; +} + /* ---------------------------------------------------------------------- assign an index to named atom property and return index returned value encodes which sub-style and index returned by sub-style @@ -179,6 +450,75 @@ void AtomVecHybrid::pack_property_atom(int multiindex, double *buf, styles[k]->pack_property_atom(index,buf,nvalues,groupbit); } +// ---------------------------------------------------------------------- +// internal methods +// ---------------------------------------------------------------------- + +/* ---------------------------------------------------------------------- + merge fields and remove duplicate fields + concat = root + Inum fields string from all substyles + return dedup = concat with duplicate fields removed + if concat_flag set, also return concat (w/ duplicates) + so caller can check for problematic fields, call will free it +------------------------------------------------------------------------- */ + +char *AtomVecHybrid::merge_fields(int inum, char *root, + int concat_flag, char *&concat_str) +{ + // create concatenated string of length size from root + all substyles + + int size = strlen(root) + 1; + for (int k = 0; k < nstyles; k++) + size += strlen(fieldstrings[k].fstr[inum]) + 1; + + char *concat = new char[size]; + strcpy(concat,root); + + for (int k = 0; k < nstyles; k++) { + if (strlen(concat)) strcat(concat," "); + strcat(concat,fieldstrings[k].fstr[inum]); + } + + // identify unique words in concatenated string + + char *copystr; + char **words; + int nwords = tokenize(concat,words,copystr); + int *unique = new int[nwords]; + + for (int i = 0; i < nwords; i++) { + unique[i] = 1; + for (int j = 0; j < i; j++) + if (strcmp(words[i],words[j]) == 0) unique[i] = 0; + } + + // construct a new deduped string + + char *dedup = new char[size]; + dedup[0] = '\0'; + + for (int i = 0; i < nwords; i++) { + if (!unique[i]) continue; + strcat(dedup,words[i]); + if (i < nwords-1) strcat(dedup," "); + } + + // clean up or return concat + + if (concat_flag) concat_str = concat; + else delete [] concat; + + // clean up + + delete [] copystr; + delete [] words; + delete [] unique; + + // return final concatenated, deduped string + + return dedup; +} + /* ---------------------------------------------------------------------- allstyles = list of all atom styles in this LAMMPS executable ------------------------------------------------------------------------- */ diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 41067d44f2..83d29112dd 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -35,6 +35,33 @@ class AtomVecHybrid : public AtomVec { void process_args(int, char **); void init(); void force_clear(int, size_t); + + 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_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 *); + bigint memory_usage_bonus(); + + void pack_restart_pre(int); + void pack_restart_post(int); + void unpack_restart_init(int); + void create_atom_post(int); + void data_atom_post(int); + void pack_data_pre(int); + void pack_data_post(int); + + //void create_atom_post(int); + //void data_atom_post(int); + //void pack_data_pre(int); + //void pack_data_post(int); + int property_atom(char *); void pack_property_atom(int, double *, int, int); @@ -42,8 +69,15 @@ class AtomVecHybrid : public AtomVec { int nallstyles; char **allstyles; - void concatenate_fields(); - void concatenate(char *&, char *); + struct FieldStrings { + char **fstr; + }; + FieldStrings *fieldstrings; + + int nstyles_bonus; + class AtomVec **styles_bonus; + + char *merge_fields(int, char *, int, char *&); void build_styles(); int known_style(char *); }; diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 3b806c959e..ded2f88c2f 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -50,12 +50,12 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel 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 = (char *) ""; fields_comm_vel = (char *) "omega"; fields_reverse = (char *) "torque"; fields_border = (char *) "molecule radius rmass"; @@ -64,7 +64,7 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) 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"; + fields_data_vel = (char *) "id v omega"; setup_fields(); } diff --git a/src/atom_vec_line.h b/src/atom_vec_line.h index a8bc8fd1bc..a47843f4f2 100644 --- a/src/atom_vec_line.h +++ b/src/atom_vec_line.h @@ -40,7 +40,6 @@ class AtomVecLine : public AtomVec { 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 *); diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 5ae4c0ca21..6796f9c8f2 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -36,12 +36,12 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) "radius rmass omega torque"; fields_copy = (char *) "radius rmass omega"; - fields_comm = NULL; + fields_comm = (char *) ""; fields_comm_vel = (char *) "omega"; fields_reverse = (char *) "torque"; fields_border = (char *) "radius rmass"; @@ -50,7 +50,7 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) fields_restart = (char *) "radius rmass omega"; fields_create = (char *) "radius rmass omega"; fields_data_atom = (char *) "id type radius rmass x"; - fields_data_vel = (char *) "omega"; + fields_data_vel = (char *) "id v omega"; setup_fields(); } diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 6da0ef7015..32d75c16f3 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -52,12 +52,12 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) // 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 + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel 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 = (char *) ""; fields_comm_vel = (char *) "omega angmom"; fields_reverse = (char *) "torque"; fields_border = (char *) "molecule radius rmass"; @@ -66,7 +66,7 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) 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"; + fields_data_vel = (char *) "id v omega angmom"; setup_fields(); } diff --git a/src/atom_vec_tri.h b/src/atom_vec_tri.h index 3c701067b2..ad4c0103ca 100644 --- a/src/atom_vec_tri.h +++ b/src/atom_vec_tri.h @@ -42,7 +42,6 @@ class AtomVecTri : public AtomVec { 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 *); From 9e52980aaae343c0c2dc912ff5b44ee7a46b8eb5 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 3 Dec 2019 11:15:16 -0700 Subject: [PATCH 05/42] all of remaining USER package styles except AWPMD --- src/SPIN/atom_vec_spin.cpp | 12 +- src/USER-EFF/atom_vec_electron.cpp | 17 +- src/USER-MESO/atom_vec_edpd.cpp | 20 +- src/USER-MESO/atom_vec_edpd.h | 1 + src/USER-MESO/atom_vec_mdpd.cpp | 903 +------------------ src/USER-MESO/atom_vec_mdpd.h | 43 +- src/USER-MESO/atom_vec_tdpd.cpp | 858 +----------------- src/USER-MESO/atom_vec_tdpd.h | 32 +- src/USER-SMD/atom_vec_smd.cpp | 1324 +++------------------------- src/USER-SMD/atom_vec_smd.h | 59 +- src/USER-SPH/atom_vec_meso.cpp | 977 +------------------- src/USER-SPH/atom_vec_meso.h | 43 +- src/atom.cpp | 128 ++- src/atom.h | 16 +- src/atom_vec_hybrid.h | 5 - src/atom_vec_sphere.cpp | 7 +- 16 files changed, 368 insertions(+), 4077 deletions(-) diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index a8ff15492a..638a3b8021 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -62,14 +62,16 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) } /* ---------------------------------------------------------------------- - clear all forces (mechanical and magnetic) + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector + include f b/c this is invoked from within SPIN pair styles ------------------------------------------------------------------------- */ -void AtomVecSpin::force_clear(int /*n*/, size_t nbytes) +void AtomVecSpin::force_clear(int n, size_t nbytes) { - memset(&atom->f[0][0],0,3*nbytes); - memset(&atom->fm[0][0],0,3*nbytes); - memset(&atom->fm_long[0][0],0,3*nbytes); + memset(&atom->f[n][0],0,3*nbytes); + memset(&atom->fm[n][0],0,3*nbytes); + memset(&atom->fm_long[n][0],0,3*nbytes); } /* ---------------------------------------------------------------------- diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index 0bad0f115f..3688f7f582 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -18,14 +18,8 @@ #include "atom_vec_electron.h" #include #include "atom.h" -#include "comm.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" #include "citeme.h" -#include "memory.h" #include "error.h" -#include "utils.h" using namespace LAMMPS_NS; @@ -46,6 +40,8 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) { if (lmp->citeme) lmp->citeme->add(cite_user_eff_package); + mass_type = 1; + molecular = 0; forceclearflag = 1; atom->ecp_flag = 0; @@ -75,11 +71,14 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ -void AtomVecElectron::force_clear(int /*n*/, size_t nbytes) +void AtomVecElectron::force_clear(int n, size_t nbytes) { - memset(&atom->erforce[0],0,nbytes); + memset(&atom->erforce[n],0,nbytes); } /* ---------------------------------------------------------------------- diff --git a/src/USER-MESO/atom_vec_edpd.cpp b/src/USER-MESO/atom_vec_edpd.cpp index b4602c760c..7a031c256b 100644 --- a/src/USER-MESO/atom_vec_edpd.cpp +++ b/src/USER-MESO/atom_vec_edpd.cpp @@ -29,9 +29,6 @@ using namespace LAMMPS_NS; AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp) { - if (strcmp(update->unit_style,"lj") != 0) - error->all(FLERR,"Atom style edpd requires lj units"); - molecular = 0; mass_type = 1; forceclearflag = 1; @@ -62,9 +59,22 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- */ -void AtomVecEDPD::force_clear(int /*n*/, size_t nbytes) +void AtomVecEDPD::init() { - memset(&atom->edpd_flux[0],0,nbytes); + AtomVec::init(); + + if (strcmp(update->unit_style,"lj") != 0) + error->all(FLERR,"Atom style edpd requires lj units"); +} + +/* ---------------------------------------------------------------------- + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ + +void AtomVecEDPD::force_clear(int n, size_t nbytes) +{ + memset(&atom->edpd_flux[n],0,nbytes); } /* ---------------------------------------------------------------------- diff --git a/src/USER-MESO/atom_vec_edpd.h b/src/USER-MESO/atom_vec_edpd.h index 7d41b51665..bb667ae792 100644 --- a/src/USER-MESO/atom_vec_edpd.h +++ b/src/USER-MESO/atom_vec_edpd.h @@ -27,6 +27,7 @@ namespace LAMMPS_NS { class AtomVecEDPD : public AtomVec { public: AtomVecEDPD(class LAMMPS *); + void init(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); diff --git a/src/USER-MESO/atom_vec_mdpd.cpp b/src/USER-MESO/atom_vec_mdpd.cpp index 4c9db36645..eefda1ff6a 100644 --- a/src/USER-MESO/atom_vec_mdpd.cpp +++ b/src/USER-MESO/atom_vec_mdpd.cpp @@ -14,14 +14,8 @@ #include "atom_vec_mdpd.h" #include #include "atom.h" -#include "comm.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" #include "update.h" -#include "memory.h" #include "error.h" -#include "utils.h" using namespace LAMMPS_NS; @@ -29,865 +23,63 @@ using namespace LAMMPS_NS; AtomVecMDPD::AtomVecMDPD(LAMMPS *lmp) : AtomVec(lmp) { - if(strcmp(update->unit_style,"lj") != 0) - error->all(FLERR,"Atom style mdpd requires lj units"); - molecular = 0; mass_type = 1; forceclearflag = 1; - comm_x_only = comm_f_only = 0; - comm->ghost_velocity = 1; - - size_forward = 3 + 4; // 3 + rho + vest[3], that means we may only communicate 4 in hybrid - size_reverse = 3 + 1; // 3 + drho - size_border = 6 + 4; // 6 + rho + vest[3] - size_velocity = 3; - size_data_atom = 6; - size_data_vel = 4; - xcol_data = 4; - atom->rho_flag = 1; atom->vest_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 a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = (char *) "rho drho vest"; + fields_copy = (char *) "rho drho vest"; + fields_comm = (char *) "rho vest"; + fields_comm_vel = (char *) "rho vest"; + fields_reverse = (char *) "drho"; + fields_border = (char *) "rho vest"; + fields_border_vel = (char *) "rho vest"; + fields_exchange = (char *) "rho vest"; + fields_restart = (char * ) "rho vest"; + fields_create = (char *) "rho drho vest"; + fields_data_atom = (char *) "id type rho x"; + fields_data_vel = (char *) "id v"; + + setup_fields(); } -/* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n - ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- */ -void AtomVecMDPD::grow(int n) +void AtomVecMDPD::init() { - 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"); - - rho = memory->grow(atom->rho, nmax, "atom:rho"); - drho = memory->grow(atom->drho, nmax*comm->nthreads, "atom:drho"); - vest = memory->grow(atom->vest, nmax, 3, "atom:vest"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); + if (strcmp(update->unit_style,"lj") != 0) + error->all(FLERR,"Atom style mdpd requires lj units"); } /* ---------------------------------------------------------------------- - reset local array ptrs - ------------------------------------------------------------------------- */ - -void AtomVecMDPD::grow_reset() { - tag = atom->tag; - type = atom->type; - mask = atom->mask; - image = atom->image; - x = atom->x; - v = atom->v; - f = atom->f; - rho = atom->rho; - drho = atom->drho; - vest = atom->vest; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMDPD::copy(int i, int j, int delflag) { - //printf("in AtomVecMDPD::copy\n"); - 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]; - - rho[j] = rho[i]; - drho[j] = drho[i]; - vest[j][0] = vest[i][0]; - vest[j][1] = vest[i][1]; - vest[j][2] = vest[i][2]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i, j,delflag); -} - -/* ---------------------------------------------------------------------- */ + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ void AtomVecMDPD::force_clear(int n, size_t nbytes) { - memset(&drho[n],0,nbytes); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_comm_hybrid(int n, int *list, double *buf) { - //printf("in AtomVecMDPD::pack_comm_hybrid\n"); - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::unpack_comm_hybrid(int n, int first, double *buf) { - //printf("in AtomVecMDPD::unpack_comm_hybrid\n"); - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - rho[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_border_hybrid(int n, int *list, double *buf) { - //printf("in AtomVecMDPD::pack_border_hybrid\n"); - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::unpack_border_hybrid(int n, int first, double *buf) { - //printf("in AtomVecMDPD::unpack_border_hybrid\n"); - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - rho[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_reverse_hybrid(int n, int first, double *buf) { - //printf("in AtomVecMDPD::pack_reverse_hybrid\n"); - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = drho[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::unpack_reverse_hybrid(int n, int *list, double *buf) { - //printf("in AtomVecMDPD::unpack_reverse_hybrid\n"); - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - drho[j] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_comm(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMDPD::pack_comm\n"); - 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++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; - } - 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++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_comm_vel(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMDPD::pack_comm_vel\n"); - 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++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; - } - 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++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMDPD::unpack_comm(int n, int first, double *buf) { - //printf("in AtomVecMDPD::unpack_comm\n"); - 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++]; - rho[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMDPD::unpack_comm_vel(int n, int first, double *buf) { - //printf("in AtomVecMDPD::unpack_comm_vel\n"); - 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++]; - rho[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_reverse(int n, int first, double *buf) { - //printf("in AtomVecMDPD::pack_reverse\n"); - 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++] = drho[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMDPD::unpack_reverse(int n, int *list, double *buf) { - //printf("in AtomVecMDPD::unpack_reverse\n"); - 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++]; - drho[j] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_border(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMDPD::pack_border\n"); - 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++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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]; - } - 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++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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 AtomVecMDPD::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++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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 (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - buf[m++] = rho[j]; - buf[m++] = vest[j][0] + dvx; - buf[m++] = vest[j][1] + dvy; - buf[m++] = vest[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = rho[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMDPD::unpack_border(int n, int first, double *buf) { - //printf("in AtomVecMDPD::unpack_border\n"); - 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; - rho[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[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]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMDPD::unpack_border_vel(int n, int first, double *buf) { - //printf("in AtomVecMDPD::unpack_border_vel\n"); - 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++]; - rho[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[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]); + memset(&atom->drho[n],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 - ------------------------------------------------------------------------- */ - -int AtomVecMDPD::pack_exchange(int i, double *buf) { - //printf("in AtomVecMDPD::pack_exchange\n"); - 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++] = rho[i]; - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][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 AtomVecMDPD::unpack_exchange(double *buf) { - //printf("in AtomVecMDPD::unpack_exchange\n"); - 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; - rho[nlocal] = buf[m++]; - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = 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 AtomVecMDPD::size_restart() { - int i; - - int nlocal = atom->nlocal; - int n = 15 * nlocal; // 11 + rho + vest[3] - - 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 AtomVecMDPD::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++] = rho[i]; - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][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 - ------------------------------------------------------------------------- */ - -int AtomVecMDPD::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++]; - rho[nlocal] = buf[m++]; - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = 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 AtomVecMDPD::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; - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - drho[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities - ------------------------------------------------------------------------- */ - -void AtomVecMDPD::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"); - - 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; - - rho[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - drho[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 AtomVecMDPD::data_atom_hybrid(int nlocal, char **values) -{ - rho[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - return 3; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecMDPD::pack_data(double **buf) +void AtomVecMDPD::data_atom_post(int ilocal) { - 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] = rho[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 AtomVecMDPD::pack_data_hybrid(int i, double *buf) -{ - buf[0] = rho[i]; - return 3; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecMDPD::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 AtomVecMDPD::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e",buf[0]); - return 3; + atom->drho[ilocal] = 0.0; + atom->vest[ilocal][0] = 0.0; + atom->vest[ilocal][1] = 0.0; + atom->vest[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -912,15 +104,17 @@ void AtomVecMDPD::pack_property_atom(int index, double *buf, { int *mask = atom->mask; int nlocal = atom->nlocal; - int n = 0; + int n = 0; if (index == 0) { + double *rho = atom->rho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { + double *drho = atom->drho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; else buf[n] = 0.0; @@ -928,24 +122,3 @@ void AtomVecMDPD::pack_property_atom(int index, double *buf, } } } - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory - ------------------------------------------------------------------------- */ - -bigint AtomVecMDPD::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("drho")) bytes += memory->usage(drho, nmax*comm->nthreads); - if (atom->memcheck("vest")) bytes += memory->usage(vest, nmax, 3); - - return bytes; -} diff --git a/src/USER-MESO/atom_vec_mdpd.h b/src/USER-MESO/atom_vec_mdpd.h index 9e9ffcdcf2..0eb4fff2df 100644 --- a/src/USER-MESO/atom_vec_mdpd.h +++ b/src/USER-MESO/atom_vec_mdpd.h @@ -27,50 +27,11 @@ namespace LAMMPS_NS { class AtomVecMDPD : public AtomVec { public: AtomVecMDPD(class LAMMPS *); - ~AtomVecMDPD() {} - void grow(int); - void grow_reset(); - void copy(int, int, int); + void init(); void force_clear(int, size_t); - 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 *); - int pack_reverse(int, int, double *); - void unpack_reverse(int, int *, double *); - int pack_comm_hybrid(int, int *, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_border_hybrid(int, int *, double *); - int unpack_border_hybrid(int, int, double *); - int pack_reverse_hybrid(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 *); - void unpack_border(int, int, double *); - void unpack_border_vel(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 pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_hybrid(FILE *, double *); + 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; - double *rho, *drho; - double **vest; // estimated velocity during force computation }; } diff --git a/src/USER-MESO/atom_vec_tdpd.cpp b/src/USER-MESO/atom_vec_tdpd.cpp index 74ac47066b..55284f69a2 100644 --- a/src/USER-MESO/atom_vec_tdpd.cpp +++ b/src/USER-MESO/atom_vec_tdpd.cpp @@ -14,12 +14,7 @@ #include "atom_vec_tdpd.h" #include #include "atom.h" -#include "comm.h" -#include "domain.h" -#include "modify.h" -#include "fix.h" #include "update.h" -#include "memory.h" #include "error.h" #include "utils.h" @@ -29,29 +24,30 @@ using namespace LAMMPS_NS; AtomVecTDPD::AtomVecTDPD(LAMMPS *lmp) : AtomVec(lmp) { - 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; - - cc_species = 0; // for now, reset in process_args() - - size_forward = 3 + cc_species + 3; //vest[3] - size_reverse = 3 + cc_species; - size_border = 6 + cc_species + 3; //vest[3] - size_velocity = 3; - // for data_atom, we read id + type + xyz[3] + cc[i] where i=1,cc_species - size_data_atom = 5 + cc_species; - size_data_vel = 4; - xcol_data = 3; - atom->tdpd_flag = 1; atom->vest_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 a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = (char *) "cc cc_flux vest"; + fields_copy = (char *) "cc vest"; + fields_comm = (char *) "cc vest"; + fields_comm_vel = (char *) "cc vest"; + fields_reverse = (char *) "cc_flux"; + fields_border = (char *) "cc vest"; + fields_border_vel = (char *) "cc vest"; + fields_exchange = (char *) "cc vest"; + fields_restart = (char * ) "cc vest"; + fields_create = (char *) "cc vest"; + fields_data_atom = (char *) "id type x cc"; + fields_data_vel = (char *) "id v"; } /* ---------------------------------------------------------------------- @@ -66,812 +62,42 @@ void AtomVecTDPD::process_args(int narg, char **arg) atom->cc_species = utils::inumeric(FLERR,arg[0],false,lmp); cc_species = atom->cc_species; - // reset sizes that depend on cc_species + atom->add_peratom_change_columns("cc",cc_species); + atom->add_peratom_change_columns("cc_species",cc_species); - size_forward = 3 + cc_species + 3; - size_reverse = 3 + cc_species; - size_border = 6 + cc_species + 3; - size_data_atom = 5 + cc_species; + // delay setting up of fields until now + + setup_fields(); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecTDPD::init() +{ + AtomVec::init(); + + if (strcmp(update->unit_style,"lj") != 0) + error->all(FLERR,"Atom style tdpd requires lj units"); } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector ------------------------------------------------------------------------- */ -void AtomVecTDPD::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"); - cc = memory->grow(atom->cc,nmax*comm->nthreads,cc_species,"atom:cc"); - cc_flux = memory->grow(atom->cc_flux,nmax*comm->nthreads,cc_species, - "atom:cc_flux"); - vest = memory->grow(atom->vest, nmax, 3, "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 AtomVecTDPD::grow_reset() -{ - tag = atom->tag; type = atom->type; - mask = atom->mask; image = atom->image; - x = atom->x; v = atom->v; f = atom->f; - cc = atom->cc; cc_flux = atom->cc_flux; - vest = atom->vest; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecTDPD::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]; - - for(int k = 0; k < cc_species; k++) - cc[j][k] = cc[i][k]; - - vest[j][0] = vest[i][0]; - vest[j][1] = vest[i][1]; - vest[j][2] = vest[i][2]; - - 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 AtomVecTDPD::force_clear(int n, size_t nbytes) { - memset(&cc_flux[n][0],0,cc_species*nbytes); -} - - -/* ---------------------------------------------------------------------- */ - -int AtomVecTDPD::pack_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,k,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]; - - for(k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; - } - 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; - - for(k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTDPD::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) -{ - int i,j,k,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]; - - for(k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - - for(k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } else { - dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; - dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; - dvz = pbc[2]*h_rate[2]; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - } - for(k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTDPD::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++]; - - for(int k = 0; k < cc_species; k++) - cc[i][k] = buf[m++]; - - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTDPD::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++]; - for(int k = 0; k < cc_species; k++) - cc[i][k] = buf[m++]; - - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTDPD::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]; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc_flux[i][k]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTDPD::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++]; - for(int k = 0; k < cc_species; k++) - cc_flux[j][k] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecTDPD::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; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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]; - } - 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; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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 AtomVecTDPD::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]; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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 (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]; - } - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[j][k]; - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTDPD::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; - for(int k = 0; k < cc_species; k++) - cc[i][k] = buf[m++]; - - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[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]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecTDPD::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++]; - for(int k = 0; k < cc_species; k++) - cc[i][k] = buf[m++]; - - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[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]); + memset(&atom->cc_flux[n][0],0,cc_species*nbytes); } /* ---------------------------------------------------------------------- - pack data for atom I for sending to another proc - xyz must be 1st 3 values, so comm::exchange() can test on them + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -int AtomVecTDPD::pack_exchange(int i, double *buf) +void AtomVecTDPD::data_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; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[i][k]; - - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][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 AtomVecTDPD::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; - for(int k = 0; k < cc_species; k++) - cc[nlocal][k] = buf[m++]; - - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = 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 AtomVecTDPD::size_restart() -{ - int i; - - int nlocal = atom->nlocal; - int n = (11 + cc_species + 3) * nlocal; // 11 + cc[i] + vest[3] - - 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 AtomVecTDPD::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]; - for(int k = 0; k < cc_species; k++) - buf[m++] = cc[i][k]; - - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][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 -------------------------------------------------------------------------- */ - -int AtomVecTDPD::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++]; - for(int k = 0; k < cc_species; k++) - cc[nlocal][k] = buf[m++]; - - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = 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 AtomVecTDPD::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; - - for(int k = 0; k < cc_species; k++) - cc[nlocal][k] = 0.0; - - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecTDPD::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"); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - for(int k = 0; k < cc_species; k++) - cc[nlocal][k] = utils::numeric(FLERR,values[5+k],true,lmp); - - 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; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecTDPD::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] = x[i][0]; - buf[i][3] = x[i][1]; - buf[i][4] = x[i][2]; - buf[i][5] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][6] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][7] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - for(int k = 0; k < cc_species; k++) - buf[i][8+k] = cc[i][k]; - } -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecTDPD::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 %d %d %d", - (tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i, - buf[i][2],buf[i][3],buf[i][4], - (int) ubuf(buf[i][5]).i,(int) ubuf(buf[i][6]).i, - (int) ubuf(buf[i][7]).i); - for(int k = 0; k < cc_species; k++) - fprintf(fp," %-1.16e",buf[i][8+k]); - fprintf(fp,"\n"); - } -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecTDPD::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("cc")) bytes += memory->usage(cc,nmax*comm->nthreads,cc_species); - if (atom->memcheck("cc_flux")) bytes += memory->usage(cc_flux,nmax*comm->nthreads,cc_species); - if (atom->memcheck("vest")) bytes += memory->usage(vest, nmax); - - return bytes; + atom->vest[ilocal][0] = 0.0; + atom->vest[ilocal][1] = 0.0; + atom->vest[ilocal][2] = 0.0; } diff --git a/src/USER-MESO/atom_vec_tdpd.h b/src/USER-MESO/atom_vec_tdpd.h index 86e9ae4bb8..7321859fb4 100644 --- a/src/USER-MESO/atom_vec_tdpd.h +++ b/src/USER-MESO/atom_vec_tdpd.h @@ -27,40 +27,12 @@ namespace LAMMPS_NS { class AtomVecTDPD : public AtomVec { public: AtomVecTDPD(class LAMMPS *); - virtual ~AtomVecTDPD() {} void process_args(int, char **); - void grow(int); - void grow_reset(); - void copy(int, int, int); + void init(); 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(); + void data_atom_post(int); protected: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double **vest; // store intermediate velocity for using mvv integrator - double **cc,**cc_flux; int cc_species; }; diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 604504c5a7..0fada3dc2a 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -25,13 +25,7 @@ #include "atom_vec_smd.h" #include #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; @@ -40,1247 +34,139 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : - AtomVec(lmp) { - molecular = 0; +AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = 0; + mass_type = 1; + forceclearflag = 1; - comm_x_only = 0; - comm_f_only = 0; - size_forward = 6; // variables that are changed by time integration - size_reverse = 4; // f[3] + de - size_border = 31; - size_velocity = 6; // v + vest - size_data_atom = 13; // 7 + 3 x0 + 3 x - size_data_vel = 4; - xcol_data = 11; + atom->smd_flag = 1; - atom->radius_flag = 1; - atom->rmass_flag = 1; - atom->vfrac_flag = 1; - atom->contact_radius_flag = 1; - atom->molecule_flag = 1; - atom->smd_data_9_flag = 1; - atom->e_flag = 1; - atom->vest_flag = 1; - atom->smd_stress_flag = 1; - atom->eff_plastic_strain_flag = 1; - atom->x0_flag = 1; - atom->damage_flag = 1; - atom->eff_plastic_strain_rate_flag = 1; + atom->radius_flag = 1; + atom->rmass_flag = 1; + atom->vfrac_flag = 1; + atom->contact_radius_flag = 1; + atom->molecule_flag = 1; + atom->smd_data_9_flag = 1; + atom->e_flag = 1; + atom->vest_flag = 1; + atom->smd_stress_flag = 1; + atom->eff_plastic_strain_flag = 1; + atom->x0_flag = 1; + atom->damage_flag = 1; + atom->eff_plastic_strain_rate_flag = 1; - forceclearflag = 1; + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file - atom->smd_flag = 1; -} + fields_grow = (char *) + "de vfrac rmass x0 radius contact_radius molecule " + "smd_data_9 e vest tlsph_stress " + "eff_plastic_strain eff_plastic_strain_rate damage"; + fields_copy = (char *) + "vfrac rmass x0 radius contact_radius molecule e " + "eff_plastic_strain eff_plastic_strain_rate vest " + "smd_data_9 smd_stress damage"; + fields_comm = (char *) "radius vfrac vest e"; + fields_comm_vel = (char *) "radius vfrac vest e"; + fields_reverse = (char *) "de"; + fields_border = (char *) + "x0 molecule radius rmass vfrac contact_radius e " + "eff_plastic_strain smd_data_9 smd_stress"; + fields_border_vel = (char *) + "x0 molecule radius rmass vfrac contact_radius e " + "eff_plastic_strain smd_data_9 smd_stress vest"; + fields_exchange = (char *) + "x0 molecule radius rmass vfrac contact_radius e " + "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " + "vest damage"; + fields_restart = (char *) + "x0 molecule radius rmass vfrac contact_radius e " + "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " + "vest damage"; + fields_create = (char *) + "x0 vest vfrac rmass radius contact_radius molecule e " + "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage"; + fields_data_atom = (char *) + "id type molecule vfrac rmass radius contact_radius x"; + fields_data_vel = (char *) "id v vest"; -/* ---------------------------------------------------------------------- */ + // set these array sizes based on defines -void AtomVecSMD::init() { - AtomVec::init(); + atom->add_peratom_change_columns("smd_data_9",NMAT_FULL); + atom->add_peratom_change_columns("smd_stress",NMAT_SYMM); - // do nothing here + setup_fields(); } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n - ------------------------------------------------------------------------- */ + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector + NOTE: does f need to be re-cleared? +------------------------------------------------------------------------- */ -void AtomVecSMD::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"); - - //printf("in grow, nmax is now %d\n", nmax); - - 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"); - de = memory->grow(atom->de, nmax * comm->nthreads, "atom:de"); - - vfrac = memory->grow(atom->vfrac, nmax, "atom:vfrac"); - rmass = memory->grow(atom->rmass, nmax, "atom:rmass"); - x0 = memory->grow(atom->x0, nmax, 3, "atom:x0"); - radius = memory->grow(atom->radius, nmax, "atom:radius"); - contact_radius = memory->grow(atom->contact_radius, nmax, "atom:contact_radius"); - molecule = memory->grow(atom->molecule, nmax, "atom:molecule"); - smd_data_9 = memory->grow(atom->smd_data_9, nmax, NMAT_FULL, "atom:defgrad_old"); - e = memory->grow(atom->e, nmax, "atom:e"); - vest = memory->grow(atom->vest, nmax, 3, "atom:vest"); - tlsph_stress = memory->grow(atom->smd_stress, nmax, NMAT_SYMM, "atom:tlsph_stress"); - eff_plastic_strain = memory->grow(atom->eff_plastic_strain, nmax, "atom:eff_plastic_strain"); - eff_plastic_strain_rate = memory->grow(atom->eff_plastic_strain_rate, nmax, "atom:eff_plastic_strain_rate"); - damage = memory->grow(atom->damage, nmax, "atom:damage"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); +void AtomVecSMD::force_clear(int n, size_t nbytes) +{ + memset(&atom->de[n],0,nbytes); + memset(&atom->f[n][0],0,3*nbytes); } /* ---------------------------------------------------------------------- - reset local array ptrs - ------------------------------------------------------------------------- */ + initialize non-zero atom quantities +------------------------------------------------------------------------- */ -void AtomVecSMD::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; +void AtomVecSMD::create_atom_post(int ilocal) +{ + atom->x0[ilocal][0] = atom->x[ilocal][0]; + atom->x0[ilocal][1] = atom->x[ilocal][1]; + atom->x0[ilocal][2] = atom->x[ilocal][2]; - vfrac = atom->vfrac; - x0 = atom->x0; - contact_radius = atom->contact_radius; - molecule = atom->molecule; - smd_data_9 = atom->smd_data_9; - e = atom->e; - de = atom->de; - tlsph_stress = atom->smd_stress; - eff_plastic_strain = atom->eff_plastic_strain; - eff_plastic_strain_rate = atom->eff_plastic_strain_rate; - damage = atom->damage; - vest = atom->vest; + atom->vfrac[ilocal] = 1.0; + atom->rmass[ilocal] = 1.0; + atom->radius[ilocal] = 0.5; + atom->contact_radius[ilocal] = 0.5; + atom->molecule[ilocal] = 1; + + atom->smd_data_9[ilocal][0] = 1.0; // xx + atom->smd_data_9[ilocal][4] = 1.0; // yy + atom->smd_data_9[ilocal][8] = 1.0; // zz } /* ---------------------------------------------------------------------- - copy atom I info to atom J - ------------------------------------------------------------------------- */ + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ -void AtomVecSMD::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]; +void AtomVecSMD::data_atom_post(int ilocal) +{ + atom->e[ilocal] = 0.0; + atom->x0[ilocal][0] = atom->x[ilocal][0]; + atom->x0[ilocal][1] = atom->x[ilocal][1]; + atom->x0[ilocal][2] = atom->x[ilocal][2]; - vfrac[j] = vfrac[i]; - rmass[j] = rmass[i]; - x0[j][0] = x0[i][0]; - x0[j][1] = x0[i][1]; - x0[j][2] = x0[i][2]; - radius[j] = radius[i]; - contact_radius[j] = contact_radius[i]; - molecule[j] = molecule[i]; - e[j] = e[i]; - eff_plastic_strain[j] = eff_plastic_strain[i]; - eff_plastic_strain_rate[j] = eff_plastic_strain_rate[i]; - vest[j][0] = vest[i][0]; - vest[j][1] = vest[i][1]; - vest[j][2] = vest[i][2]; + atom->vest[ilocal][0] = 0.0; + atom->vest[ilocal][1] = 0.0; + atom->vest[ilocal][2] = 0.0; - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[j][k] = smd_data_9[i][k]; - } + atom->damage[ilocal] = 0.0; - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[j][k] = tlsph_stress[i][k]; - } + atom->eff_plastic_strain[ilocal] = 0.0; + atom->eff_plastic_strain_rate[ilocal] = 0.0; - damage[j] = damage[i]; + for (int k = 0; k < NMAT_FULL; k++) + atom->smd_data_9[ilocal][k] = 0.0; - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i, j, delflag); + for (int k = 0; k < NMAT_SYMM; k++) + atom->smd_stress[ilocal][k] = 0.0; + + atom->smd_data_9[ilocal][0] = 1.0; // xx + atom->smd_data_9[ilocal][4] = 1.0; // yy + atom->smd_data_9[ilocal][8] = 1.0; // zz } -/* ---------------------------------------------------------------------- */ -int AtomVecSMD::pack_comm(int /*n*/, int * /*list*/, double * /*buf*/, int /*pbc_flag*/, int * /*pbc*/) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); - return -1; -} -/* ---------------------------------------------------------------------- */ -int AtomVecSMD::pack_comm_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { - // communicate quantities to ghosts, which are changed by time-integration AND are required on ghost atoms. - //no need to pack stress or defgrad information here, as these quantities are not required for ghost atoms. - // Inside pair_style tlsph, these quantities are computed and communicated to ghosts. - - // no need to communicate x0 here, as it is not changed by time integration - // if x0 is changed when the ref config is updated, this communication is performed in the fix_integrate/tlsph - // similarily, rmass could be removed here. - // radius should be communicated here for future time-integration of the radius with ulsph (not implemented yet) - 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]; //3 - buf[m++] = radius[j]; - buf[m++] = vfrac[j]; // 5 - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 8 - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 11 - buf[m++] = e[j]; // 12 - - } - } 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++] = radius[j]; - buf[m++] = vfrac[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 8 - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 11 - buf[m++] = e[j]; // 12 - - } - } 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]; -// printf("\ndvx = %f, dvy=%f, dvz=%f\n", dvx, dvy, dvz); -// printf("dx = %f, dy=%f, dz=%f\n", dx, dy, dz); - 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++] = radius[j]; - buf[m++] = vfrac[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; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 8 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 11 - } - - buf[m++] = e[j]; // 12 - - } - } - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::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++] = radius[j]; - buf[m++] = vfrac[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = e[j]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSMD::unpack_comm(int /*n*/, int /*first*/, double * /*buf*/) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSMD::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++]; //3 - radius[i] = buf[m++]; - vfrac[i] = buf[m++]; // 5 - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; // 8 - - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; // 11 - e[i] = buf[m++]; - - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::unpack_comm_hybrid(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - radius[i] = buf[m++]; - vfrac[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - e[i] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::pack_reverse(int n, int first, double *buf) { - int i, m, last; - - printf("in pack_reverse\n"); - - 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++] = de[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::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++] = de[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSMD::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++]; - de[j] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::unpack_reverse_hybrid(int n, int *list, double *buf) { - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - de[j] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::pack_border(int /*n*/, int * /*list*/, double * /*buf*/, int /*pbc_flag*/, int * /*pbc*/) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); - return -1; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecSMD::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; - - //printf("AtomVecSMD::pack_border_vel\n"); - - 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]; // 3 - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 6 - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; // 10 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 16 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 25 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 31 - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 34 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 37 - } - } 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) { - //printf("dx = %f\n", dx); - 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; // 3 - buf[m++] = x0[j][0]; // this is correct - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 6 - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; // 10 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 17 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 26 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 32 - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 35 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 38 - - } - } 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]; -// printf("\ndvx = %f, dvy=%f, dvz=%f\n", dvx, dvy, dvz); -// printf("dx = %f, dy=%f, dz=%f\n", dx, dy, dz); - 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; // 3 - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 6 - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; // 10 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 16 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 25 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 31 - - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; // 34 - buf[m++] = vest[j][0] + dvx; - buf[m++] = vest[j][1] + dvy; - buf[m++] = vest[j][2] + dvz; // 37 - - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 34 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 37 - } - - } - } - } - - 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 AtomVecSMD::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++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 3 - buf[m++] = ubuf(molecule[j]).d; // 4 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 11 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 20 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 26 - - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSMD::unpack_border(int /*n*/, int /*first*/, double * /*buf*/) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSMD::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++]; // 3 - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = buf[m++]; // 6 - 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; // 10 - - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - vfrac[i] = buf[m++]; - contact_radius[i] = buf[m++]; - e[i] = buf[m++]; - eff_plastic_strain[i] = buf[m++]; // 16 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[i][k] = buf[m++]; - } // 25 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[i][k] = buf[m++]; - } // 31 - - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; // 34 - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; // 37 - } - - 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 AtomVecSMD::unpack_border_hybrid(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = buf[m++]; // 3 - molecule[i] = (tagint) ubuf(buf[m++]).i; // 4 - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - vfrac[i] = buf[m++]; - contact_radius[i] = buf[m++]; - e[i] = buf[m++]; - eff_plastic_strain[i] = buf[m++]; // 11 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[i][k] = buf[m++]; - } // 20 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[i][k] = buf[m++]; - } // 26 - } - 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 AtomVecSMD::pack_exchange(int i, double *buf) { - int m = 1; - - //printf("in AtomVecSMD::pack_exchange tag %d\n", tag[i]); - - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; // 3 - buf[m++] = x0[i][0]; - buf[m++] = x0[i][1]; - buf[m++] = x0[i][2]; // 6 - 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++] = ubuf(molecule[i]).d; // 11 - buf[m++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = vfrac[i]; - buf[m++] = contact_radius[i]; - buf[m++] = e[i]; - buf[m++] = eff_plastic_strain[i]; // 18 - buf[m++] = eff_plastic_strain_rate[i]; // 19 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[i][k]; - } // 27 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[i][k]; - } // 33 - - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; // 36 - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][2]; // 39 - - buf[m++] = damage[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 AtomVecSMD::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++]; // 3 - x0[nlocal][0] = buf[m++]; - x0[nlocal][1] = buf[m++]; - x0[nlocal][2] = buf[m++]; // 6 - 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; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; // 11 - - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - vfrac[nlocal] = buf[m++]; - contact_radius[nlocal] = buf[m++]; - e[nlocal] = buf[m++]; - eff_plastic_strain[nlocal] = buf[m++]; // 18 - eff_plastic_strain_rate[nlocal] = buf[m++]; // 19 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = buf[m++]; - } // 27 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = buf[m++]; - } // 33 - - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; // 36 - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = buf[m++]; // 39 - - damage[nlocal] = buf[m++]; //40 - - 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 AtomVecSMD::size_restart() { - int i; - - int nlocal = atom->nlocal; - int n = 43 * nlocal; // count pack_restart + 1 (size of buffer) - - 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 AtomVecSMD::pack_restart(int i, double *buf) { - int m = 1; // 1 - - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; // 4 - buf[m++] = x0[i][0]; - buf[m++] = x0[i][1]; - buf[m++] = x0[i][2]; // 7 - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; // 10 - buf[m++] = ubuf(image[i]).d; - buf[m++] = ubuf(molecule[i]).d; - buf[m++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = vfrac[i]; // 15 - buf[m++] = contact_radius[i]; - buf[m++] = e[i]; - buf[m++] = eff_plastic_strain[i]; - buf[m++] = eff_plastic_strain_rate[i]; // 19 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[i][k]; - } // 28 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[i][k]; - } // 34 - - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; // 37 - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][2]; // 40 - - buf[m++] = damage[i]; // 41 - - 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 AtomVecSMD::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++]; // 3 - x0[nlocal][0] = buf[m++]; - x0[nlocal][1] = buf[m++]; - x0[nlocal][2] = buf[m++]; // 6 - 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; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; // 11 - - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - vfrac[nlocal] = buf[m++]; //14 - contact_radius[nlocal] = buf[m++]; //15 - e[nlocal] = buf[m++]; - eff_plastic_strain[nlocal] = buf[m++]; // 18 - eff_plastic_strain_rate[nlocal] = buf[m++]; // 29 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = buf[m++]; - } // 28 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = buf[m++]; - } // 34 - - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; // 37 - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = buf[m++]; // 40 - - damage[nlocal] = buf[m++]; //41 - - //printf("nlocal in restart is %d\n", nlocal); - - 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++; - - //printf("returning m=%d in unpack_restart\n", m); - - return m; -} - -/* ---------------------------------------------------------------------- - create one atom of itype at coord - set other values to defaults - ------------------------------------------------------------------------- */ - -void AtomVecSMD::create_atom(int itype, double *coord) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - printf("nlocal = %d, nmax = %d, calling grow\n", nlocal, nmax); - grow(0); - printf("... finished growing\n"); - } - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - x0[nlocal][0] = coord[0]; - x0[nlocal][1] = coord[1]; - x0[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; - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - - vfrac[nlocal] = 1.0; - rmass[nlocal] = 1.0; - radius[nlocal] = 0.5; - contact_radius[nlocal] = 0.5; - molecule[nlocal] = 1; - e[nlocal] = 0.0; - eff_plastic_strain[nlocal] = 0.0; - eff_plastic_strain_rate[nlocal] = 0.0; - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = 0.0; - } - smd_data_9[nlocal][0] = 1.0; // xx - smd_data_9[nlocal][4] = 1.0; // yy - smd_data_9[nlocal][8] = 1.0; // zz - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = 0.0; - } - - damage[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities - ------------------------------------------------------------------------- */ - -void AtomVecSMD::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"); - - molecule[nlocal] = utils::tnumeric(FLERR,values[2],true,lmp); - if (molecule[nlocal] <= 0) - error->one(FLERR, "Invalid molecule in Atoms section of data file"); - - vfrac[nlocal] = utils::numeric(FLERR,values[3],true,lmp); - if (vfrac[nlocal] < 0.0) - error->one(FLERR, "Invalid volume in Atoms section of data file"); - - rmass[nlocal] = utils::numeric(FLERR,values[4],true,lmp); - if (rmass[nlocal] == 0.0) - error->one(FLERR, "Invalid mass in Atoms section of data file"); - - radius[nlocal] = utils::numeric(FLERR,values[5],true,lmp); - if (radius[nlocal] < 0.0) - error->one(FLERR, "Invalid radius in Atoms section of data file"); - - contact_radius[nlocal] = utils::numeric(FLERR,values[6],true,lmp); - if (contact_radius[nlocal] < 0.0) - error->one(FLERR, "Invalid contact radius in Atoms section of data file"); - - e[nlocal] = 0.0; - - x0[nlocal][0] = utils::numeric(FLERR,values[7],true,lmp); - x0[nlocal][1] = utils::numeric(FLERR,values[8],true,lmp); - x0[nlocal][2] = utils::numeric(FLERR,values[9],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; - - damage[nlocal] = 0.0; - - eff_plastic_strain[nlocal] = 0.0; - eff_plastic_strain_rate[nlocal] = 0.0; - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = 0.0; - } - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = 0.0; - } - - smd_data_9[nlocal][0] = 1.0; // xx - smd_data_9[nlocal][4] = 1.0; // yy - smd_data_9[nlocal][8] = 1.0; // zz - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Atoms section of data file - initialize other atom quantities for this sub-style - ------------------------------------------------------------------------- */ - -int AtomVecSMD::data_atom_hybrid(int /*nlocal*/, char **/*values*/) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return -1; -} - -/* ---------------------------------------------------------------------- - unpack one line from Velocities section of data file - ------------------------------------------------------------------------- */ - -void AtomVecSMD::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); - vest[m][0] = utils::numeric(FLERR,values[0],true,lmp); - vest[m][1] = utils::numeric(FLERR,values[1],true,lmp); - vest[m][2] = utils::numeric(FLERR,values[2],true,lmp); -} - -/* ---------------------------------------------------------------------- - unpack hybrid quantities from one line in Velocities section of data file - ------------------------------------------------------------------------- */ - -int AtomVecSMD::data_vel_hybrid(int /*m*/, char **/*values*/) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return 0; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags - ------------------------------------------------------------------------- */ - -void AtomVecSMD::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] = ubuf(molecule[i]).d; - buf[i][3] = vfrac[i]; - buf[i][4] = rmass[i]; - buf[i][5] = radius[i]; - buf[i][6] = contact_radius[i]; - - buf[i][7] = x[i][0]; - buf[i][8] = x[i][1]; - buf[i][9] = x[i][2]; - - buf[i][10] = x0[i][0]; - buf[i][11] = x0[i][1]; - buf[i][12] = x0[i][2]; - - buf[i][13] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][14] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][15] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file - ------------------------------------------------------------------------- */ - -int AtomVecSMD::pack_data_hybrid(int /*i*/, double * /*buf*/) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return -1; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags - ------------------------------------------------------------------------- */ - -void AtomVecSMD::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 %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e\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], buf[i][7], buf[i][8], - buf[i][9], buf[i][10], buf[i][11], buf[i][12]); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file - ------------------------------------------------------------------------- */ - -int AtomVecSMD::write_data_hybrid(FILE * /*fp*/, double * /*buf*/) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return -1; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file - ------------------------------------------------------------------------- */ - -void AtomVecSMD::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]; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid velocity info for data file - ------------------------------------------------------------------------- */ - -int AtomVecSMD::pack_vel_hybrid(int /*i*/, double * /*buf*/) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return 0; -} - -/* ---------------------------------------------------------------------- - write velocity info to data file - ------------------------------------------------------------------------- */ - -void AtomVecSMD::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\n", (tagint) ubuf(buf[i][0]).i, buf[i][1], buf[i][2], buf[i][3]); -} - -/* ---------------------------------------------------------------------- - write hybrid velocity info to data file - ------------------------------------------------------------------------- */ - -int AtomVecSMD::write_vel_hybrid(FILE * /*fp*/, double * /*buf*/) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return 3; -} - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory - ------------------------------------------------------------------------- */ - -bigint AtomVecSMD::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("molecule")) - bytes += memory->usage(molecule, 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("vest")) - bytes += memory->usage(vest, 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("contact_radius")) - bytes += memory->usage(contact_radius, nmax); - if (atom->memcheck("vfrac")) - bytes += memory->usage(vfrac, nmax); - if (atom->memcheck("rmass")) - bytes += memory->usage(rmass, nmax); - if (atom->memcheck("eff_plastic_strain")) - bytes += memory->usage(eff_plastic_strain, nmax); - if (atom->memcheck("eff_plastic_strain_rate")) - bytes += memory->usage(eff_plastic_strain_rate, nmax); - if (atom->memcheck("e")) - bytes += memory->usage(e, nmax); - if (atom->memcheck("de")) - bytes += memory->usage(de, nmax); - - if (atom->memcheck("smd_data_9")) - bytes += memory->usage(smd_data_9, nmax, NMAT_FULL); - if (atom->memcheck("tlsph_stress")) - bytes += memory->usage(tlsph_stress, nmax, NMAT_SYMM); - - if (atom->memcheck("damage")) - bytes += memory->usage(damage, nmax); - - return bytes; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecSMD::force_clear(int n, size_t nbytes) { - //printf("clearing force on atom %d", n); - memset(&de[n], 0, nbytes); - memset(&f[0][0], 0, 3 * nbytes); -} diff --git a/src/USER-SMD/atom_vec_smd.h b/src/USER-SMD/atom_vec_smd.h index 34fdfc1f76..539f209ca7 100644 --- a/src/USER-SMD/atom_vec_smd.h +++ b/src/USER-SMD/atom_vec_smd.h @@ -9,7 +9,6 @@ * * ----------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories @@ -39,63 +38,9 @@ namespace LAMMPS_NS { class AtomVecSMD : public AtomVec { public: AtomVecSMD(class LAMMPS *); - ~AtomVecSMD() {} - void init(); - 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 *); - bigint memory_usage(); - - private: - tagint *tag; - int *type,*mask; - imageint *image; - double **x,**v,**f; - double *radius,*rmass; - - tagint *molecule; - double *vfrac,**x0,*contact_radius, **smd_data_9, *e, *de, **vest; - double **tlsph_stress; - double *eff_plastic_strain; - double *damage; - double *eff_plastic_strain_rate; - - + void create_atom_post(int); + void data_atom_post(int); }; } diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_meso.cpp index cd7c2251ab..a80ab91d2e 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_meso.cpp @@ -14,13 +14,7 @@ #include "atom_vec_meso.h" #include #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; @@ -32,921 +26,64 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) mass_type = 1; forceclearflag = 1; - comm_x_only = 0; // we communicate not only x forward but also vest ... - comm_f_only = 0; // we also communicate de and drho in reverse direction - size_forward = 8; // 3 + rho + e + vest[3], that means we may only communicate 5 in hybrid - size_reverse = 5; // 3 + drho + de - size_border = 12; // 6 + rho + e + vest[3] + cv - size_velocity = 3; - size_data_atom = 8; - size_data_vel = 4; - xcol_data = 6; - atom->e_flag = 1; atom->rho_flag = 1; atom->cv_flag = 1; atom->vest_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 a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = (char *) "rho drho e de cv vest"; + fields_copy = (char *) "rho drho e de cv vest"; + fields_comm = (char *) "rho e vest"; + fields_comm_vel = (char *) "rho e vest"; + fields_reverse = (char *) "drho de"; + fields_border = (char *) "rho e cv vest"; + fields_border_vel = (char *) "rho e cv vest"; + fields_exchange = (char *) "rho e cv vest"; + fields_restart = (char * ) "rho e cv vest"; + fields_create = (char *) "rho e cv vest de drho"; + fields_data_atom = (char *) "id type rho e cv x"; + fields_data_vel = (char *) "id v"; + + setup_fields(); } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n - ------------------------------------------------------------------------- */ - -void AtomVecMeso::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"); - - rho = memory->grow(atom->rho, nmax, "atom:rho"); - drho = memory->grow(atom->drho, nmax*comm->nthreads, "atom:drho"); - e = memory->grow(atom->e, nmax, "atom:e"); - de = memory->grow(atom->de, nmax*comm->nthreads, "atom:de"); - vest = memory->grow(atom->vest, nmax, 3, "atom:vest"); - cv = memory->grow(atom->cv, nmax, "atom:cv"); - - 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 AtomVecMeso::grow_reset() { - tag = atom->tag; - type = atom->type; - mask = atom->mask; - image = atom->image; - x = atom->x; - v = atom->v; - f = atom->f; - rho = atom->rho; - drho = atom->drho; - e = atom->e; - de = atom->de; - vest = atom->vest; - cv = atom->cv; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMeso::copy(int i, int j, int delflag) { - //printf("in AtomVecMeso::copy\n"); - 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]; - - rho[j] = rho[i]; - drho[j] = drho[i]; - e[j] = e[i]; - de[j] = de[i]; - cv[j] = cv[i]; - vest[j][0] = vest[i][0]; - vest[j][1] = vest[i][1]; - vest[j][2] = vest[i][2]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i, j,delflag); -} - -/* ---------------------------------------------------------------------- */ + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ void AtomVecMeso::force_clear(int n, size_t nbytes) { - memset(&de[n],0,nbytes); - memset(&drho[n],0,nbytes); -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_comm_hybrid(int n, int *list, double *buf) { - //printf("in AtomVecMeso::pack_comm_hybrid\n"); - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::unpack_comm_hybrid(int n, int first, double *buf) { - //printf("in AtomVecMeso::unpack_comm_hybrid\n"); - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - rho[i] = buf[m++]; - e[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_border_hybrid(int n, int *list, double *buf) { - //printf("in AtomVecMeso::pack_border_hybrid\n"); - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::unpack_border_hybrid(int n, int first, double *buf) { - //printf("in AtomVecMeso::unpack_border_hybrid\n"); - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - rho[i] = buf[m++]; - e[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_reverse_hybrid(int n, int first, double *buf) { - //printf("in AtomVecMeso::pack_reverse_hybrid\n"); - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = drho[i]; - buf[m++] = de[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::unpack_reverse_hybrid(int n, int *list, double *buf) { - //printf("in AtomVecMeso::unpack_reverse_hybrid\n"); - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - drho[j] += buf[m++]; - de[j] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_comm(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMeso::pack_comm\n"); - 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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; - } - 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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_comm_vel(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMeso::pack_comm_vel\n"); - 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++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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; - } - 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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMeso::unpack_comm(int n, int first, double *buf) { - //printf("in AtomVecMeso::unpack_comm\n"); - 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++]; - rho[i] = buf[m++]; - e[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMeso::unpack_comm_vel(int n, int first, double *buf) { - //printf("in AtomVecMeso::unpack_comm_vel\n"); - 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++]; - rho[i] = buf[m++]; - e[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_reverse(int n, int first, double *buf) { - //printf("in AtomVecMeso::pack_reverse\n"); - 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++] = drho[i]; - buf[m++] = de[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMeso::unpack_reverse(int n, int *list, double *buf) { - //printf("in AtomVecMeso::unpack_reverse\n"); - 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++]; - drho[j] += buf[m++]; - de[j] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecMeso::pack_border(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMeso::pack_border\n"); - 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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = cv[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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]; - } - 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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = cv[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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 AtomVecMeso::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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = cv[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - buf[m++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = cv[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[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 (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; - } 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++] = rho[j]; - buf[m++] = e[j]; - buf[m++] = cv[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; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMeso::unpack_border(int n, int first, double *buf) { - //printf("in AtomVecMeso::unpack_border\n"); - 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; - rho[i] = buf[m++]; - e[i] = buf[m++]; - cv[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[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]); -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecMeso::unpack_border_vel(int n, int first, double *buf) { - //printf("in AtomVecMeso::unpack_border_vel\n"); - 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++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - rho[i] = buf[m++]; - e[i] = buf[m++]; - cv[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]); + memset(&atom->de[n],0,nbytes); + memset(&atom->drho[n],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 - ------------------------------------------------------------------------- */ - -int AtomVecMeso::pack_exchange(int i, double *buf) { - //printf("in AtomVecMeso::pack_exchange\n"); - 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++] = rho[i]; - buf[m++] = e[i]; - buf[m++] = cv[i]; - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][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 AtomVecMeso::unpack_exchange(double *buf) { - //printf("in AtomVecMeso::unpack_exchange\n"); - 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; - rho[nlocal] = buf[m++]; - e[nlocal] = buf[m++]; - cv[nlocal] = buf[m++]; - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = 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 AtomVecMeso::size_restart() { - int i; - - int nlocal = atom->nlocal; - int n = 17 * nlocal; // 11 + rho + e + cv + vest[3] - - 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 AtomVecMeso::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++] = rho[i]; - buf[m++] = e[i]; - buf[m++] = cv[i]; - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][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 - ------------------------------------------------------------------------- */ - -int AtomVecMeso::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++]; - rho[nlocal] = buf[m++]; - e[nlocal] = buf[m++]; - cv[nlocal] = buf[m++]; - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = 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 AtomVecMeso::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; - e[nlocal] = 0.0; - cv[nlocal] = 1.0; - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - de[nlocal] = 0.0; - drho[nlocal] = 0.0; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities - ------------------------------------------------------------------------- */ - -void AtomVecMeso::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"); - - rho[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - e[nlocal] = utils::numeric(FLERR,values[3],true,lmp); - cv[nlocal] = utils::numeric(FLERR,values[4],true,lmp); - - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - - //printf("rho=%f, e=%f, cv=%f, x=%f\n", rho[nlocal], e[nlocal], cv[nlocal], x[nlocal][0]); - - 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; - - de[nlocal] = 0.0; - drho[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 AtomVecMeso::data_atom_hybrid(int nlocal, char **values) { - - rho[nlocal] = utils::numeric(FLERR,values[0],true,lmp); - e[nlocal] = utils::numeric(FLERR,values[1],true,lmp); - cv[nlocal] = utils::numeric(FLERR,values[2],true,lmp); - - return 3; -} - -/* ---------------------------------------------------------------------- - pack atom info for data file including 3 image flags + initialize non-zero atom quantities ------------------------------------------------------------------------- */ -void AtomVecMeso::pack_data(double **buf) +void AtomVecMeso::create_atom_post(int ilocal) { - 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] = rho[i]; - buf[i][3] = e[i]; - buf[i][4] = cv[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; - } + atom->cv[ilocal] = 1.0; } /* ---------------------------------------------------------------------- - pack hybrid atom info for data file + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities ------------------------------------------------------------------------- */ -int AtomVecMeso::pack_data_hybrid(int i, double *buf) +void AtomVecMeso::data_atom_post(int ilocal) { - buf[0] = rho[i]; - buf[1] = e[i]; - buf[2] = cv[i]; - return 3; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecMeso::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 %-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],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 AtomVecMeso::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %-1.16e %-1.16e",buf[0],buf[1],buf[2]); - return 3; + atom->vest[ilocal][0] = 0.0; + atom->vest[ilocal][1] = 0.0; + atom->vest[ilocal][2] = 0.0; + atom->de[ilocal] = 0.0; + atom->drho[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -977,30 +114,35 @@ void AtomVecMeso::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { + double *rho = atom->rho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { + double *drho = atom->drho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 2) { + double *e = atom->e; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = e[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 3) { + double *de = atom->de; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = de[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 4) { + double *cv = atom->cv; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = cv[i]; else buf[n] = 0.0; @@ -1008,40 +150,3 @@ void AtomVecMeso::pack_property_atom(int index, double *buf, } } } - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory - ------------------------------------------------------------------------- */ - -bigint AtomVecMeso::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("drho")) - bytes += memory->usage(drho, nmax*comm->nthreads); - if (atom->memcheck("e")) - bytes += memory->usage(e, nmax); - if (atom->memcheck("de")) - bytes += memory->usage(de, nmax*comm->nthreads); - if (atom->memcheck("cv")) - bytes += memory->usage(cv, nmax); - if (atom->memcheck("vest")) - bytes += memory->usage(vest, nmax); - - return bytes; -} diff --git a/src/USER-SPH/atom_vec_meso.h b/src/USER-SPH/atom_vec_meso.h index da68222e29..c8a1090474 100644 --- a/src/USER-SPH/atom_vec_meso.h +++ b/src/USER-SPH/atom_vec_meso.h @@ -27,50 +27,11 @@ namespace LAMMPS_NS { class AtomVecMeso : public AtomVec { public: AtomVecMeso(class LAMMPS *); - ~AtomVecMeso() {} - 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 *); - void unpack_comm(int, int, double *); - void unpack_comm_vel(int, int, double *); - int pack_reverse(int, int, double *); - void unpack_reverse(int, int *, double *); - int pack_comm_hybrid(int, int *, double *); - int unpack_comm_hybrid(int, int, double *); - int pack_border_hybrid(int, int *, double *); - int unpack_border_hybrid(int, int, double *); - int pack_reverse_hybrid(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 *); - void unpack_border(int, int, double *); - void unpack_border_vel(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 pack_data(double **); - int pack_data_hybrid(int, double *); - void write_data(FILE *, int, double **); - int write_data_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; - double *rho, *drho, *e, *de, *cv; - double **vest; // estimated velocity during force computation }; } diff --git a/src/atom.cpp b/src/atom.cpp index d238db5e65..8fd859478f 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -81,50 +81,21 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) image = NULL; x = v = f = NULL; - molecule = NULL; - molindex = molatom = NULL; + // charged and dipolar particles + q = NULL; mu = NULL; + + // finite-size particles + omega = angmom = torque = NULL; radius = rmass = NULL; ellipsoid = line = tri = body = NULL; - vfrac = s0 = NULL; - x0 = NULL; + // molecular systems - spin = NULL; - eradius = ervel = erforce = NULL; - cs = csforce = vforce = ervelforce = NULL; - etag = NULL; - - rho = drho = e = de = cv = NULL; - vest = NULL; - - // SPIN package - - sp = fm = fm_long = NULL; - - // USER-DPD - - uCond = uMech = uChem = uCG = uCGnew = NULL; - duChem = NULL; - dpdTheta = NULL; - - // USER-MESO - - cc = cc_flux = NULL; - edpd_temp = edpd_flux = edpd_cv = NULL; - - // USER-SMD - - contact_radius = NULL; - smd_data_9 = NULL; - smd_stress = NULL; - eff_plastic_strain = NULL; - eff_plastic_strain_rate = NULL; - damage = NULL; - - // molecular info + molecule = NULL; + molindex = molatom = NULL; bond_per_atom = extra_bond_per_atom = 0; num_bond = NULL; @@ -150,6 +121,47 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) nspecial = NULL; special = NULL; + // PERI package + + vfrac = s0 = NULL; + x0 = NULL; + + // SPIN package + + sp = fm = fm_long = NULL; + + // USER-EFF and USER-AWPMD packages + + spin = NULL; + eradius = ervel = erforce = NULL; + ervelforce = cs = csforce = NULL; + vforce = NULL; + etag = NULL; + + // USER-DPD package + + uCond = uMech = uChem = uCG = uCGnew = NULL; + duChem = dpdTheta = NULL; + + // USER-MESO package + + cc = cc_flux = NULL; + edpd_temp = edpd_flux = edpd_cv = NULL; + + // USER-SMD package + + contact_radius = NULL; + smd_data_9 = NULL; + smd_stress = NULL; + eff_plastic_strain = NULL; + eff_plastic_strain_rate = NULL; + damage = NULL; + + // USER-SPH package + + rho = drho = e = de = cv = NULL; + vest = NULL; + // user-defined molecules nmolecule = 0; @@ -532,9 +544,16 @@ void Atom::peratom_create() add_peratom("ervel",&ervel,DOUBLE,0); add_peratom("erforce",&erforce,DOUBLE,0,1); // set per-thread flag + // USER-AWPMD package + + add_peratom("cs",&cs,DOUBLE,0); + add_peratom("csforce",&csforce,DOUBLE,0); + add_peratom("vforce",&vforce,DOUBLE,3); + add_peratom("ervelforce",&ervelforce,DOUBLE,0); + add_peratom("etag",&etag,INT,0); + // 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); @@ -548,7 +567,26 @@ void Atom::peratom_create() 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); + add_peratom("cc",&cc,DOUBLE,1); + add_peratom("cc_flux",&cc_flux,DOUBLE,1,1); // set per-thread flag + + // USER-SPH package + + add_peratom("rho",&rho,DOUBLE,0); + add_peratom("drho",&drho,DOUBLE,0,1); // set per-thread flag + add_peratom("e",&e,DOUBLE,0); + add_peratom("de",&de,DOUBLE,0,1); // set per-thread flag + add_peratom("vest",&vest,DOUBLE,3); + add_peratom("cv",&cv,DOUBLE,0); + + // USER-SMD package + + add_peratom("contact_radius",&contact_radius,DOUBLE,0); + add_peratom("smd_data_9",&smd_data_9,DOUBLE,1); + add_peratom("smd_stress",&smd_stress,DOUBLE,1); + add_peratom("eff_plastic_strain",&eff_plastic_strain,DOUBLE,0); + add_peratom("eff_plastic_strain_rate",&eff_plastic_strain_rate,DOUBLE,0); + add_peratom("damage",&damage,DOUBLE,0); } /* ---------------------------------------------------------------------- @@ -579,6 +617,18 @@ void Atom::add_peratom(const char *name, void *address, nperatom++; } +/* ---------------------------------------------------------------------- + change the column count fof an existing peratom array entry + allows atom_style to specify column count as an argument + see atom_style tdpd as an example +------------------------------------------------------------------------- */ + +void Atom::add_peratom_change_columns(const char *name, int cols) +{ + for (int i = 0; i < nperatom; i++) + if (strcmp(name,peratom[i].name) == 0) peratom[i].cols = cols; +} + /* ---------------------------------------------------------------------- add info for a single per-atom array to PerAtom data struct cols = address of int variable with max columns per atom diff --git a/src/atom.h b/src/atom.h index a105b3e5b1..007d364a7b 100644 --- a/src/atom.h +++ b/src/atom.h @@ -60,6 +60,8 @@ class Atom : protected Pointers { imageint *image; double **x,**v,**f; + // charged and dipolar particles + double *rmass; double *q,**mu; @@ -69,7 +71,7 @@ class Atom : protected Pointers { double **omega,**angmom,**torque; int *ellipsoid,*line,*tri,*body; - // MOLECULE package + // molecular systems tagint *molecule; int *molindex,*molatom; @@ -101,15 +103,14 @@ class Atom : protected Pointers { // SPIN package - double **sp; - double **fm; - double **fm_long; + double **sp,**fm,**fm_long; - // USER-AWPMD and USER_EFF packages + // USER_EFF and USER-AWPMD packages int *spin; - double *eradius,*ervel,*erforce,*ervelforce; - double *cs,*csforce,*vforce; + double *eradius,*ervel,*erforce; + double *ervelforce,*cs,*csforce; + double **vforce; int *etag; // USER-DPD package @@ -261,6 +262,7 @@ class Atom : protected Pointers { void settings(class Atom *); void peratom_create(); void add_peratom(const char *, void *, int, int, int threadflag=0); + void add_peratom_change_columns(const char *, int); void add_peratom_vary(const char *, void *, int, int *, void *, int collength=0); void create_avec(const char *, int, char **, int); diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 83d29112dd..7d838b7a7f 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -57,11 +57,6 @@ class AtomVecHybrid : public AtomVec { void pack_data_pre(int); void pack_data_post(int); - //void create_atom_post(int); - //void data_atom_post(int); - //void pack_data_pre(int); - //void pack_data_post(int); - int property_atom(char *); void pack_property_atom(int, double *, int, int); diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 6796f9c8f2..81f1b02fdb 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -28,6 +28,7 @@ using namespace MathConst; AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) { + mass_type = 0; molecular = 0; atom->sphere_flag = 1; @@ -51,8 +52,6 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) fields_create = (char *) "radius rmass omega"; fields_data_atom = (char *) "id type radius rmass x"; fields_data_vel = (char *) "id v omega"; - - setup_fields(); } /* ---------------------------------------------------------------------- @@ -74,6 +73,10 @@ void AtomVecSphere::process_args(int narg, char **arg) fields_comm = (char *) "radius rmass"; fields_comm_vel = (char *) "radius rmass omega"; + + // delay setting up of fields until now + + setup_fields(); } /* ---------------------------------------------------------------------- */ From f51ee40640c98b0b238638313598591d14078d64 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 3 Dec 2019 11:24:12 -0700 Subject: [PATCH 06/42] atom_vec.cpp --- src/atom_vec.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index cfbc8b12a6..bbfccadb89 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -133,7 +133,8 @@ void AtomVec::process_args(int narg, char ** /*arg*/) } /* ---------------------------------------------------------------------- - copy of velocity remap settings from Domain + pull settings from Domain needed for pack_comm_vel and pack_border_vel + child classes may override this method, but should also invoke it ------------------------------------------------------------------------- */ void AtomVec::init() From 9af08f2d5405dd781166f239c41ae1adb4eed34e Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 6 Dec 2019 10:06:16 -0700 Subject: [PATCH 07/42] small change for atom_style mdpd --- src/USER-MESO/atom_vec_mdpd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/USER-MESO/atom_vec_mdpd.cpp b/src/USER-MESO/atom_vec_mdpd.cpp index eefda1ff6a..b87ff14c3c 100644 --- a/src/USER-MESO/atom_vec_mdpd.cpp +++ b/src/USER-MESO/atom_vec_mdpd.cpp @@ -55,6 +55,8 @@ AtomVecMDPD::AtomVecMDPD(LAMMPS *lmp) : AtomVec(lmp) void AtomVecMDPD::init() { + AtomVec::init(); + if (strcmp(update->unit_style,"lj") != 0) error->all(FLERR,"Atom style mdpd requires lj units"); } From db6d272303dfa748953c04f60b7041af00aa4ccb Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 13 Dec 2019 13:54:12 -0700 Subject: [PATCH 08/42] more additions to USER atom styles and bug fixes --- src/GRANULAR/fix_pour.cpp | 5 + src/MOLECULE/atom_vec_bond.cpp | 22 +- src/MOLECULE/atom_vec_bond.h | 4 + src/MOLECULE/atom_vec_full.cpp | 8 +- src/MOLECULE/atom_vec_molecular.cpp | 8 +- src/USER-AWPMD/atom_vec_wavepacket.cpp | 1126 +----------------------- src/USER-AWPMD/atom_vec_wavepacket.h | 75 +- src/USER-AWPMD/fix_nve_awpmd.cpp | 6 +- src/USER-DPD/atom_vec_dpd.cpp | 2 +- src/USER-EFF/atom_vec_electron.cpp | 3 - src/USER-EFF/pair_eff_cut.cpp | 27 +- src/USER-EFF/pair_eff_cut.h | 4 +- src/USER-MESO/atom_vec_edpd.cpp | 22 +- src/USER-MESO/atom_vec_tdpd.cpp | 2 +- src/USER-MESO/fix_mvv_edpd.cpp | 6 +- src/USER-SMD/atom_vec_smd.cpp | 4 +- src/atom.cpp | 4 + src/atom.h | 5 +- src/atom_vec.cpp | 24 +- src/atom_vec.h | 18 +- src/atom_vec_body.cpp | 45 +- src/atom_vec_body.h | 3 + src/atom_vec_ellipsoid.cpp | 4 +- src/atom_vec_line.cpp | 4 +- src/atom_vec_sphere.cpp | 20 +- src/atom_vec_tri.cpp | 6 +- src/fix_gravity.cpp | 21 +- src/replicate.cpp | 27 +- src/verlet.cpp | 2 +- 29 files changed, 218 insertions(+), 1289 deletions(-) diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index 2255f64eb2..b54920f7b2 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -40,6 +40,7 @@ using namespace MathConst; enum{ATOM,MOLECULE}; enum{ONE,RANGE,POLY}; +enum{CONSTANT,EQUAL}; // same as FixGravity #define EPSILON 0.001 #define SMALL 1.0e-10 @@ -318,6 +319,10 @@ void FixPour::init() if (ifix == -1) error->all(FLERR,"No fix gravity defined for fix pour"); + int varflag = ((FixGravity *) modify->fix[ifix])->varflag; + if (varflag != CONSTANT) + error->all(FLERR,"Fix gravity for fix pour must be constant"); + double xgrav = ((FixGravity *) modify->fix[ifix])->xgrav; double ygrav = ((FixGravity *) modify->fix[ifix])->ygrav; double zgrav = ((FixGravity *) modify->fix[ifix])->zgrav; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 30ad7d83e1..00e8e3260d 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -60,6 +60,20 @@ AtomVecBond::~AtomVecBond() delete [] bond_negative; } +/* ---------------------------------------------------------------------- + grow atom arrays + must set local copy of body ptr + needed in replicate when 2 atom classes exist and pack_restart() is called +------------------------------------------------------------------------- */ + +void AtomVecBond::grow(int n) +{ + AtomVec::grow(n); + num_bond = atom->num_bond; + bond_type = atom->bond_type; +} + + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -76,8 +90,8 @@ void AtomVecBond::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; + //int *num_bond = atom->num_bond; + //int **bond_type = atom->bond_type; any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { @@ -98,8 +112,8 @@ void AtomVecBond::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; + //int *num_bond = atom->num_bond; + //int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index c2bf7d6680..90c4b1f217 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -28,6 +28,7 @@ class AtomVecBond : public AtomVec { public: AtomVecBond(class LAMMPS *); ~AtomVecBond(); + void grow(int); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); @@ -37,6 +38,9 @@ class AtomVecBond : public AtomVec { int any_bond_negative; int bond_per_atom; int *bond_negative; + + int *num_bond; + int **bond_type; }; } diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index 9ab0a296e0..be7c92ce93 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -128,7 +128,7 @@ void AtomVecFull::pack_restart_pre(int ilocal) int *num_improper = atom->num_improper; int **improper_type = atom->improper_type; - int any_bond_negative = 0; + any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { bond_negative[m] = 1; @@ -137,7 +137,7 @@ void AtomVecFull::pack_restart_pre(int ilocal) } else bond_negative[m] = 0; } - int any_angle_negative = 0; + any_angle_negative = 0; for (int m = 0; m < num_angle[ilocal]; m++) { if (angle_type[ilocal][m] < 0) { angle_negative[m] = 1; @@ -146,7 +146,7 @@ void AtomVecFull::pack_restart_pre(int ilocal) } else angle_negative[m] = 0; } - int any_dihedral_negative = 0; + any_dihedral_negative = 0; for (int m = 0; m < num_dihedral[ilocal]; m++) { if (dihedral_type[ilocal][m] < 0) { dihedral_negative[m] = 1; @@ -155,7 +155,7 @@ void AtomVecFull::pack_restart_pre(int ilocal) } else dihedral_negative[m] = 0; } - int any_improper_negative = 0; + any_improper_negative = 0; for (int m = 0; m < num_improper[ilocal]; m++) { if (improper_type[ilocal][m] < 0) { improper_negative[m] = 1; diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index 52947ceb71..ea15216aee 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -128,7 +128,7 @@ void AtomVecMolecular::pack_restart_pre(int ilocal) int *num_improper = atom->num_improper; int **improper_type = atom->improper_type; - int any_bond_negative = 0; + any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { bond_negative[m] = 1; @@ -137,7 +137,7 @@ void AtomVecMolecular::pack_restart_pre(int ilocal) } else bond_negative[m] = 0; } - int any_angle_negative = 0; + any_angle_negative = 0; for (int m = 0; m < num_angle[ilocal]; m++) { if (angle_type[ilocal][m] < 0) { angle_negative[m] = 1; @@ -146,7 +146,7 @@ void AtomVecMolecular::pack_restart_pre(int ilocal) } else angle_negative[m] = 0; } - int any_dihedral_negative = 0; + any_dihedral_negative = 0; for (int m = 0; m < num_dihedral[ilocal]; m++) { if (dihedral_type[ilocal][m] < 0) { dihedral_negative[m] = 1; @@ -155,7 +155,7 @@ void AtomVecMolecular::pack_restart_pre(int ilocal) } else dihedral_negative[m] = 0; } - int any_improper_negative = 0; + any_improper_negative = 0; for (int m = 0; m < num_improper[ilocal]; m++) { if (improper_type[ilocal][m] < 0) { improper_negative[m] = 1; diff --git a/src/USER-AWPMD/atom_vec_wavepacket.cpp b/src/USER-AWPMD/atom_vec_wavepacket.cpp index bce334a7b3..d643ae8e0a 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.cpp +++ b/src/USER-AWPMD/atom_vec_wavepacket.cpp @@ -18,13 +18,7 @@ #include "atom_vec_wavepacket.h" #include #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; @@ -32,1079 +26,69 @@ using namespace LAMMPS_NS; AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) { - comm_x_only = comm_f_only = 0; - mass_type = 1; molecular = 0; forceclearflag = 1; - size_forward = 4; // coords[3]+radius[1] - size_reverse = 10; // force[3]+erforce[1]+ervelforce[1]+vforce[3]+csforce[2] - size_border = 10; // coords[3]+tag[1]+type[1]+mask[1]+q[1]+spin[1]+eradius[1]+etag[1] - size_velocity = 6; // +velocities[3]+ ervel[1]+cs[2] - size_data_atom = 11; // for input file: 1-tag 2-type 3-q 4-spin 5-eradius 6-etag 7-cs_re 8-cs_im 9-x 10-y 11-z - size_data_vel = 5; // for input file: vx vy vz ervel - xcol_data = 9; // starting column for x data - atom->wavepacket_flag = 1; - atom->electron_flag = 1; // compatible with eff + + atom->electron_flag = 1; // compatible with eff atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->ervel_flag = atom->erforce_flag = 1; + atom->cs_flag = atom->csforce_flag = + atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1; - atom->cs_flag = atom->csforce_flag = atom->vforce_flag = atom->ervelforce_flag = atom->etag_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 a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = (char *) + "q spin eradius ervel erforce cs csforce " + "vforce ervelforce etag"; + fields_copy = (char *) "q spin eradius ervel cs etag"; + fields_comm = (char *) "eradius"; + fields_comm_vel = (char *) "eradius ervel cs"; + fields_reverse = (char *) "erforce ervelforce vforce csforce"; + fields_border = (char *) "q spin eradius etag"; + fields_border_vel = (char *) "q spin eradius etag ervel cs"; + fields_exchange = (char *) "q spin eradius ervel etag cs"; + fields_restart = (char *) "q spin eradius ervel etag cs"; + fields_create = (char *) "q spin eradius ervel etag cs"; + fields_data_atom = (char *) "id type q spin eradius etag cs x"; + fields_data_vel = (char *) "id v ervel"; + + setup_fields(); } /* ---------------------------------------------------------------------- - grow atom-electron arrays - n = 0 grows arrays by a chunk - n > 0 allocates arrays to size n + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector ------------------------------------------------------------------------- */ -void AtomVecWavepacket::grow(int n) -{ - if (n == 0) grow_nmax(); - else nmax = n; - atom->nmax = nmax; - - 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"); - - cs = memory->grow(atom->cs,2*nmax,"atom:cs"); - csforce = memory->grow(atom->csforce,2*nmax,"atom:csforce"); - vforce = memory->grow(atom->vforce,3*nmax,"atom:vforce"); - ervelforce = memory->grow(atom->ervelforce,nmax,"atom:ervelforce"); - etag = memory->grow(atom->etag,nmax,"atom:etag"); - - 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 AtomVecWavepacket::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; - - cs = atom->cs; - csforce = atom->csforce; - vforce = atom->vforce; - ervelforce = atom->ervelforce; - etag = atom->etag; -} - -/* ---------------------------------------------------------------------- - copy atom I info to atom J -------------------------------------------------------------------------- */ - -void AtomVecWavepacket::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]; - - cs[2*j] = cs[2*i]; - cs[2*j+1] = cs[2*i+1]; - etag[j] = etag[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); -} - -/* ---------------------------------------------------------------------- */ - void AtomVecWavepacket::force_clear(int n, size_t nbytes) { - memset(&erforce[n],0,nbytes); -} - -/* ---------------------------------------------------------------------- */ -// this will be used as partial pack for unsplit Hartree packets (v, ervel not regarded as separate variables) - -int AtomVecWavepacket::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; -} - -/* ---------------------------------------------------------------------- */ -// this is a complete pack of all 'position' variables of AWPMD - -int AtomVecWavepacket::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]; - - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - } 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]; - - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - } 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]; - } - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - } - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecWavepacket::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]; - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecWavepacket::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 AtomVecWavepacket::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++]; - - ervel[i] = buf[m++]; - cs[2*i] = buf[m++]; - cs[2*i+1] = buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecWavepacket::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++]; - ervel[i] = buf[m++]; - cs[2*i] = buf[m++]; - cs[2*i+1] = buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecWavepacket::pack_reverse(int n, int first, double *buf) -{ - int i,m,last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { //10 - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = erforce[i]; - - buf[m++] = ervelforce[i]; - buf[m++] = vforce[3*i]; - buf[m++] = vforce[3*i+1]; - buf[m++] = vforce[3*i+2]; - buf[m++] = csforce[2*i]; - buf[m++] = csforce[2*i+1]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecWavepacket::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]; - - buf[m++] = ervelforce[i]; - buf[m++] = vforce[3*i]; - buf[m++] = vforce[3*i+1]; - buf[m++] = vforce[3*i+2]; - buf[m++] = csforce[2*i]; - buf[m++] = csforce[2*i+1]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecWavepacket::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++]; - - ervelforce[j] += buf[m++]; - vforce[3*j] += buf[m++]; - vforce[3*j+1] += buf[m++]; - vforce[3*j+2] += buf[m++]; - csforce[2*j] += buf[m++]; - csforce[2*j+1] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -int AtomVecWavepacket::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++]; - - ervelforce[j] += buf[m++]; - vforce[3*j] += buf[m++]; - vforce[3*j+1] += buf[m++]; - vforce[3*j+2] += buf[m++]; - csforce[2*j] += buf[m++]; - csforce[2*j+1] += buf[m++]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ -// will be used for Hartree unsplit version (the etag is added however) -int AtomVecWavepacket::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]; - buf[m++] = ubuf(etag[j]).d; - } - } 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]; - buf[m++] = ubuf(etag[j]).d; - } - } - - 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 AtomVecWavepacket::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++] = ubuf(etag[j]).d; - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - } 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++] = ubuf(etag[j]).d; - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - - - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - } 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]; - buf[m++] = ubuf(etag[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++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - } - } - - 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 AtomVecWavepacket::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]; - - buf[m++] = ubuf(etag[j]).d; - buf[m++] = ervel[j]; - buf[m++] = cs[2*j]; - buf[m++] = cs[2*j+1]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecWavepacket::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++]; - etag[i] = (int) ubuf(buf[m++]).i; - } - - 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 AtomVecWavepacket::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++]; - etag[i] = (int) ubuf(buf[m++]).i; - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; - ervel[i] = buf[m++]; - cs[2*i] = buf[m++]; - cs[2*i+1] = 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 AtomVecWavepacket::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++]; - etag[i] = (int) ubuf(buf[m++]).i; - ervel[i] = buf[m++]; - cs[2*i] = buf[m++]; - cs[2*i+1] = buf[m++]; - } - return m; + memset(&atom->erforce[n],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 + make each atom a proton ------------------------------------------------------------------------- */ -int AtomVecWavepacket::pack_exchange(int i, double *buf) +void AtomVecWavepacket::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]; - - buf[m++] = ubuf(etag[i]).d; - buf[m++] = cs[2*i]; - buf[m++] = cs[2*i+1]; - - 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 AtomVecWavepacket::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++]; - - etag[nlocal] = (int) ubuf(buf[m++]).i; - cs[2*nlocal] = buf[m++]; - cs[2*nlocal+1] = 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->q[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 AtomVecWavepacket::size_restart() +void AtomVecWavepacket::data_atom_post(int ilocal) { - int i; - - int nlocal = atom->nlocal; - int n = 18 * 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 AtomVecWavepacket::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]; - - buf[m++] = ubuf(etag[i]).d; - buf[m++] = cs[2*i]; - buf[m++] = cs[2*i+1]; - - 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 AtomVecWavepacket::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++]; - - etag[nlocal] = (int) ubuf(buf[m++]).i; - cs[2*nlocal] = buf[m++]; - cs[2*nlocal+1] = 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 - AWPMD: creates a proton -------------------------------------------------------------------------- */ - -void AtomVecWavepacket::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] = 1.; - spin[nlocal] = 0; - eradius[nlocal] = 0.0; - ervel[nlocal] = 0.0; - - etag[nlocal] = 0; - cs[2*nlocal] = 0.; - cs[2*nlocal+1] = 0.; - - atom->nlocal++; -} - -/* ---------------------------------------------------------------------- - unpack one line from Atoms section of data file - initialize other atom quantities - AWPMD: 0-tag 1-type 2-q 3-spin 4-eradius 5-etag 6-cs_re 7-cs_im -------------------------------------------------------------------------- */ - -void AtomVecWavepacket::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); - eradius[nlocal] = utils::numeric(FLERR,values[4],true,lmp); - if (eradius[nlocal] < 0.0) - error->one(FLERR,"Invalid eradius in Atoms section of data file"); - - etag[nlocal] = utils::inumeric(FLERR,values[5],true,lmp); - cs[2*nlocal] = utils::numeric(FLERR,values[6],true,lmp); - cs[2*nlocal+1] = utils::numeric(FLERR,values[7],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 AtomVecWavepacket::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"); - - etag[nlocal] = utils::inumeric(FLERR,values[3],true,lmp); - cs[2*nlocal] = utils::inumeric(FLERR,values[4],true,lmp); - cs[2*nlocal+1] = utils::numeric(FLERR,values[5],true,lmp); - - 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 AtomVecWavepacket::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 AtomVecWavepacket::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 AtomVecWavepacket::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] = ubuf(etag[i]).d; - buf[i][6] = cs[2*i]; - buf[i][7] = cs[2*i+1]; - buf[i][8] = x[i][0]; - buf[i][9] = x[i][1]; - buf[i][10] = x[i][2]; - buf[i][11] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][12] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][13] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } -} - -/* ---------------------------------------------------------------------- - pack hybrid atom info for data file -------------------------------------------------------------------------- */ - -int AtomVecWavepacket::pack_data_hybrid(int i, double *buf) -{ - buf[0] = q[i]; - buf[1] = ubuf(spin[i]).d; - buf[2] = eradius[i]; - buf[3] = ubuf(etag[i]).d; - buf[4] = cs[2*i]; - buf[5] = cs[2*i+1]; - return 6; -} - -/* ---------------------------------------------------------------------- - write atom info to data file including 3 image flags -------------------------------------------------------------------------- */ - -void AtomVecWavepacket::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 %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],(int) ubuf(buf[i][3]).i,buf[i][4], - (int) ubuf(buf[i][5]).i,buf[i][6],buf[i][8], - buf[i][8],buf[i][9],buf[i][10], - (int) ubuf(buf[i][11]).i,(int) ubuf(buf[i][12]).i, - (int) ubuf(buf[i][13]).i); -} - -/* ---------------------------------------------------------------------- - write hybrid atom info to data file -------------------------------------------------------------------------- */ - -int AtomVecWavepacket::write_data_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e %d %-1.16e %d %-1.16e %-1.16e", - buf[0],(int) ubuf(buf[1]).i,buf[2],(int) ubuf(buf[3]).i, - buf[4],buf[5]); - return 6; -} - -/* ---------------------------------------------------------------------- - pack velocity info for data file -------------------------------------------------------------------------- */ - -void AtomVecWavepacket::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 hybrid velocity info for data file -------------------------------------------------------------------------- */ - -int AtomVecWavepacket::pack_vel_hybrid(int i, double *buf) -{ - buf[0] = ervel[i]; - return 1; -} - -/* ---------------------------------------------------------------------- - write velocity info to data file -------------------------------------------------------------------------- */ - -void AtomVecWavepacket::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 AtomVecWavepacket::write_vel_hybrid(FILE *fp, double *buf) -{ - fprintf(fp," %-1.16e",buf[0]); - return 1; + atom->ervel[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -1131,27 +115,31 @@ void AtomVecWavepacket::pack_property_atom(int index, double *buf, { int *mask = atom->mask; int nlocal = atom->nlocal; - int n = 0; + 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; @@ -1159,35 +147,3 @@ void AtomVecWavepacket::pack_property_atom(int index, double *buf, } } } - -/* ---------------------------------------------------------------------- - return # of bytes of allocated memory -------------------------------------------------------------------------- */ - -bigint AtomVecWavepacket::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); - - if (atom->memcheck("ervelforce")) bytes += memory->usage(ervelforce,nmax); - if (atom->memcheck("cs")) bytes += memory->usage(cs,2*nmax); - if (atom->memcheck("csforce")) bytes += memory->usage(csforce,2*nmax); - if (atom->memcheck("vforce")) bytes += memory->usage(vforce,3*nmax); - if (atom->memcheck("etag")) bytes += memory->usage(etag,nmax); - - return bytes; -} diff --git a/src/USER-AWPMD/atom_vec_wavepacket.h b/src/USER-AWPMD/atom_vec_wavepacket.h index d1a0c7c7f2..e7db15db14 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.h +++ b/src/USER-AWPMD/atom_vec_wavepacket.h @@ -11,11 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Ilya Valuev (JIHT RAS) -------------------------------------------------------------------------- */ - - #ifdef ATOM_CLASS AtomStyle(wavepacket,AtomVecWavepacket) @@ -32,77 +27,11 @@ namespace LAMMPS_NS { class AtomVecWavepacket : public AtomVec { public: AtomVecWavepacket(class LAMMPS *); - ~AtomVecWavepacket() {} - 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; - - ///\en spin: -1 or 1 for electron, 0 for ion (compatible with eff) - int *spin; - ///\en charge: must be specified in the corresponding units (-1 for electron in real units, eff compatible) - double *q; - ///\en width of the wavepacket (compatible with eff) - double *eradius; - ///\en width velocity for the wavepacket (compatible with eff) - double *ervel; - ///\en (generalized) force on width (compatible with eff) - double *erforce; - - // AWPMD- specific: - ///\en electron tag: must be the same for the WPs belonging to the same electron - int *etag; - ///\en wavepacket split coefficients: cre, cim, size is 2*N - double *cs; - ///\en force on wavepacket split coefficients: re, im, size is 2*N - double *csforce; - ///\en (generalized) force on velocity, size is 3*N - double *vforce; - ///\en (generalized) force on radius velocity, size is N - double *ervelforce; }; } diff --git a/src/USER-AWPMD/fix_nve_awpmd.cpp b/src/USER-AWPMD/fix_nve_awpmd.cpp index b4a1cbf72a..2aa2e7680b 100644 --- a/src/USER-AWPMD/fix_nve_awpmd.cpp +++ b/src/USER-AWPMD/fix_nve_awpmd.cpp @@ -74,8 +74,6 @@ void FixNVEAwpmd::init() void FixNVEAwpmd::initial_integrate(int /* vflag */) { - - // update v,vr and x,radius of atoms in group double **x = atom->x; @@ -84,7 +82,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */) double *ervel = atom->ervel; double **f = atom->f; double *erforce = atom->erforce; - double *vforce=atom->vforce; + double **vforce=atom->vforce; double *ervelforce=atom->ervelforce; double *mass = atom->mass; @@ -101,7 +99,7 @@ void FixNVEAwpmd::initial_integrate(int /* vflag */) double dtfm = dtf / mass[type[i]]; double dtfmr=dtfm; for(int j=0;j<3;j++){ - x[i][j] += dtv*vforce[3*i+j]; + x[i][j] += dtv*vforce[i][j]; v[i][j] += dtfm*f[i][j]; } eradius[i]+= dtv*ervelforce[i]; diff --git a/src/USER-DPD/atom_vec_dpd.cpp b/src/USER-DPD/atom_vec_dpd.cpp index ce35178d8d..124a081191 100644 --- a/src/USER-DPD/atom_vec_dpd.cpp +++ b/src/USER-DPD/atom_vec_dpd.cpp @@ -47,7 +47,7 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp) 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 *) "id v omega"; + fields_data_vel = (char *) "id v"; setup_fields(); } diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index 3688f7f582..0ac56c48a3 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -44,8 +44,6 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) molecular = 0; forceclearflag = 1; - atom->ecp_flag = 0; - atom->electron_flag = 1; atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->ervel_flag = atom->erforce_flag = 1; @@ -99,7 +97,6 @@ void AtomVecElectron::create_atom_post(int ilocal) void AtomVecElectron::data_atom_post(int ilocal) { atom->ervel[ilocal] = 0.0; - if (atom->spin[ilocal] == 3) atom->ecp_flag = 1; } /* ---------------------------------------------------------------------- diff --git a/src/USER-EFF/pair_eff_cut.cpp b/src/USER-EFF/pair_eff_cut.cpp index e7aed14030..f9333f4bec 100644 --- a/src/USER-EFF/pair_eff_cut.cpp +++ b/src/USER-EFF/pair_eff_cut.cpp @@ -801,7 +801,7 @@ void PairEffCut::settings(int narg, char **arg) int atype; int iarg = 1; - int ecp_found = 0; + ecp_found = 0; while (iarg < narg) { if (strcmp(arg[iarg],"limit/eradius") == 0) { @@ -821,17 +821,15 @@ void PairEffCut::settings(int narg, char **arg) else if (strcmp(arg[iarg+1],"O") == 0) ecp_type[atype] = 8; else if (strcmp(arg[iarg+1],"Al") == 0) ecp_type[atype] = 13; else if (strcmp(arg[iarg+1],"Si") == 0) ecp_type[atype] = 14; - else error->all(FLERR, "Note: there are no default parameters for this atom ECP\n"); + else error->all(FLERR, "No default parameters for this atom ECP\n"); iarg += 2; ecp_found = 1; } - } + } else error->all(FLERR,"Illegal pair style command"); } - if (!ecp_found && atom->ecp_flag) - error->all(FLERR,"Need to specify ECP type on pair_style command"); - // Need to introduce 2 new constants w/out changing update.cpp + if (force->qqr2e==332.06371) { // i.e. Real units chosen h2e = 627.509; // hartree->kcal/mol hhmss2e = 175.72044219620075; // hartree->kcal/mol * (Bohr->Angstrom)^2 @@ -872,9 +870,24 @@ void PairEffCut::init_style() if (update->whichflag == 1) { if (force->qqr2e == 332.06371 && update->dt == 1.0) - error->all(FLERR,"You must lower the default real units timestep for pEFF "); + error->all(FLERR,"Must lower the default real units timestep for pEFF "); } + // check if any atom's spin = 3 and ECP type was not set + + int *spin = atom->spin; + int nlocal = atom->nlocal; + + int flag = 0; + for (int i = 0; i < nlocal; i++) + if (spin[i] == 3) flag = 1; + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + + if (flagall && !ecp_found) + error->all(FLERR,"Need to specify ECP type on pair_style command"); + // need a half neigh list and optionally a granular history neigh list neighbor->request(this,instance_me); diff --git a/src/USER-EFF/pair_eff_cut.h b/src/USER-EFF/pair_eff_cut.h index 63dabe5db8..bd04344373 100644 --- a/src/USER-EFF/pair_eff_cut.h +++ b/src/USER-EFF/pair_eff_cut.h @@ -46,10 +46,12 @@ class PairEffCut : public Pair { private: int limit_eradius_flag, pressure_with_evirials_flag; + int ecp_found; double cut_global; double **cut; int ecp_type[100]; - double PAULI_CORE_A[100], PAULI_CORE_B[100], PAULI_CORE_C[100], PAULI_CORE_D[100], PAULI_CORE_E[100]; + double PAULI_CORE_A[100],PAULI_CORE_B[100],PAULI_CORE_C[100]; + double PAULI_CORE_D[100],PAULI_CORE_E[100]; double hhmss2e, h2e; int nmax; diff --git a/src/USER-MESO/atom_vec_edpd.cpp b/src/USER-MESO/atom_vec_edpd.cpp index 7a031c256b..e06ac633ec 100644 --- a/src/USER-MESO/atom_vec_edpd.cpp +++ b/src/USER-MESO/atom_vec_edpd.cpp @@ -41,16 +41,16 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - 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_grow = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp"; + fields_copy = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp"; + fields_comm = (char *) "edpd_temp vest vest_temp"; + fields_comm_vel = (char *) "edpd_temp vest vest_temp"; 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_border = (char *) "edpd_cv edpd_temp vest vest_temp"; + fields_border_vel = (char *) "edpd_cv edpd_temp vest vest_temp"; + fields_exchange = (char *) "edpd_cv edpd_temp vest vest_temp"; + fields_restart = (char * ) "edpd_cv edpd_temp vest vest_temp"; + fields_create = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp"; fields_data_atom = (char *) "id type edpd_temp edpd_cv x"; fields_data_vel = (char *) "id v"; @@ -85,7 +85,7 @@ void AtomVecEDPD::create_atom_post(int ilocal) { atom->edpd_temp[ilocal] = 1.0; atom->edpd_cv[ilocal]= 1.0e5; - atom->vest[ilocal][3] = atom->edpd_temp[ilocal]; + atom->vest_temp[ilocal] = atom->edpd_temp[ilocal]; } /* ---------------------------------------------------------------------- @@ -99,5 +99,5 @@ void AtomVecEDPD::data_atom_post(int ilocal) 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]; + atom->vest_temp[ilocal] = atom->edpd_temp[ilocal]; } diff --git a/src/USER-MESO/atom_vec_tdpd.cpp b/src/USER-MESO/atom_vec_tdpd.cpp index 55284f69a2..5734fcf9ad 100644 --- a/src/USER-MESO/atom_vec_tdpd.cpp +++ b/src/USER-MESO/atom_vec_tdpd.cpp @@ -63,7 +63,7 @@ void AtomVecTDPD::process_args(int narg, char **arg) cc_species = atom->cc_species; atom->add_peratom_change_columns("cc",cc_species); - atom->add_peratom_change_columns("cc_species",cc_species); + atom->add_peratom_change_columns("cc_flux",cc_species); // delay setting up of fields until now diff --git a/src/USER-MESO/fix_mvv_edpd.cpp b/src/USER-MESO/fix_mvv_edpd.cpp index bd9cd9cc2a..3294d8d682 100644 --- a/src/USER-MESO/fix_mvv_edpd.cpp +++ b/src/USER-MESO/fix_mvv_edpd.cpp @@ -88,6 +88,7 @@ void FixMvvEDPD::initial_integrate(int /*vflag*/) double *edpd_flux = atom->edpd_flux; double *edpd_cv = atom->edpd_cv; double **vest = atom->vest; + double *vest_temp = atom->vest_temp; double *rmass = atom->rmass; double *mass = atom->mass; int *type = atom->type; @@ -105,7 +106,7 @@ void FixMvvEDPD::initial_integrate(int /*vflag*/) vest[i][0] = v[i][0] + dtfm * f[i][0]; vest[i][1] = v[i][1] + dtfm * f[i][1]; vest[i][2] = v[i][2] + dtfm * f[i][2]; - vest[i][3] = edpd_temp[i] + dtT * edpd_flux[i]; + vest_temp[i] = edpd_temp[i] + dtT * edpd_flux[i]; x[i][0] += dtv * vest[i][0]; x[i][1] += dtv * vest[i][1]; @@ -131,6 +132,7 @@ void FixMvvEDPD::final_integrate() double *edpd_flux = atom->edpd_flux; double *edpd_cv = atom->edpd_cv; double **vest = atom->vest; + double *vest_temp = atom->vest_temp; double *rmass = atom->rmass; double *mass = atom->mass; int *type = atom->type; @@ -148,7 +150,7 @@ void FixMvvEDPD::final_integrate() v[i][0] = vest[i][0] + dtfm * f[i][0]; v[i][1] = vest[i][1] + dtfm * f[i][1]; v[i][2] = vest[i][2] + dtfm * f[i][2]; - edpd_temp[i] = vest[i][3] + dtT * edpd_flux[i]; + edpd_temp[i] = vest_temp[i] + dtT * edpd_flux[i]; } } diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 0fada3dc2a..9f0ed04a09 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -63,7 +63,7 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) fields_grow = (char *) "de vfrac rmass x0 radius contact_radius molecule " - "smd_data_9 e vest tlsph_stress " + "smd_data_9 e vest smd_stress " "eff_plastic_strain eff_plastic_strain_rate damage"; fields_copy = (char *) "vfrac rmass x0 radius contact_radius molecule e " @@ -91,7 +91,7 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage"; fields_data_atom = (char *) "id type molecule vfrac rmass radius contact_radius x"; - fields_data_vel = (char *) "id v vest"; + fields_data_vel = (char *) "id v"; // set these array sizes based on defines diff --git a/src/atom.cpp b/src/atom.cpp index 8fd859478f..0fbee8f583 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -566,6 +566,7 @@ void Atom::peratom_create() add_peratom("edpd_cv",&edpd_cv,DOUBLE,0); add_peratom("edpd_temp",&edpd_temp,DOUBLE,0); + add_peratom("vest_temp",&vest_temp,DOUBLE,0); add_peratom("edpd_flux",&edpd_flux,DOUBLE,0,1); // set per-thread flag add_peratom("cc",&cc,DOUBLE,1); add_peratom("cc_flux",&cc_flux,DOUBLE,1,1); // set per-thread flag @@ -625,8 +626,11 @@ void Atom::add_peratom(const char *name, void *address, void Atom::add_peratom_change_columns(const char *name, int cols) { + int i; for (int i = 0; i < nperatom; i++) if (strcmp(name,peratom[i].name) == 0) peratom[i].cols = cols; + if (i == nperatom) + error->all(FLERR,"Could not find name of peratom array for column change"); } /* ---------------------------------------------------------------------- diff --git a/src/atom.h b/src/atom.h index 007d364a7b..bc1eb1a7d7 100644 --- a/src/atom.h +++ b/src/atom.h @@ -124,6 +124,7 @@ class Atom : protected Pointers { double **cc,**cc_flux; // cc = chemical concentration double *edpd_temp,*edpd_flux; // temperature and heat flux + double *vest_temp; double *edpd_cv; // heat capacity int cc_species; @@ -162,10 +163,6 @@ class Atom : protected Pointers { int sp_flag; - // USER-EFF package - - int ecp_flag; - // USER-SMD package int smd_flag; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index bbfccadb89..e31c235760 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -45,6 +45,7 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) forceclearflag = 0; maxexchange = 0; bonus_flag = 0; + size_forward_bonus = size_border_bonus = 0; kokkosable = 0; @@ -176,7 +177,7 @@ int AtomVec::grow_nmax_bonus(int nmax_bonus) void AtomVec::grow(int n) { - int i,datatype,cols,maxcols; + int datatype,cols,maxcols; void *pdata,*plength; if (n == 0) grow_nmax(); @@ -193,7 +194,7 @@ void AtomVec::grow(int n) v = memory->grow(atom->v,nmax,3,"atom:v"); f = memory->grow(atom->f,nmax*nthreads,3,"atom:f"); - for (i = 0; i < ngrow; i++) { + for (int i = 0; i < ngrow; i++) { pdata = mgrow.pdata[i]; datatype = mgrow.datatype[i]; cols = mgrow.cols[i]; @@ -415,7 +416,7 @@ int AtomVec::pack_comm(int n, int *list, double *buf, /* ---------------------------------------------------------------------- */ int AtomVec::pack_comm_vel(int n, int *list, double *buf, - int pbc_flag, int *pbc) + int pbc_flag, int *pbc) { int i,j,m,mm,nn,datatype,cols; double dx,dy,dz,dvx,dvy,dvz; @@ -1375,15 +1376,15 @@ int AtomVec::size_restart() if (nrestart) { for (nn = 0; nn < nrestart; nn++) { - cols = mrestart.cols[i]; + cols = mrestart.cols[nn]; if (cols == 0) n += nlocal; else if (cols > 0) n += cols*nlocal; else { collength = mrestart.collength[nn]; plength = mrestart.plength[nn]; for (i = 0; i < nlocal; i++) { - if (collength) ncols = (*((int ***) plength))[nlocal][collength-1]; - else ncols = (*((int **) plength))[nlocal]; + if (collength) ncols = (*((int ***) plength))[i][collength-1]; + else ncols = (*((int **) plength))[i]; n += ncols; } } @@ -1435,7 +1436,7 @@ int AtomVec::pack_restart(int i, double *buf) if (cols == 0) { double *vec = *((double **) pdata); buf[m++] = vec[i]; - } else if (ncols > 0) { + } else if (cols > 0) { double **array = *((double ***) pdata); for (mm = 0; mm < cols; mm++) buf[m++] = array[i][mm]; @@ -1469,7 +1470,7 @@ int AtomVec::pack_restart(int i, double *buf) if (cols == 0) { bigint *vec = *((bigint **) pdata); buf[m++] = ubuf(vec[i]).d; - } else if (ncols > 0) { + } else if (cols > 0) { bigint **array = *((bigint ***) pdata); for (mm = 0; mm < cols; mm++) buf[m++] = ubuf(array[i][mm]).d; @@ -1705,7 +1706,7 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, char **values) vec[nlocal] = utils::numeric(FLERR,values[ivalue++],true,lmp); } else { double **array = *((double ***) pdata); - if (array == atom->x) { // already set by coord arg + if (array == atom->x) { // x was already set by coord arg ivalue += cols; continue; } @@ -1878,9 +1879,9 @@ void AtomVec::data_vel(int ilocal, char **values) v[ilocal][1] = utils::numeric(FLERR,values[1],true,lmp); v[ilocal][2] = utils::numeric(FLERR,values[2],true,lmp); - if (ndata_vel) { + if (ndata_vel > 2) { int ivalue = 3; - for (n = 0; n < ndata_vel; n++) { + for (n = 2; n < ndata_vel; n++) { pdata = mdata_vel.pdata[n]; datatype = mdata_vel.datatype[n]; cols = mdata_vel.cols[n]; @@ -2434,6 +2435,7 @@ void AtomVec::setup_fields() else size_data_atom += cols; } + size_data_vel = 0; for (n = 0; n < ndata_vel; n++) { cols = mdata_vel.cols[n]; diff --git a/src/atom_vec.h b/src/atom_vec.h index 69ea1d51ab..5911c8414b 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -74,7 +74,7 @@ class AtomVec : protected Pointers { virtual void force_clear(int, size_t) {} - void grow(int); + virtual void grow(int); void copy(int, int, int); virtual void copy_bonus(int, int, int) {} @@ -122,13 +122,11 @@ class AtomVec : protected Pointers { void data_atom(double *, imageint, char **); virtual void data_atom_post(int) {} - - void data_atom_bonus(int, char **) {} - void data_body(int, int, int, int *, double *) {} + virtual void data_atom_bonus(int, char **) {} + virtual void data_body(int, int, int, int *, double *) {} void pack_data(double **); void write_data(FILE *, int, double **); - virtual void pack_data_pre(int) {} virtual void pack_data_post(int) {} @@ -145,19 +143,19 @@ class AtomVec : protected Pointers { int pack_improper(tagint **); void write_improper(FILE *, int, tagint **, int); - int property_atom(char *) {return -1;} - void pack_property_atom(int, double *, int, int) {} + virtual int property_atom(char *) {return -1;} + virtual void pack_property_atom(int, double *, int, int) {} bigint memory_usage(); virtual bigint memory_usage_bonus() {} protected: - int nmax; // local copy of atom->nmax - int deform_vremap; // local copy of domain properties + int nmax; // local copy of atom->nmax + int deform_vremap; // local copy of domain properties int deform_groupbit; double *h_rate; - tagint *tag; // peratom fields common to all styles + tagint *tag; // peratom fields common to all styles int *type,*mask; imageint *image; double **x,**v,**f; diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 19ac69cef3..a04f23a47c 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -40,8 +40,8 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) // size_data_bonus is not used by Atom class for body style size_forward_bonus = 4; - size_border_bonus = 9; - size_restart_bonus_one = 9; + size_border_bonus = 10; + size_restart_bonus_one = 10; size_data_bonus = 0; atom->body_flag = 1; @@ -72,11 +72,9 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) 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_create = (char *) "radius rmass angmom body"; fields_data_atom = (char *) "id type body rmass x"; fields_data_vel = (char *) "id v angmom"; - - setup_fields(); } /* ---------------------------------------------------------------------- */ @@ -127,6 +125,20 @@ void AtomVecBody::process_args(int narg, char **arg) size_forward_bonus += bptr->size_forward; size_border_bonus += bptr->size_border; + + setup_fields(); +} + +/* ---------------------------------------------------------------------- + grow atom arrays + must set local copy of body ptr + needed in replicate when 2 atom classes exist and pack_restart() is called +------------------------------------------------------------------------- */ + +void AtomVecBody::grow(int n) +{ + AtomVec::grow(n); + body = atom->body; } /* ---------------------------------------------------------------------- @@ -150,8 +162,6 @@ void AtomVecBody::grow_bonus() void AtomVecBody::copy_bonus(int i, int j, int delflag) { - int *body = atom->body; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && body[j] >= 0) { @@ -206,8 +216,6 @@ 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]; @@ -231,8 +239,6 @@ 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++) { @@ -254,8 +260,6 @@ 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]; @@ -287,8 +291,6 @@ 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++) { @@ -330,8 +332,6 @@ int AtomVecBody::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *body = atom->body; - if (body[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -363,8 +363,6 @@ int AtomVecBody::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *body = atom->body; - body[ilocal] = (int) ubuf(buf[m++]).i; if (body[ilocal] == 0) body[ilocal] = -1; else { @@ -408,8 +406,6 @@ int AtomVecBody::size_restart_bonus() { int i; - int *body = atom->body; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -418,8 +414,7 @@ int AtomVecBody::size_restart_bonus() if (intdoubleratio == 1) n += bonus[body[i]].ninteger; else n += (bonus[body[i]].ninteger+1)/2; n += bonus[body[i]].ndouble; - } - n++; + } else n++; } return n; @@ -435,8 +430,6 @@ int AtomVecBody::pack_restart_bonus(int i, double *buf) { int m = 0; - int *body = atom->body; - if (body[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -470,8 +463,6 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *body = atom->body; - body[ilocal] = (int) ubuf(buf[m++]).i; if (body[ilocal] == 0) body[ilocal] = -1; else { diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 939b01878d..3f32c8223c 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -43,6 +43,7 @@ class AtomVecBody : public AtomVec { ~AtomVecBody(); void process_args(int, char **); + void grow(int); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -74,6 +75,8 @@ class AtomVecBody : public AtomVec { int intdoubleratio; // sizeof(double) / sizeof(int) int body_flag; + int *body; + MyPoolChunk *icp; MyPoolChunk *dcp; diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 9166293384..e8ab6d5613 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -38,7 +38,7 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp) size_forward_bonus = 4; size_border_bonus = 8; - size_restart_bonus_one = 7; + size_restart_bonus_one = 8; size_data_bonus = 8; atom->ellipsoid_flag = 1; @@ -320,7 +320,7 @@ int AtomVecEllipsoid::size_restart_bonus() int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { if (ellipsoid[i] >= 0) n += size_restart_bonus_one; - n++; + else n++; } return n; diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index ded2f88c2f..7ab697b349 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -37,7 +37,7 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) size_forward_bonus = 1; size_border_bonus = 3; - size_restart_bonus_one = 2; + size_restart_bonus_one = 3; size_data_bonus = 5; atom->line_flag = 1; @@ -286,7 +286,7 @@ int AtomVecLine::size_restart_bonus() int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { if (line[i] >= 0) n += size_restart_bonus_one; - n++; + else n++; } return n; diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 81f1b02fdb..b601fc8f7c 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -61,18 +61,22 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSphere::process_args(int narg, char **arg) { - if (narg == 0) return; - if (narg != 1) error->all(FLERR,"Illegal atom_style sphere command"); - - radvary = utils::numeric(FLERR,arg[0],true,lmp); - if (radvary < 0 || radvary > 1) + if (narg != 0 && narg != 1) error->all(FLERR,"Illegal atom_style sphere command"); - if (radvary == 0) return; + + radvary = 0; + if (narg == 1) { + radvary = utils::numeric(FLERR,arg[0],true,lmp); + if (radvary < 0 || radvary > 1) + error->all(FLERR,"Illegal atom_style sphere command"); + } // dynamic particle radius and mass must be communicated every step - fields_comm = (char *) "radius rmass"; - fields_comm_vel = (char *) "radius rmass omega"; + if (radvary) { + fields_comm = (char *) "radius rmass"; + fields_comm_vel = (char *) "radius rmass omega"; + } // delay setting up of fields until now diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 32d75c16f3..7345646a1e 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -38,7 +38,7 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) size_forward_bonus = 4; size_border_bonus = 17; - size_restart_bonus_one = 16; + size_restart_bonus_one = 17; size_data_bonus = 10; atom->tri_flag = 1; @@ -64,7 +64,7 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) 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_create = (char *) "molecule radius rmass omega angmom tri"; fields_data_atom = (char *) "id molecule type tri rmass x"; fields_data_vel = (char *) "id v omega angmom"; @@ -381,7 +381,7 @@ int AtomVecTri::size_restart_bonus() int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { if (tri[i] >= 0) n += size_restart_bonus_one; - n++; + else n++; } return n; diff --git a/src/fix_gravity.cpp b/src/fix_gravity.cpp index 14ba913c01..e00bbb4e17 100644 --- a/src/fix_gravity.cpp +++ b/src/fix_gravity.cpp @@ -31,7 +31,7 @@ using namespace FixConst; using namespace MathConst; enum{CHUTE,SPHERICAL,VECTOR}; -enum{CONSTANT,EQUAL}; +enum{CONSTANT,EQUAL}; // same as FixPour /* ---------------------------------------------------------------------- */ @@ -134,6 +134,16 @@ FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) : eflag = 0; egrav = 0.0; + + // set gravity components once and for all if CONSTANT + + varflag = CONSTANT; + if (mstyle != CONSTANT || vstyle != CONSTANT || pstyle != CONSTANT || + tstyle != CONSTANT || xstyle != CONSTANT || ystyle != CONSTANT || + zstyle != CONSTANT) varflag = EQUAL; + + if (varflag == CONSTANT) set_acceleration(); + } /* ---------------------------------------------------------------------- */ @@ -222,15 +232,6 @@ void FixGravity::init() if (!input->variable->equalstyle(zvar)) error->all(FLERR,"Variable for fix gravity is invalid style"); } - - varflag = CONSTANT; - if (mstyle != CONSTANT || vstyle != CONSTANT || pstyle != CONSTANT || - tstyle != CONSTANT || xstyle != CONSTANT || ystyle != CONSTANT || - zstyle != CONSTANT) varflag = EQUAL; - - // set gravity components once and for all - - if (varflag == CONSTANT) set_acceleration(); } /* ---------------------------------------------------------------------- */ diff --git a/src/replicate.cpp b/src/replicate.cpp index 1617ab0313..3659f7cf7a 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -331,35 +331,43 @@ void Replicate::command(int narg, char **arg) if (me == 0 && screen) { fprintf(screen," bounding box image = (%i %i %i) to (%i %i %i)\n", - _imagelo[0],_imagelo[1],_imagelo[2],_imagehi[0],_imagehi[1],_imagehi[2]); + _imagelo[0],_imagelo[1],_imagelo[2], + _imagehi[0],_imagehi[1],_imagehi[2]); fprintf(screen," bounding box extra memory = %.2f MB\n", (double)size_buf_all*sizeof(double)/1024/1024); } // rnk offsets - int * disp_buf_rnk; + int *disp_buf_rnk; memory->create(disp_buf_rnk, nprocs, "replicate:disp_buf_rnk"); disp_buf_rnk[0] = 0; - for (i=1; icreate(buf_all, size_buf_all, "replicate:buf_all"); - MPI_Allgatherv(buf, n, MPI_DOUBLE, buf_all, size_buf_rnk, disp_buf_rnk, MPI_DOUBLE, world); + MPI_Allgatherv(buf,n,MPI_DOUBLE,buf_all,size_buf_rnk,disp_buf_rnk, + MPI_DOUBLE,world); // bounding box of original unwrapped system double _orig_lo[3], _orig_hi[3]; if (triclinic) { - _orig_lo[0] = domain->boxlo[0] + _imagelo[0] * old_xprd + _imagelo[1] * old_xy + _imagelo[2] * old_xz; - _orig_lo[1] = domain->boxlo[1] + _imagelo[1] * old_yprd + _imagelo[2] * old_yz; + _orig_lo[0] = domain->boxlo[0] + + _imagelo[0] * old_xprd + _imagelo[1] * old_xy + _imagelo[2] * old_xz; + _orig_lo[1] = domain->boxlo[1] + + _imagelo[1] * old_yprd + _imagelo[2] * old_yz; _orig_lo[2] = domain->boxlo[2] + _imagelo[2] * old_zprd; - _orig_hi[0] = domain->boxlo[0] + (_imagehi[0]+1) * old_xprd + (_imagehi[1]+1) * old_xy + (_imagehi[2]+1) * old_xz; - _orig_hi[1] = domain->boxlo[1] + (_imagehi[1]+1) * old_yprd + (_imagehi[2]+1) * old_yz; + _orig_hi[0] = domain->boxlo[0] + + (_imagehi[0]+1) * old_xprd + + (_imagehi[1]+1) * old_xy + (_imagehi[2]+1) * old_xz; + _orig_hi[1] = domain->boxlo[1] + + (_imagehi[1]+1) * old_yprd + (_imagehi[2]+1) * old_yz; _orig_hi[2] = domain->boxlo[2] + (_imagehi[2]+1) * old_zprd; } else { _orig_lo[0] = domain->boxlo[0] + _imagelo[0] * old_xprd; @@ -605,7 +613,8 @@ void Replicate::command(int narg, char **arg) MPI_Reduce(&num_replicas_added, &sum, 1, MPI_INT, MPI_SUM, 0, world); double avg = (double) sum / nprocs; if (me == 0 && screen) - fprintf(screen," average # of replicas added to proc = %.2f out of %i (%.2f %%)\n", + fprintf(screen," average # of replicas added to proc = %.2f " + "out of %i (%.2f %%)\n", avg,nx*ny*nz,avg/(nx*ny*nz)*100.0); } else { diff --git a/src/verlet.cpp b/src/verlet.cpp index 8cd6fe940d..fe9645618a 100644 --- a/src/verlet.cpp +++ b/src/verlet.cpp @@ -109,7 +109,7 @@ void Verlet::setup(int flag) domain->pbc(); domain->reset_box(); comm->setup(); - if (neighbor->style) neighbor->setup_bins(); + if (neighbor->style) neighbor->setup_bins(); comm->exchange(); if (atom->sortfreq > 0) atom->sort(); comm->borders(); From b6374bacfb13a4b9c7273c2d07dd5dd1dd055ba0 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 18 Dec 2019 08:56:03 -0700 Subject: [PATCH 09/42] enable replicate to work with local ptrs --- src/DIPOLE/atom_vec_dipole.cpp | 15 +++- src/DIPOLE/atom_vec_dipole.h | 5 ++ src/MOLECULE/atom_vec_angle.cpp | 39 ++++++---- src/MOLECULE/atom_vec_angle.h | 6 ++ src/MOLECULE/atom_vec_bond.cpp | 29 +++---- src/MOLECULE/atom_vec_bond.h | 10 ++- src/MOLECULE/atom_vec_full.cpp | 55 ++++++------- src/MOLECULE/atom_vec_full.h | 6 ++ src/MOLECULE/atom_vec_molecular.cpp | 55 ++++++------- src/MOLECULE/atom_vec_molecular.h | 6 ++ src/MOLECULE/atom_vec_template.cpp | 23 ++++-- src/MOLECULE/atom_vec_template.h | 5 ++ src/PERI/atom_vec_peri.cpp | 37 +++++---- src/PERI/atom_vec_peri.h | 7 ++ src/SPIN/atom_vec_spin.cpp | 29 +++++-- src/SPIN/atom_vec_spin.h | 5 ++ src/USER-DPD/atom_vec_dpd.cpp | 34 +++++--- src/USER-DPD/atom_vec_dpd.h | 7 ++ src/USER-EFF/atom_vec_electron.cpp | 25 ++++-- src/USER-EFF/atom_vec_electron.h | 6 ++ src/USER-MESO/atom_vec_edpd.cpp | 32 +++++--- src/USER-MESO/atom_vec_edpd.h | 7 ++ src/USER-MESO/atom_vec_mdpd.cpp | 24 ++++-- src/USER-MESO/atom_vec_mdpd.h | 6 ++ src/USER-MESO/atom_vec_tdpd.cpp | 14 +++- src/USER-MESO/atom_vec_tdpd.h | 5 ++ src/USER-SMD/atom_vec_smd.cpp | 90 ++++++++++++--------- src/USER-SMD/atom_vec_smd.h | 8 ++ src/USER-SPH/atom_vec_meso.cpp | 36 +++++---- src/USER-SPH/atom_vec_meso.h | 6 ++ src/atom.cpp | 83 +++++++------------- src/atom.h | 15 ++-- src/atom_vec.cpp | 6 +- src/atom_vec.h | 3 +- src/atom_vec_body.cpp | 58 +++++++------- src/atom_vec_body.h | 6 +- src/atom_vec_ellipsoid.cpp | 61 ++++++--------- src/atom_vec_ellipsoid.h | 6 +- src/atom_vec_hybrid.cpp | 16 ++-- src/atom_vec_hybrid.h | 3 +- src/atom_vec_line.cpp | 93 ++++++++++------------ src/atom_vec_line.h | 7 +- src/atom_vec_sphere.cpp | 45 +++++++---- src/atom_vec_sphere.h | 6 +- src/atom_vec_tri.cpp | 116 +++++++++++++--------------- src/atom_vec_tri.h | 7 +- src/replicate.cpp | 3 +- 47 files changed, 686 insertions(+), 480 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 5cdbab1b33..074a59d5a1 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -54,6 +54,16 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecDipole::grow_pointers() +{ + mu = atom->mu; +} + /* ---------------------------------------------------------------------- modify what AtomVec::data_atom() just unpacked or initialize other atom quantities @@ -61,6 +71,7 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) void AtomVecDipole::data_atom_post(int ilocal) { - double *mu = atom->mu[ilocal]; - mu[3] = sqrt(mu[0]*mu[0] + mu[1]*mu[1] + mu[2]*mu[2]); + double *mu_one = mu[ilocal]; + mu_one[3] = + sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]); } diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index 45f33d109d..2030892a43 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -27,7 +27,12 @@ namespace LAMMPS_NS { class AtomVecDipole : public AtomVec { public: AtomVecDipole(class LAMMPS *); + + void grow_pointers(); void data_atom_post(int); + + private: + double **mu; }; } diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 1bd6f9a071..f3ebe3258b 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -66,6 +66,20 @@ AtomVecAngle::~AtomVecAngle() delete [] angle_negative; } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecAngle::grow_pointers() +{ + num_bond = atom->num_bond; + bond_type = atom->bond_type; + num_angle = atom->num_angle; + angle_type = atom->angle_type; + nspecial = atom->nspecial; +} + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -87,11 +101,6 @@ void AtomVecAngle::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; - int any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -120,15 +129,11 @@ void AtomVecAngle::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; for (int m = 0; m < num_angle[ilocal]; m++) if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } @@ -140,9 +145,9 @@ void AtomVecAngle::pack_restart_post(int ilocal) void AtomVecAngle::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -152,9 +157,9 @@ void AtomVecAngle::unpack_restart_init(int ilocal) void AtomVecAngle::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->num_angle[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + num_angle[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_angle.h b/src/MOLECULE/atom_vec_angle.h index 48e55b0988..0ce0b4baab 100644 --- a/src/MOLECULE/atom_vec_angle.h +++ b/src/MOLECULE/atom_vec_angle.h @@ -28,12 +28,18 @@ class AtomVecAngle : public AtomVec { public: AtomVecAngle(class LAMMPS *); ~AtomVecAngle(); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond,*num_angle; + int **bond_type,**angle_type; + int **nspecial; + int any_bond_negative,any_angle_negative; int bond_per_atom,angle_per_atom; int *bond_negative,*angle_negative; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 00e8e3260d..64a52fa80a 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -61,19 +61,17 @@ AtomVecBond::~AtomVecBond() } /* ---------------------------------------------------------------------- - grow atom arrays - must set local copy of body ptr - needed in replicate when 2 atom classes exist and pack_restart() is called + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() ------------------------------------------------------------------------- */ -void AtomVecBond::grow(int n) +void AtomVecBond::grow_pointers() { - AtomVec::grow(n); num_bond = atom->num_bond; bond_type = atom->bond_type; + nspecial = atom->nspecial; } - /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -90,9 +88,6 @@ void AtomVecBond::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - //int *num_bond = atom->num_bond; - //int **bond_type = atom->bond_type; - any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -112,8 +107,6 @@ void AtomVecBond::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - //int *num_bond = atom->num_bond; - //int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } @@ -125,9 +118,9 @@ void AtomVecBond::pack_restart_post(int ilocal) void AtomVecBond::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -137,8 +130,8 @@ void AtomVecBond::unpack_restart_init(int ilocal) void AtomVecBond::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index 90c4b1f217..c938655127 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -28,19 +28,21 @@ class AtomVecBond : public AtomVec { public: AtomVecBond(class LAMMPS *); ~AtomVecBond(); - void grow(int); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond; + int **bond_type; + int **nspecial; + int any_bond_negative; int bond_per_atom; int *bond_negative; - - int *num_bond; - int **bond_type; }; } diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index be7c92ce93..89afae5005 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -88,6 +88,24 @@ AtomVecFull::~AtomVecFull() delete [] improper_negative; } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecFull::grow_pointers() +{ + num_bond = atom->num_bond; + bond_type = atom->bond_type; + num_angle = atom->num_angle; + angle_type = atom->angle_type; + num_dihedral = atom->num_dihedral; + dihedral_type = atom->dihedral_type; + num_improper = atom->num_improper; + improper_type = atom->improper_type; + nspecial = atom->nspecial; +} + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -119,15 +137,6 @@ void AtomVecFull::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; - any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -174,30 +183,22 @@ void AtomVecFull::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; for (int m = 0; m < num_angle[ilocal]; m++) if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } if (any_dihedral_negative) { - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; for (int m = 0; m < num_dihedral[ilocal]; m++) if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; for (int m = 0; m < num_improper[ilocal]; m++) if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; @@ -210,9 +211,9 @@ void AtomVecFull::pack_restart_post(int ilocal) void AtomVecFull::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -222,11 +223,11 @@ void AtomVecFull::unpack_restart_init(int ilocal) void AtomVecFull::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->num_angle[ilocal] = 0; - atom->num_dihedral[ilocal] = 0; - atom->num_improper[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + num_angle[ilocal] = 0; + num_dihedral[ilocal] = 0; + num_improper[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_full.h b/src/MOLECULE/atom_vec_full.h index 455bbd0d5e..1abd3351d3 100644 --- a/src/MOLECULE/atom_vec_full.h +++ b/src/MOLECULE/atom_vec_full.h @@ -28,12 +28,18 @@ class AtomVecFull : public AtomVec { public: AtomVecFull(class LAMMPS *); ~AtomVecFull(); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond,*num_angle,*num_dihedral,*num_improper; + int **bond_type,**angle_type,**dihedral_type,**improper_type; + int **nspecial; + int any_bond_negative,any_angle_negative, any_dihedral_negative,any_improper_negative; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index ea15216aee..c2b71468c0 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -88,6 +88,24 @@ AtomVecMolecular::~AtomVecMolecular() delete [] improper_negative; } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMolecular::grow_pointers() +{ + num_bond = atom->num_bond; + bond_type = atom->bond_type; + num_angle = atom->num_angle; + angle_type = atom->angle_type; + num_dihedral = atom->num_dihedral; + dihedral_type = atom->dihedral_type; + num_improper = atom->num_improper; + improper_type = atom->improper_type; + nspecial = atom->nspecial; +} + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -119,15 +137,6 @@ void AtomVecMolecular::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; - any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -174,30 +183,22 @@ void AtomVecMolecular::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; for (int m = 0; m < num_angle[ilocal]; m++) if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } if (any_dihedral_negative) { - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; for (int m = 0; m < num_dihedral[ilocal]; m++) if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; for (int m = 0; m < num_improper[ilocal]; m++) if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; @@ -210,9 +211,9 @@ void AtomVecMolecular::pack_restart_post(int ilocal) void AtomVecMolecular::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -222,11 +223,11 @@ void AtomVecMolecular::unpack_restart_init(int ilocal) void AtomVecMolecular::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->num_angle[ilocal] = 0; - atom->num_dihedral[ilocal] = 0; - atom->num_improper[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + num_angle[ilocal] = 0; + num_dihedral[ilocal] = 0; + num_improper[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_molecular.h b/src/MOLECULE/atom_vec_molecular.h index 5b79f8b5c6..bcfa13d9d3 100644 --- a/src/MOLECULE/atom_vec_molecular.h +++ b/src/MOLECULE/atom_vec_molecular.h @@ -28,12 +28,18 @@ class AtomVecMolecular : public AtomVec { public: AtomVecMolecular(class LAMMPS *); ~AtomVecMolecular(); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond,*num_angle,*num_dihedral,*num_improper; + int **bond_type,**angle_type,**dihedral_type,**improper_type; + int **nspecial; + int any_bond_negative,any_angle_negative, any_dihedral_negative,any_improper_negative; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index 546c19da12..97d4c865ba 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -96,14 +96,25 @@ void AtomVecTemplate::process_args(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecTemplate::grow_pointers() +{ + molindex = atom->molindex; + molatom = atom->molatom; +} + /* ---------------------------------------------------------------------- initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecTemplate::create_atom_post(int ilocal) { - atom->molindex[ilocal] = -1; - atom->molatom[ilocal] = -1; + molindex[ilocal] = -1; + molatom[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -113,11 +124,11 @@ void AtomVecTemplate::create_atom_post(int ilocal) void AtomVecTemplate::data_atom_post(int ilocal) { - int molindex = atom->molindex[ilocal]; - int molatom = atom->molatom[ilocal]; + int molindex_one = molindex[ilocal]; + int molatom_one = molatom[ilocal]; - if (molindex < 0 || molindex >= nset) + if (molindex_one < 0 || molindex_one >= nset) error->one(FLERR,"Invalid template index in Atoms section of data file"); - if (molatom < 0 || molatom >= onemols[molindex]->natoms) + if (molatom_one < 0 || molatom_one >= onemols[molindex_one]->natoms) error->one(FLERR,"Invalid template atom in Atoms section of data file"); } diff --git a/src/MOLECULE/atom_vec_template.h b/src/MOLECULE/atom_vec_template.h index 52ef5e70e1..3bf2ec6273 100644 --- a/src/MOLECULE/atom_vec_template.h +++ b/src/MOLECULE/atom_vec_template.h @@ -27,9 +27,14 @@ namespace LAMMPS_NS { class AtomVecTemplate : public AtomVec { public: AtomVecTemplate(class LAMMPS *); + + void grow_pointers(); void process_args(int, char **); void create_atom_post(int); void data_atom_post(int); + + private: + int *molindex,*molatom; }; } diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 58ff9c54d9..46d03c35eb 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -69,18 +69,31 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecPeri::grow_pointers() +{ + rmass = atom->rmass; + vfrac = atom->vfrac; + s0 = atom->s0; + x0 = atom->x0; +} + /* ---------------------------------------------------------------------- initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecPeri::create_atom_post(int ilocal) { - atom->vfrac[ilocal] = 1.0; - atom->rmass[ilocal] = 1.0; - atom->s0[ilocal] = DBL_MAX; - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + vfrac[ilocal] = 1.0; + rmass[ilocal] = 1.0; + s0[ilocal] = DBL_MAX; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; } /* ---------------------------------------------------------------------- @@ -90,12 +103,12 @@ void AtomVecPeri::create_atom_post(int ilocal) void AtomVecPeri::data_atom_post(int ilocal) { - atom->s0[ilocal] = DBL_MAX; - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + s0[ilocal] = DBL_MAX; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid mass in Atoms section of data file"); } @@ -124,14 +137,12 @@ void AtomVecPeri::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - double *vfrac = atom->vfrac; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = vfrac[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *s0 = atom->s0; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = s0[i]; else buf[n] = 0.0; diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 13a62eb194..5739ea55c1 100644 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -27,10 +27,17 @@ namespace LAMMPS_NS { class AtomVecPeri : public AtomVec { public: AtomVecPeri(class LAMMPS *); + + void grow_pointers(); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + double *rmass,*vfrac,*s0; + double **x0; + }; } diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 638a3b8021..1e745fd0c1 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -61,6 +61,18 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecSpin::grow_pointers() +{ + sp = atom->sp; + fm = atom->fm; + fm_long = atom->fm_long; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -69,9 +81,9 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSpin::force_clear(int n, size_t nbytes) { - memset(&atom->f[n][0],0,3*nbytes); - memset(&atom->fm[n][0],0,3*nbytes); - memset(&atom->fm_long[n][0],0,3*nbytes); + memset(&f[n][0],0,3*nbytes); + memset(&fm[n][0],0,3*nbytes); + memset(&fm_long[n][0],0,3*nbytes); } /* ---------------------------------------------------------------------- @@ -81,9 +93,10 @@ void AtomVecSpin::force_clear(int n, size_t nbytes) void AtomVecSpin::data_atom_post(int ilocal) { - double *sp = atom->sp[ilocal]; - double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]); - sp[0] *= inorm; - sp[1] *= inorm; - sp[2] *= inorm; + double *sp_one = sp[ilocal]; + double norm = + 1.0/sqrt(sp_one[0]*sp_one[0] + sp_one[1]*sp_one[1] + sp_one[2]*sp_one[2]); + sp_one[0] *= norm; + sp_one[1] *= norm; + sp_one[2] *= norm; } diff --git a/src/SPIN/atom_vec_spin.h b/src/SPIN/atom_vec_spin.h index c68f3a0419..f24791605d 100644 --- a/src/SPIN/atom_vec_spin.h +++ b/src/SPIN/atom_vec_spin.h @@ -27,8 +27,13 @@ namespace LAMMPS_NS { class AtomVecSpin : public AtomVec { public: AtomVecSpin(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void data_atom_post(int); + + private: + double **sp,**fm,**fm_long; }; } diff --git a/src/USER-DPD/atom_vec_dpd.cpp b/src/USER-DPD/atom_vec_dpd.cpp index 124a081191..34efd9bc2b 100644 --- a/src/USER-DPD/atom_vec_dpd.cpp +++ b/src/USER-DPD/atom_vec_dpd.cpp @@ -52,14 +52,30 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecDPD::grow_pointers() +{ + rho = atom->rho; + dpdTheta = atom->dpdTheta; + uCond = atom->uCond; + uMech = atom->uMech; + uChem = atom->uChem; + uCG = atom->uCG; + uCGnew = atom->uCGnew; +} + /* ---------------------------------------------------------------------- initialize other atom quantities after AtomVec::unpack_restart() ------------------------------------------------------------------------- */ void AtomVecDPD::unpack_restart_init(int ilocal) { - atom->uCG[ilocal] = 0.0; - atom->uCGnew[ilocal] = 0.0; + uCG[ilocal] = 0.0; + uCGnew[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -69,14 +85,14 @@ void AtomVecDPD::unpack_restart_init(int ilocal) void AtomVecDPD::data_atom_post(int ilocal) { - 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; + rho[ilocal] = 0.0; + uCond[ilocal] = 0.0; + uMech[ilocal] = 0.0; + uChem[ilocal] = 0.0; + uCG[ilocal] = 0.0; + uCGnew[ilocal] = 0.0; - if (atom->dpdTheta[ilocal] <= 0) + if (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 20c8a9a2d2..61abc658b8 100644 --- a/src/USER-DPD/atom_vec_dpd.h +++ b/src/USER-DPD/atom_vec_dpd.h @@ -27,8 +27,15 @@ namespace LAMMPS_NS { class AtomVecDPD : public AtomVec { public: AtomVecDPD(class LAMMPS *); + + void grow_pointers(); void unpack_restart_init(int); void data_atom_post(int); + +private: + double *rho,*dpdTheta; + double *uCond,*uMech,*uChem; + double *uCG,*uCGnew; }; } diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index 0ac56c48a3..0912fb0498 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -69,6 +69,19 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecElectron::grow_pointers() +{ + spin = atom->spin; + eradius = atom->eradius; + ervel = atom->ervel; + erforce = atom->erforce; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -76,7 +89,7 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) void AtomVecElectron::force_clear(int n, size_t nbytes) { - memset(&atom->erforce[n],0,nbytes); + memset(&erforce[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -85,8 +98,8 @@ void AtomVecElectron::force_clear(int n, size_t nbytes) void AtomVecElectron::create_atom_post(int ilocal) { - atom->spin[ilocal] = 1; - atom->eradius[ilocal] = 1.0; + spin[ilocal] = 1; + eradius[ilocal] = 1.0; } /* ---------------------------------------------------------------------- @@ -96,7 +109,7 @@ void AtomVecElectron::create_atom_post(int ilocal) void AtomVecElectron::data_atom_post(int ilocal) { - atom->ervel[ilocal] = 0.0; + ervel[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -126,28 +139,24 @@ 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; diff --git a/src/USER-EFF/atom_vec_electron.h b/src/USER-EFF/atom_vec_electron.h index fabb03438d..9175ca52f7 100644 --- a/src/USER-EFF/atom_vec_electron.h +++ b/src/USER-EFF/atom_vec_electron.h @@ -27,11 +27,17 @@ namespace LAMMPS_NS { class AtomVecElectron : public AtomVec { public: AtomVecElectron(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + +private: + int *spin; + double *eradius,*ervel,*erforce; }; } diff --git a/src/USER-MESO/atom_vec_edpd.cpp b/src/USER-MESO/atom_vec_edpd.cpp index e06ac633ec..d08a626fad 100644 --- a/src/USER-MESO/atom_vec_edpd.cpp +++ b/src/USER-MESO/atom_vec_edpd.cpp @@ -67,6 +67,20 @@ void AtomVecEDPD::init() error->all(FLERR,"Atom style edpd requires lj units"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecEDPD::grow_pointers() +{ + edpd_cv = atom->edpd_cv; + edpd_temp = atom->edpd_temp; + edpd_flux = atom->edpd_flux; + vest = atom->vest; + vest_temp = atom->vest_temp; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -74,7 +88,7 @@ void AtomVecEDPD::init() void AtomVecEDPD::force_clear(int n, size_t nbytes) { - memset(&atom->edpd_flux[n],0,nbytes); + memset(&edpd_flux[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -83,9 +97,9 @@ void AtomVecEDPD::force_clear(int n, size_t nbytes) void AtomVecEDPD::create_atom_post(int ilocal) { - atom->edpd_temp[ilocal] = 1.0; - atom->edpd_cv[ilocal]= 1.0e5; - atom->vest_temp[ilocal] = atom->edpd_temp[ilocal]; + edpd_temp[ilocal] = 1.0; + edpd_cv[ilocal]= 1.0e5; + vest_temp[ilocal] = edpd_temp[ilocal]; } /* ---------------------------------------------------------------------- @@ -95,9 +109,9 @@ void AtomVecEDPD::create_atom_post(int ilocal) void AtomVecEDPD::data_atom_post(int ilocal) { - 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_temp[ilocal] = atom->edpd_temp[ilocal]; + edpd_flux[ilocal] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; + vest_temp[ilocal] = edpd_temp[ilocal]; } diff --git a/src/USER-MESO/atom_vec_edpd.h b/src/USER-MESO/atom_vec_edpd.h index bb667ae792..a69c44a035 100644 --- a/src/USER-MESO/atom_vec_edpd.h +++ b/src/USER-MESO/atom_vec_edpd.h @@ -28,9 +28,16 @@ class AtomVecEDPD : public AtomVec { public: AtomVecEDPD(class LAMMPS *); void init(); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); + + private: + double *edpd_cv,*edpd_temp,*edpd_flux; + double **vest; + double *vest_temp; }; } diff --git a/src/USER-MESO/atom_vec_mdpd.cpp b/src/USER-MESO/atom_vec_mdpd.cpp index b87ff14c3c..0acaaf6253 100644 --- a/src/USER-MESO/atom_vec_mdpd.cpp +++ b/src/USER-MESO/atom_vec_mdpd.cpp @@ -61,6 +61,18 @@ void AtomVecMDPD::init() error->all(FLERR,"Atom style mdpd requires lj units"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMDPD::grow_pointers() +{ + rho = atom->rho; + drho = atom->drho; + vest = atom->vest; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -68,7 +80,7 @@ void AtomVecMDPD::init() void AtomVecMDPD::force_clear(int n, size_t nbytes) { - memset(&atom->drho[n],0,nbytes); + memset(&drho[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -78,10 +90,10 @@ void AtomVecMDPD::force_clear(int n, size_t nbytes) void AtomVecMDPD::data_atom_post(int ilocal) { - atom->drho[ilocal] = 0.0; - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; + drho[ilocal] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -109,14 +121,12 @@ void AtomVecMDPD::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - double *rho = atom->rho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *drho = atom->drho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; else buf[n] = 0.0; diff --git a/src/USER-MESO/atom_vec_mdpd.h b/src/USER-MESO/atom_vec_mdpd.h index 0eb4fff2df..55f5e9bb2d 100644 --- a/src/USER-MESO/atom_vec_mdpd.h +++ b/src/USER-MESO/atom_vec_mdpd.h @@ -28,10 +28,16 @@ class AtomVecMDPD : public AtomVec { public: AtomVecMDPD(class LAMMPS *); void init(); + + void grow_pointers(); void force_clear(int, size_t); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + double *rho,*drho; + double **vest; }; } diff --git a/src/USER-MESO/atom_vec_tdpd.cpp b/src/USER-MESO/atom_vec_tdpd.cpp index 5734fcf9ad..f50fe168d6 100644 --- a/src/USER-MESO/atom_vec_tdpd.cpp +++ b/src/USER-MESO/atom_vec_tdpd.cpp @@ -80,6 +80,18 @@ void AtomVecTDPD::init() error->all(FLERR,"Atom style tdpd requires lj units"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecTDPD::grow_pointers() +{ + cc_flux = atom->cc_flux; + vest = atom->vest; +} + + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -87,7 +99,7 @@ void AtomVecTDPD::init() void AtomVecTDPD::force_clear(int n, size_t nbytes) { - memset(&atom->cc_flux[n][0],0,cc_species*nbytes); + memset(&cc_flux[n][0],0,cc_species*nbytes); } /* ---------------------------------------------------------------------- diff --git a/src/USER-MESO/atom_vec_tdpd.h b/src/USER-MESO/atom_vec_tdpd.h index 7321859fb4..971696cc5c 100644 --- a/src/USER-MESO/atom_vec_tdpd.h +++ b/src/USER-MESO/atom_vec_tdpd.h @@ -29,10 +29,15 @@ class AtomVecTDPD : public AtomVec { AtomVecTDPD(class LAMMPS *); void process_args(int, char **); void init(); + + void grow_pointers(); void force_clear(int, size_t); void data_atom_post(int); protected: + double **cc_flux; + double **vest; + int cc_species; }; diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 9f0ed04a09..4c8126d2cc 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -62,11 +62,11 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) - "de vfrac rmass x0 radius contact_radius molecule " - "smd_data_9 e vest smd_stress " + "e de vfrac rmass x0 radius contact_radius molecule " + "smd_data_9 vest smd_stress " "eff_plastic_strain eff_plastic_strain_rate damage"; fields_copy = (char *) - "vfrac rmass x0 radius contact_radius molecule e " + "e vfrac rmass x0 radius contact_radius molecule " "eff_plastic_strain eff_plastic_strain_rate vest " "smd_data_9 smd_stress damage"; fields_comm = (char *) "radius vfrac vest e"; @@ -101,6 +101,29 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecSMD::grow_pointers() +{ + e = atom->e; + de = atom->de; + vfrac = atom->vfrac; + rmass = atom->rmass; + x0 = atom->x0; + radius = atom->radius; + contact_radius = atom->contact_radius; + molecule = atom->molecule; + smd_data_9 = atom->smd_data_9; + vest = atom->vest; + smd_stress = atom->smd_stress; + eff_plastic_strain = atom->eff_plastic_strain; + eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + damage = atom->damage; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -109,8 +132,8 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSMD::force_clear(int n, size_t nbytes) { - memset(&atom->de[n],0,nbytes); - memset(&atom->f[n][0],0,3*nbytes); + memset(&de[n],0,nbytes); + memset(&f[n][0],0,3*nbytes); } /* ---------------------------------------------------------------------- @@ -119,19 +142,19 @@ void AtomVecSMD::force_clear(int n, size_t nbytes) void AtomVecSMD::create_atom_post(int ilocal) { - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; - atom->vfrac[ilocal] = 1.0; - atom->rmass[ilocal] = 1.0; - atom->radius[ilocal] = 0.5; - atom->contact_radius[ilocal] = 0.5; - atom->molecule[ilocal] = 1; + vfrac[ilocal] = 1.0; + rmass[ilocal] = 1.0; + radius[ilocal] = 0.5; + contact_radius[ilocal] = 0.5; + molecule[ilocal] = 1; - atom->smd_data_9[ilocal][0] = 1.0; // xx - atom->smd_data_9[ilocal][4] = 1.0; // yy - atom->smd_data_9[ilocal][8] = 1.0; // zz + smd_data_9[ilocal][0] = 1.0; // xx + smd_data_9[ilocal][4] = 1.0; // yy + smd_data_9[ilocal][8] = 1.0; // zz } /* ---------------------------------------------------------------------- @@ -141,32 +164,27 @@ void AtomVecSMD::create_atom_post(int ilocal) void AtomVecSMD::data_atom_post(int ilocal) { - atom->e[ilocal] = 0.0; - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + e[ilocal] = 0.0; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; - atom->damage[ilocal] = 0.0; + damage[ilocal] = 0.0; - atom->eff_plastic_strain[ilocal] = 0.0; - atom->eff_plastic_strain_rate[ilocal] = 0.0; + eff_plastic_strain[ilocal] = 0.0; + eff_plastic_strain_rate[ilocal] = 0.0; for (int k = 0; k < NMAT_FULL; k++) - atom->smd_data_9[ilocal][k] = 0.0; + smd_data_9[ilocal][k] = 0.0; for (int k = 0; k < NMAT_SYMM; k++) - atom->smd_stress[ilocal][k] = 0.0; + smd_stress[ilocal][k] = 0.0; - atom->smd_data_9[ilocal][0] = 1.0; // xx - atom->smd_data_9[ilocal][4] = 1.0; // yy - atom->smd_data_9[ilocal][8] = 1.0; // zz + smd_data_9[ilocal][0] = 1.0; // xx + smd_data_9[ilocal][4] = 1.0; // yy + smd_data_9[ilocal][8] = 1.0; // zz } - - - - - diff --git a/src/USER-SMD/atom_vec_smd.h b/src/USER-SMD/atom_vec_smd.h index 539f209ca7..00709aeada 100644 --- a/src/USER-SMD/atom_vec_smd.h +++ b/src/USER-SMD/atom_vec_smd.h @@ -38,9 +38,17 @@ namespace LAMMPS_NS { class AtomVecSMD : public AtomVec { public: AtomVecSMD(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); + + private: + int *molecule; + double *e,*de,*vfrac,*rmass,*radius,*contact_radius; + double *eff_plastic_strain,*eff_plastic_strain_rate,*damage; + double **x0,**smd_data_9,**smd_stress,**vest; }; } diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_meso.cpp index a80ab91d2e..fdddd15f27 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_meso.cpp @@ -52,6 +52,21 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMeso::grow_pointers() +{ + rho = atom->rho; + drho = atom->drho; + e = atom->e; + de = atom->de; + cv = atom->cv; + vest = atom->vest; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -59,8 +74,8 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) void AtomVecMeso::force_clear(int n, size_t nbytes) { - memset(&atom->de[n],0,nbytes); - memset(&atom->drho[n],0,nbytes); + memset(&de[n],0,nbytes); + memset(&drho[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -69,7 +84,7 @@ void AtomVecMeso::force_clear(int n, size_t nbytes) void AtomVecMeso::create_atom_post(int ilocal) { - atom->cv[ilocal] = 1.0; + cv[ilocal] = 1.0; } /* ---------------------------------------------------------------------- @@ -79,11 +94,11 @@ void AtomVecMeso::create_atom_post(int ilocal) void AtomVecMeso::data_atom_post(int ilocal) { - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; - atom->de[ilocal] = 0.0; - atom->drho[ilocal] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; + de[ilocal] = 0.0; + drho[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -114,35 +129,30 @@ void AtomVecMeso::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - double *rho = atom->rho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *drho = atom->drho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 2) { - double *e = atom->e; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = e[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 3) { - double *de = atom->de; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = de[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 4) { - double *cv = atom->cv; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = cv[i]; else buf[n] = 0.0; diff --git a/src/USER-SPH/atom_vec_meso.h b/src/USER-SPH/atom_vec_meso.h index c8a1090474..bd84c34fbc 100644 --- a/src/USER-SPH/atom_vec_meso.h +++ b/src/USER-SPH/atom_vec_meso.h @@ -27,11 +27,17 @@ namespace LAMMPS_NS { class AtomVecMeso : public AtomVec { public: AtomVecMeso(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + double *rho,*drho,*e,*de,*cv; + double **vest; }; } diff --git a/src/atom.cpp b/src/atom.cpp index 0fbee8f583..353ed510a4 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -175,42 +175,8 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) iname = dname = NULL; // initialize atom style and array existence flags - // customize by adding new flag - sphere_flag = peri_flag = electron_flag = 0; - wavepacket_flag = sph_flag = 0; - - molecule_flag = 0; - q_flag = mu_flag = 0; - omega_flag = torque_flag = angmom_flag = 0; - radius_flag = rmass_flag = 0; - ellipsoid_flag = line_flag = tri_flag = body_flag = 0; - - // magnetic flags - - sp_flag = 0; - - vfrac_flag = 0; - spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; - cs_flag = csforce_flag = vforce_flag = etag_flag = 0; - - rho_flag = e_flag = cv_flag = vest_flag = 0; - dpd_flag = edpd_flag = tdpd_flag = 0; - - // USER-SMD - - smd_flag = 0; - contact_radius_flag = 0; - smd_data_9_flag = 0; - smd_stress_flag = 0; - x0_flag = 0; - eff_plastic_strain_flag = 0; - eff_plastic_strain_rate_flag = 0; - damage_flag = 0; - - // Peridynamic scale factor - - pdscale = 1.0; + set_atomflag_defaults(); // initialize peratom data structure @@ -668,6 +634,32 @@ void Atom::add_peratom_vary(const char *name, void *address, nperatom++; } +/* ---------------------------------------------------------------------- + add info for a single per-atom array to PerAtom data struct + customize by adding new flag, identical list as atom.h 2nd customization +------------------------------------------------------------------------- */ + +void Atom::set_atomflag_defaults() +{ + sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0; + peri_flag = electron_flag = 0; + wavepacket_flag = sph_flag = 0; + molecule_flag = molindex_flag = molatom_flag = 0; + q_flag = mu_flag = 0; + rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0; + vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; + cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0; + rho_flag = e_flag = cv_flag = vest_flag = 0; + dpd_flag = edpd_flag = tdpd_flag = 0; + sp_flag = 0; + x0_flag = 0; + smd_flag = damage_flag = 0; + contact_radius_flag = smd_data_9_flag = smd_stress_flag = 0; + eff_plastic_strain_flag = eff_plastic_strain_rate_flag = 0; + + pdscale = 1.0; +} + /* ---------------------------------------------------------------------- create an AtomVec style called from lammps.cpp, input script, restart file, replicate @@ -682,26 +674,8 @@ void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix) // unset atom style and array existence flags // may have been set by old avec - // customize by adding new flag - sphere_flag = peri_flag = electron_flag = 0; - wavepacket_flag = sph_flag = 0; - - molecule_flag = 0; - q_flag = mu_flag = 0; - omega_flag = torque_flag = angmom_flag = 0; - radius_flag = rmass_flag = 0; - ellipsoid_flag = line_flag = tri_flag = body_flag = 0; - - // magnetic flags - - sp_flag = 0; - - vfrac_flag = 0; - spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; - cs_flag = csforce_flag = vforce_flag = etag_flag = 0; - - rho_flag = e_flag = cv_flag = vest_flag = 0; + set_atomflag_defaults(); // create instance of AtomVec // use grow() to initialize atom-based arrays to length 1 @@ -785,6 +759,7 @@ AtomVec *Atom::avec_creator(LAMMPS *lmp) return new T(lmp); } + /* ---------------------------------------------------------------------- */ void Atom::init() diff --git a/src/atom.h b/src/atom.h index bc1eb1a7d7..6c7110b5be 100644 --- a/src/atom.h +++ b/src/atom.h @@ -143,7 +143,8 @@ class Atom : protected Pointers { double **vest; // -------------------------------------------------------------------- - // 1st customization section: customize by adding new flags + // 2nd customization section: customize by adding new flags + // identical list as Atom::set_atomflag_defaults() // most are existence flags for per-atom vectors and arrays // 1 if variable is used, 0 if not @@ -165,14 +166,10 @@ class Atom : protected Pointers { // USER-SMD package - int smd_flag; - int contact_radius_flag; - int smd_data_9_flag; - int smd_stress_flag; int x0_flag; - int eff_plastic_strain_flag; - int eff_plastic_strain_rate_flag; - int damage_flag; + int smd_flag,damage_flag; + int contact_radius_flag,smd_data_9_flag,smd_stress_flag; + int eff_plastic_strain_flag,eff_plastic_strain_rate_flag; // Peridynamics scale factor, used by dump cfg @@ -264,6 +261,7 @@ class Atom : protected Pointers { void *, int collength=0); void create_avec(const char *, int, char **, int); virtual class AtomVec *new_avec(const char *, int, int &); + void init(); void setup(); @@ -380,6 +378,7 @@ class Atom : protected Pointers { double bininvx,bininvy,bininvz; // inverse actual bin sizes double bboxlo[3],bboxhi[3]; // bounding box of my sub-domain + void set_atomflag_defaults(); void setup_sort_bins(); int next_prime(int); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index e31c235760..fac4cc2f6e 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -185,7 +185,7 @@ void AtomVec::grow(int 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"); @@ -230,6 +230,8 @@ void AtomVec::grow(int n) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); + + grow_pointers(); } /* ---------------------------------------------------------------------- @@ -2387,7 +2389,6 @@ void AtomVec::setup_fields() // set style-specific sizes // NOTE: check for others vars in atom_vec.cpp/h ?? - // NOTE: need to set maxexchange, e.g for style hybrid? comm_x_only = 1; if (ncomm) comm_x_only = 0; @@ -2435,7 +2436,6 @@ void AtomVec::setup_fields() else size_data_atom += cols; } - size_data_vel = 0; for (n = 0; n < ndata_vel; n++) { cols = mdata_vel.cols[n]; diff --git a/src/atom_vec.h b/src/atom_vec.h index 5911c8414b..94517f80ad 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -74,7 +74,8 @@ class AtomVec : protected Pointers { virtual void force_clear(int, size_t) {} - virtual void grow(int); + void grow(int); + virtual void grow_pointers() {} void copy(int, int, int); virtual void copy_bonus(int, int, int) {} diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index a04f23a47c..0f3557596f 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -100,6 +100,7 @@ AtomVecBody::~AtomVecBody() void AtomVecBody::process_args(int narg, char **arg) { // suppress unused parameter warning dependent on style_body.h + (void)(arg); if (narg < 1) error->all(FLERR,"Invalid atom_style body command"); @@ -120,11 +121,12 @@ void AtomVecBody::process_args(int narg, char **arg) icp = bptr->icp; dcp = bptr->dcp; - // max size of forward/border comm + // max size of forward/border and exchange comm // bptr values = max number of additional ivalues/dvalues from Body class size_forward_bonus += bptr->size_forward; size_border_bonus += bptr->size_border; + maxexchange = bptr->maxexchange; setup_fields(); } @@ -138,7 +140,11 @@ void AtomVecBody::process_args(int narg, char **arg) void AtomVecBody::grow(int n) { AtomVec::grow(n); + body = atom->body; + rmass = atom->rmass; + radius = atom->radius; + angmom = atom->angmom; } /* ---------------------------------------------------------------------- @@ -186,7 +192,7 @@ void AtomVecBody::copy_bonus(int i, int j, int delflag) void AtomVecBody::copy_bonus_all(int i, int j) { - atom->body[bonus[i].ilocal] = j; + body[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -503,9 +509,9 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf) void AtomVecBody::create_atom_post(int ilocal) { - atom->radius[ilocal] = 0.5; - atom->rmass[ilocal] = 1.0; - atom->body[ilocal] = -1; + radius[ilocal] = 0.5; + rmass[ilocal] = 1.0; + body[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -515,19 +521,19 @@ void AtomVecBody::create_atom_post(int ilocal) void AtomVecBody::data_atom_post(int ilocal) { - body_flag = atom->body[ilocal]; + body_flag = 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; + body[ilocal] = body_flag; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); - atom->radius[ilocal] = 0.5; - atom->angmom[ilocal][0] = 0.0; - atom->angmom[ilocal][1] = 0.0; - atom->angmom[ilocal][2] = 0.0; + radius[ilocal] = 0.5; + angmom[ilocal][0] = 0.0; + angmom[ilocal][1] = 0.0; + angmom[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -537,12 +543,12 @@ void AtomVecBody::data_atom_post(int ilocal) void AtomVecBody::data_body(int m, int ninteger, int ndouble, int *ivalues, double *dvalues) { - if (atom->body[m]) + if (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); - atom->body[m] = nlocal_bonus++; + body[m] = nlocal_bonus++; } /* ---------------------------------------------------------------------- @@ -570,10 +576,10 @@ bigint AtomVecBody::memory_usage_bonus() void AtomVecBody::pack_data_pre(int ilocal) { - body_flag = atom->body[ilocal]; + body_flag = body[ilocal]; - if (body_flag < 0) atom->body[ilocal] = 0; - else atom->body[ilocal] = 1; + if (body_flag < 0) body[ilocal] = 0; + else body[ilocal] = 1; } /* ---------------------------------------------------------------------- @@ -582,7 +588,7 @@ void AtomVecBody::pack_data_pre(int ilocal) void AtomVecBody::pack_data_post(int ilocal) { - atom->body[ilocal] = body_flag; + body[ilocal] = body_flag; } /* ---------------------------------------------------------------------- @@ -602,8 +608,8 @@ double AtomVecBody::radius_body(int ninteger, int ndouble, void AtomVecBody::set_quat(int m, double *quat_external) { - if (atom->body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom"); - double *quat = bonus[atom->body[m]].quat; + if (body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom"); + double *quat = bonus[body[m]].quat; quat[0] = quat_external[0]; quat[1] = quat_external[1]; quat[2] = quat_external[2]; quat[3] = quat_external[3]; } @@ -616,15 +622,15 @@ void AtomVecBody::set_quat(int m, double *quat_external) void AtomVecBody::check(int flag) { for (int i = 0; i < atom->nlocal; i++) { - if (atom->body[i] >= 0 && atom->body[i] >= nlocal_bonus) { + if (body[i] >= 0 && body[i] >= nlocal_bonus) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD AAA"); } } for (int i = atom->nlocal; i < atom->nlocal+atom->nghost; i++) { - if (atom->body[i] >= 0 && - (atom->body[i] < nlocal_bonus || - atom->body[i] >= nlocal_bonus+nghost_bonus)) { + if (body[i] >= 0 && + (body[i] < nlocal_bonus || + body[i] >= nlocal_bonus+nghost_bonus)) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD BBB"); } @@ -636,7 +642,7 @@ void AtomVecBody::check(int flag) } } for (int i = 0; i < nlocal_bonus; i++) { - if (atom->body[bonus[i].ilocal] != i) { + if (body[bonus[i].ilocal] != i) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD DDD"); } @@ -649,7 +655,7 @@ void AtomVecBody::check(int flag) } } for (int i = nlocal_bonus; i < nlocal_bonus+nghost_bonus; i++) { - if (atom->body[bonus[i].ilocal] != i) { + if (body[bonus[i].ilocal] != i) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD FFF"); } diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 3f32c8223c..adfc7768eb 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -71,12 +71,14 @@ class AtomVecBody : public AtomVec { int nlocal_bonus; private: + int *body; + double *rmass,*radius; + double **angmom; + int nghost_bonus,nmax_bonus; int intdoubleratio; // sizeof(double) / sizeof(int) int body_flag; - int *body; - MyPoolChunk *icp; MyPoolChunk *dcp; diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index e8ab6d5613..2537fe2538 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -75,6 +75,17 @@ AtomVecEllipsoid::~AtomVecEllipsoid() memory->sfree(bonus); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid::grow_pointers() +{ + ellipsoid = atom->ellipsoid; + rmass = atom->rmass; +} + /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -95,8 +106,6 @@ void AtomVecEllipsoid::grow_bonus() void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag) { - int *ellipsoid = atom->ellipsoid; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && ellipsoid[j] >= 0) { @@ -118,7 +127,7 @@ void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag) void AtomVecEllipsoid::copy_bonus_all(int i, int j) { - atom->ellipsoid[bonus[i].ilocal] = j; + ellipsoid[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -143,8 +152,6 @@ 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]; @@ -167,8 +174,6 @@ 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++) { @@ -190,8 +195,6 @@ int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf) double dx,dy,dz; double *shape,*quat; - int *ellipsoid = atom->ellipsoid; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -220,8 +223,6 @@ 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++) { @@ -257,8 +258,6 @@ int AtomVecEllipsoid::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -283,8 +282,6 @@ int AtomVecEllipsoid::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; else { @@ -314,8 +311,6 @@ int AtomVecEllipsoid::size_restart_bonus() { int i; - int *ellipsoid = atom->ellipsoid; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -336,8 +331,6 @@ int AtomVecEllipsoid::pack_restart_bonus(int i, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -362,8 +355,6 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; else { @@ -390,8 +381,6 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf) 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"); @@ -414,7 +403,7 @@ void AtomVecEllipsoid::data_atom_bonus(int m, char **values) // reset ellipsoid mass // previously stored density in rmass - atom->rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; + rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; bonus[nlocal_bonus].ilocal = m; ellipsoid[m] = nlocal_bonus++; @@ -437,8 +426,8 @@ bigint AtomVecEllipsoid::memory_usage_bonus() void AtomVecEllipsoid::create_atom_post(int ilocal) { - atom->rmass[ilocal] = 1.0; - atom->ellipsoid[ilocal] = -1; + rmass[ilocal] = 1.0; + ellipsoid[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -448,13 +437,13 @@ void AtomVecEllipsoid::create_atom_post(int ilocal) void AtomVecEllipsoid::data_atom_post(int ilocal) { - ellipsoid_flag = atom->ellipsoid[ilocal]; + ellipsoid_flag = 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; + ellipsoid[ilocal] = ellipsoid_flag; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); } @@ -467,14 +456,14 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal) double *shape; ellipsoid_flag = atom->ellipsoid[ilocal]; - rmass = atom->rmass[ilocal]; + rmass_one = atom->rmass[ilocal]; - if (ellipsoid_flag < 0) atom->ellipsoid[ilocal] = 0; - else atom->ellipsoid[ilocal] = 1; + if (ellipsoid_flag < 0) ellipsoid[ilocal] = 0; + else 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]; + rmass[ilocal] /= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; } } @@ -484,8 +473,8 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal) void AtomVecEllipsoid::pack_data_post(int ilocal) { - atom->ellipsoid[ilocal] = ellipsoid_flag; - atom->rmass[ilocal] = rmass; + ellipsoid[ilocal] = ellipsoid_flag; + rmass[ilocal] = rmass_one; } /* ---------------------------------------------------------------------- @@ -497,8 +486,6 @@ void AtomVecEllipsoid::pack_data_post(int ilocal) 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(); diff --git a/src/atom_vec_ellipsoid.h b/src/atom_vec_ellipsoid.h index 79d17a2206..bbf3922bb3 100644 --- a/src/atom_vec_ellipsoid.h +++ b/src/atom_vec_ellipsoid.h @@ -36,6 +36,7 @@ class AtomVecEllipsoid : public AtomVec { AtomVecEllipsoid(class LAMMPS *); ~AtomVecEllipsoid(); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -62,9 +63,12 @@ class AtomVecEllipsoid : public AtomVec { int nlocal_bonus; private: + int *ellipsoid; + double *rmass; + int nghost_bonus,nmax_bonus; int ellipsoid_flag; - double rmass; + double rmass_one; void grow_bonus(); void copy_bonus_all(int, int); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 9a79f66972..d1166e5a8e 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -36,7 +36,6 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) // NOTE: set bonus_flag if any substyle does // set nstyles_bonus, styles_bonus - // NOTE: call method in each sub-style to set q_flag ?? // these strings will be concatenated from sub-style strings // fields_data_atom & fields_data_vel start with fields common to all styles @@ -124,8 +123,8 @@ void AtomVecHybrid::process_args(int narg, char **arg) for (int k = 0; k < nstyles; k++) { if ((styles[k]->molecular == 1 && molecular == 2) || (styles[k]->molecular == 2 && molecular == 1)) - error->all(FLERR,"Cannot mix molecular and molecule template " - "atom styles"); + error->all(FLERR, + "Cannot mix molecular and molecule template atom styles"); molecular = MAX(molecular,styles[k]->molecular); bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow); @@ -135,11 +134,9 @@ void AtomVecHybrid::process_args(int narg, char **arg) mass_type = MAX(mass_type,styles[k]->mass_type); dipole_type = MAX(dipole_type,styles[k]->dipole_type); forceclearflag = MAX(forceclearflag,styles[k]->forceclearflag); + maxexchange += styles[k]->maxexchange; if (styles[k]->molecular == 2) onemols = styles[k]->onemols; - - // NOTE: need to sum this one? - maxexchange += styles[k]->maxexchange; } // issue a warning if both per-type mass and per-atom rmass are defined @@ -237,6 +234,13 @@ void AtomVecHybrid::init() /* ---------------------------------------------------------------------- */ +void AtomVecHybrid::grow_pointers() +{ + for (int k = 0; k < nstyles; k++) styles[k]->grow_pointers(); +} + +/* ---------------------------------------------------------------------- */ + void AtomVecHybrid::force_clear(int n, size_t nbytes) { for (int k = 0; k < nstyles; k++) diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 7d838b7a7f..7d8e45c579 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -34,8 +34,9 @@ class AtomVecHybrid : public AtomVec { ~AtomVecHybrid(); void process_args(int, char **); void init(); - void force_clear(int, size_t); + void grow_pointers(); + void force_clear(int, size_t); void copy_bonus(int, int, int); void clear_bonus() {} int pack_comm_bonus(int, int *, double *); diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 7ab697b349..e178d1f78a 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -86,6 +86,19 @@ void AtomVecLine::init() error->all(FLERR,"Atom_style line can only be used in 2d simulations"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecLine::grow_pointers() +{ + line = atom->line; + radius = atom->radius; + rmass = atom->rmass; + omega = atom->omega; +} + /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -106,8 +119,6 @@ void AtomVecLine::grow_bonus() void AtomVecLine::copy_bonus(int i, int j, int delflag) { - int *line = atom->line; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && line[j] >= 0) { @@ -129,7 +140,7 @@ void AtomVecLine::copy_bonus(int i, int j, int delflag) void AtomVecLine::copy_bonus_all(int i, int j) { - atom->line[bonus[i].ilocal] = j; + line[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -153,8 +164,6 @@ int AtomVecLine::pack_comm_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]; @@ -170,8 +179,6 @@ 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++) { @@ -185,8 +192,6 @@ 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]; @@ -207,8 +212,6 @@ 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++) { @@ -237,8 +240,6 @@ int AtomVecLine::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *line = atom->line; - if (line[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -256,8 +257,6 @@ int AtomVecLine::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *line = atom->line; - line[ilocal] = (int) ubuf(buf[m++]).i; if (line[ilocal] == 0) line[ilocal] = -1; else { @@ -280,8 +279,6 @@ int AtomVecLine::size_restart_bonus() { int i; - int *line = atom->line; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -302,8 +299,6 @@ int AtomVecLine::pack_restart_bonus(int i, double *buf) { int m = 0; - int *line = atom->line; - if (line[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -323,8 +318,6 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *line = atom->line; - line[ilocal] = (int) ubuf(buf[m++]).i; if (line[ilocal] == 0) line[ilocal] = -1; else { @@ -344,8 +337,6 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf) 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(); @@ -377,8 +368,8 @@ void AtomVecLine::data_atom_bonus(int m, char **values) // reset line radius and mass // rmass currently holds density - atom->radius[m] = 0.5 * length; - atom->rmass[m] *= length; + radius[m] = 0.5 * length; + rmass[m] *= length; bonus[nlocal_bonus].ilocal = m; line[m] = nlocal_bonus++; @@ -402,10 +393,10 @@ bigint AtomVecLine::memory_usage_bonus() 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; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] = 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + line[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -415,24 +406,24 @@ void AtomVecLine::create_atom_post(int ilocal) void AtomVecLine::data_atom_post(int ilocal) { - line_flag = atom->line[ilocal]; + line_flag = 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; + line[ilocal] = line_flag; - if (atom->rmass[ilocal] <= 0.0) + if (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; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + } else radius[ilocal] = 0.0; - atom->omega[ilocal][0] = 0.0; - atom->omega[ilocal][1] = 0.0; - atom->omega[ilocal][2] = 0.0; + omega[ilocal][0] = 0.0; + omega[ilocal][1] = 0.0; + omega[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -441,16 +432,16 @@ void AtomVecLine::data_atom_post(int ilocal) void AtomVecLine::pack_data_pre(int ilocal) { - line_flag = atom->line[ilocal]; - rmass = atom->rmass[ilocal]; + line_flag = line[ilocal]; + rmass_one = rmass[ilocal]; - if (line_flag < 0) atom->line[ilocal] = 0; - else atom->line[ilocal] = 1; + if (line_flag < 0) line[ilocal] = 0; + else 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; + double radius_one = radius[ilocal]; + rmass[ilocal] /= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + } else rmass[ilocal] /= bonus[line_flag].length; } /* ---------------------------------------------------------------------- @@ -459,8 +450,8 @@ void AtomVecLine::pack_data_pre(int ilocal) void AtomVecLine::pack_data_post(int ilocal) { - atom->line[ilocal] = line_flag; - atom->rmass[ilocal] = rmass; + line[ilocal] = line_flag; + rmass[ilocal] = rmass_one; } /* ---------------------------------------------------------------------- @@ -471,8 +462,6 @@ void AtomVecLine::pack_data_post(int ilocal) 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(); @@ -489,8 +478,8 @@ void AtomVecLine::set_length(int i, double 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; + radius[i] = 0.5 * value; + if (value == 0.0) radius[i] = 0.5; } /* ---------------------------------------------------------------------- diff --git a/src/atom_vec_line.h b/src/atom_vec_line.h index a47843f4f2..7bca58c64b 100644 --- a/src/atom_vec_line.h +++ b/src/atom_vec_line.h @@ -36,6 +36,7 @@ class AtomVecLine : public AtomVec { ~AtomVecLine(); void init(); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -62,9 +63,13 @@ class AtomVecLine : public AtomVec { int nlocal_bonus; private: + int *line; + double *radius,*rmass; + double **omega; + int nghost_bonus,nmax_bonus; int line_flag; - double rmass; + double rmass_one; void grow_bonus(); void copy_bonus_all(int, int); diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index b601fc8f7c..64a198c94d 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -100,14 +100,25 @@ void AtomVecSphere::init() } } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecSphere::grow_pointers() +{ + radius = atom->radius; + rmass = atom->rmass; +} + /* ---------------------------------------------------------------------- initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecSphere::create_atom_post(int ilocal) { - atom->radius[ilocal] = 0.5; - atom->rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5; + radius[ilocal] = 0.5; + rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5; } /* ---------------------------------------------------------------------- @@ -117,13 +128,12 @@ void AtomVecSphere::create_atom_post(int ilocal) void AtomVecSphere::data_atom_post(int ilocal) { - double radius = 0.5 * atom->radius[ilocal]; - atom->radius[ilocal] = radius; - if (radius > 0.0) - atom->rmass[ilocal] = - 4.0*MY_PI/3.0 * radius*radius*radius * atom->rmass[ilocal]; + radius_one = 0.5 * atom->radius[ilocal]; + radius[ilocal] = radius_one; + if (radius_one > 0.0) + rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); } @@ -132,13 +142,14 @@ void AtomVecSphere::data_atom_post(int ilocal) ------------------------------------------------------------------------- */ void AtomVecSphere::pack_data_pre(int ilocal) -{ - radius = atom->radius[ilocal]; - rmass = atom->rmass[ilocal]; +{ + radius_one = radius[ilocal]; + rmass_one = rmass[ilocal]; - atom->radius[ilocal] *= 2.0; - if (radius == 0.0) - atom->rmass[ilocal] = rmass / (4.0*MY_PI/3.0 * radius*radius*radius); + radius[ilocal] *= 2.0; + if (radius_one!= 0.0) + rmass[ilocal] = + rmass_one / (4.0*MY_PI/3.0 * radius_one*radius_one*radius_one); } /* ---------------------------------------------------------------------- @@ -146,7 +157,7 @@ void AtomVecSphere::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecSphere::pack_data_post(int ilocal) -{ - atom->radius[ilocal] = radius; - atom->rmass[ilocal] = rmass; +{ + radius[ilocal] = radius_one; + rmass[ilocal] = rmass_one; } diff --git a/src/atom_vec_sphere.h b/src/atom_vec_sphere.h index c205ba43de..2b735f1163 100644 --- a/src/atom_vec_sphere.h +++ b/src/atom_vec_sphere.h @@ -29,14 +29,18 @@ class AtomVecSphere : public AtomVec { AtomVecSphere(class LAMMPS *); void process_args(int, char **); void init(); + + void grow_pointers(); void create_atom_post(int); void data_atom_post(int); void pack_data_pre(int); void pack_data_post(int); private: + double *radius,*rmass; + int radvary; - double radius,rmass; + double radius_one,rmass_one; }; } diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 7345646a1e..b130198075 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -88,6 +88,20 @@ void AtomVecTri::init() error->all(FLERR,"Atom_style tri can only be used in 3d simulations"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecTri::grow_pointers() +{ + tri = atom->tri; + radius = atom->radius; + rmass = atom->rmass; + omega = atom->omega; + angmom = atom->angmom; +} + /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -109,8 +123,6 @@ void AtomVecTri::grow_bonus() void AtomVecTri::copy_bonus(int i, int j, int delflag) { - int *tri = atom->tri; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && tri[j] >= 0) { @@ -132,7 +144,7 @@ void AtomVecTri::copy_bonus(int i, int j, int delflag) void AtomVecTri::copy_bonus_all(int i, int j) { - atom->tri[bonus[i].ilocal] = j; + tri[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -157,8 +169,6 @@ 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]; @@ -181,8 +191,6 @@ 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++) { @@ -203,8 +211,6 @@ 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]; @@ -245,8 +251,6 @@ 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++) { @@ -294,8 +298,6 @@ int AtomVecTri::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *tri = atom->tri; - if (tri[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -332,8 +334,6 @@ int AtomVecTri::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *tri = atom->tri; - tri[ilocal] = (int) ubuf(buf[m++]).i; if (tri[ilocal] == 0) tri[ilocal] = -1; else { @@ -375,8 +375,6 @@ int AtomVecTri::size_restart_bonus() { int i; - int *tri = atom->tri; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -395,8 +393,6 @@ int AtomVecTri::pack_restart_bonus(int i, double *buf) { int m = 0; - int *tri = atom->tri; - if (tri[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -435,8 +431,6 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *tri = atom->tri; - tri[ilocal] = (int) ubuf(buf[m++]).i; if (tri[ilocal] == 0) tri[ilocal] = -1; else { @@ -475,8 +469,6 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf) 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(); @@ -523,9 +515,9 @@ void AtomVecTri::data_atom_bonus(int m, char **values) if (delta/size > EPSILON) error->one(FLERR,"Inconsistent triangle in data file"); - atom->x[m][0] = centroid[0]; - atom->x[m][1] = centroid[1]; - atom->x[m][2] = centroid[2]; + x[m][0] = centroid[0]; + x[m][1] = centroid[1]; + x[m][2] = centroid[2]; // reset tri radius and mass // rmass currently holds density @@ -533,22 +525,22 @@ void AtomVecTri::data_atom_bonus(int m, char **values) double c4[3]; MathExtra::sub3(c1,centroid,c4); - atom->radius[m] = MathExtra::lensq3(c4); + radius[m] = MathExtra::lensq3(c4); MathExtra::sub3(c2,centroid,c4); - atom->radius[m] = MAX(atom->radius[m],MathExtra::lensq3(c4)); + radius[m] = MAX(radius[m],MathExtra::lensq3(c4)); MathExtra::sub3(c3,centroid,c4); - atom->radius[m] = MAX(atom->radius[m],MathExtra::lensq3(c4)); - atom->radius[m] = sqrt(atom->radius[m]); + radius[m] = MAX(radius[m],MathExtra::lensq3(c4)); + radius[m] = sqrt(radius[m]); double norm[3]; MathExtra::cross3(c2mc1,c3mc1,norm); double area = 0.5 * MathExtra::len3(norm); - atom->rmass[m] *= area; + rmass[m] *= area; // inertia = inertia tensor of triangle as 6-vector in Voigt notation double inertia[6]; - MathExtra::inertia_triangle(c1,c2,c3,atom->rmass[m],inertia); + MathExtra::inertia_triangle(c1,c2,c3,rmass[m],inertia); // diagonalize inertia tensor via Jacobi rotations // bonus[].inertia = 3 eigenvalues = principal moments of inertia @@ -622,10 +614,10 @@ bigint AtomVecTri::memory_usage_bonus() 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; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] = 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + tri[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -635,27 +627,27 @@ void AtomVecTri::create_atom_post(int ilocal) void AtomVecTri::data_atom_post(int ilocal) { - tri_flag = atom->tri[ilocal]; + tri_flag = 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; + tri[ilocal] = tri_flag; - if (atom->rmass[ilocal] <= 0.0) + if (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; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + } else 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; + omega[ilocal][0] = 0.0; + omega[ilocal][1] = 0.0; + omega[ilocal][2] = 0.0; + angmom[ilocal][0] = 0.0; + angmom[ilocal][1] = 0.0; + angmom[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -664,22 +656,22 @@ void AtomVecTri::data_atom_post(int ilocal) void AtomVecTri::pack_data_pre(int ilocal) { - tri_flag = atom->tri[ilocal]; - rmass = atom->rmass[ilocal]; + tri_flag = tri[ilocal]; + rmass_one = rmass[ilocal]; - if (tri_flag < 0) atom->tri[ilocal] = 0; - else atom->tri[ilocal] = 1; + if (tri_flag < 0) tri[ilocal] = 0; + else tri[ilocal] = 1; if (tri_flag < 0) { - double radius = atom->radius[ilocal]; - atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * radius*radius*radius; + double radius_one = radius[ilocal]; + rmass[ilocal] /= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; } 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; + rmass[ilocal] /= area; } } @@ -689,8 +681,8 @@ void AtomVecTri::pack_data_pre(int ilocal) void AtomVecTri::pack_data_post(int ilocal) { - atom->tri[ilocal] = tri_flag; - atom->rmass[ilocal] = rmass; + tri[ilocal] = tri_flag; + rmass[ilocal] = rmass_one; } /* ---------------------------------------------------------------------- @@ -704,8 +696,6 @@ 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(); @@ -730,11 +720,11 @@ void AtomVecTri::set_equilateral(int i, double size) 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); + radius[i] = MathExtra::len3(c1); bonus[nlocal_bonus].ilocal = i; tri[i] = nlocal_bonus++; } else if (size == 0.0) { - atom->radius[i] = 0.5; + radius[i] = 0.5; copy_bonus_all(nlocal_bonus-1,tri[i]); nlocal_bonus--; tri[i] = -1; @@ -755,6 +745,6 @@ void AtomVecTri::set_equilateral(int i, double size) 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); + radius[i] = MathExtra::len3(c1); } } diff --git a/src/atom_vec_tri.h b/src/atom_vec_tri.h index ad4c0103ca..0b16285fe6 100644 --- a/src/atom_vec_tri.h +++ b/src/atom_vec_tri.h @@ -38,6 +38,7 @@ class AtomVecTri : public AtomVec { ~AtomVecTri(); void init(); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -64,9 +65,13 @@ class AtomVecTri : public AtomVec { int nlocal_bonus; private: + int *tri; + double *radius,*rmass; + double **omega,**angmom; + int nghost_bonus,nmax_bonus; int tri_flag; - double rmass; + double rmass_one; void grow_bonus(); void copy_bonus_all(int, int); diff --git a/src/replicate.cpp b/src/replicate.cpp index 3659f7cf7a..26b61769b0 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -100,7 +100,8 @@ void Replicate::command(int narg, char **arg) maxmol = maxmol_all; } - // check image flags maximum extent; only efficient small image flags compared to new system + // check image flags maximum extent + // only efficient small image flags compared to new system int _imagelo[3], _imagehi[3]; _imagelo[0] = 0; From ccc8f29d60cabd9971c7db62b9db1e84b95d6aa8 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 18 Dec 2019 12:04:37 -0700 Subject: [PATCH 10/42] added support for USER-AWPMD package --- src/USER-AWPMD/atom_vec_wavepacket.cpp | 25 +++++++++++------ src/USER-AWPMD/atom_vec_wavepacket.h | 6 ++++ src/USER-AWPMD/pair_awpmd_cut.cpp | 26 +++++++++--------- src/USER-SMD/atom_vec_smd.cpp | 2 +- src/atom.cpp | 8 +++--- src/atom.h | 6 ++-- src/atom_vec.cpp | 7 ++--- src/atom_vec_body.cpp | 9 ++---- src/atom_vec_body.h | 2 +- src/atom_vec_hybrid.cpp | 38 ++++++++++++++++++++++---- src/atom_vec_hybrid.h | 3 +- 11 files changed, 86 insertions(+), 46 deletions(-) diff --git a/src/USER-AWPMD/atom_vec_wavepacket.cpp b/src/USER-AWPMD/atom_vec_wavepacket.cpp index d643ae8e0a..c71a3cb6c2 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.cpp +++ b/src/USER-AWPMD/atom_vec_wavepacket.cpp @@ -61,6 +61,20 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecWavepacket::grow_pointers() +{ + q = atom->q; + spin = atom->spin; + eradius = atom->eradius; + ervel = atom->ervel; + erforce = atom->erforce; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -68,7 +82,7 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) void AtomVecWavepacket::force_clear(int n, size_t nbytes) { - memset(&atom->erforce[n],0,nbytes); + memset(&erforce[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -78,7 +92,7 @@ void AtomVecWavepacket::force_clear(int n, size_t nbytes) void AtomVecWavepacket::create_atom_post(int ilocal) { - atom->q[ilocal] = 1.0; + q[ilocal] = 1.0; } /* ---------------------------------------------------------------------- @@ -88,7 +102,7 @@ void AtomVecWavepacket::create_atom_post(int ilocal) void AtomVecWavepacket::data_atom_post(int ilocal) { - atom->ervel[ilocal] = 0.0; + ervel[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -113,33 +127,28 @@ int AtomVecWavepacket::property_atom(char *name) void AtomVecWavepacket::pack_property_atom(int index, double *buf, int nvalues, int groupbit) { - int *mask = atom->mask; int nlocal = atom->nlocal; 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; diff --git a/src/USER-AWPMD/atom_vec_wavepacket.h b/src/USER-AWPMD/atom_vec_wavepacket.h index e7db15db14..123414eeb7 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.h +++ b/src/USER-AWPMD/atom_vec_wavepacket.h @@ -27,11 +27,17 @@ namespace LAMMPS_NS { class AtomVecWavepacket : public AtomVec { public: AtomVecWavepacket(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + int *spin; + double *q,*eradius,*ervel,*erforce; }; } diff --git a/src/USER-AWPMD/pair_awpmd_cut.cpp b/src/USER-AWPMD/pair_awpmd_cut.cpp index 092327c367..e382a1cb9c 100644 --- a/src/USER-AWPMD/pair_awpmd_cut.cpp +++ b/src/USER-AWPMD/pair_awpmd_cut.cpp @@ -259,7 +259,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) Vector_3 xx=Vector_3(x[i][0],x[i][1],x[i][2]); Vector_3 rv=m*Vector_3(v[i][0],v[i][1],v[i][2]); double pv=ermscale*m*atom->ervel[i]; - Vector_2 cc=Vector_2(atom->cs[2*i],atom->cs[2*i+1]); + Vector_2 cc=Vector_2(atom->cs[i][0],atom->cs[i][1]); gmap[i]=wpmd->add_split(xx,rv,atom->eradius[i],pv,cc,1.,atom->q[i],itag[i] : -atom->tag[i]); // resetting for the case constraints were applied v[i][0]=rv[0]/m; @@ -284,7 +284,7 @@ void PairAWPMDCut::compute(int eflag, int vflag) } else { // electron int iel=gmap[i]; int s=spin[i] >0 ? 0 : 1; - wpmd->get_wp_force(s,iel,(Vector_3 *)f[i],(Vector_3 *)(atom->vforce+3*i),atom->erforce+i,atom->ervelforce+i,(Vector_2 *)(atom->csforce+2*i)); + wpmd->get_wp_force(s,iel,(Vector_3 *)f[i],(Vector_3 *)(atom->vforce[i]),atom->erforce+i,atom->ervelforce+i,(Vector_2 *)(atom->csforce[i])); } } @@ -671,11 +671,11 @@ void PairAWPMDCut::min_xf_get(int /* ignore */) double *eradius = atom->eradius; double *erforce = atom->erforce; double **v=atom->v; - double *vforce=atom->vforce; + double **vforce=atom->vforce; double *ervel=atom->ervel; double *ervelforce=atom->ervelforce; - double *cs=atom->cs; - double *csforce=atom->csforce; + double **cs=atom->cs; + double **csforce=atom->csforce; int *spin = atom->spin; int nlocal = atom->nlocal; @@ -686,14 +686,14 @@ void PairAWPMDCut::min_xf_get(int /* ignore */) min_varforce[7*i] = eradius[i]*erforce[i]; for(int j=0;j<3;j++){ min_var[7*i+1+3*j] = v[i][j]; - min_varforce[7*i+1+3*j] = vforce[3*i+j]; + min_varforce[7*i+1+3*j] = vforce[i][j]; } min_var[7*i+4] = ervel[i]; min_varforce[7*i+4] = ervelforce[i]; - min_var[7*i+5] = cs[2*i]; - min_varforce[7*i+5] = csforce[2*i]; - min_var[7*i+6] = cs[2*i+1]; - min_varforce[7*i+6] = csforce[2*i+1]; + min_var[7*i+5] = cs[i][0]; + min_varforce[7*i+5] = csforce[i][0]; + min_var[7*i+6] = cs[i][1]; + min_varforce[7*i+6] = csforce[i][1]; } else { for(int j=0;j<7;j++) @@ -710,7 +710,7 @@ void PairAWPMDCut::min_x_set(int /* ignore */) double *eradius = atom->eradius; double **v=atom->v; double *ervel=atom->ervel; - double *cs=atom->cs; + double **cs=atom->cs; int *spin = atom->spin; int nlocal = atom->nlocal; @@ -721,8 +721,8 @@ void PairAWPMDCut::min_x_set(int /* ignore */) for(int j=0;j<3;j++) v[i][j]=min_var[7*i+1+3*j]; ervel[i]=min_var[7*i+4]; - cs[2*i]=min_var[7*i+5]; - cs[2*i+1]=min_var[7*i+6]; + cs[i][0]=min_var[7*i+5]; + cs[i][1]=min_var[7*i+6]; } } } diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 4c8126d2cc..42978d67d6 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -90,7 +90,7 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) "x0 vest vfrac rmass radius contact_radius molecule e " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage"; fields_data_atom = (char *) - "id type molecule vfrac rmass radius contact_radius x"; + "id type molecule vfrac rmass radius contact_radius x0 x"; fields_data_vel = (char *) "id v"; // set these array sizes based on defines diff --git a/src/atom.cpp b/src/atom.cpp index 353ed510a4..1470c873a6 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -134,8 +134,8 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) spin = NULL; eradius = ervel = erforce = NULL; - ervelforce = cs = csforce = NULL; - vforce = NULL; + ervelforce = NULL; + cs = csforce = vforce = NULL; etag = NULL; // USER-DPD package @@ -512,8 +512,8 @@ void Atom::peratom_create() // USER-AWPMD package - add_peratom("cs",&cs,DOUBLE,0); - add_peratom("csforce",&csforce,DOUBLE,0); + add_peratom("cs",&cs,DOUBLE,2); + add_peratom("csforce",&csforce,DOUBLE,2); add_peratom("vforce",&vforce,DOUBLE,3); add_peratom("ervelforce",&ervelforce,DOUBLE,0); add_peratom("etag",&etag,INT,0); diff --git a/src/atom.h b/src/atom.h index 6c7110b5be..ab1ad35f5f 100644 --- a/src/atom.h +++ b/src/atom.h @@ -109,8 +109,8 @@ class Atom : protected Pointers { int *spin; double *eradius,*ervel,*erforce; - double *ervelforce,*cs,*csforce; - double **vforce; + double *ervelforce; + double **cs,**csforce,**vforce; int *etag; // USER-DPD package @@ -322,7 +322,7 @@ class Atom : protected Pointers { inline int get_map_size() {return map_tag_max+1;}; inline int get_map_maxarray() {return map_maxarray+1;}; - // NOTE: placeholder method until AtomVec is refactored + // NOTE: placeholder method until KOKKOS/AtomVec is refactored int memcheck(const char *) {return 1;} bigint memory_usage(); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index fac4cc2f6e..77ba68f651 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -1368,7 +1368,7 @@ int AtomVec::size_restart() int i,nn,cols,collength,ncols; void *plength; - // NOTE: need to worry about overflow of returned int ?? + // NOTE: need to worry about overflow of returned int N int nlocal = atom->nlocal; @@ -1738,9 +1738,9 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, char **values) // error checks applicable to all styles - if (atom->tag[nlocal] <= 0) + if (tag[nlocal] <= 0) error->one(FLERR,"Invalid atom ID in Atoms section of data file"); - if (atom->type[nlocal] <= 0 || atom->type[nlocal] > atom->ntypes) + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) error->one(FLERR,"Invalid atom type in Atoms section of data file"); // if needed, modify unpacked values or initialize other peratom values @@ -2388,7 +2388,6 @@ void AtomVec::setup_fields() } // set style-specific sizes - // NOTE: check for others vars in atom_vec.cpp/h ?? comm_x_only = 1; if (ncomm) comm_x_only = 0; diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 0f3557596f..c262f1a5b6 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -132,15 +132,12 @@ void AtomVecBody::process_args(int narg, char **arg) } /* ---------------------------------------------------------------------- - grow atom arrays - must set local copy of body ptr - needed in replicate when 2 atom classes exist and pack_restart() is called + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() ------------------------------------------------------------------------- */ -void AtomVecBody::grow(int n) +void AtomVecBody::grow_pointers() { - AtomVec::grow(n); - body = atom->body; rmass = atom->rmass; radius = atom->radius; diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index adfc7768eb..a47cfb3b54 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -43,7 +43,7 @@ class AtomVecBody : public AtomVec { ~AtomVecBody(); void process_args(int, char **); - void grow(int); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index d1166e5a8e..965bfe8543 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -31,12 +31,10 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) keywords = NULL; fieldstrings = NULL; + bonus_flag = 0; nstyles_bonus = 0; styles_bonus = NULL; - // NOTE: set bonus_flag if any substyle does - // set nstyles_bonus, styles_bonus - // these strings will be concatenated from sub-style strings // fields_data_atom & fields_data_vel start with fields common to all styles @@ -45,6 +43,8 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) fields_exchange = fields_restart = fields_create = (char *) ""; fields_data_atom = (char *) "id type x"; fields_data_vel = (char *) "id v"; + + fields_allocated = 0; } /* ---------------------------------------------------------------------- */ @@ -56,7 +56,10 @@ AtomVecHybrid::~AtomVecHybrid() for (int k = 0; k < nstyles; k++) delete [] keywords[k]; delete [] keywords; - // NOTE: need to check these have actually been allocated + for (int k = 0; k < nstyles_bonus; k++) delete styles_bonus[k]; + delete [] styles_bonus; + + if (!fields_allocated) return; delete [] fields_grow; delete [] fields_copy; @@ -198,6 +201,8 @@ void AtomVecHybrid::process_args(int narg, char **arg) fields_data_atom = merge_fields(10,fields_data_atom,0,null); fields_data_vel = merge_fields(11,fields_data_vel,0,null); + fields_allocated = 1; + // check concat_grow for multiple special-case fields // may cause issues with style-specific create_atom() and data_atom() methods // issue warnings if appear in multiple sub-styles @@ -219,6 +224,23 @@ void AtomVecHybrid::process_args(int narg, char **arg) delete [] concat_grow; + // set bonus_flag if any substyle has bonus data + // set nstyles_bonus & styles_bonus + + nstyles_bonus = 0; + for (int k = 0; k < nstyles; k++) + if (styles[k]->bonus_flag) nstyles_bonus++; + + if (nstyles_bonus) { + bonus_flag = 1; + styles_bonus = new AtomVec*[nstyles_bonus]; + nstyles_bonus = 0; + for (int k = 0; k < nstyles; k++) { + if (styles[k]->bonus_flag) + styles_bonus[nstyles_bonus++] = styles[k]; + } + } + // parent AtomVec can now operate on merged fields setup_fields(); @@ -326,7 +348,13 @@ void AtomVecHybrid::copy_bonus(int i, int j, int delflag) styles_bonus[k]->copy_bonus(i,j,delflag); } -// NOTE: need a clear_bonus() ? +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::clear_bonus() +{ + for (int k = 0; k < nstyles_bonus; k++) + styles_bonus[k]->clear_bonus(); +} /* ---------------------------------------------------------------------- */ diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 7d8e45c579..69b0aab7b7 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -38,7 +38,7 @@ class AtomVecHybrid : public AtomVec { void grow_pointers(); void force_clear(int, size_t); void copy_bonus(int, int, int); - void clear_bonus() {} + void clear_bonus(); int pack_comm_bonus(int, int *, double *); void unpack_comm_bonus(int, int, double *); int pack_border_bonus(int, int *, double *); @@ -64,6 +64,7 @@ class AtomVecHybrid : public AtomVec { private: int nallstyles; char **allstyles; + int fields_allocated; struct FieldStrings { char **fstr; From 44178a335e37dbe33d4a10988baedb15afd22424 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 29 Jan 2020 13:56:34 -0700 Subject: [PATCH 11/42] Propagate rename to Kokkos styles --- src/KOKKOS/atom_kokkos.cpp | 2 +- src/KOKKOS/atom_vec_angle_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_angle_kokkos.h | 2 +- src/KOKKOS/atom_vec_atomic_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_atomic_kokkos.h | 2 +- src/KOKKOS/atom_vec_bond_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_bond_kokkos.h | 2 +- src/KOKKOS/atom_vec_charge_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_charge_kokkos.h | 2 +- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_dpd_kokkos.h | 2 +- src/KOKKOS/atom_vec_full_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_full_kokkos.h | 2 +- src/KOKKOS/atom_vec_hybrid_kokkos.cpp | 6 +++--- src/KOKKOS/atom_vec_hybrid_kokkos.h | 2 +- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_molecular_kokkos.h | 2 +- src/KOKKOS/atom_vec_sphere_kokkos.cpp | 4 ++-- src/KOKKOS/atom_vec_sphere_kokkos.h | 2 +- 19 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/KOKKOS/atom_kokkos.cpp b/src/KOKKOS/atom_kokkos.cpp index 4637a9a21c..49fdbb95bb 100644 --- a/src/KOKKOS/atom_kokkos.cpp +++ b/src/KOKKOS/atom_kokkos.cpp @@ -237,7 +237,7 @@ void AtomKokkos::grow(unsigned int mask){ sync(Device, mask); modified(Device, mask); memoryKK->grow_kokkos(k_special,special,nmax,maxspecial,"atom:special"); - avec->grow_reset(); + avec->grow_pointers(); sync(Host, mask); } } diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 736e1c1fca..bbb5d2617d 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -98,7 +98,7 @@ void AtomVecAngleKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_angle_atom3,atomKK->angle_atom3,nmax,atomKK->angle_per_atom, "atom:angle_atom3"); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); if (atom->nextra_grow) @@ -110,7 +110,7 @@ void AtomVecAngleKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecAngleKokkos::grow_reset() +void AtomVecAngleKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_angle_kokkos.h b/src/KOKKOS/atom_vec_angle_kokkos.h index abdd48fce5..4fc71725b0 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.h +++ b/src/KOKKOS/atom_vec_angle_kokkos.h @@ -58,7 +58,7 @@ class AtomVecAngleKokkos : public AtomVecKokkos { int write_data_hybrid(FILE *, double *); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, const int & iswap, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index 4fec5740d6..7b657fa0d1 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -74,7 +74,7 @@ void AtomVecAtomicKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_v,atomKK->v,nmax,3,"atom:v"); memoryKK->grow_kokkos(atomKK->k_f,atomKK->f,nmax,3,"atom:f"); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); if (atom->nextra_grow) @@ -86,7 +86,7 @@ void AtomVecAtomicKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecAtomicKokkos::grow_reset() +void AtomVecAtomicKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.h b/src/KOKKOS/atom_vec_atomic_kokkos.h index e4d2654e2c..212132ef60 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.h +++ b/src/KOKKOS/atom_vec_atomic_kokkos.h @@ -48,7 +48,7 @@ class AtomVecAtomicKokkos : public AtomVecKokkos { void write_data(FILE *, int, double **); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, int pbc_flag, int *pbc, ExecutionSpace space); diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index 74c05a506c..60ea024c08 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -84,7 +84,7 @@ void AtomVecBondKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_bond_type,atomKK->bond_type,nmax,atomKK->bond_per_atom,"atom:bond_type"); memoryKK->grow_kokkos(atomKK->k_bond_atom,atomKK->bond_atom,nmax,atomKK->bond_per_atom,"atom:bond_atom"); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); if (atom->nextra_grow) @@ -96,7 +96,7 @@ void AtomVecBondKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecBondKokkos::grow_reset() +void AtomVecBondKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_bond_kokkos.h b/src/KOKKOS/atom_vec_bond_kokkos.h index 7ec15450ef..f38ade8f64 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.h +++ b/src/KOKKOS/atom_vec_bond_kokkos.h @@ -52,7 +52,7 @@ class AtomVecBondKokkos : public AtomVecKokkos { int write_data_hybrid(FILE *, double *); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, int pbc_flag, int *pbc, ExecutionSpace space); diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 3f26b1e9ea..f50bc6bd62 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -79,7 +79,7 @@ void AtomVecChargeKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_q,atomKK->q,nmax,"atom:q"); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); if (atom->nextra_grow) @@ -91,7 +91,7 @@ void AtomVecChargeKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecChargeKokkos::grow_reset() +void AtomVecChargeKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_charge_kokkos.h b/src/KOKKOS/atom_vec_charge_kokkos.h index e9ff70bbe1..39d641b844 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.h +++ b/src/KOKKOS/atom_vec_charge_kokkos.h @@ -53,7 +53,7 @@ class AtomVecChargeKokkos : public AtomVecKokkos { int write_data_hybrid(FILE *, double *); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, int pbc_flag, int *pbc, ExecutionSpace space); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 144ef26f19..2885c292c1 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -93,7 +93,7 @@ void AtomVecDPDKokkos::grow(int n) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); } @@ -101,7 +101,7 @@ void AtomVecDPDKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecDPDKokkos::grow_reset() +void AtomVecDPDKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.h b/src/KOKKOS/atom_vec_dpd_kokkos.h index cec1b82357..e969a28cb8 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.h +++ b/src/KOKKOS/atom_vec_dpd_kokkos.h @@ -61,7 +61,7 @@ class AtomVecDPDKokkos : public AtomVecKokkos { int write_data_hybrid(FILE *, double *); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, const int & iswap, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 1fdbcbec8c..0f8aaade8a 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -123,7 +123,7 @@ void AtomVecFullKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_improper_atom4,atomKK->improper_atom4,nmax, atomKK->improper_per_atom,"atom:improper_atom4"); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); if (atom->nextra_grow) @@ -135,7 +135,7 @@ void AtomVecFullKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecFullKokkos::grow_reset() +void AtomVecFullKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_full_kokkos.h b/src/KOKKOS/atom_vec_full_kokkos.h index 33760a8b5f..a2d4fa9cf4 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.h +++ b/src/KOKKOS/atom_vec_full_kokkos.h @@ -52,7 +52,7 @@ class AtomVecFullKokkos : public AtomVecKokkos { int write_data_hybrid(FILE *, double *); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, int pbc_flag, int *pbc, ExecutionSpace space); diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp index 40303051b2..8f8a0c8c00 100644 --- a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp +++ b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp @@ -163,7 +163,7 @@ void AtomVecHybridKokkos::grow(int n) // for sub-styles, do this in case // multiple sub-style reallocs of same array occurred - grow_reset(); + grow_pointers(); if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) @@ -174,7 +174,7 @@ void AtomVecHybridKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecHybridKokkos::grow_reset() +void AtomVecHybridKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; @@ -216,7 +216,7 @@ void AtomVecHybridKokkos::grow_reset() d_angmom = atomKK->k_angmom.d_view; h_angmom = atomKK->k_angmom.h_view; - for (int k = 0; k < nstyles; k++) styles[k]->grow_reset(); + for (int k = 0; k < nstyles; k++) styles[k]->grow_pointers(); } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.h b/src/KOKKOS/atom_vec_hybrid_kokkos.h index 4cfb186b17..02f9044d73 100644 --- a/src/KOKKOS/atom_vec_hybrid_kokkos.h +++ b/src/KOKKOS/atom_vec_hybrid_kokkos.h @@ -36,7 +36,7 @@ class AtomVecHybridKokkos : public AtomVecKokkos { void process_args(int, char **); void init(); void grow(int); - void grow_reset(); + void grow_pointers(); void copy(int, int, int); void clear_bonus(); void force_clear(int, size_t); diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index f3b4ae98ca..0c4bf483d3 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -121,7 +121,7 @@ void AtomVecMolecularKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_improper_atom4,atomKK->improper_atom4,nmax, atomKK->improper_per_atom,"atom:improper_atom4"); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); if (atom->nextra_grow) @@ -133,7 +133,7 @@ void AtomVecMolecularKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecMolecularKokkos::grow_reset() +void AtomVecMolecularKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.h b/src/KOKKOS/atom_vec_molecular_kokkos.h index 06444510e0..cede4f42a8 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.h +++ b/src/KOKKOS/atom_vec_molecular_kokkos.h @@ -58,7 +58,7 @@ class AtomVecMolecularKokkos : public AtomVecKokkos { int write_data_hybrid(FILE *, double *); bigint memory_usage(); - void grow_reset(); + void grow_pointers(); int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, const int & iswap, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 67aaa32c21..35f93294a8 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -119,7 +119,7 @@ void AtomVecSphereKokkos::grow(int n) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); - grow_reset(); + grow_pointers(); atomKK->sync(Host,ALL_MASK); } @@ -127,7 +127,7 @@ void AtomVecSphereKokkos::grow(int n) reset local array ptrs ------------------------------------------------------------------------- */ -void AtomVecSphereKokkos::grow_reset() +void AtomVecSphereKokkos::grow_pointers() { tag = atomKK->tag; d_tag = atomKK->k_tag.d_view; diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.h b/src/KOKKOS/atom_vec_sphere_kokkos.h index 28c8a3c8f6..3f6d34e8b2 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.h +++ b/src/KOKKOS/atom_vec_sphere_kokkos.h @@ -33,7 +33,7 @@ class AtomVecSphereKokkos : public AtomVecKokkos { ~AtomVecSphereKokkos() {} void init(); void grow(int); - void grow_reset(); + void grow_pointers(); void copy(int, int, int); int pack_comm(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *); From 34778c4919d21fd12d8e9a5ff870c1862bb28157 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 29 Jan 2020 14:10:42 -0700 Subject: [PATCH 12/42] Restore virtual keyword for Kokkos package --- src/atom_vec.h | 66 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/atom_vec.h b/src/atom_vec.h index 94517f80ad..b34ee5adb4 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -74,41 +74,41 @@ class AtomVec : protected Pointers { virtual void force_clear(int, size_t) {} - void grow(int); + virtual void grow(int); virtual void grow_pointers() {} - void copy(int, int, int); + virtual void copy(int, int, int); 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(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 *); 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 *); + virtual int pack_reverse(int, int, double *); + virtual void unpack_reverse(int, int *, double *); - int pack_border(int, int *, double *, int, int *); - int pack_border_vel(int, int *, double *, int, int *); - void unpack_border(int, int, double *); - void unpack_border_vel(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_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(int, double *); + virtual int unpack_exchange(double *); virtual int pack_exchange_bonus(int, double *) {} virtual int unpack_exchange_bonus(int, double *) {} - int size_restart(); - int pack_restart(int, double *); - int unpack_restart(double *); + virtual int size_restart(); + virtual int pack_restart(int, double *); + virtual int unpack_restart(double *); virtual void pack_restart_pre(int) {} virtual void pack_restart_post(int) {} @@ -118,36 +118,36 @@ class AtomVec : protected Pointers { virtual int pack_restart_bonus(int, double *) {} virtual int unpack_restart_bonus(int, double *) {} - void create_atom(int, double *); + virtual void create_atom(int, double *); virtual void create_atom_post(int) {} - void data_atom(double *, imageint, char **); + virtual void data_atom(double *, imageint, char **); virtual void data_atom_post(int) {} virtual void data_atom_bonus(int, char **) {} virtual void data_body(int, int, int, int *, double *) {} - void pack_data(double **); - void write_data(FILE *, int, double **); + virtual void pack_data(double **); + virtual void write_data(FILE *, int, double **); virtual void pack_data_pre(int) {} virtual void pack_data_post(int) {} - void data_vel(int, char **); - void pack_vel(double **); - void write_vel(FILE *, int, double **); + virtual void data_vel(int, char **); + virtual void pack_vel(double **); + virtual void write_vel(FILE *, int, double **); - int pack_bond(tagint **); - void write_bond(FILE *, int, tagint **, int); - int pack_angle(tagint **); - void write_angle(FILE *, int, tagint **, int); - int pack_dihedral(tagint **); - void write_dihedral(FILE *, int, tagint **, int); - int pack_improper(tagint **); - void write_improper(FILE *, int, tagint **, int); + virtual int pack_bond(tagint **); + virtual void write_bond(FILE *, int, tagint **, int); + virtual int pack_angle(tagint **); + virtual void write_angle(FILE *, int, tagint **, int); + virtual int pack_dihedral(tagint **); + virtual void write_dihedral(FILE *, int, tagint **, int); + virtual int pack_improper(tagint **); + virtual void write_improper(FILE *, int, tagint **, int); virtual int property_atom(char *) {return -1;} virtual void pack_property_atom(int, double *, int, int) {} - bigint memory_usage(); + virtual bigint memory_usage(); virtual bigint memory_usage_bonus() {} protected: From d34f9af2914ff8aa3e214a022509979bb29b638d Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Jan 2020 14:27:45 -0700 Subject: [PATCH 13/42] fixed bug with writing of data file velocities --- src/atom_vec.cpp | 64 +++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 77ba68f651..08f9c54e56 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -1979,47 +1979,43 @@ void AtomVec::write_vel(FILE *fp, int n, double **buf) void *pdata; for (i = 0; i < n; i++) { - fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e\n", - (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]); + fprintf(fp,TAGINT_FORMAT,(tagint) ubuf(buf[i][0]).i); - if (ndata_vel) { - j = 4; - for (nn = 0; nn < ndata_vel; nn++) { - pdata = mdata_vel.pdata[nn]; - datatype = mdata_vel.datatype[nn]; - cols = mdata_vel.cols[nn]; - if (datatype == DOUBLE) { - if (cols == 0) { - double *vec = *((double **) pdata); + j = 1; + for (nn = 1; nn < ndata_vel; nn++) { + pdata = mdata_vel.pdata[nn]; + datatype = mdata_vel.datatype[nn]; + cols = mdata_vel.cols[nn]; + if (datatype == DOUBLE) { + if (cols == 0) { + double *vec = *((double **) pdata); + fprintf(fp," %-1.16e",buf[i][j++]); + } else { + double **array = *((double ***) pdata); + for (m = 0; m < cols; m++) fprintf(fp," %-1.16e",buf[i][j++]); - } else { - double **array = *((double ***) pdata); - for (m = 0; m < cols; m++) - fprintf(fp," %-1.16e",buf[i][j++]); - } - } else if (datatype == INT) { - if (cols == 0) { - int *vec = *((int **) pdata); + } + } else if (datatype == INT) { + if (cols == 0) { + int *vec = *((int **) pdata); + fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); + } else { + int **array = *((int ***) pdata); + for (m = 0; m < cols; m++) fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); - } else { - int **array = *((int ***) pdata); - for (m = 0; m < cols; m++) - fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); - } - } else if (datatype == BIGINT) { - if (cols == 0) { - bigint *vec = *((bigint **) pdata); + } + } else if (datatype == BIGINT) { + if (cols == 0) { + bigint *vec = *((bigint **) pdata); + fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); + } else { + bigint **array = *((bigint ***) pdata); + for (m = 0; m < cols; m++) fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); - } else { - bigint **array = *((bigint ***) pdata); - for (m = 0; m < cols; m++) - fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); - } } } } - - fprintf(fp,"\n"); + fprintf(fp,"\n"); } } From 986e5b746e1c9a2ed8e7fd3c0585ec693ca3961a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 18 Mar 2020 16:40:29 -0600 Subject: [PATCH 14/42] new doc edits for refactored AtomVec styles --- doc/src/Modify.rst | 6 - doc/src/Modify_atom.rst | 224 +++++++++------- doc/src/atom_style.rst | 64 +++-- doc/src/compute_property_atom.rst | 88 +++--- doc/src/read_data.rst | 428 +++++++++++------------------- 5 files changed, 360 insertions(+), 450 deletions(-) diff --git a/doc/src/Modify.rst b/doc/src/Modify.rst index f875084d50..531fb6b1f3 100644 --- a/doc/src/Modify.rst +++ b/doc/src/Modify.rst @@ -10,7 +10,6 @@ If you add a new feature to LAMMPS and think it will be of interest to general users, we encourage you to submit it for inclusion in LAMMPS as a pull request on our `GitHub site `_, after reading the :doc:`Modify contribute ` doc page. - .. toctree:: :maxdepth: 1 @@ -33,8 +32,3 @@ as a pull request on our `GitHub site `_, afte Modify_body Modify_thermo Modify_variable - - -.. _lws: http://lammps.sandia.gov -.. _ld: Manual.html -.. _lc: Commands_all.html diff --git a/doc/src/Modify_atom.rst b/doc/src/Modify_atom.rst index d44a805161..64f44797b5 100644 --- a/doc/src/Modify_atom.rst +++ b/doc/src/Modify_atom.rst @@ -3,122 +3,168 @@ Atom styles Classes that define an :doc:`atom style ` are derived from the AtomVec class and managed by the Atom class. The atom style -determines what attributes are associated with an atom. A new atom -style can be created if one of the existing atom styles does not -define all the attributes you need to store and communicate with -atoms. +determines what attributes are associated with an atom and +communicated when it is a ghost atom or migrates to a new processor. +A new atom style can be created if one of the existing atom styles +does not define all the attributes you need to store and communicate +with atoms. -Atom\_vec\_atomic.cpp is a simple example of an atom style. +Atom\_vec\_atomic.cpp is the simplest example of an atom style. +Examining the code for others will make these instructions more clear. -Here is a brief description of methods you define in your new derived -class. See atom\_vec.h for details. +Note that the :doc:`atom style hybrid ` command can be +used to define atoms or particles which have the union of properties +of individual styles. Also the :doc:`fix property/atom ` command can be used to add a single property (e.g. charge +or a molecule ID) to a style that does not have it. It can also be +used to add custom properties to an atom, with options to communicate +them with ghost atoms or read them from a data file. Other LAMMPS +commands can access these custom properties, as can new pair, fix, +compute styles that are written to work with these properties. For +example, the :doc:`set ` command can be used to set the values of +custom per-atom properties from an input script. All of these methods +are less work than writing code for a new atom style. + +If you follow these directions your new style will automatically work +in tandem with others via the :doc:`atom_style hybrid ` +command. + +The first step is to define a set of strings in the constructor of the +new derived class. Each string will have zero or more space-separated +variable names which are identical to those used in the atom.h header +file for per-atom properties. Note that some represent per-atom +vectors (q, molecule) while other are per-atom arrays (x,v). For all +but the last 2 strings you do not need to specify any of +(id,type,x,v,f). Those are included automatically as needed in the +other strings. +-------------------------+--------------------------------------------------------------------------------+ -| init | one time setup (optional) | +| fields\_grow | full list of properties which is allocated and stored | +-------------------------+--------------------------------------------------------------------------------+ -| grow | re-allocate atom arrays to longer lengths (required) | +| fields\_copy | list of properties to copy atoms are rearranged on-processor | +-------------------------+--------------------------------------------------------------------------------+ -| grow\_reset | make array pointers in Atom and AtomVec classes consistent (required) | +| fields\_comm | list of properties communicated to ghost atoms every step | +-------------------------+--------------------------------------------------------------------------------+ -| copy | copy info for one atom to another atom's array locations (required) | +| fields\_comm\_vel | additional properties communicated if :doc:`comm_modify vel ` is used | +-------------------------+--------------------------------------------------------------------------------+ -| pack\_comm | store an atom's info in a buffer communicated every timestep (required) | +| fields\_reverse | list of properties summed from ghost atoms every step | +-------------------------+--------------------------------------------------------------------------------+ -| pack\_comm\_vel | add velocity info to communication buffer (required) | +| fields\_border | list of properties communicated with ghost atoms every reneighboring step | +-------------------------+--------------------------------------------------------------------------------+ -| pack\_comm\_hybrid | store extra info unique to this atom style (optional) | +| fields\_border\_vel | additional properties communicated if :doc:`comm_modify vel ` is used | +-------------------------+--------------------------------------------------------------------------------+ -| unpack\_comm | retrieve an atom's info from the buffer (required) | +| fields\_exchange | list of properties communicated when an atom migrates to another processor | +-------------------------+--------------------------------------------------------------------------------+ -| unpack\_comm\_vel | also retrieve velocity info (required) | +| fields\_restart | list of properties written/read to/from a restart file | +-------------------------+--------------------------------------------------------------------------------+ -| unpack\_comm\_hybrid | retrieve extra info unique to this atom style (optional) | +| fields\_create | list of properties defined when an atom is created by :doc:`create_atoms ` | +-------------------------+--------------------------------------------------------------------------------+ -| pack\_reverse | store an atom's info in a buffer communicating partial forces (required) | +| fields\_data\_atom | list of properties (in order) in the Atoms section of a data file, as read by :doc:`read_data ` | +-------------------------+--------------------------------------------------------------------------------+ -| pack\_reverse\_hybrid | store extra info unique to this atom style (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_reverse | retrieve an atom's info from the buffer (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_reverse\_hybrid | retrieve extra info unique to this atom style (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| pack\_border | store an atom's info in a buffer communicated on neighbor re-builds (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| pack\_border\_vel | add velocity info to buffer (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| pack\_border\_hybrid | store extra info unique to this atom style (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_border | retrieve an atom's info from the buffer (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_border\_vel | also retrieve velocity info (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_border\_hybrid | retrieve extra info unique to this atom style (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| pack\_exchange | store all an atom's info to migrate to another processor (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_exchange | retrieve an atom's info from the buffer (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| size\_restart | number of restart quantities associated with proc's atoms (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| pack\_restart | pack atom quantities into a buffer (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| unpack\_restart | unpack atom quantities from a buffer (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| create\_atom | create an individual atom of this style (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| data\_atom | parse an atom line from the data file (required) | -+-------------------------+--------------------------------------------------------------------------------+ -| data\_atom\_hybrid | parse additional atom info unique to this atom style (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| data\_vel | parse one line of velocity information from data file (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| data\_vel\_hybrid | parse additional velocity data unique to this atom style (optional) | -+-------------------------+--------------------------------------------------------------------------------+ -| memory\_usage | tally memory allocated by atom arrays (required) | +| fields\_data\_vel | list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data ` | +-------------------------+--------------------------------------------------------------------------------+ -The constructor of the derived class sets values for several variables -that you must set when defining a new atom style, which are documented -in atom\_vec.h. New atom arrays are defined in atom.cpp. Search for -the word "customize" and you will find locations you will need to -modify. +In these strings you can list variable names which LAMMPS already +defines (in some other atom style), or you can create new variable +names. You should not re-use a LAMMPS variable for something with +different meaning in your atom style. If the meaning is related, but +interpreted differently by your atom style, then using the same +variable name means a user should not use your style and the other +style together in a :doc:`atom_style hybrid ` command. +Because there will only be one value of the variable and different +parts of LAMMPS will then likely use it differently. LAMMPS has +no way of checking for this. -.. note:: +If you are defining new variable names then make them descriptive and +unique to your new atom style. For example choosing "e" for energy is +a bad choice; it is too generic. A better choice would be "e\_foo", +where "foo" is specific to your style. - It is possible to add some attributes, such as a molecule ID, to - atom styles that do not have them via the :doc:`fix property/atom ` command. This command also - allows new custom attributes consisting of extra integer or - floating-point values to be added to atoms. See the :doc:`fix property/atom ` doc page for examples of cases - where this is useful and details on how to initialize, access, and - output the custom values. +If any of the variable names in your new atom style do not exist in +LAMMPS, you need to add them to the src/atom.h and atom.cpp files. -New :doc:`pair styles `, :doc:`fixes `, or -:doc:`computes ` can be added to LAMMPS, as discussed below. -The code for these classes can use the per-atom properties defined by -fix property/atom. The Atom class has a find\_custom() method that is -useful in this context: +Search for the word "customize" or "customization" in these 2 files to +see where to add your variable. Adding a flag to the 2nd +customization section in atom.h is only necessary if your code (e.g. a +pair style) needs to check that a per-atom property is defined. These +flags should also be set in the constructor of the atom style child +class. +In atom.cpp, aside from the constructor and destructor, there are 3 +methods that a new variable name or flag needs to be added to. -.. parsed-literal:: +In Atom::peratom\_create() when using the add_peratom() method, a +final length argument of 0 is for per-atom vectors, a length > 1 is +for per-atom arrays. Note the use of an extra per-thread flag and the +add_peratom_vary() method when last dimension of the array is +variable-length. - int index = atom->find_custom(char \*name, int &flag); +Adding the variable name to Atom::extract() enable the per-atom data +to be accessed through the :doc:`LAMMPS library interface +` by a calling code, including from :doc:`Python +`. -The "name" of a custom attribute, as specified in the :doc:`fix property/atom ` command, is checked to verify -that it exists and its index is returned. The method also sets flag = -0/1 depending on whether it is an integer or floating-point attribute. -The vector of values associated with the attribute can then be -accessed using the returned index as +The constructor of the new atom style will also typically set a few +flags which are defined at the top of atom_vec.h. If these are +unclear, see how other atom styles use them. +The grow_pointers() method is also required to make +a copy of peratom data pointers, as explained in the code. -.. parsed-literal:: +There are a number of other optional methods which your atom style can +implement. These are only needed if you need to do something +out-of-the-oridinary which the default operation of the AtomVec parent +class does not take care of. The best way to figure out why they are +sometimes useful is to look at how other atom styles use them. - int \*ivector = atom->ivector[index]; - double \*dvector = atom->dvector[index]; +* process_args = use if the atom style has arguments +* init = called before each run +* force_clear = called before force computations each timestep -Ivector or dvector are vectors of length Nlocal = # of owned atoms, -which store the attributes of individual atoms. +A few atom styles define "bonus" data associated with some or all of +their particles, such as :doc:`atom_style ellipsoid or tri +`. These methods work with that data: +* copy_bonus +* clear_bonus +* pack_comm_bonus +* unpack_comm_bonus +* pack_border_bonus +* unpack_border_bonus +* pack_exchange_bonus +* unpack_exchange_bonus +* size_restart_bonus +* pack_restart_bonus +* unpack_restart_bonus +* data_atom_bonus +* memory_usage_bonus -.. _lws: http://lammps.sandia.gov -.. _ld: Manual.html -.. _lc: Commands_all.html +The :doc:`atom_style body ` command can define a particle +geomerty with an arbitrary number of values. This method reads it +from a data file: + +* data_body + +These methods are called before or after operations handled by the +parent AtomVec class. They allow an atom style to do customized +operations on the per-atom values. For example :doc:`atom_style +sphere ` reads a diameter and density of each particle +from a data file. But these need to be converted internally to a +radius and mass. That operation is done in the data_\atom\_post() +method. + +* pack_restart_pre +* pack_restart_post +* unpack_restart_init +* create_atom_post +* data_atom_post +* pack_data_pre +* pack_data_post + +These methods enable the :doc:`compute property/atom ` command to access per-atom variables it does not +already define as arguments, so that they can be written to a dump +file or used by other LAMMPS commands. + +* property_atom +* pack_property_atom diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index d2ebc220d6..a44741f891 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -6,20 +6,21 @@ atom_style command Syntax """""" - .. code-block:: LAMMPS atom_style style args -* style = *angle* or *atomic* or *body* or *bond* or *charge* or *dipole* or *dpd* or *edpd* or *mdpd* or *tdpd* or *electron* or *ellipsoid* or *full* or *line* or *meso* or *molecular* or *peri* or *smd* or *sphere* or *spin* or *tri* or *template* or *hybrid* - +* style = *angle* or *atomic* or *body* or *bond* or *charge* or *dipole* or *dpd* or *edpd* or *electron* or *ellipsoid* or *full* or *line* or *mdpd* or *meso* or *molecular* or *peri* or *smd* or *sphere* or *spin* or *tdpd* or *tri* or *template* or *hybrid* + .. parsed-literal:: - + args = none for any style except the following *body* args = bstyle bstyle-args bstyle = style of body particles bstyle-args = additional arguments specific to the bstyle - see the :doc:`Howto body ` doc page for details + see the :doc:`Howto body ` doc + page for details + *sphere* arg = 0/1 (optional) for static/dynamic particle radii *tdpd* arg = Nspecies Nspecies = # of chemical species *template* arg = template-ID @@ -28,11 +29,9 @@ Syntax * accelerated styles (with same args) = *angle/kk* or *atomic/kk* or *bond/kk* or *charge/kk* or *full/kk* or *molecular/kk* - Examples """""""" - .. code-block:: LAMMPS atom_style atomic @@ -50,8 +49,8 @@ Description Define what style of atoms to use in a simulation. This determines what attributes are associated with the atoms. This command must be -used before a simulation is setup via a :doc:`read\_data `, -:doc:`read\_restart `, or :doc:`create\_box ` +used before a simulation is setup via a :doc:`read_data `, +:doc:`read_restart `, or :doc:`create_box ` command. .. note:: @@ -68,12 +67,12 @@ style more general than needed, though it may be slightly inefficient. The choice of style affects what quantities are stored by each atom, what quantities are communicated between processors to enable forces to be computed, and what quantities are listed in the data file read -by the :doc:`read\_data ` command. +by the :doc:`read_data ` command. These are the additional attributes of each style and the typical kinds of physical systems they are used to model. All styles store coordinates, velocities, atom IDs and types. See the -:doc:`read\_data `, :doc:`create\_atoms `, and +:doc:`read_data `, :doc:`create_atoms `, and :doc:`set ` commands for info on how to set these various quantities. @@ -94,10 +93,6 @@ quantities. +--------------+-----------------------------------------------------+--------------------------------------+ | *edpd* | temperature and heat capacity | eDPD particles | +--------------+-----------------------------------------------------+--------------------------------------+ -| *mdpd* | density | mDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *tdpd* | chemical concentration | tDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ | *electron* | charge and spin and eradius | electronic force field | +--------------+-----------------------------------------------------+--------------------------------------+ | *ellipsoid* | shape, quaternion, angular momentum | aspherical particles | @@ -106,6 +101,8 @@ quantities. +--------------+-----------------------------------------------------+--------------------------------------+ | *line* | end points, angular velocity | rigid bodies | +--------------+-----------------------------------------------------+--------------------------------------+ +| *mdpd* | density | mDPD particles | ++--------------+-----------------------------------------------------+--------------------------------------+ | *meso* | rho, e, cv | SPH particles | +--------------+-----------------------------------------------------+--------------------------------------+ | *molecular* | bonds, angles, dihedrals, impropers | uncharged molecules | @@ -118,6 +115,8 @@ quantities. +--------------+-----------------------------------------------------+--------------------------------------+ | *spin* | magnetic moment | system with magnetic particles | +--------------+-----------------------------------------------------+--------------------------------------+ +| *tdpd* | chemical concentration | tDPD particles | ++--------------+-----------------------------------------------------+--------------------------------------+ | *template* | template index, template atom | small molecules with fixed topology | +--------------+-----------------------------------------------------+--------------------------------------+ | *tri* | corner points, angular momentum | rigid bodies | @@ -147,9 +146,16 @@ basis. For the *sphere* style, the particles are spheres and each stores a per-particle diameter and mass. If the diameter > 0.0, the particle is a finite-size sphere. If the diameter = 0.0, it is a point -particle. Note that by use of the *disc* keyword with the :doc:`fix nve/sphere `, :doc:`fix nvt/sphere `, -:doc:`fix nph/sphere `, :doc:`fix npt/sphere ` commands, spheres can be effectively -treated as 2d discs for a 2d simulation if desired. See also the :doc:`set density/disc ` command. +particle. Note that by use of the *disc* keyword with the :doc:`fix +nve/sphere `, :doc:`fix nvt/sphere `, +:doc:`fix nph/sphere `, :doc:`fix npt/sphere +` commands, spheres can be effectively treated as 2d +discs for a 2d simulation if desired. See also the :doc:`set +density/disc ` command. The *sphere* style takes an optional 0 +or 1 argument. A value of 0 means the radius of each sphere is +constant for the duration of the simulation. A value of 1 means the +radii may vary dynamically during the simulation, e.g. due to use of +the :doc:`fix adapt ` command. For the *ellipsoid* style, the particles are ellipsoids and each stores a flag which indicates whether it is a finite-size ellipsoid or @@ -173,7 +179,7 @@ per-particle mass and volume. The *dpd* style is for dissipative particle dynamics (DPD) particles. Note that it is part of the USER-DPD package, and is not for use with -the :doc:`pair\_style dpd or dpd/stat ` commands, which can +the :doc:`pair_style dpd or dpd/stat ` commands, which can simply use atom\_style atomic. Atom\_style dpd extends DPD particle properties with internal temperature (dpdTheta), internal conductive energy (uCond), internal mechanical energy (uMech), and internal @@ -240,7 +246,7 @@ can be advantageous for large-scale coarse-grained systems. another CO2, then you probably do not want each molecule file to define 2 atom types and a single bond type, because they will conflict with each other when a mixture system of H2O and CO2 molecules is - defined, e.g. by the :doc:`read\_data ` command. Rather the + defined, e.g. by the :doc:`read_data ` command. Rather the H2O molecule should define atom types 1 and 2, and bond type 1. And the CO2 molecule should define atom types 3 and 4 (or atom types 3 and 2 if a single oxygen type is desired), and bond type 2. @@ -262,10 +268,8 @@ Note that there may be additional arguments required along with the *bstyle* specification, in the atom\_style body command. These arguments are described on the :doc:`Howto body ` doc page. - ---------- - Typically, simulations require only a single (non-hybrid) atom style. If some atoms in the simulation do not have all the properties defined by a particular style, use the simplest style that defines all the @@ -287,10 +291,8 @@ per-atom basis. LAMMPS can be extended with new atom styles as well as new body styles; see the :doc:`Modify ` doc page. - ---------- - Styles with a *kk* suffix are functionally the same as the corresponding style without the suffix. They have been optimized to run faster, depending on your available hardware, as discussed in on @@ -315,9 +317,8 @@ instructions on how to use the accelerated styles effectively. Restrictions """""""""""" - This command cannot be used after the simulation box is defined by a -:doc:`read\_data ` or :doc:`create\_box ` command. +:doc:`read_data ` or :doc:`create_box ` command. Many of the styles listed above are only enabled if LAMMPS was built with a specific package, as listed below. See the :doc:`Build package ` doc page for more info. @@ -338,7 +339,7 @@ The *electron* style is part of the USER-EFF package for :doc:`electronic force The *dpd* style is part of the USER-DPD package for dissipative particle dynamics (DPD). -The *edpd*\ , *mdpd*\ , and *tdpd* styles are part of the USER-MESO package +The *edpd*\ , *mdpd*\ , and *tdpd* styles are part of the USER-MESODPD package for energy-conserving dissipative particle dynamics (eDPD), many-body dissipative particle dynamics (mDPD), and transport dissipative particle dynamics (tDPD), respectively. @@ -354,20 +355,17 @@ The *wavepacket* style is part of the USER-AWPMD package for the Related commands """""""""""""""" -:doc:`read\_data `, :doc:`pair\_style ` +:doc:`read_data `, :doc:`pair_style ` Default """"""" -atom\_style atomic - +The default atom style is atomic. If atom\_style sphere is used its +default argument is 0. ---------- - .. _Grime: - - **(Grime)** Grime and Voth, to appear in J Chem Theory & Computation (2014). diff --git a/doc/src/compute_property_atom.rst b/doc/src/compute_property_atom.rst index f78798e6f5..0ce0f32e96 100644 --- a/doc/src/compute_property_atom.rst +++ b/doc/src/compute_property_atom.rst @@ -6,7 +6,6 @@ compute property/atom command Syntax """""" - .. parsed-literal:: compute ID group-ID property/atom input1 input2 ... @@ -14,9 +13,9 @@ Syntax * ID, group-ID are documented in :doc:`compute ` command * property/atom = style name of this compute command * input = one or more atom attributes - + .. parsed-literal:: - + possible attributes = id, mol, proc, type, mass, x, y, z, xs, ys, zs, xu, yu, zu, ix, iy, iz, vx, vy, vz, fx, fy, fz, @@ -36,9 +35,8 @@ Syntax rho, drho, e, de, cv, i_name, d_name - .. parsed-literal:: - + id = atom ID mol = molecule ID proc = ID of processor that owns atom @@ -66,46 +64,39 @@ Syntax corner123x, corner123y, corner123z = corner points of triangle nbonds = number of bonds assigned to an atom - .. parsed-literal:: - - PERI package per-atom properties: - vfrac = ??? - s0 = ??? - + PERI package per-atom properties: + vfrac = volume fraction + s0 = max stretch of any bond a particle is part of + .. parsed-literal:: - + USER-EFF and USER-AWPMD package per-atom properties: spin = electron spin eradius = electron radius ervel = electron radial velocity erforce = electron radial force - .. parsed-literal:: - - USER-SPH package per-atom properties: - rho = ??? - drho = ??? - e = ??? - de = ??? - cv = ??? - + USER-SPH package per-atom properties: + rho = density of SPH particles + drho = change in density + e = energy + de = change in thermal energy + cv = heat capacity + .. parsed-literal:: - + :doc:`fix property/atom ` per-atom properties: i_name = custom integer vector with name d_name = custom integer vector with name - - Examples """""""" - -.. parsed-literal:: +.. code-block:: LAMMPS compute 1 all property/atom xs vx fx mux compute 2 all property/atom type @@ -117,13 +108,17 @@ Description Define a computation that simply stores atom attributes for each atom in the group. This is useful so that the values can be used by other -:doc:`output commands ` that take computes as inputs. See -for example, the :doc:`compute reduce `, :doc:`fix ave/atom `, :doc:`fix ave/histo `, :doc:`fix ave/chunk `, and :doc:`atom-style variable ` -commands. +:doc:`output commands ` that take computes as inputs. +See for example, the :doc:`compute reduce `, :doc:`fix +ave/atom `, :doc:`fix ave/histo `, +:doc:`fix ave/chunk `, and :doc:`atom-style variable +` commands. -The list of possible attributes is the same as that used by the :doc:`dump custom ` command, which describes their meaning, with some -additional quantities that are only defined for certain :doc:`atom styles `. Basically, this augmented list gives an -input script access to any per-atom quantity stored by LAMMPS. +The list of possible attributes is the same as that used by the +:doc:`dump custom ` command, which describes their meaning, with +some additional quantities that are only defined for certain +:doc:`atom styles `. Basically, this augmented list gives +an input script access to any per-atom quantity stored by LAMMPS. The values are stored in a per-atom vector or array as discussed below. Zeroes are stored for atoms not in the specified group or for @@ -141,8 +136,9 @@ particles and body particles and store the 4-vector quaternion representing the orientation of each particle. See the :doc:`set ` command for an explanation of the quaternion vector. -*End1x*\ , *end1y*\ , *end1z*\ , *end2x*\ , *end2y*\ , *end2z*\ , are defined for -line segment particles and define the end points of each line segment. +*End1x*\ , *end1y*\ , *end1z*\ , *end2x*\ , *end2y*\ , *end2z*\ , are +defined for line segment particles and define the end points of each +line segment. *Corner1x*\ , *corner1y*\ , *corner1z*\ , *corner2x*\ , *corner2y*\ , *corner2z*\ , *corner3x*\ , *corner3y*\ , *corner3z*\ , are defined for @@ -153,14 +149,14 @@ number of explicit bonds assigned to an atom. Note that if the :doc:`newton bond ` command is set to *on*\ , which is the default, then every bond in the system is assigned to only one of the two atoms in the bond. Thus a bond between atoms I,J may be tallied -for either atom I or atom J. If :doc:`newton bond off ` is set, -it will be tallied with both atom I and atom J. +for either atom I or atom J. If :doc:`newton bond off ` is +set, it will be tallied with both atom I and atom J. The *i\_name* and *d\_name* attributes refer to custom integer and floating-point properties that have been added to each atom via the -:doc:`fix property/atom ` command. When that command -is used specific names are given to each attribute which are what is -specified as the "name" portion of *i\_name* or *d\_name*. +:doc:`fix property/atom ` command. When that +command is used specific names are given to each attribute which are +what is specified as the "name" portion of *i\_name* or *d\_name*. **Output info:** @@ -169,8 +165,8 @@ on the number of input values. If a single input is specified, a per-atom vector is produced. If two or more inputs are specified, a per-atom array is produced where the number of columns = the number of inputs. The vector or array can be accessed by any command that uses -per-atom values from a compute as input. See the :doc:`Howto output ` doc page for an overview of LAMMPS output -options. +per-atom values from a compute as input. See the :doc:`Howto output +` doc page for an overview of LAMMPS output options. The vector or array values will be in whatever :doc:`units ` the corresponding attribute is in, e.g. velocity units for vx, charge @@ -187,12 +183,8 @@ Restrictions Related commands """""""""""""""" -:doc:`dump custom `, :doc:`compute reduce `, :doc:`fix ave/atom `, :doc:`fix ave/chunk `, -:doc:`fix property/atom ` +:doc:`dump custom `, :doc:`compute reduce `, +:doc::doc:`fix ave/atom `, :doc:`fix ave/chunk +:doc:`, `fix property/atom ` **Default:** none - - -.. _lws: http://lammps.sandia.gov -.. _ld: Manual.html -.. _lc: Commands_all.html diff --git a/doc/src/read_data.rst b/doc/src/read_data.rst index 798f95e5ec..410a372a34 100644 --- a/doc/src/read_data.rst +++ b/doc/src/read_data.rst @@ -1,22 +1,21 @@ -.. index:: read\_data +.. index:: read_data -read\_data command -================== +read_data command +================= Syntax """""" - -.. parsed-literal:: +.. code-block:: LAMMPS read_data file keyword args ... * file = name of data file to read in * zero or more keyword/arg pairs may be appended * keyword = *add* or *offset* or *shift* or *extra/atom/types* or *extra/bond/types* or *extra/angle/types* or *extra/dihedral/types* or *extra/improper/types* or *extra/bond/per/atom* or *extra/angle/per/atom* or *extra/dihedral/per/atom* or *extra/improper/per/atom* or *group* or *nocoeff* or *fix* - + .. parsed-literal:: - + *add* arg = *append* or *IDoffset* or *IDoffset MOLoffset* or *merge* append = add new atoms with atom IDs appended to current IDs IDoffset = add new atoms with atom IDs having IDoffset added @@ -48,13 +47,10 @@ Syntax header-string = header lines containing this string will be passed to fix section-string = section names with this string will be passed to fix - - Examples """""""" - -.. parsed-literal:: +.. code-block:: LAMMPS read_data data.lj read_data ../run7/data.polymer.gz @@ -68,8 +64,8 @@ Description Read in a data file containing information LAMMPS needs to run a simulation. The file can be ASCII text or a gzipped text file (detected by a .gz suffix). This is one of 3 ways to specify initial -atom coordinates; see the :doc:`read\_restart ` and -:doc:`create\_atoms ` commands for alternative methods. +atom coordinates; see the :doc:`read_restart ` and +:doc:`create_atoms ` commands for alternative methods. Also see the explanation of the :doc:`-restart command-line switch ` which can convert a restart file to a data file. @@ -83,7 +79,7 @@ specified group-ID. The group will be created if it does not already exist. This is useful if you are reading multiple data files and wish to put sets of atoms into different groups so they can be operated on later. E.g. a group of added atoms can be moved to new positions via -the :doc:`displace\_atoms ` command. Note that atoms +the :doc:`displace_atoms ` command. Note that atoms read from the data file are also always added to the "all" group. The :doc:`group ` command discusses atom groups, as used in LAMMPS. @@ -95,10 +91,8 @@ styles defined, or to read a data file for a different force field. The use of the *fix* keyword is discussed below. - ---------- - **Reading multiple data files** The read\_data command can be used multiple times with the same or @@ -107,7 +101,7 @@ contained in individual data files. For example one data file could contain fluid in a confined domain; a second could contain wall atoms, and the second file could be read a third time to create a wall on the other side of the fluid. The third set of atoms could be rotated to -an opposing direction using the :doc:`displace\_atoms ` +an opposing direction using the :doc:`displace_atoms ` command, after the third read\_data command is used. The *add*\ , *offset*\ , *shift*\ , *extra*\ , and *group* keywords are @@ -116,7 +110,7 @@ useful in this context. If a simulation box does not yet exist, the *add* keyword cannot be used; the read\_data command is being used for the first time. If a simulation box does exist, due to using the -:doc:`create\_box ` command, or a previous read\_data command, +:doc:`create_box ` command, or a previous read\_data command, then the *add* keyword must be used. .. note:: @@ -175,9 +169,9 @@ for a 2d simulation. This is a mechanism for adding structured collections of atoms at different locations within the simulation box, to build up a complex geometry. It is up to you to insure atoms do not end up overlapping unphysically which would lead to bad dynamics. -Note that the :doc:`displace\_atoms ` command can be used +Note that the :doc:`displace_atoms ` command can be used to move a subset of atoms after they have been read from a data file. -Likewise, the :doc:`delete\_atoms ` command can be used to +Likewise, the :doc:`delete_atoms ` command can be used to remove overlapping atoms. Note that the shift values (Sx, Sy, Sz) are also added to the simulation box information (xlo, xhi, ylo, yhi, zlo, zhi) in the data file to shift its boundaries. E.g. xlo\_new = xlo + @@ -212,17 +206,15 @@ interactions in your input script to have a complete pairwise interaction model. An alternative to using the *extra* keywords with the read\_data -command, is to use the :doc:`create\_box ` command to +command, is to use the :doc:`create_box ` command to initialize the simulation box and all the various type limits you need via its *extra* keywords. Then use the read\_data command one or more times to populate the system with atoms, bonds, angles, etc, using the *offset* keyword if desired to alter types used in the various data files you read. - ---------- - **Format of a data file** The structure of the data file is important, though many settings and @@ -266,10 +258,8 @@ be capitalized as shown and can't have extra white-space between their words - e.g. two spaces or a tab between the 2 words in "xlo xhi" or the 2 words in "Bond Coeffs", is not valid. - ---------- - **Format of the header of a data file** These are the recognized header keywords. Header lines can come in @@ -408,7 +398,7 @@ molecules defined in the data file. Using this header flag is deprecated; please use the *extra/special/per/atom* keyword instead. Using this setting will pre-allocate space in the LAMMPS data structures for storing these neighbors. See the -:doc:`special\_bonds ` and :doc:`molecule ` doc +:doc:`special_bonds ` and :doc:`molecule ` doc pages for more discussion of 1-2,1-3,1-4 neighbors. .. note:: @@ -421,7 +411,7 @@ pages for more discussion of 1-2,1-3,1-4 neighbors. If they appear in later data files, they are ignored. The "ellipsoids" and "lines" and "triangles" and "bodies" settings are -only used with :doc:`atom\_style ellipsoid or line or tri or body ` and specify how many of the atoms are +only used with :doc:`atom_style ellipsoid or line or tri or body ` and specify how many of the atoms are finite-size ellipsoids or lines or triangles or bodies; the remainder are point particles. See the discussion of ellipsoidflag and the *Ellipsoids* section below. See the discussion of lineflag and the @@ -431,7 +421,7 @@ are point particles. See the discussion of ellipsoidflag and the .. note:: - For :doc:`atom\_style template `, the molecular + For :doc:`atom_style template `, the molecular topology (bonds,angles,etc) is contained in the molecule templates read-in by the :doc:`molecule ` command. This means you cannot set the *bonds*\ , *angles*\ , etc header keywords in the data @@ -440,10 +430,8 @@ are point particles. See the discussion of ellipsoidflag and the keywords, though it is not necessary. If specified, they must match the maximum values defined in any of the template molecules. - ---------- - **Format of the body of a data file** These are the section keywords for the body of the file. @@ -460,14 +448,13 @@ currently defined style: For example, these lines: - .. parsed-literal:: Atoms # sphere Pair Coeffs # lj/cut -will check if the currently-defined :doc:`atom\_style ` is -*sphere*\ , and the current :doc:`pair\_style ` is *lj/cut*\ . +will check if the currently-defined :doc:`atom_style ` is +*sphere*\ , and the current :doc:`pair_style ` is *lj/cut*\ . If not, LAMMPS will issue a warning to indicate that the data file section likely does not contain the correct number or type of parameters expected for the currently-defined style. @@ -480,120 +467,97 @@ Any individual line in the various sections can have a trailing comment starting with "#" for annotation purposes. E.g. in the Atoms section: - .. parsed-literal:: 10 1 17 -1.0 10.0 5.0 6.0 # salt ion - ---------- - *Angle Coeffs* section: * one line per angle type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = angle type (1-N) coeffs = list of coeffs * example: - + .. parsed-literal:: - + 6 70 108.5 0 0 - - The number and meaning of the coefficients are specific to the defined -angle style. See the :doc:`angle\_style ` and -:doc:`angle\_coeff ` commands for details. Coefficients can -also be set via the :doc:`angle\_coeff ` command in the +angle style. See the :doc:`angle_style ` and +:doc:`angle_coeff ` commands for details. Coefficients can +also be set via the :doc:`angle_coeff ` command in the input script. - ---------- - *AngleAngle Coeffs* section: * one line per improper type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = improper type (1-N) coeffs = list of coeffs (see :doc:`improper_coeff `) - - - ---------- - *AngleAngleTorsion Coeffs* section: * one line per dihedral type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = dihedral type (1-N) coeffs = list of coeffs (see :doc:`dihedral_coeff `) - - - ---------- - *Angles* section: * one line per angle * line syntax: ID type atom1 atom2 atom3 - + .. parsed-literal:: - + ID = number of angle (1-Nangles) type = angle type (1-Nangletype) atom1,atom2,atom3 = IDs of 1st,2nd,3rd atoms in angle example: - + .. parsed-literal:: - + 2 2 17 29 430 - - The 3 atoms are ordered linearly within the angle. Thus the central atom (around which the angle is computed) is the atom2 in the list. E.g. H,O,H for a water molecule. The *Angles* section must appear after the *Atoms* section. All values in this section must be integers (1, not 1.0). - ---------- - *AngleTorsion Coeffs* section: * one line per dihedral type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = dihedral type (1-N) coeffs = list of coeffs (see :doc:`dihedral_coeff `) - - - ---------- - *Atoms* section: * one line per atom @@ -624,10 +588,6 @@ of analysis. +------------+---------------------------------------------------------------------------+ | edpd | atom-ID atom-type edpd\_temp edpd\_cv x y z | +------------+---------------------------------------------------------------------------+ -| mdpd | atom-ID atom-type rho x y z | -+------------+---------------------------------------------------------------------------+ -| tdpd | atom-ID atom-type x y z cc1 cc2 ... ccNspecies | -+------------+---------------------------------------------------------------------------+ | electron | atom-ID atom-type q spin eradius x y z | +------------+---------------------------------------------------------------------------+ | ellipsoid | atom-ID atom-type ellipsoidflag density x y z | @@ -636,17 +596,22 @@ of analysis. +------------+---------------------------------------------------------------------------+ | line | atom-ID molecule-ID atom-type lineflag density x y z | +------------+---------------------------------------------------------------------------+ +| mdpd | atom-ID atom-type rho x y z | ++------------+---------------------------------------------------------------------------+ | meso | atom-ID atom-type rho e cv x y z | +------------+---------------------------------------------------------------------------+ | molecular | atom-ID molecule-ID atom-type x y z | +------------+---------------------------------------------------------------------------+ | peri | atom-ID atom-type volume density x y z | +------------+---------------------------------------------------------------------------+ -| smd | atom-ID atom-type molecule volume mass kernel-radius contact-radius x y z | +| smd | atom-ID atom-type molecule volume mass kernel-radius +contact-radius x0 y0 z0 x y z | +------------+---------------------------------------------------------------------------+ | sphere | atom-ID atom-type diameter density x y z | +------------+---------------------------------------------------------------------------+ -| spin | atom-ID atom-type sp x y z spx spy spz | +| spin | atom-ID atom-type x y z spx spy spz sp | ++------------+---------------------------------------------------------------------------+ +| tdpd | atom-ID atom-type x y z cc1 cc2 ... ccNspecies | +------------+---------------------------------------------------------------------------+ | template | atom-ID molecule-ID template-index template-atom atom-type x y z | +------------+---------------------------------------------------------------------------+ @@ -662,7 +627,7 @@ The per-atom values have these meanings and units, listed alphabetically: * atom-ID = integer ID of atom * atom-type = type of atom (1-Ntype) * bodyflag = 1 for body particles, 0 for point particles -* cc = chemical concentration for tDPD particles for each species (mole/volume units) +* ccN = chemical concentration for tDPD particles for each species (mole/volume units) * contact-radius = ??? (distance units) * cs\_re,cs\_im = real/imaginary parts of wave packet coefficients * cv = heat capacity (need units) for SPH particles @@ -682,14 +647,15 @@ The per-atom values have these meanings and units, listed alphabetically: * q = charge on atom (charge units) * rho = density (need units) for SPH particles * spin = electron spin (+1/-1), 0 = nuclei, 2 = fixed-core, 3 = pseudo-cores (i.e. ECP) -* sp = norm of magnetic spin of atom (in number of Bohr magnetons) -* spx,spy,spz = components of magnetic spin of atom (adim normalized vector) +* sp = magnitude of magnetic spin of atom (Bohr magnetons) +* spx,spy,spz = components of magnetic spin of atom (unit vector) * template-atom = which atom within a template molecule the atom is * template-index = which molecule within the molecule template the atom is part of * theta = internal temperature of a DPD particle * triangleflag = 1 for triangular particles, 0 for point or spherical particles * volume = volume of Peridynamic particle (distance\^3 units) * x,y,z = coordinates of atom (distance units) +* x0,y0,z0 = original (strain-free) coordinates of atom (distance units) The units for these quantities depend on the unit style; see the :doc:`units ` command for details. @@ -702,7 +668,7 @@ in dump files. Normally, it is a unique value from 1 to Natoms for each atom. Unique values larger than Natoms can be used, but they will cause extra memory to be allocated on each processor, if an atom map array is used, but not if an atom map hash is used; see the -:doc:`atom\_modify ` command for details. If an atom map is +:doc:`atom_modify ` command for details. If an atom map is not used (e.g. an atomic system with no bonds), and you don't care if unique atom IDs appear in dump files, then the atom-IDs can all be set to 0. @@ -723,7 +689,7 @@ triangle, or body in the corresponding *Ellipsoids*\ , *Lines*\ , *Triangles*\ , or *Bodies* section. The *template-index* and *template-atom* are only defined used by -:doc:`atom\_style template `. In this case the +:doc:`atom_style template `. In this case the :doc:`molecule ` command is used to define a molecule template which contains one or more molecules. If an atom belongs to one of those molecules, its *template-index* and *template-atom* are both set @@ -754,15 +720,14 @@ used. A *disc* keyword can also be used with time integration fixes, such as :doc:`fix nve/sphere ` and :doc:`fix nvt/sphere ` to time integrate their motion as 2d discs (not 3d spheres), by changing their moment of inertia. -For atom\_style hybrid, following the 5 initial values (ID,type,x,y,z), -specific values for each sub-style must be listed. The order of the -sub-styles is the same as they were listed in the -:doc:`atom\_style ` command. The sub-style specific values -are those that are not the 5 standard ones (ID,type,x,y,z). For -example, for the "charge" sub-style, a "q" value would appear. For -the "full" sub-style, a "molecule-ID" and "q" would appear. These are -listed in the same order they appear as listed above. Thus if - +For atom\_style hybrid, following the 5 initial values +(ID,type,x,y,z), specific values for each sub-style must be listed. +The order of the sub-styles is the same as they were listed in the +:doc:`atom_style ` command. The specific values for each +sub-style are those that are not the 5 standard ones (ID,type,x,y,z). +For example, for the "charge" sub-style, a "q" value would appear. +For the "full" sub-style, a "molecule-ID" and "q" would appear. These +are listed in the same order they appear as listed above. Thus if .. parsed-literal:: @@ -770,19 +735,19 @@ listed in the same order they appear as listed above. Thus if were used in the input script, each atom line would have these fields: - .. parsed-literal:: atom-ID atom-type x y z q diameter density Note that if a non-standard value is defined by multiple sub-styles, -it must appear multiple times in the atom line. E.g. the atom line -for atom\_style hybrid dipole full would list "q" twice: - +it only appears once in the atom line. E.g. the atom line for +atom\_style hybrid dipole full would list "q" only once, with the +dipole sub-style fields; "q" does not appear with the full sub-style +fields. .. parsed-literal:: - atom-ID atom-type x y z q mux muy myz molecule-ID q + atom-ID atom-type x y z q mux muy myz molecule-ID Atom lines specify the (x,y,z) coordinates of atoms. These can be inside or outside the simulation box. When the data file is read, @@ -827,7 +792,6 @@ that use unwrapped coordinates internally are as follows: continued run (restarted from a data file) begins with image flags that are consistent with the previous run. - .. note:: If your system is an infinite periodic crystal with bonds then @@ -841,41 +805,37 @@ a *Velocities* section in the data file or by a :doc:`velocity ` or :doc:`set ` command in the input script. - ---------- - *Bodies* section: * one or more lines per body * first line syntax: atom-ID Ninteger Ndouble - + .. parsed-literal:: - + Ninteger = # of integer quantities for this particle Ndouble = # of floating-point quantities for this particle * 0 or more integer lines with total of Ninteger values * 0 or more double lines with total of Ndouble values * example: - + .. parsed-literal:: - + 12 3 6 2 3 2 1.0 2.0 3.0 1.0 2.0 4.0 * example: - + .. parsed-literal:: - + 12 0 14 1.0 2.0 3.0 1.0 2.0 4.0 1.0 2.0 3.0 1.0 2.0 4.0 4.0 2.0 - - -The *Bodies* section must appear if :doc:`atom\_style body ` +The *Bodies* section must appear if :doc:`atom_style body ` is used and any atoms listed in the *Atoms* section have a bodyflag = 1. The number of bodies should be specified in the header section via the "bodies" keyword. @@ -883,7 +843,7 @@ the "bodies" keyword. Each body can have a variable number of integer and/or floating-point values. The number and meaning of the values is defined by the body style, as described in the :doc:`Howto body ` doc page. The -body style is given as an argument to the :doc:`atom\_style body ` command. +body style is given as an argument to the :doc:`atom_style body ` command. The Ninteger and Ndouble values determine how many integer and floating-point values are specified for this particle. Ninteger and @@ -896,187 +856,155 @@ particular type, no lines appear for that type. The *Bodies* section must appear after the *Atoms* section. - ---------- - *Bond Coeffs* section: * one line per bond type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = bond type (1-N) coeffs = list of coeffs * example: - + .. parsed-literal:: - + 4 250 1.49 - - The number and meaning of the coefficients are specific to the defined -bond style. See the :doc:`bond\_style ` and -:doc:`bond\_coeff ` commands for details. Coefficients can -also be set via the :doc:`bond\_coeff ` command in the input +bond style. See the :doc:`bond_style ` and +:doc:`bond_coeff ` commands for details. Coefficients can +also be set via the :doc:`bond_coeff ` command in the input script. - ---------- - *BondAngle Coeffs* section: * one line per angle type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = angle type (1-N) coeffs = list of coeffs (see class 2 section of :doc:`angle_coeff `) - - - ---------- - *BondBond Coeffs* section: * one line per angle type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = angle type (1-N) coeffs = list of coeffs (see class 2 section of :doc:`angle_coeff `) - - - ---------- - *BondBond13 Coeffs* section: * one line per dihedral type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = dihedral type (1-N) coeffs = list of coeffs (see class 2 section of :doc:`dihedral_coeff `) - - - ---------- - *Bonds* section: * one line per bond * line syntax: ID type atom1 atom2 - + .. parsed-literal:: - + ID = bond number (1-Nbonds) type = bond type (1-Nbondtype) atom1,atom2 = IDs of 1st,2nd atoms in bond * example: - + .. parsed-literal:: - + 12 3 17 29 - - The *Bonds* section must appear after the *Atoms* section. All values in this section must be integers (1, not 1.0). - ---------- - *Dihedral Coeffs* section: * one line per dihedral type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = dihedral type (1-N) coeffs = list of coeffs * example: - + .. parsed-literal:: - + 3 0.6 1 0 1 - - The number and meaning of the coefficients are specific to the defined -dihedral style. See the :doc:`dihedral\_style ` and -:doc:`dihedral\_coeff ` commands for details. +dihedral style. See the :doc:`dihedral_style ` and +:doc:`dihedral_coeff ` commands for details. Coefficients can also be set via the -:doc:`dihedral\_coeff ` command in the input script. - +:doc:`dihedral_coeff ` command in the input script. ---------- - *Dihedrals* section: * one line per dihedral * line syntax: ID type atom1 atom2 atom3 atom4 - + .. parsed-literal:: - + ID = number of dihedral (1-Ndihedrals) type = dihedral type (1-Ndihedraltype) atom1,atom2,atom3,atom4 = IDs of 1st,2nd,3rd,4th atoms in dihedral * example: - + .. parsed-literal:: - + 12 4 17 29 30 21 - - The 4 atoms are ordered linearly within the dihedral. The *Dihedrals* section must appear after the *Atoms* section. All values in this section must be integers (1, not 1.0). - ---------- - *Ellipsoids* section: * one line per ellipsoid * line syntax: atom-ID shapex shapey shapez quatw quati quatj quatk - + .. parsed-literal:: - + atom-ID = ID of atom which is an ellipsoid shapex,shapey,shapez = 3 diameters of ellipsoid (distance units) quatw,quati,quatj,quatk = quaternion components for orientation of atom * example: - + .. parsed-literal:: - + 12 1 2 1 1 0 0 0 - - -The *Ellipsoids* section must appear if :doc:`atom\_style ellipsoid ` is used and any atoms are listed in the +The *Ellipsoids* section must appear if :doc:`atom_style ellipsoid ` is used and any atoms are listed in the *Atoms* section with an ellipsoidflag = 1. The number of ellipsoids should be specified in the header section via the "ellipsoids" keyword. @@ -1099,73 +1027,61 @@ specified as a unit vector. The *Ellipsoids* section must appear after the *Atoms* section. - ---------- - *EndBondTorsion Coeffs* section: * one line per dihedral type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = dihedral type (1-N) coeffs = list of coeffs (see class 2 section of :doc:`dihedral_coeff `) - - - ---------- - *Improper Coeffs* section: * one line per improper type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = improper type (1-N) coeffs = list of coeffs * example: - + .. parsed-literal:: - + 2 20 0.0548311 - - The number and meaning of the coefficients are specific to the defined -improper style. See the :doc:`improper\_style ` and -:doc:`improper\_coeff ` commands for details. +improper style. See the :doc:`improper_style ` and +:doc:`improper_coeff ` commands for details. Coefficients can also be set via the -:doc:`improper\_coeff ` command in the input script. - +:doc:`improper_coeff ` command in the input script. ---------- - *Impropers* section: * one line per improper * line syntax: ID type atom1 atom2 atom3 atom4 - + .. parsed-literal:: - + ID = number of improper (1-Nimpropers) type = improper type (1-Nimpropertype) atom1,atom2,atom3,atom4 = IDs of 1st,2nd,3rd,4th atoms in improper * example: - + .. parsed-literal:: - + 12 3 17 29 13 100 - - The ordering of the 4 atoms determines the definition of the improper angle used in the formula for each :doc:`improper style `. See the doc pages for individual styles for details. @@ -1173,30 +1089,26 @@ for details. The *Impropers* section must appear after the *Atoms* section. All values in this section must be integers (1, not 1.0). - ---------- - *Lines* section: * one line per line segment * line syntax: atom-ID x1 y1 x2 y2 - + .. parsed-literal:: - + atom-ID = ID of atom which is a line segment x1,y1 = 1st end point x2,y2 = 2nd end point * example: - + .. parsed-literal:: - + 12 1.0 0.0 2.0 0.0 - - -The *Lines* section must appear if :doc:`atom\_style line ` +The *Lines* section must appear if :doc:`atom_style line ` is used and any atoms are listed in the *Atoms* section with a lineflag = 1. The number of lines should be specified in the header section via the "lines" keyword. @@ -1210,139 +1122,119 @@ for defining some interactions. The *Lines* section must appear after the *Atoms* section. - ---------- - *Masses* section: * one line per atom type * line syntax: ID mass - + .. parsed-literal:: - + ID = atom type (1-N) mass = mass value * example: - + .. parsed-literal:: - + 3 1.01 - - This defines the mass of each atom type. This can also be set via the :doc:`mass ` command in the input script. This section cannot be used for atom styles that define a mass for individual atoms - -e.g. :doc:`atom\_style sphere `. - +e.g. :doc:`atom_style sphere `. ---------- - *MiddleBondTorsion Coeffs* section: * one line per dihedral type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = dihedral type (1-N) coeffs = list of coeffs (see class 2 section of :doc:`dihedral_coeff `) - - - ---------- - *Pair Coeffs* section: * one line per atom type * line syntax: ID coeffs - + .. parsed-literal:: - + ID = atom type (1-N) coeffs = list of coeffs * example: - + .. parsed-literal:: - + 3 0.022 2.35197 0.022 2.35197 - - The number and meaning of the coefficients are specific to the defined -pair style. See the :doc:`pair\_style ` and -:doc:`pair\_coeff ` commands for details. Since pair +pair style. See the :doc:`pair_style ` and +:doc:`pair_coeff ` commands for details. Since pair coefficients for types I != J are not specified, these will be generated automatically by the pair style's mixing rule. See the -individual pair\_style doc pages and the :doc:`pair\_modify mix ` command for details. Pair coefficients can also -be set via the :doc:`pair\_coeff ` command in the input +individual pair\_style doc pages and the :doc:`pair_modify mix ` command for details. Pair coefficients can also +be set via the :doc:`pair_coeff ` command in the input script. - ---------- - *PairIJ Coeffs* section: * one line per pair of atom types for all I,J with I <= J * line syntax: ID1 ID2 coeffs - + .. parsed-literal:: - + ID1 = atom type I = 1-N ID2 = atom type J = I-N, with I <= J coeffs = list of coeffs * examples: - + .. parsed-literal:: - + 3 3 0.022 2.35197 0.022 2.35197 3 5 0.022 2.35197 0.022 2.35197 - - This section must have N\*(N+1)/2 lines where N = # of atom types. The number and meaning of the coefficients are specific to the defined -pair style. See the :doc:`pair\_style ` and -:doc:`pair\_coeff ` commands for details. Since pair +pair style. See the :doc:`pair_style ` and +:doc:`pair_coeff ` commands for details. Since pair coefficients for types I != J are all specified, these values will turn off the default mixing rule defined by the pair style. See the -individual pair\_style doc pages and the :doc:`pair\_modify mix ` command for details. Pair coefficients can also -be set via the :doc:`pair\_coeff ` command in the input +individual pair\_style doc pages and the :doc:`pair_modify mix ` command for details. Pair coefficients can also +be set via the :doc:`pair_coeff ` command in the input script. - ---------- - *Triangles* section: * one line per triangle * line syntax: atom-ID x1 y1 z1 x2 y2 z2 x3 y3 z3 - + .. parsed-literal:: - + atom-ID = ID of atom which is a line segment x1,y1,z1 = 1st corner point x2,y2,z2 = 2nd corner point x3,y3,z3 = 3rd corner point * example: - + .. parsed-literal:: - + 12 0.0 0.0 0.0 2.0 0.0 1.0 0.0 2.0 1.0 - - -The *Triangles* section must appear if :doc:`atom\_style tri ` is used and any atoms are listed in the *Atoms* +The *Triangles* section must appear if :doc:`atom_style tri ` is used and any atoms are listed in the *Atoms* section with a triangleflag = 1. The number of lines should be specified in the header section via the "triangles" keyword. @@ -1354,10 +1246,8 @@ orientation may be important for defining some interactions. The *Triangles* section must appear after the *Atoms* section. - ---------- - *Velocities* section: * one line per atom @@ -1394,21 +1284,19 @@ Wz are in units of angular velocity (radians/time). For atom\_style hybrid, following the 4 initial values (ID,vx,vy,vz), specific values for each sub-style must be listed. The order of the sub-styles is the same as they were listed in the -:doc:`atom\_style ` command. The sub-style specific values +:doc:`atom_style ` command. The sub-style specific values are those that are not the 5 standard ones (ID,vx,vy,vz). For example, for the "sphere" sub-style, "wx", "wy", "wz" values would appear. These are listed in the same order they appear as listed above. Thus if - -.. parsed-literal:: +.. code-block:: LAMMPS atom_style hybrid electron sphere were used in the input script, each velocity line would have these fields: - .. parsed-literal:: atom-ID vx vy vz ervel wx wy wz @@ -1416,14 +1304,11 @@ fields: Translational velocities can also be set by the :doc:`velocity ` command in the input script. - ---------- - Restrictions """""""""""" - To read gzipped data files, you must compile LAMMPS with the -DLAMMPS\_GZIP option. See the :doc:`Build settings ` doc page for details. @@ -1431,15 +1316,10 @@ doc page for details. Related commands """""""""""""""" -:doc:`read\_dump `, :doc:`read\_restart `, -:doc:`create\_atoms `, :doc:`write\_data ` +:doc:`read_dump `, :doc:`read_restart `, +:doc:`create_atoms `, :doc:`write_data ` Default """"""" The default for all the *extra* keywords is 0. - - -.. _lws: http://lammps.sandia.gov -.. _ld: Manual.html -.. _lc: Commands_all.html From dda5cb09676ac6f40c486de4d1c1c08489e252d6 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 12:02:49 -0600 Subject: [PATCH 15/42] typo in atom_vec.h --- src/atom_vec.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/atom_vec.h b/src/atom_vec.h index 21cd9a05fc..fd3551c8ed 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -73,8 +73,7 @@ class AtomVec : protected Pointers { virtual void init(); virtual void force_clear(int, size_t) {} - - virtual bigint AtomVec::roundup(bigint n) + virtual bigint roundup(bigint); virtual void grow(int); virtual void grow_pointers() {} From 5ec357adfcf209b628ea98e408926d77339588cc Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 15:06:59 -0600 Subject: [PATCH 16/42] spelling errors --- doc/src/Modify_atom.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/Modify_atom.rst b/doc/src/Modify_atom.rst index ffdb48f3db..83f57a3d3d 100644 --- a/doc/src/Modify_atom.rst +++ b/doc/src/Modify_atom.rst @@ -113,7 +113,7 @@ a copy of peratom data pointers, as explained in the code. There are a number of other optional methods which your atom style can implement. These are only needed if you need to do something -out-of-the-oridinary which the default operation of the AtomVec parent +out-of-the-ordinary which the default operation of the AtomVec parent class does not take care of. The best way to figure out why they are sometimes useful is to look at how other atom styles use them. @@ -140,7 +140,7 @@ their particles, such as :doc:`atom_style ellipsoid or tri * memory_usage_bonus The :doc:`atom_style body ` command can define a particle -geomerty with an arbitrary number of values. This method reads it +geometry with an arbitrary number of values. This method reads it from a data file: * data_body From 4eb4839f6da26294f97f37d739330c85701dd494 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 16:40:09 -0600 Subject: [PATCH 17/42] renaming of variables and command names in USER-SPH --- doc/src/atom_style.rst | 12 +- doc/src/compute.rst | 6 +- ...meso_e_atom.rst => compute_sph_e_atom.rst} | 14 +- ..._rho_atom.rst => compute_sph_rho_atom.rst} | 21 ++- ...meso_t_atom.rst => compute_sph_t_atom.rst} | 14 +- doc/src/fix.rst | 4 +- doc/src/{fix_meso.rst => fix_sph.rst} | 16 +-- ..._stationary.rst => fix_sph_stationary.rst} | 14 +- doc/src/set.rst | 123 +++++++++--------- .../{atom_vec_meso.cpp => atom_vec_sph.cpp} | 56 ++++---- .../{atom_vec_meso.h => atom_vec_sph.h} | 12 +- ...meso_e_atom.cpp => compute_sph_e_atom.cpp} | 22 ++-- ...ute_meso_e_atom.h => compute_sph_e_atom.h} | 12 +- ..._rho_atom.cpp => compute_sph_rho_atom.cpp} | 17 +-- ...meso_rho_atom.h => compute_sph_rho_atom.h} | 12 +- ...meso_t_atom.cpp => compute_sph_t_atom.cpp} | 23 ++-- ...ute_meso_t_atom.h => compute_sph_t_atom.h} | 12 +- src/USER-SPH/{fix_meso.cpp => fix_sph.cpp} | 34 ++--- src/USER-SPH/{fix_meso.h => fix_sph.h} | 10 +- ..._stationary.cpp => fix_sph_stationary.cpp} | 32 ++--- ...meso_stationary.h => fix_sph_stationary.h} | 10 +- src/USER-SPH/pair_sph_heatconduction.cpp | 10 +- src/USER-SPH/pair_sph_idealgas.cpp | 16 +-- src/USER-SPH/pair_sph_lj.cpp | 12 +- src/USER-SPH/pair_sph_taitwater.cpp | 6 +- src/USER-SPH/pair_sph_taitwater_morris.cpp | 6 +- src/atom.cpp | 47 +++++-- src/atom.h | 9 +- src/set.cpp | 22 ++-- 29 files changed, 318 insertions(+), 286 deletions(-) rename doc/src/{compute_meso_e_atom.rst => compute_sph_e_atom.rst} (81%) rename doc/src/{compute_meso_rho_atom.rst => compute_sph_rho_atom.rst} (64%) rename doc/src/{compute_meso_t_atom.rst => compute_sph_t_atom.rst} (79%) rename doc/src/{fix_meso.rst => fix_sph.rst} (79%) rename doc/src/{fix_meso_stationary.rst => fix_sph_stationary.rst} (84%) rename src/USER-SPH/{atom_vec_meso.cpp => atom_vec_sph.cpp} (76%) rename src/USER-SPH/{atom_vec_meso.h => atom_vec_sph.h} (83%) rename src/USER-SPH/{compute_meso_e_atom.cpp => compute_sph_e_atom.cpp} (80%) rename src/USER-SPH/{compute_meso_e_atom.h => compute_sph_e_atom.h} (78%) rename src/USER-SPH/{compute_meso_rho_atom.cpp => compute_sph_rho_atom.cpp} (83%) rename src/USER-SPH/{compute_meso_rho_atom.h => compute_sph_rho_atom.h} (77%) rename src/USER-SPH/{compute_meso_t_atom.cpp => compute_sph_t_atom.cpp} (79%) rename src/USER-SPH/{compute_meso_t_atom.h => compute_sph_t_atom.h} (78%) rename src/USER-SPH/{fix_meso.cpp => fix_sph.cpp} (84%) rename src/USER-SPH/{fix_meso.h => fix_sph.h} (88%) rename src/USER-SPH/{fix_meso_stationary.cpp => fix_sph_stationary.cpp} (74%) rename src/USER-SPH/{fix_meso_stationary.h => fix_sph_stationary.h} (83%) diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index 629c02e1b4..91aa95d7cd 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -10,7 +10,7 @@ Syntax atom_style style args -* style = *angle* or *atomic* or *body* or *bond* or *charge* or *dipole* or *dpd* or *edpd* or *electron* or *ellipsoid* or *full* or *line* or *mdpd* or *meso* or *molecular* or *peri* or *smd* or *sphere* or *spin* or *tdpd* or *tri* or *template* or *hybrid* +* style = *angle* or *atomic* or *body* or *bond* or *charge* or *dipole* or *dpd* or *edpd* or *electron* or *ellipsoid* or *full* or *line* or *mdpd* or *molecular* or *peri* or *smd* or *sph* or *sphere* or *spin* or *tdpd* or *tri* or *template* or *hybrid* .. parsed-literal:: @@ -103,14 +103,14 @@ quantities. +--------------+-----------------------------------------------------+--------------------------------------+ | *mdpd* | density | mDPD particles | +--------------+-----------------------------------------------------+--------------------------------------+ -| *meso* | rho, e, cv | SPH particles | -+--------------+-----------------------------------------------------+--------------------------------------+ | *molecular* | bonds, angles, dihedrals, impropers | uncharged molecules | +--------------+-----------------------------------------------------+--------------------------------------+ | *peri* | mass, volume | mesoscopic Peridynamic models | +--------------+-----------------------------------------------------+--------------------------------------+ | *smd* | volume, kernel diameter, contact radius, mass | solid and fluid SPH particles | +--------------+-----------------------------------------------------+--------------------------------------+ +| *sph* | rho, esph, cv | SPH particles | ++--------------+-----------------------------------------------------+--------------------------------------+ | *sphere* | diameter, mass, angular velocity | granular models | +--------------+-----------------------------------------------------+--------------------------------------+ | *spin* | magnetic moment | system with magnetic particles | @@ -198,8 +198,8 @@ particles which store a set of chemical concentration. An integer "cc_species" is required to specify the number of chemical species involved in a tDPD system. -The *meso* style is for smoothed particle hydrodynamics (SPH) -particles which store a density (rho), energy (e), and heat capacity +The *sph* style is for smoothed particle hydrodynamics (SPH) +particles which store a density (rho), energy (esph), and heat capacity (cv). The *smd* style is for a general formulation of Smooth Particle @@ -344,7 +344,7 @@ for energy-conserving dissipative particle dynamics (eDPD), many-body dissipative particle dynamics (mDPD), and transport dissipative particle dynamics (tDPD), respectively. -The *meso* style is part of the USER-SPH package for smoothed particle +The *sph* style is part of the USER-SPH package for smoothed particle hydrodynamics (SPH). See `this PDF guide `_ to using SPH in LAMMPS. The *spin* style is part of the SPIN package. diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 0726a502bc..418a0f0e1d 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -225,9 +225,6 @@ The individual style names on the :doc:`Commands compute ` doc * :doc:`ke/atom/eff ` - per-atom translational and radial kinetic energy in the electron force field model * :doc:`ke/eff ` - kinetic energy of a group of nuclei and electrons in the electron force field model * :doc:`ke/rigid ` - translational kinetic energy of rigid bodies -* :doc:`meso/e/atom ` - per-atom internal energy of Smooth-Particle Hydrodynamics atoms -* :doc:`meso/rho/atom ` - per-atom mesoscopic density of Smooth-Particle Hydrodynamics atoms -* :doc:`meso/t/atom ` - per-atom internal temperature of Smooth-Particle Hydrodynamics atoms * :doc:`momentum ` - translational momentum * :doc:`msd ` - mean-squared displacement of group of atoms * :doc:`msd/chunk ` - mean-squared displacement for each chunk @@ -279,6 +276,9 @@ The individual style names on the :doc:`Commands compute ` doc * :doc:`sna/atom ` - bispectrum components for each atom * :doc:`snad/atom ` - derivative of bispectrum components for each atom * :doc:`snav/atom ` - virial contribution from bispectrum components for each atom +* :doc:`sph/e/atom ` - per-atom internal energy of Smooth-Particle Hydrodynamics atoms +* :doc:`sph/rho/atom ` - per-atom density of Smooth-Particle Hydrodynamics atoms +* :doc:`sph/t/atom ` - per-atom internal temperature of Smooth-Particle Hydrodynamics atoms * :doc:`spin ` - magnetic quantities for a system of atoms having spins * :doc:`stress/atom ` - stress tensor for each atom * :doc:`stress/mop ` - normal components of the local stress tensor using the method of planes diff --git a/doc/src/compute_meso_e_atom.rst b/doc/src/compute_sph_e_atom.rst similarity index 81% rename from doc/src/compute_meso_e_atom.rst rename to doc/src/compute_sph_e_atom.rst index ad8e46cafb..f35976ed10 100644 --- a/doc/src/compute_meso_e_atom.rst +++ b/doc/src/compute_sph_e_atom.rst @@ -1,6 +1,6 @@ -.. index:: compute meso/e/atom +.. index:: compute sph/e/atom -compute meso/e/atom command +compute sph/e/atom command =========================== Syntax @@ -8,17 +8,17 @@ Syntax .. parsed-literal:: - compute ID group-ID meso/e/atom + compute ID group-ID sph/e/atom * ID, group-ID are documented in :doc:`compute ` command -* meso/e/atom = style name of this compute command +* sph/e/atom = style name of this compute command Examples """""""" .. code-block:: LAMMPS - compute 1 all meso/e/atom + compute 1 all sph/e/atom Description """"""""""" @@ -27,8 +27,8 @@ Define a computation that calculates the per-atom internal energy for each atom in a group. The internal energy is the energy associated with the internal degrees -of freedom of a mesoscopic particles, e.g. a Smooth-Particle -Hydrodynamics particle. +of freedom of an SPH particle, i.e. a Smooth-Particle Hydrodynamics +particle. See `this PDF guide `_ to using SPH in LAMMPS. diff --git a/doc/src/compute_meso_rho_atom.rst b/doc/src/compute_sph_rho_atom.rst similarity index 64% rename from doc/src/compute_meso_rho_atom.rst rename to doc/src/compute_sph_rho_atom.rst index d4611c5cb7..4237bf0bf5 100644 --- a/doc/src/compute_meso_rho_atom.rst +++ b/doc/src/compute_sph_rho_atom.rst @@ -1,6 +1,6 @@ -.. index:: compute meso/rho/atom +.. index:: compute sph/rho/atom -compute meso/rho/atom command +compute sph/rho/atom command ============================= Syntax @@ -8,32 +8,31 @@ Syntax .. parsed-literal:: - compute ID group-ID meso/rho/atom + compute ID group-ID sph/rho/atom * ID, group-ID are documented in :doc:`compute ` command -* meso/rho/atom = style name of this compute command +* sph/rho/atom = style name of this compute command Examples """""""" .. code-block:: LAMMPS - compute 1 all meso/rho/atom + compute 1 all sph/rho/atom Description """"""""""" -Define a computation that calculates the per-atom mesoscopic density -for each atom in a group. +Define a computation that calculates the per-atom SPH density for each +atom in a group, i.e. a Smooth-Particle Hydrodynamics density. -The mesoscopic density is the mass density of a mesoscopic particle, -calculated by kernel function interpolation using "pair style -sph/rhosum". +The SPH density is the mass density of an SPH particle, calculated by +kernel function interpolation using "pair style sph/rhosum". See `this PDF guide `_ to using SPH in LAMMPS. -The value of the mesoscopic density will be 0.0 for atoms not in the +The value of the SPH density will be 0.0 for atoms not in the specified compute group. **Output info:** diff --git a/doc/src/compute_meso_t_atom.rst b/doc/src/compute_sph_t_atom.rst similarity index 79% rename from doc/src/compute_meso_t_atom.rst rename to doc/src/compute_sph_t_atom.rst index e44425a65c..1766e1d712 100644 --- a/doc/src/compute_meso_t_atom.rst +++ b/doc/src/compute_sph_t_atom.rst @@ -1,6 +1,6 @@ -.. index:: compute meso/t/atom +.. index:: compute sph/t/atom -compute meso/t/atom command +compute sph/t/atom command =========================== Syntax @@ -8,17 +8,17 @@ Syntax .. parsed-literal:: - compute ID group-ID meso/t/atom + compute ID group-ID sph/t/atom * ID, group-ID are documented in :doc:`compute ` command -* meso/t/atom = style name of this compute command +* sph/t/atom = style name of this compute command Examples """""""" .. code-block:: LAMMPS - compute 1 all meso/t/atom + compute 1 all sph/t/atom Description """"""""""" @@ -27,8 +27,8 @@ Define a computation that calculates the per-atom internal temperature for each atom in a group. The internal temperature is the ratio of internal energy over the heat -capacity associated with the internal degrees of freedom of a mesoscopic -particles, e.g. a Smooth-Particle Hydrodynamics particle. +capacity associated with the internal degrees of freedom of an SPH +particles, i.e. a Smooth-Particle Hydrodynamics particle. .. math:: diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 2b5ed48ac9..61f69ed22d 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -237,9 +237,7 @@ accelerated styles exist. * :doc:`lb/viscous ` - * :doc:`lineforce ` - constrain atoms to move in a line * :doc:`manifoldforce ` - restrain atoms to a manifold during minimization -* :doc:`meso ` - time integration for SPH/DPDE particles * :doc:`meso/move ` - move mesoscopic SPH/SDPD particles in a prescribed fashion -* :doc:`meso/stationary ` - * :doc:`momentum ` - zero the linear and/or angular momentum of a group of atoms * :doc:`move ` - move atoms in a prescribed fashion * :doc:`mscg ` - apply MSCG method for force-matching to generate coarse grain models @@ -344,6 +342,8 @@ accelerated styles exist. * :doc:`smd/move_tri_surf ` - * :doc:`smd/setvel ` - * :doc:`smd/wall_surface ` - +* :doc:`sph ` - time integration for SPH/DPDE particles +* :doc:`sph/stationary ` - * :doc:`spring ` - apply harmonic spring force to group of atoms * :doc:`spring/chunk ` - apply harmonic spring force to each chunk of atoms * :doc:`spring/rg ` - spring on radius of gyration of group of atoms diff --git a/doc/src/fix_meso.rst b/doc/src/fix_sph.rst similarity index 79% rename from doc/src/fix_meso.rst rename to doc/src/fix_sph.rst index dc9f1cb991..d514285886 100644 --- a/doc/src/fix_meso.rst +++ b/doc/src/fix_sph.rst @@ -1,6 +1,6 @@ -.. index:: fix meso +.. index:: fix sph -fix meso command +fix sph command ================ Syntax @@ -8,25 +8,25 @@ Syntax .. parsed-literal:: - fix ID group-ID meso + fix ID group-ID sph * ID, group-ID are documented in :doc:`fix ` command -* meso = style name of this fix command +* sph = style name of this fix command Examples """""""" .. code-block:: LAMMPS - fix 1 all meso + fix 1 all sph Description """"""""""" Perform time integration to update position, velocity, internal energy and local density for atoms in the group each timestep. This fix is -needed to time-integrate mesoscopic systems where particles carry -internal variables such as SPH or DPDE. +needed to time-integrate SPH systems where particles carry internal +variables such as internal energy. SPH is Smoothed Particle Dynamics. See `this PDF guide `_ to using SPH in LAMMPS. @@ -48,6 +48,6 @@ LAMMPS was built with that package. See the :doc:`Build package Related commands """""""""""""""" -"fix meso/stationary" +:doc:`fix sph/stationary ` **Default:** none diff --git a/doc/src/fix_meso_stationary.rst b/doc/src/fix_sph_stationary.rst similarity index 84% rename from doc/src/fix_meso_stationary.rst rename to doc/src/fix_sph_stationary.rst index 89c30ece14..cd0d3e4d73 100644 --- a/doc/src/fix_meso_stationary.rst +++ b/doc/src/fix_sph_stationary.rst @@ -1,6 +1,6 @@ -.. index:: fix meso/stationary +.. index:: fix sph/stationary -fix meso/stationary command +fix sph/stationary command =========================== Syntax @@ -8,17 +8,17 @@ Syntax .. parsed-literal:: - fix ID group-ID meso/stationary + fix ID group-ID sph/stationary * ID, group-ID are documented in :doc:`fix ` command -* meso = style name of this fix command +* sph = style name of this fix command Examples """""""" .. code-block:: LAMMPS - fix 1 boundary meso/stationary + fix 1 boundary sph/stationary Description """"""""""" @@ -27,7 +27,7 @@ Perform time integration to update internal energy and local density, but not position or velocity for atoms in the group each timestep. This fix is needed for SPH simulations to correctly time-integrate fixed boundary particles which constrain a fluid to a given region in -space. +space. SPH stands for Smoothed Particle Hydrodynamics. See `this PDF guide `_ to using SPH in LAMMPS. @@ -49,6 +49,6 @@ LAMMPS was built with that package. See the :doc:`Build package Related commands """""""""""""""" -"fix meso" +:doc:`fix sph ` **Default:** none diff --git a/doc/src/set.rst b/doc/src/set.rst index 84792d1a58..b986e4b26f 100644 --- a/doc/src/set.rst +++ b/doc/src/set.rst @@ -13,7 +13,7 @@ Syntax * style = *atom* or *type* or *mol* or *group* or *region* * ID = atom ID range or type range or mol ID range or group ID or region ID * one or more keyword/value pairs may be appended -* keyword = *type* or *type/fraction* or *type/ratio* or *type/subset* or *mol* or *x* or *y* or *z* or *charge* or *dipole* or *dipole/random* or *quat* or *spin* or *spin/random* or *quat* or *quat/random* or *diameter* or *shape* or *length* or *tri* or *theta* or *theta/random* or *angmom* or *omega* or *mass* or *density* or *density/disc* or *volume* or *image* or *bond* or *angle* or *dihedral* or *improper* or *meso/e* or *meso/cv* or *meso/rho* or *smd/contact/radius* or *smd/mass/density* or *dpd/theta* or *edpd/temp* or *edpd/cv* or *cc* or *i_name* or *d_name* +* keyword = *type* or *type/fraction* or *type/ratio* or *type/subset* or *mol* or *x* or *y* or *z* or *charge* or *dipole* or *dipole/random* or *quat* or *spin* or *spin/random* or *quat* or *quat/random* or *diameter* or *shape* or *length* or *tri* or *theta* or *theta/random* or *angmom* or *omega* or *mass* or *density* or *density/disc* or *volume* or *image* or *bond* or *angle* or *dihedral* or *improper* or *sph/e* or *sph/cv* or *sph/rho* or *smd/contact/radius* or *smd/mass/density* or *dpd/theta* or *edpd/temp* or *edpd/cv* or *cc* or *i_name* or *d_name* .. parsed-literal:: @@ -94,11 +94,11 @@ Syntax *angle* value = angle type for all angles between selected atoms *dihedral* value = dihedral type for all dihedrals between selected atoms *improper* value = improper type for all impropers between selected atoms - *meso/e* value = energy of SPH particles (need units) + *sph/e* value = energy of SPH particles (need units) value can be an atom-style variable (see below) - *meso/cv* value = heat capacity of SPH particles (need units) + *sph/cv* value = heat capacity of SPH particles (need units) value can be an atom-style variable (see below) - *meso/rho* value = density of SPH particles (need units) + *sph/rho* value = density of SPH particles (need units) value can be an atom-style variable (see below) *smd/contact/radius* = radius for short range interactions, i.e. contact and friction value can be an atom-style variable (see below) @@ -299,29 +299,31 @@ for each particle set by this command. This keyword does not allow use of an atom-style variable. Keyword *diameter* sets the size of the selected atoms. The particles -must be finite-size spheres as defined by the :doc:`atom_style sphere ` command. The diameter of a particle can be -set to 0.0, which means they will be treated as point particles. Note -that this command does not adjust the particle mass, even if it was -defined with a density, e.g. via the :doc:`read_data ` -command. +must be finite-size spheres as defined by the :doc:`atom_style sphere +` command. The diameter of a particle can be set to 0.0, +which means they will be treated as point particles. Note that this +command does not adjust the particle mass, even if it was defined with +a density, e.g. via the :doc:`read_data ` command. Keyword *shape* sets the size and shape of the selected atoms. The -particles must be ellipsoids as defined by the :doc:`atom_style ellipsoid ` command. The *Sx*\ , *Sy*\ , *Sz* settings are -the 3 diameters of the ellipsoid in each direction. All 3 can be set -to the same value, which means the ellipsoid is effectively a sphere. -They can also all be set to 0.0 which means the particle will be -treated as a point particle. Note that this command does not adjust -the particle mass, even if it was defined with a density, e.g. via the -:doc:`read_data ` command. +particles must be ellipsoids as defined by the :doc:`atom_style +ellipsoid ` command. The *Sx*\ , *Sy*\ , *Sz* settings +are the 3 diameters of the ellipsoid in each direction. All 3 can be +set to the same value, which means the ellipsoid is effectively a +sphere. They can also all be set to 0.0 which means the particle will +be treated as a point particle. Note that this command does not +adjust the particle mass, even if it was defined with a density, +e.g. via the :doc:`read_data ` command. Keyword *length* sets the length of selected atoms. The particles -must be line segments as defined by the :doc:`atom_style line ` command. If the specified value is non-zero the -line segment is (re)set to a length = the specified value, centered -around the particle position, with an orientation along the x-axis. -If the specified value is 0.0, the particle will become a point -particle. Note that this command does not adjust the particle mass, -even if it was defined with a density, e.g. via the -:doc:`read_data ` command. +must be line segments as defined by the :doc:`atom_style line +` command. If the specified value is non-zero the line +segment is (re)set to a length = the specified value, centered around +the particle position, with an orientation along the x-axis. If the +specified value is 0.0, the particle will become a point particle. +Note that this command does not adjust the particle mass, even if it +was defined with a density, e.g. via the :doc:`read_data ` +command. Keyword *tri* sets the size of selected atoms. The particles must be triangles as defined by the :doc:`atom_style tri ` command. @@ -335,7 +337,8 @@ does not adjust the particle mass, even if it was defined with a density, e.g. via the :doc:`read_data ` command. Keyword *theta* sets the orientation of selected atoms. The particles -must be line segments as defined by the :doc:`atom_style line ` command. The specified value is used to set the +must be line segments as defined by the :doc:`atom_style line +` command. The specified value is used to set the orientation angle of the line segments with respect to the x axis. Keyword *theta/random* randomizes the orientation of theta for the @@ -346,44 +349,47 @@ regardless of how many processors are being used. This keyword does not allow use of an atom-style variable. Keyword *angmom* sets the angular momentum of selected atoms. The -particles must be ellipsoids as defined by the :doc:`atom_style ellipsoid ` command or triangles as defined by the -:doc:`atom_style tri ` command. The angular momentum vector -of the particles is set to the 3 specified components. +particles must be ellipsoids as defined by the :doc:`atom_style +ellipsoid ` command or triangles as defined by the +:doc:`atom_style tri ` command. The angular momentum +vector of the particles is set to the 3 specified components. Keyword *omega* sets the angular velocity of selected atoms. The -particles must be spheres as defined by the -:doc:`atom_style sphere ` command. The angular velocity -vector of the particles is set to the 3 specified components. +particles must be spheres as defined by the :doc:`atom_style sphere +` command. The angular velocity vector of the particles +is set to the 3 specified components. Keyword *mass* sets the mass of all selected particles. The particles must have a per-atom mass attribute, as defined by the -:doc:`atom_style ` command. See the "mass" command for how -to set mass values on a per-type basis. +:doc:`atom_style ` command. See the "mass" command for +how to set mass values on a per-type basis. Keyword *density* or *density/disc* also sets the mass of all selected particles, but in a different way. The particles must have a per-atom mass attribute, as defined by the :doc:`atom_style ` -command. If the atom has a radius attribute (see :doc:`atom_style sphere `) and its radius is non-zero, its mass is set -from the density and particle volume for 3d systems (the input density -is assumed to be in mass/distance\^3 units). For 2d, the default is -for LAMMPS to model particles with a radius attribute as spheres. +command. If the atom has a radius attribute (see :doc:`atom_style +sphere `) and its radius is non-zero, its mass is set from +the density and particle volume for 3d systems (the input density is +assumed to be in mass/distance\^3 units). For 2d, the default is for +LAMMPS to model particles with a radius attribute as spheres. However, if the *density/disc* keyword is used, then they can be modeled as 2d discs (circles). Their mass is set from the density and particle area (the input density is assumed to be in mass/distance\^2 units). -If the atom has a shape attribute (see :doc:`atom_style ellipsoid `) and its 3 shape parameters are non-zero, -then its mass is set from the density and particle volume (the input -density is assumed to be in mass/distance\^3 units). The -*density/disc* keyword has no effect; it does not (yet) treat 3d -ellipsoids as 2d ellipses. +If the atom has a shape attribute (see :doc:`atom_style ellipsoid +`) and its 3 shape parameters are non-zero, then its mass +is set from the density and particle volume (the input density is +assumed to be in mass/distance\^3 units). The *density/disc* keyword +has no effect; it does not (yet) treat 3d ellipsoids as 2d ellipses. -If the atom has a length attribute (see :doc:`atom_style line `) and its length is non-zero, then its mass is -set from the density and line segment length (the input density is -assumed to be in mass/distance units). If the atom has an area -attribute (see :doc:`atom_style tri `) and its area is -non-zero, then its mass is set from the density and triangle area (the -input density is assumed to be in mass/distance\^2 units). +If the atom has a length attribute (see :doc:`atom_style line +`) and its length is non-zero, then its mass is set from +the density and line segment length (the input density is assumed to +be in mass/distance units). If the atom has an area attribute (see +:doc:`atom_style tri `) and its area is non-zero, then its +mass is set from the density and triangle area (the input density is +assumed to be in mass/distance\^2 units). If none of these cases are valid, then the mass is set to the density value directly (the input density is assumed to be in mass units). @@ -399,14 +405,15 @@ defined. A value of 2 means add 2 box lengths to get the true value. A value of -1 means subtract 1 box length to get the true value. LAMMPS updates these flags as atoms cross periodic boundaries during the simulation. The flags can be output with atom snapshots via the -:doc:`dump ` command. If a value of NULL is specified for any of -nx,ny,nz, then the current image value for that dimension is unchanged. -For non-periodic dimensions only a value of 0 can be specified. -This command can be useful after a system has been equilibrated and -atoms have diffused one or more box lengths in various directions. -This command can then reset the image values for atoms so that they -are effectively inside the simulation box, e.g if a diffusion -coefficient is about to be measured via the :doc:`compute msd ` command. Care should be taken not to reset the +:doc:`dump ` command. If a value of NULL is specified for any +of nx,ny,nz, then the current image value for that dimension is +unchanged. For non-periodic dimensions only a value of 0 can be +specified. This command can be useful after a system has been +equilibrated and atoms have diffused one or more box lengths in +various directions. This command can then reset the image values for +atoms so that they are effectively inside the simulation box, e.g if a +diffusion coefficient is about to be measured via the :doc:`compute +msd ` command. Care should be taken not to reset the image flags of two atoms in a bond to the same value if the bond straddles a periodic boundary (rather they should be different by +/- 1). This will not affect the dynamics of a simulation, but may mess @@ -423,10 +430,10 @@ etc) was set by the *bond types* (\ *angle types*\ , etc) field in the header of the data file read by the :doc:`read_data ` command. These keywords do not allow use of an atom-style variable. -Keywords *meso/e*\ , *meso/cv*\ , and *meso/rho* set the energy, heat +Keywords *sph/e*\ , *sph/cv*\ , and *sph/rho* set the energy, heat capacity, and density of smoothed particle hydrodynamics (SPH) -particles. See `this PDF guide `_ to -using SPH in LAMMPS. +particles. See `this PDF guide `_ +to using SPH in LAMMPS. Keyword *smd/mass/density* sets the mass of all selected particles, but it is only applicable to the Smooth Mach Dynamics package diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_sph.cpp similarity index 76% rename from src/USER-SPH/atom_vec_meso.cpp rename to src/USER-SPH/atom_vec_sph.cpp index fdddd15f27..84a60e44f7 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_sph.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "atom_vec_meso.h" +#include "atom_vec_sph.h" #include #include "atom.h" #include "error.h" @@ -20,13 +20,13 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) +AtomVecSPH::AtomVecSPH(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; mass_type = 1; forceclearflag = 1; - atom->e_flag = 1; + atom->esph_flag = 1; atom->rho_flag = 1; atom->cv_flag = 1; atom->vest_flag = 1; @@ -36,17 +36,17 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) "rho drho e de cv vest"; - fields_copy = (char *) "rho drho e de cv vest"; - fields_comm = (char *) "rho e vest"; - fields_comm_vel = (char *) "rho e vest"; - fields_reverse = (char *) "drho de"; - fields_border = (char *) "rho e cv vest"; - fields_border_vel = (char *) "rho e cv vest"; - fields_exchange = (char *) "rho e cv vest"; - fields_restart = (char * ) "rho e cv vest"; - fields_create = (char *) "rho e cv vest de drho"; - fields_data_atom = (char *) "id type rho e cv x"; + fields_grow = (char *) "rho drho esph desph cv vest"; + fields_copy = (char *) "rho drho esph desph cv vest"; + fields_comm = (char *) "rho esph vest"; + fields_comm_vel = (char *) "rho esph vest"; + fields_reverse = (char *) "drho desph"; + fields_border = (char *) "rho esph cv vest"; + fields_border_vel = (char *) "rho esph cv vest"; + fields_exchange = (char *) "rho esph cv vest"; + fields_restart = (char * ) "rho esph cv vest"; + fields_create = (char *) "rho esph cv vest de drho"; + fields_data_atom = (char *) "id type rho esph cv x"; fields_data_vel = (char *) "id v"; setup_fields(); @@ -57,12 +57,12 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) needed in replicate when 2 atom classes exist and it calls pack_restart() ------------------------------------------------------------------------- */ -void AtomVecMeso::grow_pointers() +void AtomVecSPH::grow_pointers() { rho = atom->rho; drho = atom->drho; - e = atom->e; - de = atom->de; + esph = atom->esph; + desph = atom->desph; cv = atom->cv; vest = atom->vest; } @@ -72,9 +72,9 @@ void AtomVecMeso::grow_pointers() nbytes = # of bytes to clear for a per-atom vector ------------------------------------------------------------------------- */ -void AtomVecMeso::force_clear(int n, size_t nbytes) +void AtomVecSPH::force_clear(int n, size_t nbytes) { - memset(&de[n],0,nbytes); + memset(&desph[n],0,nbytes); memset(&drho[n],0,nbytes); } @@ -82,7 +82,7 @@ void AtomVecMeso::force_clear(int n, size_t nbytes) initialize non-zero atom quantities ------------------------------------------------------------------------- */ -void AtomVecMeso::create_atom_post(int ilocal) +void AtomVecSPH::create_atom_post(int ilocal) { cv[ilocal] = 1.0; } @@ -92,12 +92,12 @@ void AtomVecMeso::create_atom_post(int ilocal) or initialize other atom quantities ------------------------------------------------------------------------- */ -void AtomVecMeso::data_atom_post(int ilocal) +void AtomVecSPH::data_atom_post(int ilocal) { vest[ilocal][0] = 0.0; vest[ilocal][1] = 0.0; vest[ilocal][2] = 0.0; - de[ilocal] = 0.0; + desph[ilocal] = 0.0; drho[ilocal] = 0.0; } @@ -106,12 +106,12 @@ void AtomVecMeso::data_atom_post(int ilocal) return -1 if name is unknown to this atom style ------------------------------------------------------------------------- */ -int AtomVecMeso::property_atom(char *name) +int AtomVecSPH::property_atom(char *name) { if (strcmp(name,"rho") == 0) return 0; if (strcmp(name,"drho") == 0) return 1; - if (strcmp(name,"e") == 0) return 2; - if (strcmp(name,"de") == 0) return 3; + if (strcmp(name,"esph") == 0) return 2; + if (strcmp(name,"desph") == 0) return 3; if (strcmp(name,"cv") == 0) return 4; return -1; } @@ -121,7 +121,7 @@ int AtomVecMeso::property_atom(char *name) index maps to data specific to this atom style ------------------------------------------------------------------------- */ -void AtomVecMeso::pack_property_atom(int index, double *buf, +void AtomVecSPH::pack_property_atom(int index, double *buf, int nvalues, int groupbit) { int *mask = atom->mask; @@ -142,13 +142,13 @@ void AtomVecMeso::pack_property_atom(int index, double *buf, } } else if (index == 2) { for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = e[i]; + if (mask[i] & groupbit) buf[n] = esph[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 3) { for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = de[i]; + if (mask[i] & groupbit) buf[n] = desph[i]; else buf[n] = 0.0; n += nvalues; } diff --git a/src/USER-SPH/atom_vec_meso.h b/src/USER-SPH/atom_vec_sph.h similarity index 83% rename from src/USER-SPH/atom_vec_meso.h rename to src/USER-SPH/atom_vec_sph.h index bd84c34fbc..634c3c72f5 100644 --- a/src/USER-SPH/atom_vec_meso.h +++ b/src/USER-SPH/atom_vec_sph.h @@ -13,20 +13,20 @@ #ifdef ATOM_CLASS -AtomStyle(meso,AtomVecMeso) +AtomStyle(sph,AtomVecSPH) #else -#ifndef LMP_ATOM_VEC_MESO_H -#define LMP_ATOM_VEC_MESO_H +#ifndef LMP_ATOM_VEC_SPH_H +#define LMP_ATOM_VEC_SPH_H #include "atom_vec.h" namespace LAMMPS_NS { -class AtomVecMeso : public AtomVec { +class AtomVecSPH : public AtomVec { public: - AtomVecMeso(class LAMMPS *); + AtomVecSPH(class LAMMPS *); void grow_pointers(); void force_clear(int, size_t); @@ -36,7 +36,7 @@ class AtomVecMeso : public AtomVec { void pack_property_atom(int, double *, int, int); private: - double *rho,*drho,*e,*de,*cv; + double *rho,*drho,*esph,*desph,*cv; double **vest; }; diff --git a/src/USER-SPH/compute_meso_e_atom.cpp b/src/USER-SPH/compute_sph_e_atom.cpp similarity index 80% rename from src/USER-SPH/compute_meso_e_atom.cpp rename to src/USER-SPH/compute_sph_e_atom.cpp index c56243e5ed..8869dae5f7 100644 --- a/src/USER-SPH/compute_meso_e_atom.cpp +++ b/src/USER-SPH/compute_sph_e_atom.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "compute_meso_e_atom.h" +#include "compute_sph_e_atom.h" #include #include "atom.h" #include "update.h" @@ -24,11 +24,13 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ComputeMesoEAtom::ComputeMesoEAtom(LAMMPS *lmp, int narg, char **arg) : +ComputeSPHEAtom::ComputeSPHEAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - if (narg != 3) error->all(FLERR,"Number of arguments for compute meso/e/atom command != 3"); - if (atom->e_flag != 1) error->all(FLERR,"compute meso/e/atom command requires atom_style with energy (e.g. meso)"); + if (narg != 3) + error->all(FLERR,"Number of arguments for compute sph/e/atom command != 3"); + if (atom->esph_flag != 1) + error->all(FLERR,"Compute sph/e/atom command requires atom_style sph)"); peratom_flag = 1; size_peratom_cols = 0; @@ -39,14 +41,14 @@ ComputeMesoEAtom::ComputeMesoEAtom(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -ComputeMesoEAtom::~ComputeMesoEAtom() +ComputeSPHEAtom::~ComputeSPHEAtom() { memory->sfree(evector); } /* ---------------------------------------------------------------------- */ -void ComputeMesoEAtom::init() +void ComputeSPHEAtom::init() { int count = 0; @@ -58,7 +60,7 @@ void ComputeMesoEAtom::init() /* ---------------------------------------------------------------------- */ -void ComputeMesoEAtom::compute_peratom() +void ComputeSPHEAtom::compute_peratom() { invoked_peratom = update->ntimestep; @@ -71,13 +73,13 @@ void ComputeMesoEAtom::compute_peratom() vector_atom = evector; } - double *e = atom->e; + double *esph = atom->esph; int *mask = atom->mask; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - evector[i] = e[i]; + evector[i] = esph[i]; } else { evector[i] = 0.0; @@ -89,7 +91,7 @@ void ComputeMesoEAtom::compute_peratom() memory usage of local atom-based array ------------------------------------------------------------------------- */ -double ComputeMesoEAtom::memory_usage() +double ComputeSPHEAtom::memory_usage() { double bytes = nmax * sizeof(double); return bytes; diff --git a/src/USER-SPH/compute_meso_e_atom.h b/src/USER-SPH/compute_sph_e_atom.h similarity index 78% rename from src/USER-SPH/compute_meso_e_atom.h rename to src/USER-SPH/compute_sph_e_atom.h index 3cdbfa7aa8..370fab148b 100644 --- a/src/USER-SPH/compute_meso_e_atom.h +++ b/src/USER-SPH/compute_sph_e_atom.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS -ComputeStyle(meso/e/atom,ComputeMesoEAtom) +ComputeStyle(sph/e/atom,ComputeSPHEAtom) #else -#ifndef LMP_COMPUTE_MESO_E_ATOM_H -#define LMP_COMPUTE_MESO_E_ATOM_H +#ifndef LMP_COMPUTE_SPH_E_ATOM_H +#define LMP_COMPUTE_SPH_E_ATOM_H #include "compute.h" namespace LAMMPS_NS { -class ComputeMesoEAtom : public Compute { +class ComputeSPHEAtom : public Compute { public: - ComputeMesoEAtom(class LAMMPS *, int, char **); - ~ComputeMesoEAtom(); + ComputeSPHEAtom(class LAMMPS *, int, char **); + ~ComputeSPHEAtom(); void init(); void compute_peratom(); double memory_usage(); diff --git a/src/USER-SPH/compute_meso_rho_atom.cpp b/src/USER-SPH/compute_sph_rho_atom.cpp similarity index 83% rename from src/USER-SPH/compute_meso_rho_atom.cpp rename to src/USER-SPH/compute_sph_rho_atom.cpp index b2fbd2d70a..1d6d03811c 100644 --- a/src/USER-SPH/compute_meso_rho_atom.cpp +++ b/src/USER-SPH/compute_sph_rho_atom.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "compute_meso_rho_atom.h" +#include "compute_sph_rho_atom.h" #include #include "atom.h" #include "update.h" @@ -24,11 +24,12 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ComputeMesoRhoAtom::ComputeMesoRhoAtom(LAMMPS *lmp, int narg, char **arg) : +ComputeSPHRhoAtom::ComputeSPHRhoAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - if (narg != 3) error->all(FLERR,"Illegal compute meso/rho/atom command"); - if (atom->rho_flag != 1) error->all(FLERR,"compute meso/rho/atom command requires atom_style with density (e.g. meso)"); + if (narg != 3) error->all(FLERR,"Illegal compute sph/rho/atom command"); + if (atom->rho_flag != 1) + error->all(FLERR,"Compute sph/rho/atom command requires atom_style sph"); peratom_flag = 1; size_peratom_cols = 0; @@ -39,14 +40,14 @@ ComputeMesoRhoAtom::ComputeMesoRhoAtom(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -ComputeMesoRhoAtom::~ComputeMesoRhoAtom() +ComputeSPHRhoAtom::~ComputeSPHRhoAtom() { memory->sfree(rhoVector); } /* ---------------------------------------------------------------------- */ -void ComputeMesoRhoAtom::init() +void ComputeSPHRhoAtom::init() { int count = 0; @@ -58,7 +59,7 @@ void ComputeMesoRhoAtom::init() /* ---------------------------------------------------------------------- */ -void ComputeMesoRhoAtom::compute_peratom() +void ComputeSPHRhoAtom::compute_peratom() { invoked_peratom = update->ntimestep; @@ -91,7 +92,7 @@ void ComputeMesoRhoAtom::compute_peratom() memory usage of local atom-based array ------------------------------------------------------------------------- */ -double ComputeMesoRhoAtom::memory_usage() +double ComputeSPHRhoAtom::memory_usage() { double bytes = nmax * sizeof(double); return bytes; diff --git a/src/USER-SPH/compute_meso_rho_atom.h b/src/USER-SPH/compute_sph_rho_atom.h similarity index 77% rename from src/USER-SPH/compute_meso_rho_atom.h rename to src/USER-SPH/compute_sph_rho_atom.h index ec4942ef92..bd38f41199 100644 --- a/src/USER-SPH/compute_meso_rho_atom.h +++ b/src/USER-SPH/compute_sph_rho_atom.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS -ComputeStyle(meso/rho/atom,ComputeMesoRhoAtom) +ComputeStyle(sph/rho/atom,ComputeSPHRhoAtom) #else -#ifndef LMP_COMPUTE_MESO_RHO_ATOM_H -#define LMP_COMPUTE_MESO_RHO_ATOM_H +#ifndef LMP_COMPUTE_MESO_SPH_ATOM_H +#define LMP_COMPUTE_MESO_SPH_ATOM_H #include "compute.h" namespace LAMMPS_NS { -class ComputeMesoRhoAtom : public Compute { +class ComputeSPHRhoAtom : public Compute { public: - ComputeMesoRhoAtom(class LAMMPS *, int, char **); - ~ComputeMesoRhoAtom(); + ComputeSPHRhoAtom(class LAMMPS *, int, char **); + ~ComputeSPHRhoAtom(); void init(); void compute_peratom(); double memory_usage(); diff --git a/src/USER-SPH/compute_meso_t_atom.cpp b/src/USER-SPH/compute_sph_t_atom.cpp similarity index 79% rename from src/USER-SPH/compute_meso_t_atom.cpp rename to src/USER-SPH/compute_sph_t_atom.cpp index bab96468dd..063af70026 100644 --- a/src/USER-SPH/compute_meso_t_atom.cpp +++ b/src/USER-SPH/compute_sph_t_atom.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "compute_meso_t_atom.h" +#include "compute_sph_t_atom.h" #include #include "atom.h" #include "update.h" @@ -24,12 +24,13 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ComputeMesoTAtom::ComputeMesoTAtom(LAMMPS *lmp, int narg, char **arg) : +ComputeSPHTAtom::ComputeSPHTAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - if (narg != 3) error->all(FLERR,"Number of arguments for compute meso/t/atom command != 3"); - if ((atom->e_flag != 1) || (atom->cv_flag != 1)) - error->all(FLERR,"Compute meso/t/atom command requires atom_style with both energy and heat capacity (e.g. meso)"); + if (narg != 3) + error->all(FLERR,"Number of arguments for compute sph/t/atom command != 3"); + if ((atom->esph_flag != 1) || (atom->cv_flag != 1)) + error->all(FLERR,"Compute sph/t/atom command requires atom_style sph"); peratom_flag = 1; size_peratom_cols = 0; @@ -40,14 +41,14 @@ ComputeMesoTAtom::ComputeMesoTAtom(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -ComputeMesoTAtom::~ComputeMesoTAtom() +ComputeSPHTAtom::~ComputeSPHTAtom() { memory->sfree(tvector); } /* ---------------------------------------------------------------------- */ -void ComputeMesoTAtom::init() +void ComputeSPHTAtom::init() { int count = 0; @@ -59,7 +60,7 @@ void ComputeMesoTAtom::init() /* ---------------------------------------------------------------------- */ -void ComputeMesoTAtom::compute_peratom() +void ComputeSPHTAtom::compute_peratom() { invoked_peratom = update->ntimestep; @@ -72,7 +73,7 @@ void ComputeMesoTAtom::compute_peratom() vector_atom = tvector; } - double *e = atom->e; + double *esph = atom->esph; double *cv = atom->cv; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -80,7 +81,7 @@ void ComputeMesoTAtom::compute_peratom() for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (cv[i] > 0.0) { - tvector[i] = e[i] / cv[i]; + tvector[i] = esph[i] / cv[i]; } } else { @@ -93,7 +94,7 @@ void ComputeMesoTAtom::compute_peratom() memory usage of local atom-based array ------------------------------------------------------------------------- */ -double ComputeMesoTAtom::memory_usage() +double ComputeSPHTAtom::memory_usage() { double bytes = nmax * sizeof(double); return bytes; diff --git a/src/USER-SPH/compute_meso_t_atom.h b/src/USER-SPH/compute_sph_t_atom.h similarity index 78% rename from src/USER-SPH/compute_meso_t_atom.h rename to src/USER-SPH/compute_sph_t_atom.h index 9e4b253712..b3bf93a0eb 100644 --- a/src/USER-SPH/compute_meso_t_atom.h +++ b/src/USER-SPH/compute_sph_t_atom.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS -ComputeStyle(meso/t/atom,ComputeMesoTAtom) +ComputeStyle(sph/t/atom,ComputeSPHTAtom) #else -#ifndef LMP_COMPUTE_MESO_T_ATOM_H -#define LMP_COMPUTE_MESO_T_ATOM_H +#ifndef LMP_COMPUTE_SPH_T_ATOM_H +#define LMP_COMPUTE_SPH_T_ATOM_H #include "compute.h" namespace LAMMPS_NS { -class ComputeMesoTAtom : public Compute { +class ComputeSPHTAtom : public Compute { public: - ComputeMesoTAtom(class LAMMPS *, int, char **); - ~ComputeMesoTAtom(); + ComputeSPHTAtom(class LAMMPS *, int, char **); + ~ComputeSPHTAtom(); void init(); void compute_peratom(); double memory_usage(); diff --git a/src/USER-SPH/fix_meso.cpp b/src/USER-SPH/fix_sph.cpp similarity index 84% rename from src/USER-SPH/fix_meso.cpp rename to src/USER-SPH/fix_sph.cpp index 4f4e532291..843edc8e92 100644 --- a/src/USER-SPH/fix_meso.cpp +++ b/src/USER-SPH/fix_sph.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "fix_meso.h" +#include "fix_sph.h" #include "atom.h" #include "force.h" #include "update.h" @@ -22,22 +22,22 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixMeso::FixMeso(LAMMPS *lmp, int narg, char **arg) : +FixSPH::FixSPH(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if ((atom->e_flag != 1) || (atom->rho_flag != 1)) + if ((atom->esph_flag != 1) || (atom->rho_flag != 1)) error->all(FLERR, - "fix meso command requires atom_style with both energy and density"); + "Fix sph command requires atom_style with both energy and density"); if (narg != 3) - error->all(FLERR,"Illegal number of arguments for fix meso command"); + error->all(FLERR,"Illegal number of arguments for fix sph command"); time_integrate = 1; } /* ---------------------------------------------------------------------- */ -int FixMeso::setmask() { +int FixSPH::setmask() { int mask = 0; mask |= INITIAL_INTEGRATE; mask |= FINAL_INTEGRATE; @@ -47,12 +47,12 @@ int FixMeso::setmask() { /* ---------------------------------------------------------------------- */ -void FixMeso::init() { +void FixSPH::init() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; } -void FixMeso::setup_pre_force(int /*vflag*/) +void FixSPH::setup_pre_force(int /*vflag*/) { // set vest equal to v double **v = atom->v; @@ -75,7 +75,7 @@ void FixMeso::setup_pre_force(int /*vflag*/) allow for both per-type and per-atom mass ------------------------------------------------------------------------- */ -void FixMeso::initial_integrate(int /*vflag*/) { +void FixSPH::initial_integrate(int /*vflag*/) { // update v and x and rho and e of atoms in group double **x = atom->x; @@ -84,8 +84,8 @@ void FixMeso::initial_integrate(int /*vflag*/) { double **vest = atom->vest; double *rho = atom->rho; double *drho = atom->drho; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *mass = atom->mass; double *rmass = atom->rmass; int rmass_flag = atom->rmass_flag; @@ -107,7 +107,7 @@ void FixMeso::initial_integrate(int /*vflag*/) { dtfm = dtf / mass[type[i]]; } - e[i] += dtf * de[i]; // half-step update of particle internal energy + esph[i] += dtf * desph[i]; // half-step update of particle internal energy rho[i] += dtf * drho[i]; // ... and density // extrapolate velocity for use with velocity-dependent potentials, e.g. SPH @@ -128,14 +128,14 @@ void FixMeso::initial_integrate(int /*vflag*/) { /* ---------------------------------------------------------------------- */ -void FixMeso::final_integrate() { +void FixSPH::final_integrate() { // update v, rho, and e of atoms in group double **v = atom->v; double **f = atom->f; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *rho = atom->rho; double *drho = atom->drho; int *type = atom->type; @@ -160,7 +160,7 @@ void FixMeso::final_integrate() { v[i][1] += dtfm * f[i][1]; v[i][2] += dtfm * f[i][2]; - e[i] += dtf * de[i]; + esph[i] += dtf * desph[i]; rho[i] += dtf * drho[i]; } } @@ -168,7 +168,7 @@ void FixMeso::final_integrate() { /* ---------------------------------------------------------------------- */ -void FixMeso::reset_dt() { +void FixSPH::reset_dt() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; } diff --git a/src/USER-SPH/fix_meso.h b/src/USER-SPH/fix_sph.h similarity index 88% rename from src/USER-SPH/fix_meso.h rename to src/USER-SPH/fix_sph.h index 3eebb0f774..0a43997508 100644 --- a/src/USER-SPH/fix_meso.h +++ b/src/USER-SPH/fix_sph.h @@ -13,20 +13,20 @@ #ifdef FIX_CLASS -FixStyle(meso,FixMeso) +FixStyle(sph,FixSPH) #else -#ifndef LMP_FIX_MESO_H -#define LMP_FIX_MESO_H +#ifndef LMP_FIX_SPH_H +#define LMP_FIX_SPH_H #include "fix.h" namespace LAMMPS_NS { -class FixMeso : public Fix { +class FixSPH : public Fix { public: - FixMeso(class LAMMPS *, int, char **); + FixSPH(class LAMMPS *, int, char **); int setmask(); virtual void init(); virtual void setup_pre_force(int); diff --git a/src/USER-SPH/fix_meso_stationary.cpp b/src/USER-SPH/fix_sph_stationary.cpp similarity index 74% rename from src/USER-SPH/fix_meso_stationary.cpp rename to src/USER-SPH/fix_sph_stationary.cpp index b7f0675ef8..56ac71f2c5 100644 --- a/src/USER-SPH/fix_meso_stationary.cpp +++ b/src/USER-SPH/fix_sph_stationary.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "fix_meso_stationary.h" +#include "fix_sph_stationary.h" #include "atom.h" #include "force.h" #include "update.h" @@ -22,22 +22,22 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixMesoStationary::FixMesoStationary(LAMMPS *lmp, int narg, char **arg) : +FixSPHStationary::FixSPHStationary(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if ((atom->e_flag != 1) || (atom->rho_flag != 1)) + if ((atom->esph_flag != 1) || (atom->rho_flag != 1)) error->all(FLERR, - "fix meso/stationary command requires atom_style with both energy and density, e.g. meso"); + "Fix sph/stationary command requires atom_style with both energy and density, e.g. meso"); if (narg != 3) - error->all(FLERR,"Illegal number of arguments for fix meso/stationary command"); + error->all(FLERR,"Illegal number of arguments for fix sph/stationary command"); time_integrate = 0; } /* ---------------------------------------------------------------------- */ -int FixMesoStationary::setmask() { +int FixSPHStationary::setmask() { int mask = 0; mask |= INITIAL_INTEGRATE; mask |= FINAL_INTEGRATE; @@ -46,7 +46,7 @@ int FixMesoStationary::setmask() { /* ---------------------------------------------------------------------- */ -void FixMesoStationary::init() { +void FixSPHStationary::init() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; } @@ -55,12 +55,12 @@ void FixMesoStationary::init() { allow for both per-type and per-atom mass ------------------------------------------------------------------------- */ -void FixMesoStationary::initial_integrate(int /*vflag*/) { +void FixSPHStationary::initial_integrate(int /*vflag*/) { double *rho = atom->rho; double *drho = atom->drho; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -71,7 +71,7 @@ void FixMesoStationary::initial_integrate(int /*vflag*/) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - e[i] += dtf * de[i]; // half-step update of particle internal energy + esph[i] += dtf * desph[i]; // half-step update of particle internal energy rho[i] += dtf * drho[i]; // ... and density } } @@ -79,10 +79,10 @@ void FixMesoStationary::initial_integrate(int /*vflag*/) { /* ---------------------------------------------------------------------- */ -void FixMesoStationary::final_integrate() { +void FixSPHStationary::final_integrate() { - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *rho = atom->rho; double *drho = atom->drho; int *mask = atom->mask; @@ -92,7 +92,7 @@ void FixMesoStationary::final_integrate() { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - e[i] += dtf * de[i]; + esph[i] += dtf * desph[i]; rho[i] += dtf * drho[i]; } } @@ -100,7 +100,7 @@ void FixMesoStationary::final_integrate() { /* ---------------------------------------------------------------------- */ -void FixMesoStationary::reset_dt() { +void FixSPHStationary::reset_dt() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; } diff --git a/src/USER-SPH/fix_meso_stationary.h b/src/USER-SPH/fix_sph_stationary.h similarity index 83% rename from src/USER-SPH/fix_meso_stationary.h rename to src/USER-SPH/fix_sph_stationary.h index 326c13dcd3..f2bb6c39f2 100644 --- a/src/USER-SPH/fix_meso_stationary.h +++ b/src/USER-SPH/fix_sph_stationary.h @@ -13,20 +13,20 @@ #ifdef FIX_CLASS -FixStyle(meso/stationary,FixMesoStationary) +FixStyle(sph/stationary,FixSPHStationary) #else -#ifndef LMP_FIX_MESO_STATIONARY_H -#define LMP_FIX_MESO_STATIONARY_H +#ifndef LMP_FIX_SPH_STATIONARY_H +#define LMP_FIX_SPH_STATIONARY_H #include "fix.h" namespace LAMMPS_NS { -class FixMesoStationary : public Fix { +class FixSPHStationary : public Fix { public: - FixMesoStationary(class LAMMPS *, int, char **); + FixSPHStationary(class LAMMPS *, int, char **); int setmask(); virtual void init(); virtual void initial_integrate(int); diff --git a/src/USER-SPH/pair_sph_heatconduction.cpp b/src/USER-SPH/pair_sph_heatconduction.cpp index cff9009015..ebd2cef684 100644 --- a/src/USER-SPH/pair_sph_heatconduction.cpp +++ b/src/USER-SPH/pair_sph_heatconduction.cpp @@ -53,8 +53,8 @@ void PairSPHHeatConduction::compute(int eflag, int vflag) { ev_init(eflag, vflag); double **x = atom->x; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *mass = atom->mass; double *rho = atom->rho; int *type = atom->type; @@ -116,11 +116,11 @@ void PairSPHHeatConduction::compute(int eflag, int vflag) { deltaE = 2.0 * imass * jmass / (imass+jmass); deltaE *= (rho[i] + rho[j]) / (rho[i] * rho[j]); - deltaE *= D * (e[i] - e[j]) * wfd; + deltaE *= D * (esph[i] - esph[j]) * wfd; - de[i] += deltaE; + desph[i] += deltaE; if (newton_pair || j < nlocal) { - de[j] -= deltaE; + desph[j] -= deltaE; } } diff --git a/src/USER-SPH/pair_sph_idealgas.cpp b/src/USER-SPH/pair_sph_idealgas.cpp index f206bf68f5..1f6b63e199 100644 --- a/src/USER-SPH/pair_sph_idealgas.cpp +++ b/src/USER-SPH/pair_sph_idealgas.cpp @@ -58,8 +58,8 @@ void PairSPHIdealGas::compute(int eflag, int vflag) { double **f = atom->f; double *rho = atom->rho; double *mass = atom->mass; - double *de = atom->de; - double *e = atom->e; + double *desph = atom->desph; + double *esph = atom->esph; double *drho = atom->drho; int *type = atom->type; int nlocal = atom->nlocal; @@ -86,8 +86,8 @@ void PairSPHIdealGas::compute(int eflag, int vflag) { imass = mass[itype]; - fi = 0.4 * e[i] / imass / rho[i]; // ideal gas EOS; this expression is fi = pressure / rho^2 - ci = sqrt(0.4*e[i]/imass); // speed of sound with heat capacity ratio gamma=1.4 + fi = 0.4 * esph[i] / imass / rho[i]; // ideal gas EOS; this expression is fi = pressure / rho^2 + ci = sqrt(0.4*esph[i]/imass); // speed of sound with heat capacity ratio gamma=1.4 for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -119,7 +119,7 @@ void PairSPHIdealGas::compute(int eflag, int vflag) { wfd = -19.098593171027440292e0 * wfd * wfd * ihsq * ihsq * ihsq; } - fj = 0.4 * e[j] / jmass / rho[j]; + fj = 0.4 * esph[j] / jmass / rho[j]; // dot product of velocity delta and distance vector delVdotDelR = delx * (vxtmp - v[j][0]) + dely * (vytmp - v[j][1]) @@ -127,7 +127,7 @@ void PairSPHIdealGas::compute(int eflag, int vflag) { // artificial viscosity (Monaghan 1992) if (delVdotDelR < 0.) { - cj = sqrt(0.4*e[j]/jmass); + cj = sqrt(0.4*esph[j]/jmass); mu = h * delVdotDelR / (rsq + 0.01 * h * h); fvisc = -viscosity[itype][jtype] * (ci + cj) * mu / (rho[i] + rho[j]); } else { @@ -146,13 +146,13 @@ void PairSPHIdealGas::compute(int eflag, int vflag) { drho[i] += jmass * delVdotDelR * wfd; // change in thermal energy - de[i] += deltaE; + desph[i] += deltaE; if (newton_pair || j < nlocal) { f[j][0] -= delx * fpair; f[j][1] -= dely * fpair; f[j][2] -= delz * fpair; - de[j] += deltaE; + desph[j] += deltaE; drho[j] += imass * delVdotDelR * wfd; } diff --git a/src/USER-SPH/pair_sph_lj.cpp b/src/USER-SPH/pair_sph_lj.cpp index 3173e2a47d..ae42c413e7 100644 --- a/src/USER-SPH/pair_sph_lj.cpp +++ b/src/USER-SPH/pair_sph_lj.cpp @@ -58,8 +58,8 @@ void PairSPHLJ::compute(int eflag, int vflag) { double **f = atom->f; double *rho = atom->rho; double *mass = atom->mass; - double *de = atom->de; - double *e = atom->e; + double *desph = atom->desph; + double *esph = atom->esph; double *cv = atom->cv; double *drho = atom->drho; int *type = atom->type; @@ -88,7 +88,7 @@ void PairSPHLJ::compute(int eflag, int vflag) { imass = mass[itype]; // compute pressure of particle i with LJ EOS - LJEOS2(rho[i], e[i], cv[i], &fi, &ci); + LJEOS2(rho[i], esph[i], cv[i], &fi, &ci); fi /= (rho[i] * rho[i]); //printf("fi = %f\n", fi); @@ -124,7 +124,7 @@ void PairSPHLJ::compute(int eflag, int vflag) { } // function call to LJ EOS - LJEOS2(rho[j], e[j], cv[j], &fj, &cj); + LJEOS2(rho[j], esph[j], cv[j], &fj, &cj); fj /= (rho[j] * rho[j]); // apply long-range correction to model a LJ fluid with cutoff @@ -157,13 +157,13 @@ void PairSPHLJ::compute(int eflag, int vflag) { drho[i] += jmass * delVdotDelR * wfd; // change in thermal energy - de[i] += deltaE; + desph[i] += deltaE; if (newton_pair || j < nlocal) { f[j][0] -= delx * fpair; f[j][1] -= dely * fpair; f[j][2] -= delz * fpair; - de[j] += deltaE; + desph[j] += deltaE; drho[j] += imass * delVdotDelR * wfd; } diff --git a/src/USER-SPH/pair_sph_taitwater.cpp b/src/USER-SPH/pair_sph_taitwater.cpp index f2a34d4edd..79d9ac7742 100644 --- a/src/USER-SPH/pair_sph_taitwater.cpp +++ b/src/USER-SPH/pair_sph_taitwater.cpp @@ -64,7 +64,7 @@ void PairSPHTaitwater::compute(int eflag, int vflag) { double **f = atom->f; double *rho = atom->rho; double *mass = atom->mass; - double *de = atom->de; + double *desph = atom->desph; double *drho = atom->drho; int *type = atom->type; int nlocal = atom->nlocal; @@ -176,13 +176,13 @@ void PairSPHTaitwater::compute(int eflag, int vflag) { drho[i] += jmass * delVdotDelR * wfd; // change in thermal energy - de[i] += deltaE; + desph[i] += deltaE; if (newton_pair || j < nlocal) { f[j][0] -= delx * fpair; f[j][1] -= dely * fpair; f[j][2] -= delz * fpair; - de[j] += deltaE; + desph[j] += deltaE; drho[j] += imass * delVdotDelR * wfd; } diff --git a/src/USER-SPH/pair_sph_taitwater_morris.cpp b/src/USER-SPH/pair_sph_taitwater_morris.cpp index 9ca03e3476..862d2a8053 100644 --- a/src/USER-SPH/pair_sph_taitwater_morris.cpp +++ b/src/USER-SPH/pair_sph_taitwater_morris.cpp @@ -64,7 +64,7 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) { double **f = atom->f; double *rho = atom->rho; double *mass = atom->mass; - double *de = atom->de; + double *desph = atom->desph; double *drho = atom->drho; int *type = atom->type; int nlocal = atom->nlocal; @@ -177,13 +177,13 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) { drho[i] += jmass * delVdotDelR * wfd; // change in thermal energy - de[i] += deltaE; + desph[i] += deltaE; if (newton_pair || j < nlocal) { f[j][0] -= delx * fpair + velx * fvisc; f[j][1] -= dely * fpair + vely * fvisc; f[j][2] -= delz * fpair + velz * fvisc; - de[j] += deltaE; + desph[j] += deltaE; drho[j] += imass * delVdotDelR * wfd; } diff --git a/src/atom.cpp b/src/atom.cpp index 5324eea1fc..1e86a778a4 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -73,8 +73,8 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) nperatom = maxperatom = 0; peratom = NULL; - // initialize atom arrays - // customize by adding new array + // -------------------------------------------------------------------- + // 1st customization section: customize by adding new per-atom variables tag = NULL; type = mask = NULL; @@ -159,9 +159,12 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) // USER-SPH package - rho = drho = e = de = cv = NULL; + rho = drho = esph = desph = cv = NULL; vest = NULL; + // end of customization section + // -------------------------------------------------------------------- + // user-defined molecules nmolecule = 0; @@ -240,8 +243,9 @@ Atom::~Atom() delete [] peratom[i].name; memory->sfree(peratom); + // -------------------------------------------------------------------- + // 2nd customization section: customize by adding new per-atom variables // delete atom arrays - // customize by adding new array memory->destroy(tag); memory->destroy(type); @@ -287,8 +291,8 @@ Atom::~Atom() memory->destroy(rho); memory->destroy(drho); - memory->destroy(e); - memory->destroy(de); + memory->destroy(esph); + memory->destroy(desph); memory->destroy(cv); memory->destroy(vest); @@ -340,6 +344,9 @@ Atom::~Atom() memory->destroy(improper_atom3); memory->destroy(improper_atom4); + // end of customization section + // -------------------------------------------------------------------- + // delete custom atom arrays for (int i = 0; i < nivector; i++) { @@ -411,7 +418,8 @@ void Atom::peratom_create() peratom = NULL; nperatom = maxperatom = 0; - // customize: add new peratom variables here, order does not matter + // -------------------------------------------------------------------- + // 3rd customization section: add peratom variables here, order does not matter // register tagint & imageint variables as INT or BIGINT int tagintsize = INT; @@ -541,8 +549,8 @@ void Atom::peratom_create() add_peratom("rho",&rho,DOUBLE,0); add_peratom("drho",&drho,DOUBLE,0,1); // set per-thread flag - add_peratom("e",&e,DOUBLE,0); - add_peratom("de",&de,DOUBLE,0,1); // set per-thread flag + add_peratom("esph",&esph,DOUBLE,0); + add_peratom("desph",&desph,DOUBLE,0,1); // set per-thread flag add_peratom("vest",&vest,DOUBLE,3); add_peratom("cv",&cv,DOUBLE,0); @@ -554,6 +562,9 @@ void Atom::peratom_create() add_peratom("eff_plastic_strain",&eff_plastic_strain,DOUBLE,0); add_peratom("eff_plastic_strain_rate",&eff_plastic_strain_rate,DOUBLE,0); add_peratom("damage",&damage,DOUBLE,0); + + // end of customization section + // -------------------------------------------------------------------- } /* ---------------------------------------------------------------------- @@ -636,11 +647,14 @@ void Atom::add_peratom_vary(const char *name, void *address, /* ---------------------------------------------------------------------- add info for a single per-atom array to PerAtom data struct - customize by adding new flag, identical list as atom.h 2nd customization ------------------------------------------------------------------------- */ void Atom::set_atomflag_defaults() { + // -------------------------------------------------------------------- + // 4th customization section: customize by adding new flag + // identical list as 2nd customization in atom.h + sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0; peri_flag = electron_flag = 0; wavepacket_flag = sph_flag = 0; @@ -649,7 +663,7 @@ void Atom::set_atomflag_defaults() rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0; vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0; - rho_flag = e_flag = cv_flag = vest_flag = 0; + rho_flag = esph_flag = cv_flag = vest_flag = 0; dpd_flag = edpd_flag = tdpd_flag = 0; sp_flag = 0; x0_flag = 0; @@ -2472,11 +2486,13 @@ void Atom::remove_custom(int flag, int index) /* ---------------------------------------------------------------------- return a pointer to a named internal variable if don't recognize name, return NULL - customize by adding names ------------------------------------------------------------------------- */ void *Atom::extract(char *name) { + // -------------------------------------------------------------------- + // 5th customization section: customize by adding new variable name + if (strcmp(name,"mass") == 0) return (void *) mass; if (strcmp(name,"id") == 0) return (void *) tag; @@ -2514,8 +2530,8 @@ void *Atom::extract(char *name) if (strcmp(name,"rho") == 0) return (void *) rho; if (strcmp(name,"drho") == 0) return (void *) drho; - if (strcmp(name,"e") == 0) return (void *) e; - if (strcmp(name,"de") == 0) return (void *) de; + if (strcmp(name,"esph") == 0) return (void *) esph; + if (strcmp(name,"desph") == 0) return (void *) desph; if (strcmp(name,"cv") == 0) return (void *) cv; if (strcmp(name,"vest") == 0) return (void *) vest; @@ -2531,6 +2547,9 @@ void *Atom::extract(char *name) if (strcmp(name,"dpdTheta") == 0) return (void *) dpdTheta; if (strcmp(name,"edpd_temp") == 0) return (void *) edpd_temp; + // end of customization section + // -------------------------------------------------------------------- + return NULL; } diff --git a/src/atom.h b/src/atom.h index 7ba6536399..3a7335b796 100644 --- a/src/atom.h +++ b/src/atom.h @@ -139,9 +139,12 @@ class Atom : protected Pointers { // USER-SPH package - double *rho,*drho,*e,*de,*cv; + double *rho,*drho,*esph,*desph,*cv; double **vest; + // end of customization section + // -------------------------------------------------------------------- + // -------------------------------------------------------------------- // 2nd customization section: customize by adding new flags // identical list as Atom::set_atomflag_defaults() @@ -157,7 +160,7 @@ class Atom : protected Pointers { int rmass_flag,radius_flag,omega_flag,torque_flag,angmom_flag; int vfrac_flag,spin_flag,eradius_flag,ervel_flag,erforce_flag; int cs_flag,csforce_flag,vforce_flag,ervelforce_flag,etag_flag; - int rho_flag,e_flag,cv_flag,vest_flag; + int rho_flag,esph_flag,cv_flag,vest_flag; int dpd_flag,edpd_flag,tdpd_flag; // SPIN package @@ -175,7 +178,7 @@ class Atom : protected Pointers { double pdscale; - // end of 2 customization sections + // end of customization section // -------------------------------------------------------------------- // per-atom data struct describing all per-atom vectors/arrays diff --git a/src/set.cpp b/src/set.cpp index e3b1962d5d..80636a3ae2 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -47,7 +47,7 @@ enum{TYPE,TYPE_FRACTION,TYPE_RATIO,TYPE_SUBSET, DIPOLE,DIPOLE_RANDOM,SPIN,SPIN_RANDOM,QUAT,QUAT_RANDOM, THETA,THETA_RANDOM,ANGMOM,OMEGA, DIAMETER,DENSITY,VOLUME,IMAGE,BOND,ANGLE,DIHEDRAL,IMPROPER, - MESO_E,MESO_CV,MESO_RHO,EDPD_TEMP,EDPD_CV,CC,SMD_MASS_DENSITY, + SPH_E,SPH_CV,SPH_RHO,EDPD_TEMP,EDPD_CV,CC,SMD_MASS_DENSITY, SMD_CONTACT_RADIUS,DPDTHETA,INAME,DNAME,VX,VY,VZ}; #define BIG INT_MAX @@ -472,31 +472,31 @@ void Set::command(int narg, char **arg) topology(IMPROPER); iarg += 2; - } else if (strcmp(arg[iarg],"meso/e") == 0) { + } else if (strcmp(arg[iarg],"sph/e") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1); else dvalue = force->numeric(FLERR,arg[iarg+1]); - if (!atom->e_flag) + if (!atom->esph_flag) error->all(FLERR,"Cannot set meso/e for this atom style"); - set(MESO_E); + set(SPH_E); iarg += 2; - } else if (strcmp(arg[iarg],"meso/cv") == 0) { + } else if (strcmp(arg[iarg],"sph/cv") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1); else dvalue = force->numeric(FLERR,arg[iarg+1]); if (!atom->cv_flag) error->all(FLERR,"Cannot set meso/cv for this atom style"); - set(MESO_CV); + set(SPH_CV); iarg += 2; - } else if (strcmp(arg[iarg],"meso/rho") == 0) { + } else if (strcmp(arg[iarg],"sph/rho") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal set command"); if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1); else dvalue = force->numeric(FLERR,arg[iarg+1]); if (!atom->rho_flag) error->all(FLERR,"Cannot set meso/rho for this atom style"); - set(MESO_RHO); + set(SPH_RHO); iarg += 2; } else if (strcmp(arg[iarg],"edpd/temp") == 0) { @@ -797,9 +797,9 @@ void Set::set(int keyword) if (dvalue <= 0.0) error->one(FLERR,"Invalid volume in set command"); atom->vfrac[i] = dvalue; } - else if (keyword == MESO_E) atom->e[i] = dvalue; - else if (keyword == MESO_CV) atom->cv[i] = dvalue; - else if (keyword == MESO_RHO) atom->rho[i] = dvalue; + else if (keyword == SPH_E) atom->esph[i] = dvalue; + else if (keyword == SPH_CV) atom->cv[i] = dvalue; + else if (keyword == SPH_RHO) atom->rho[i] = dvalue; else if (keyword == EDPD_TEMP) atom->edpd_temp[i] = dvalue; else if (keyword == EDPD_CV) atom->edpd_cv[i] = dvalue; From ec9b7c787db25f474facf5f8125bfb5f97d9e927 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 16:52:32 -0600 Subject: [PATCH 18/42] more doc changes for USER-SPH --- doc/src/Commands_compute.rst | 6 ++--- doc/src/Commands_fix.rst | 4 +-- doc/src/Modify_atom.rst | 51 ++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 1c46bfad6e..878b7b072e 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -79,9 +79,6 @@ KOKKOS, o = USER-OMP, t = OPT. * :doc:`ke/atom/eff ` * :doc:`ke/eff ` * :doc:`ke/rigid ` - * :doc:`meso/e/atom ` - * :doc:`meso/rho/atom ` - * :doc:`meso/t/atom ` * :doc:`momentum ` * :doc:`msd ` * :doc:`msd/chunk ` @@ -133,6 +130,9 @@ KOKKOS, o = USER-OMP, t = OPT. * :doc:`sna/atom ` * :doc:`snad/atom ` * :doc:`snav/atom ` + * :doc:`sph/e/atom ` + * :doc:`sph/rho/atom ` + * :doc:`sph/t/atom ` * :doc:`spin ` * :doc:`stress/atom ` * :doc:`stress/mop ` diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index ce7cade0f6..8860a75e5e 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -94,9 +94,7 @@ OPT. * :doc:`lb/viscous ` * :doc:`lineforce ` * :doc:`manifoldforce ` - * :doc:`meso ` * :doc:`meso/move ` - * :doc:`meso/stationary ` * :doc:`momentum (k) ` * :doc:`move ` * :doc:`mscg ` @@ -201,6 +199,8 @@ OPT. * :doc:`smd/move_tri_surf ` * :doc:`smd/setvel ` * :doc:`smd/wall_surface ` + * :doc:`sph ` + * :doc:`sph/stationary ` * :doc:`spring ` * :doc:`spring/chunk ` * :doc:`spring/rg ` diff --git a/doc/src/Modify_atom.rst b/doc/src/Modify_atom.rst index 83f57a3d3d..f207dd4f7f 100644 --- a/doc/src/Modify_atom.rst +++ b/doc/src/Modify_atom.rst @@ -38,31 +38,32 @@ but the last 2 strings you do not need to specify any of (id,type,x,v,f). Those are included automatically as needed in the other strings. -+-------------------------+--------------------------------------------------------------------------------+ -| fields_grow | full list of properties which is allocated and stored | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_copy | list of properties to copy atoms are rearranged on-processor | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_comm | list of properties communicated to ghost atoms every step | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_comm_vel | additional properties communicated if :doc:`comm_modify vel ` is used | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_reverse | list of properties summed from ghost atoms every step | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_border | list of properties communicated with ghost atoms every reneighboring step | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_border_vel | additional properties communicated if :doc:`comm_modify vel ` is used | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_exchange | list of properties communicated when an atom migrates to another processor | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_restart | list of properties written/read to/from a restart file | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_create | list of properties defined when an atom is created by :doc:`create_atoms ` | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_data_atom | list of properties (in order) in the Atoms section of a data file, as read by :doc:`read_data ` | -+-------------------------+--------------------------------------------------------------------------------+ -| fields_data_vel | list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data ` | -+-------------------------+--------------------------------------------------------------------------------+ +.. list-table:: + + * - fields_grow + - full list of properties which is allocated and stored + * - fields_copy + - list of properties to copy atoms are rearranged on-processor + * - fields_comm + - list of properties communicated to ghost atoms every step + * - fields_comm_vel + - additional properties communicated if :doc:`comm_modify vel ` is used + * - fields_reverse + - list of properties summed from ghost atoms every step + * - fields_border + - list of properties communicated with ghost atoms every reneighboring step + * - fields_border_vel + - additional properties communicated if :doc:`comm_modify vel ` is used + * - fields_exchange + - list of properties communicated when an atom migrates to another processor + * - fields_restart + - list of properties written/read to/from a restart file + * - fields_create + - list of properties defined when an atom is created by :doc:`create_atoms ` + * - fields_data_atom + - list of properties (in order) in the Atoms section of a data file, as read by :doc:`read_data ` + * - fields_data_vel + - list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data ` In these strings you can list variable names which LAMMPS already defines (in some other atom style), or you can create new variable From 5e619b65f6d697d299efc80265b3463e0405017f Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 17:08:05 -0600 Subject: [PATCH 19/42] USER-SPH doc tweak --- doc/src/fix_sph.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/src/fix_sph.rst b/doc/src/fix_sph.rst index d514285886..7e9159cac4 100644 --- a/doc/src/fix_sph.rst +++ b/doc/src/fix_sph.rst @@ -26,7 +26,8 @@ Description Perform time integration to update position, velocity, internal energy and local density for atoms in the group each timestep. This fix is needed to time-integrate SPH systems where particles carry internal -variables such as internal energy. SPH is Smoothed Particle Dynamics. +variables such as internal energy. SPH stands for Smoothed Particle +Hydrodynamics. See `this PDF guide `_ to using SPH in LAMMPS. From 25b6d9865800e86ab38ab931779d0609668706d0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 Apr 2020 20:19:23 -0400 Subject: [PATCH 20/42] correct references and table format --- doc/src/Modify_atom.rst | 8 ++++---- doc/src/atom_style.rst | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/src/Modify_atom.rst b/doc/src/Modify_atom.rst index f207dd4f7f..34a529020a 100644 --- a/doc/src/Modify_atom.rst +++ b/doc/src/Modify_atom.rst @@ -14,8 +14,8 @@ Examining the code for others will make these instructions more clear. Note that the :doc:`atom style hybrid ` command can be used to define atoms or particles which have the union of properties -of individual styles. Also the :doc:`fix property/atom ` command can be used to add a single property (e.g. charge +of individual styles. Also the :doc:`fix property/atom ` +command can be used to add a single property (e.g. charge or a molecule ID) to a style that does not have it. It can also be used to add custom properties to an atom, with options to communicate them with ghost atoms or read them from a data file. Other LAMMPS @@ -162,8 +162,8 @@ method. * pack_data_pre * pack_data_post -These methods enable the :doc:`compute property/atom ` command to access per-atom variables it does not +These methods enable the :doc:`compute property/atom ` +command to access per-atom variables it does not already define as arguments, so that they can be written to a dump file or used by other LAMMPS commands. diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index 91aa95d7cd..44fac6c1f3 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -109,7 +109,7 @@ quantities. +--------------+-----------------------------------------------------+--------------------------------------+ | *smd* | volume, kernel diameter, contact radius, mass | solid and fluid SPH particles | +--------------+-----------------------------------------------------+--------------------------------------+ -| *sph* | rho, esph, cv | SPH particles | +| *sph* | rho, esph, cv | SPH particles | +--------------+-----------------------------------------------------+--------------------------------------+ | *sphere* | diameter, mass, angular velocity | granular models | +--------------+-----------------------------------------------------+--------------------------------------+ From 9dacbe5f4625c7500517250fe99d65185fdde53a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 21:22:19 -0600 Subject: [PATCH 21/42] two other dirs depend on changed esph and desph --- src/USER-SDPD/fix_meso_move.cpp | 18 ++++++------ src/USER-SDPD/fix_rigid_meso.cpp | 14 ++++----- src/USER-SMD/atom_vec_smd.cpp | 30 ++++++++++---------- src/USER-SMD/atom_vec_smd.h | 2 +- src/USER-SMD/compute_smd_internal_energy.cpp | 6 ++-- src/USER-SMD/fix_smd_integrate_tlsph.cpp | 6 ++-- src/USER-SMD/fix_smd_integrate_ulsph.cpp | 8 +++--- src/USER-SMD/pair_smd_tlsph.cpp | 12 ++++---- src/USER-SMD/pair_smd_ulsph.cpp | 10 +++---- 9 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/USER-SDPD/fix_meso_move.cpp b/src/USER-SDPD/fix_meso_move.cpp index 176cd8b895..0406b6f0a3 100644 --- a/src/USER-SDPD/fix_meso_move.cpp +++ b/src/USER-SDPD/fix_meso_move.cpp @@ -46,7 +46,7 @@ FixMesoMove::FixMesoMove (LAMMPS *lmp, int narg, char **arg) : xvarstr(NULL), yvarstr(NULL), zvarstr(NULL), vxvarstr(NULL), vyvarstr(NULL), vzvarstr(NULL), xoriginal(NULL), displace(NULL), velocity(NULL) { - if ((atom->e_flag != 1) || (atom->rho_flag != 1)) + if ((atom->esph_flag != 1) || (atom->rho_flag != 1)) error->all(FLERR, "fix meso/move command requires atom_style with both energy and density"); @@ -393,8 +393,8 @@ void FixMesoMove::initial_integrate (int /*vflag*/) { double **vest = atom->vest; double *rho = atom->rho; double *drho = atom->drho; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double **f = atom->f; double *rmass = atom->rmass; double *mass = atom->mass; @@ -415,7 +415,7 @@ void FixMesoMove::initial_integrate (int /*vflag*/) { xold[1] = x[i][1]; xold[2] = x[i][2]; - e[i] += dtf * de[i]; // half-step update of particle internal energy + esph[i] += dtf * desph[i]; // half-step update of particle internal energy rho[i] += dtf * drho[i]; // ... and density if (vxflag) { @@ -467,7 +467,7 @@ void FixMesoMove::initial_integrate (int /*vflag*/) { xold[1] = x[i][1]; xold[2] = x[i][2]; - e[i] += dtf * de[i]; // half-step update of particle internal energy + esph[i] += dtf * desph[i]; // half-step update of particle internal energy rho[i] += dtf * drho[i]; // ... and density if (axflag) { @@ -535,7 +535,7 @@ void FixMesoMove::initial_integrate (int /*vflag*/) { xold[1] = x[i][1]; xold[2] = x[i][2]; - e[i] += dtf * de[i]; // half-step update of particle internal energy + esph[i] += dtf * desph[i]; // half-step update of particle internal energy rho[i] += dtf * drho[i]; // ... and density d[0] = xoriginal[i][0] - point[0]; @@ -757,8 +757,8 @@ void FixMesoMove::final_integrate () { double **v = atom->v; double **f = atom->f; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *rho = atom->rho; double *drho = atom->drho; double *rmass = atom->rmass; @@ -773,7 +773,7 @@ void FixMesoMove::final_integrate () { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - e[i] += dtf * de[i]; + esph[i] += dtf * desph[i]; rho[i] += dtf * drho[i]; if (xflag) { diff --git a/src/USER-SDPD/fix_rigid_meso.cpp b/src/USER-SDPD/fix_rigid_meso.cpp index e93c543e72..01dd2bb99b 100644 --- a/src/USER-SDPD/fix_rigid_meso.cpp +++ b/src/USER-SDPD/fix_rigid_meso.cpp @@ -43,7 +43,7 @@ FixRigidMeso::FixRigidMeso (LAMMPS *lmp, int narg, char **arg) : FixRigid (lmp, narg, arg) { scalar_flag = 0; size_array_cols = 28; - if ((atom->e_flag != 1) || (atom->rho_flag != 1)) + if ((atom->esph_flag != 1) || (atom->rho_flag != 1)) error->all (FLERR, "fix rigid/meso command requires atom_style with" " both energy and density"); @@ -247,8 +247,8 @@ void FixRigidMeso::set_xv () { double **v = atom->v; double **vest = atom->vest; double **f = atom->f; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *rho = atom->rho; double *drho = atom->drho; double *rmass = atom->rmass; @@ -272,7 +272,7 @@ void FixRigidMeso::set_xv () { if (body[i] < 0) continue; // half-step update of particle internal energy and density - e[i] += dtf * de[i]; + esph[i] += dtf * desph[i]; rho[i] += dtf * drho[i]; ibody = body[i]; @@ -377,8 +377,8 @@ void FixRigidMeso::set_v () { double **x = atom->x; double **v = atom->v; double **f = atom->f; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *rho = atom->rho; double *drho = atom->drho; double *rmass = atom->rmass; @@ -401,7 +401,7 @@ void FixRigidMeso::set_v () { if (body[i] < 0) continue; // half-step update of particle internal energy and density - e[i] += dtf * de[i]; + esph[i] += dtf * desph[i]; rho[i] += dtf * drho[i]; const int ibody = body[i]; diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 42978d67d6..8e51f661ea 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -48,7 +48,7 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) atom->contact_radius_flag = 1; atom->molecule_flag = 1; atom->smd_data_9_flag = 1; - atom->e_flag = 1; + atom->esph_flag = 1; atom->vest_flag = 1; atom->smd_stress_flag = 1; atom->eff_plastic_strain_flag = 1; @@ -62,32 +62,32 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) - "e de vfrac rmass x0 radius contact_radius molecule " + "esph desph vfrac rmass x0 radius contact_radius molecule " "smd_data_9 vest smd_stress " "eff_plastic_strain eff_plastic_strain_rate damage"; fields_copy = (char *) - "e vfrac rmass x0 radius contact_radius molecule " + "esph vfrac rmass x0 radius contact_radius molecule " "eff_plastic_strain eff_plastic_strain_rate vest " "smd_data_9 smd_stress damage"; - fields_comm = (char *) "radius vfrac vest e"; - fields_comm_vel = (char *) "radius vfrac vest e"; - fields_reverse = (char *) "de"; + fields_comm = (char *) "radius vfrac vest esph"; + fields_comm_vel = (char *) "radius vfrac vest esph"; + fields_reverse = (char *) "desph"; fields_border = (char *) - "x0 molecule radius rmass vfrac contact_radius e " + "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain smd_data_9 smd_stress"; fields_border_vel = (char *) - "x0 molecule radius rmass vfrac contact_radius e " + "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain smd_data_9 smd_stress vest"; fields_exchange = (char *) - "x0 molecule radius rmass vfrac contact_radius e " + "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " "vest damage"; fields_restart = (char *) - "x0 molecule radius rmass vfrac contact_radius e " + "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " "vest damage"; fields_create = (char *) - "x0 vest vfrac rmass radius contact_radius molecule e " + "x0 vest vfrac rmass radius contact_radius molecule esph " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage"; fields_data_atom = (char *) "id type molecule vfrac rmass radius contact_radius x0 x"; @@ -108,8 +108,8 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSMD::grow_pointers() { - e = atom->e; - de = atom->de; + esph = atom->esph; + desph = atom->desph; vfrac = atom->vfrac; rmass = atom->rmass; x0 = atom->x0; @@ -132,7 +132,7 @@ void AtomVecSMD::grow_pointers() void AtomVecSMD::force_clear(int n, size_t nbytes) { - memset(&de[n],0,nbytes); + memset(&desph[n],0,nbytes); memset(&f[n][0],0,3*nbytes); } @@ -164,7 +164,7 @@ void AtomVecSMD::create_atom_post(int ilocal) void AtomVecSMD::data_atom_post(int ilocal) { - e[ilocal] = 0.0; + esph[ilocal] = 0.0; x0[ilocal][0] = x[ilocal][0]; x0[ilocal][1] = x[ilocal][1]; x0[ilocal][2] = x[ilocal][2]; diff --git a/src/USER-SMD/atom_vec_smd.h b/src/USER-SMD/atom_vec_smd.h index 00709aeada..c4d66c0b64 100644 --- a/src/USER-SMD/atom_vec_smd.h +++ b/src/USER-SMD/atom_vec_smd.h @@ -46,7 +46,7 @@ class AtomVecSMD : public AtomVec { private: int *molecule; - double *e,*de,*vfrac,*rmass,*radius,*contact_radius; + double *esph,*desph,*vfrac,*rmass,*radius,*contact_radius; double *eff_plastic_strain,*eff_plastic_strain_rate,*damage; double **x0,**smd_data_9,**smd_stress,**vest; }; diff --git a/src/USER-SMD/compute_smd_internal_energy.cpp b/src/USER-SMD/compute_smd_internal_energy.cpp index f88da8bc33..90ddb74839 100644 --- a/src/USER-SMD/compute_smd_internal_energy.cpp +++ b/src/USER-SMD/compute_smd_internal_energy.cpp @@ -40,7 +40,7 @@ ComputeSMDInternalEnergy::ComputeSMDInternalEnergy(LAMMPS *lmp, int narg, char * Compute(lmp, narg, arg) { if (narg != 3) error->all(FLERR,"Illegal compute smd/internal_energy command"); - if (atom->e_flag != 1) error->all(FLERR,"compute smd/internal_energy command requires atom_style with internal_energy (e.g. smd)"); + if (atom->esph_flag != 1) error->all(FLERR,"compute smd/internal_energy command requires atom_style with internal_energy (e.g. smd)"); peratom_flag = 1; size_peratom_cols = 0; @@ -83,13 +83,13 @@ void ComputeSMDInternalEnergy::compute_peratom() vector_atom = internal_energy_vector; } - double *e = atom->e; + double *esph = atom->esph; int *mask = atom->mask; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - internal_energy_vector[i] = e[i]; + internal_energy_vector[i] = esph[i]; } else { internal_energy_vector[i] = 0.0; diff --git a/src/USER-SMD/fix_smd_integrate_tlsph.cpp b/src/USER-SMD/fix_smd_integrate_tlsph.cpp index 8464bed609..ed039d39d4 100644 --- a/src/USER-SMD/fix_smd_integrate_tlsph.cpp +++ b/src/USER-SMD/fix_smd_integrate_tlsph.cpp @@ -203,8 +203,8 @@ void FixSMDIntegrateTlsph::final_integrate() { double **v = atom->v; double **f = atom->f; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *rmass = atom->rmass; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -231,7 +231,7 @@ void FixSMDIntegrateTlsph::final_integrate() { } } - e[i] += dtv * de[i]; + esph[i] += dtv * desph[i]; } } } diff --git a/src/USER-SMD/fix_smd_integrate_ulsph.cpp b/src/USER-SMD/fix_smd_integrate_ulsph.cpp index 0f0d224f95..4978416e66 100644 --- a/src/USER-SMD/fix_smd_integrate_ulsph.cpp +++ b/src/USER-SMD/fix_smd_integrate_ulsph.cpp @@ -42,7 +42,7 @@ using namespace FixConst; FixSMDIntegrateUlsph::FixSMDIntegrateUlsph(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if ((atom->e_flag != 1) || (atom->vfrac_flag != 1)) + if ((atom->esph_flag != 1) || (atom->vfrac_flag != 1)) error->all(FLERR, "fix smd/integrate_ulsph command requires atom_style with both energy and volume"); if (narg < 3) @@ -239,8 +239,8 @@ void FixSMDIntegrateUlsph::initial_integrate(int /*vflag*/) { void FixSMDIntegrateUlsph::final_integrate() { double **v = atom->v; double **f = atom->f; - double *e = atom->e; - double *de = atom->de; + double *esph = atom->esph; + double *desph = atom->desph; double *vfrac = atom->vfrac; double *radius = atom->radius; double *contact_radius = atom->contact_radius; @@ -286,7 +286,7 @@ void FixSMDIntegrateUlsph::final_integrate() { } } - e[i] += dtf * de[i]; + esph[i] += dtf * desph[i]; if (adjust_radius_flag) { if (nn[i] < min_nn) { diff --git a/src/USER-SMD/pair_smd_tlsph.cpp b/src/USER-SMD/pair_smd_tlsph.cpp index cad9923054..c932086a32 100644 --- a/src/USER-SMD/pair_smd_tlsph.cpp +++ b/src/USER-SMD/pair_smd_tlsph.cpp @@ -418,7 +418,7 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { double **x0 = atom->x0; double **f = atom->f; double *vfrac = atom->vfrac; - double *de = atom->de; + double *desph = atom->desph; double *rmass = atom->rmass; double *radius = atom->radius; double *damage = atom->damage; @@ -592,7 +592,7 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { f[i][0] += sumForces(0); f[i][1] += sumForces(1); f[i][2] += sumForces(2); - de[i] += deltaE; + desph[i] += deltaE; // tally atomistic stress tensor if (evflag) { @@ -703,7 +703,7 @@ void PairTlsph::AssembleStress() { double *damage = atom->damage; double *rmass = atom->rmass; double *vfrac = atom->vfrac; - double *e = atom->e; + double *esph = atom->esph; double pInitial, d_iso, pFinal, p_rate, plastic_strain_increment; int i, itype; int nlocal = atom->nlocal; @@ -745,7 +745,7 @@ void PairTlsph::AssembleStress() { d_iso = D[i].trace(); // volumetric part of stretch rate d_dev = Deviator(D[i]); // deviatoric part of stretch rate strain = 0.5 * (Fincr[i].transpose() * Fincr[i] - eye); - mass_specific_energy = e[i] / rmass[i]; // energy per unit mass + mass_specific_energy = esph[i] / rmass[i]; // energy per unit mass rho = rmass[i] / (detF[i] * vfrac[i]); vol_specific_energy = mass_specific_energy * rho; // energy per current volume @@ -2034,12 +2034,12 @@ void PairTlsph::ComputeStressDeviator(const int i, const Matrix3d sigmaInitial_d int *type = atom->type; double *rmass = atom->rmass; //double *vfrac = atom->vfrac; - double *e = atom->e; + double *esph = atom->esph; double dt = update->dt; double yieldStress; int itype; - double mass_specific_energy = e[i] / rmass[i]; // energy per unit mass + double mass_specific_energy = esph[i] / rmass[i]; // energy per unit mass plastic_strain_increment = 0.0; itype = type[i]; diff --git a/src/USER-SMD/pair_smd_ulsph.cpp b/src/USER-SMD/pair_smd_ulsph.cpp index b53eb779de..8c8da7b2bc 100644 --- a/src/USER-SMD/pair_smd_ulsph.cpp +++ b/src/USER-SMD/pair_smd_ulsph.cpp @@ -357,7 +357,7 @@ void PairULSPH::compute(int eflag, int vflag) { double **vint = atom->v; // Velocity-Verlet algorithm velocities double **f = atom->f; double *vfrac = atom->vfrac; - double *de = atom->de; + double *desph = atom->desph; double *rmass = atom->rmass; double *radius = atom->radius; double *contact_radius = atom->contact_radius; @@ -586,7 +586,7 @@ void PairULSPH::compute(int eflag, int vflag) { f[i][0] += sumForces(0); f[i][1] += sumForces(1); f[i][2] += sumForces(2); - de[i] += deltaE; + desph[i] += deltaE; // accumulate smooth velocities shepardWeight[i] += jvol * wf; @@ -597,7 +597,7 @@ void PairULSPH::compute(int eflag, int vflag) { f[j][0] -= sumForces(0); f[j][1] -= sumForces(1); f[j][2] -= sumForces(2); - de[j] += deltaE; + desph[j] += deltaE; shepardWeight[j] += ivol * wf; smoothVel[j] -= ivol * wf * dvint; @@ -639,7 +639,7 @@ void PairULSPH::AssembleStressTensor() { double *rmass = atom->rmass; double *eff_plastic_strain = atom->eff_plastic_strain; double **tlsph_stress = atom->smd_stress; - double *e = atom->e; + double *esph = atom->esph; int *type = atom->type; int i, itype; int nlocal = atom->nlocal; @@ -686,7 +686,7 @@ void PairULSPH::AssembleStressTensor() { break; case EOS_PERFECT_GAS: - PerfectGasEOS(Lookup[EOS_PERFECT_GAS_GAMMA][itype], vol, rmass[i], e[i], newPressure, c0[i]); + PerfectGasEOS(Lookup[EOS_PERFECT_GAS_GAMMA][itype], vol, rmass[i], esph[i], newPressure, c0[i]); break; case EOS_LINEAR: newPressure = Lookup[BULK_MODULUS][itype] * (rho / Lookup[REFERENCE_DENSITY][itype] - 1.0); From e52fee0c56055e0704f155829f0e7b0b73b887a7 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 21:27:24 -0600 Subject: [PATCH 22/42] fix omp uses desph --- src/USER-OMP/fix_omp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/USER-OMP/fix_omp.cpp b/src/USER-OMP/fix_omp.cpp index 25a3a09816..53ad46bc28 100644 --- a/src/USER-OMP/fix_omp.cpp +++ b/src/USER-OMP/fix_omp.cpp @@ -347,7 +347,7 @@ void FixOMP::pre_force(int) double **f = atom->f; double **torque = atom->torque; double *erforce = atom->erforce; - double *de = atom->de; + double *desph = atom->desph; double *drho = atom->drho; #if defined(_OPENMP) @@ -356,7 +356,7 @@ void FixOMP::pre_force(int) { const int tid = get_tid(); thr[tid]->check_tid(tid); - thr[tid]->init_force(nall,f,torque,erforce,de,drho); + thr[tid]->init_force(nall,f,torque,erforce,desph,drho); } // end of omp parallel region _reduced = false; From 907ffae7b462b9188d363c41a031656280e5c462 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 30 Apr 2020 21:32:59 -0600 Subject: [PATCH 23/42] add return 0 to atom_vec --- src/atom_vec.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/atom_vec.h b/src/atom_vec.h index fd3551c8ed..b54e827995 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -87,7 +87,7 @@ class AtomVec : protected Pointers { virtual void unpack_comm(int, int, double *); virtual void unpack_comm_vel(int, int, double *); - virtual int pack_comm_bonus(int, int *, double *) {} + virtual int pack_comm_bonus(int, int *, double *) {return 0;} virtual void unpack_comm_bonus(int, int, double *) {} virtual int pack_reverse(int, int, double *); @@ -98,14 +98,14 @@ class AtomVec : protected Pointers { virtual void unpack_border(int, int, double *); virtual void unpack_border_vel(int, int, double *); - virtual int pack_border_bonus(int, int *, double *) {} - virtual int unpack_border_bonus(int, int, double *) {} + virtual int pack_border_bonus(int, int *, double *) {return 0;} + virtual int unpack_border_bonus(int, int, double *) {return 0;} virtual int pack_exchange(int, double *); virtual int unpack_exchange(double *); - virtual int pack_exchange_bonus(int, double *) {} - virtual int unpack_exchange_bonus(int, double *) {} + virtual int pack_exchange_bonus(int, double *) {return 0;} + virtual int unpack_exchange_bonus(int, double *) {return 0;} virtual int size_restart(); virtual int pack_restart(int, double *); @@ -116,8 +116,8 @@ class AtomVec : protected Pointers { 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 *) {} + virtual int pack_restart_bonus(int, double *) {return 0;} + virtual int unpack_restart_bonus(int, double *) {return 0;} virtual void create_atom(int, double *); virtual void create_atom_post(int) {} From adc04f87f67304e739664a27e4d5f050f0155253 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 1 May 2020 08:24:24 -0400 Subject: [PATCH 24/42] whitespace fixes --- src/DIPOLE/atom_vec_dipole.cpp | 2 +- src/GRANULAR/fix_pour.cpp | 2 +- src/MOLECULE/atom_vec_angle.cpp | 4 ++-- src/MOLECULE/atom_vec_bond.cpp | 2 +- src/MOLECULE/atom_vec_bond.h | 2 +- src/MOLECULE/atom_vec_full.cpp | 10 +++++----- src/MOLECULE/atom_vec_molecular.cpp | 10 +++++----- src/PERI/atom_vec_peri.cpp | 2 +- src/SPIN/atom_vec_spin.cpp | 2 +- src/USER-AWPMD/atom_vec_wavepacket.cpp | 4 ++-- src/USER-SMD/atom_vec_smd.cpp | 22 +++++++++++----------- src/atom.cpp | 18 +++++++++--------- src/atom.h | 4 ++-- src/atom_vec.cpp | 26 +++++++++++++------------- src/atom_vec.h | 2 +- src/atom_vec_body.cpp | 8 ++++---- src/atom_vec_ellipsoid.cpp | 4 ++-- src/atom_vec_hybrid.cpp | 14 +++++++------- src/atom_vec_line.cpp | 4 ++-- src/atom_vec_sphere.cpp | 10 +++++----- src/atom_vec_tri.cpp | 4 ++-- src/replicate.cpp | 12 ++++++------ src/verlet.cpp | 2 +- 23 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 074a59d5a1..b6895be301 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -72,6 +72,6 @@ void AtomVecDipole::grow_pointers() void AtomVecDipole::data_atom_post(int ilocal) { double *mu_one = mu[ilocal]; - mu_one[3] = + mu_one[3] = sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]); } diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index b8db9fb8e6..73b42b9653 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -320,7 +320,7 @@ void FixPour::init() error->all(FLERR,"No fix gravity defined for fix pour"); int varflag = ((FixGravity *) modify->fix[ifix])->varflag; - if (varflag != CONSTANT) + if (varflag != CONSTANT) error->all(FLERR,"Fix gravity for fix pour must be constant"); double xgrav = ((FixGravity *) modify->fix[ifix])->xgrav; diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index f3ebe3258b..1e00a73617 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -31,7 +31,7 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) + fields_grow = (char *) "molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; fields_copy = (char *) @@ -45,7 +45,7 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) fields_exchange = (char *) "molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special"; - fields_restart = (char *) + fields_restart = (char *) "molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3"; fields_create = (char *) "molecule num_bond num_angle nspecial"; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 64a52fa80a..2fa445c8ee 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -31,7 +31,7 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) + fields_grow = (char *) "molecule num_bond bond_type bond_atom nspecial special"; fields_copy = (char *) "molecule num_bond bond_type bond_atom nspecial special"; diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index c938655127..403167ac11 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -36,7 +36,7 @@ class AtomVecBond : public AtomVec { void data_atom_post(int); private: - int *num_bond; + int *num_bond; int **bond_type; int **nspecial; diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index 89afae5005..866cf796c9 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -31,7 +31,7 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) + fields_grow = (char *) "q molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " @@ -60,14 +60,14 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) "num_improper improper_type improper_atom1 improper_atom2 " "improper_atom3 improper_atom4 " "nspecial special"; - fields_restart = (char *) + fields_restart = (char *) "q molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " "dihedral_atom3 dihedral_atom4 " "num_improper improper_type improper_atom1 improper_atom2 " "improper_atom3 improper_atom4"; - fields_create = (char *) + fields_create = (char *) "q molecule num_bond num_angle num_dihedral num_improper nspecial"; fields_data_atom = (char *) "id molecule type q x"; fields_data_vel = (char *) "id v"; @@ -194,13 +194,13 @@ void AtomVecFull::pack_restart_post(int ilocal) if (any_dihedral_negative) { for (int m = 0; m < num_dihedral[ilocal]; m++) - if (dihedral_negative[m]) + if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { for (int m = 0; m < num_improper[ilocal]; m++) - if (improper_negative[m]) + if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; } } diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index c2b71468c0..e90bec5108 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -31,7 +31,7 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) + fields_grow = (char *) "molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " @@ -60,14 +60,14 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) "num_improper improper_type improper_atom1 improper_atom2 " "improper_atom3 improper_atom4 " "nspecial special"; - fields_restart = (char *) + fields_restart = (char *) "molecule num_bond bond_type bond_atom " "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " "dihedral_atom3 dihedral_atom4 " "num_improper improper_type improper_atom1 improper_atom2 " "improper_atom3 improper_atom4"; - fields_create = (char *) + fields_create = (char *) "molecule num_bond num_angle num_dihedral num_improper nspecial"; fields_data_atom = (char *) "id molecule type x"; fields_data_vel = (char *) "id v"; @@ -194,13 +194,13 @@ void AtomVecMolecular::pack_restart_post(int ilocal) if (any_dihedral_negative) { for (int m = 0; m < num_dihedral[ilocal]; m++) - if (dihedral_negative[m]) + if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { for (int m = 0; m < num_improper[ilocal]; m++) - if (improper_negative[m]) + if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; } } diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 46d03c35eb..093878d4cf 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -108,7 +108,7 @@ void AtomVecPeri::data_atom_post(int ilocal) x0[ilocal][1] = x[ilocal][1]; x0[ilocal][2] = x[ilocal][2]; - if (rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid mass in Atoms section of data file"); } diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 1e745fd0c1..2f7f3f7655 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -94,7 +94,7 @@ void AtomVecSpin::force_clear(int n, size_t nbytes) void AtomVecSpin::data_atom_post(int ilocal) { double *sp_one = sp[ilocal]; - double norm = + double norm = 1.0/sqrt(sp_one[0]*sp_one[0] + sp_one[1]*sp_one[1] + sp_one[2]*sp_one[2]); sp_one[0] *= norm; sp_one[1] *= norm; diff --git a/src/USER-AWPMD/atom_vec_wavepacket.cpp b/src/USER-AWPMD/atom_vec_wavepacket.cpp index c71a3cb6c2..0d11e983ad 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.cpp +++ b/src/USER-AWPMD/atom_vec_wavepacket.cpp @@ -35,7 +35,7 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) atom->electron_flag = 1; // compatible with eff atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->ervel_flag = atom->erforce_flag = 1; - atom->cs_flag = atom->csforce_flag = + atom->cs_flag = atom->csforce_flag = atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1; // strings with peratom variables to include in each AtomVec method @@ -43,7 +43,7 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) + fields_grow = (char *) "q spin eradius ervel erforce cs csforce " "vforce ervelforce etag"; fields_copy = (char *) "q spin eradius ervel cs etag"; diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 8e51f661ea..670783a3d7 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) +AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; mass_type = 1; @@ -61,35 +61,35 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) + fields_grow = (char *) "esph desph vfrac rmass x0 radius contact_radius molecule " "smd_data_9 vest smd_stress " "eff_plastic_strain eff_plastic_strain_rate damage"; - fields_copy = (char *) + fields_copy = (char *) "esph vfrac rmass x0 radius contact_radius molecule " "eff_plastic_strain eff_plastic_strain_rate vest " "smd_data_9 smd_stress damage"; fields_comm = (char *) "radius vfrac vest esph"; fields_comm_vel = (char *) "radius vfrac vest esph"; fields_reverse = (char *) "desph"; - fields_border = (char *) + fields_border = (char *) "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain smd_data_9 smd_stress"; - fields_border_vel = (char *) + fields_border_vel = (char *) "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain smd_data_9 smd_stress vest"; - fields_exchange = (char *) + fields_exchange = (char *) "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " "vest damage"; - fields_restart = (char *) + fields_restart = (char *) "x0 molecule radius rmass vfrac contact_radius esph " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress " "vest damage"; - fields_create = (char *) + fields_create = (char *) "x0 vest vfrac rmass radius contact_radius molecule esph " "eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage"; - fields_data_atom = (char *) + fields_data_atom = (char *) "id type molecule vfrac rmass radius contact_radius x0 x"; fields_data_vel = (char *) "id v"; @@ -130,7 +130,7 @@ void AtomVecSMD::grow_pointers() NOTE: does f need to be re-cleared? ------------------------------------------------------------------------- */ -void AtomVecSMD::force_clear(int n, size_t nbytes) +void AtomVecSMD::force_clear(int n, size_t nbytes) { memset(&desph[n],0,nbytes); memset(&f[n][0],0,3*nbytes); @@ -151,7 +151,7 @@ void AtomVecSMD::create_atom_post(int ilocal) radius[ilocal] = 0.5; contact_radius[ilocal] = 0.5; molecule[ilocal] = 1; - + smd_data_9[ilocal][0] = 1.0; // xx smd_data_9[ilocal][4] = 1.0; // yy smd_data_9[ilocal][8] = 1.0; // zz diff --git a/src/atom.cpp b/src/atom.cpp index 1e86a778a4..bbdecc5b98 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -139,7 +139,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) etag = NULL; // USER-DPD package - + uCond = uMech = uChem = uCG = uCGnew = NULL; duChem = dpdTheta = NULL; @@ -158,7 +158,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) damage = NULL; // USER-SPH package - + rho = drho = esph = desph = cv = NULL; vest = NULL; @@ -569,17 +569,17 @@ void Atom::peratom_create() /* ---------------------------------------------------------------------- add info for a single per-atom vector/array to PerAtom data struct - cols = 0: per-atom vector + cols = 0: per-atom vector cols = N: static per-atom array with N columns use add_peratom_vary() when column count varies per atom ------------------------------------------------------------------------- */ -void Atom::add_peratom(const char *name, void *address, +void Atom::add_peratom(const char *name, void *address, int datatype, int cols, int threadflag) { if (nperatom == maxperatom) { maxperatom += DELTA_PERATOM; - peratom = (PerAtom *) + peratom = (PerAtom *) memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom"); } @@ -606,7 +606,7 @@ void Atom::add_peratom_change_columns(const char *name, int cols) int i; for (int i = 0; i < nperatom; i++) if (strcmp(name,peratom[i].name) == 0) peratom[i].cols = cols; - if (i == nperatom) + if (i == nperatom) error->all(FLERR,"Could not find name of peratom array for column change"); } @@ -616,18 +616,18 @@ void Atom::add_peratom_change_columns(const char *name, int cols) for collength = 0: length = address of peratom vector with column count per atom e.g. num_bond - for collength = N: + for collength = N: length = address of peratom array with column count per atom collength = index of column (1 to N) in peratom array with count e.g. nspecial ------------------------------------------------------------------------- */ -void Atom::add_peratom_vary(const char *name, void *address, +void Atom::add_peratom_vary(const char *name, void *address, int datatype, int *cols, void *length, int collength) { if (nperatom == maxperatom) { maxperatom += DELTA_PERATOM; - peratom = (PerAtom *) + peratom = (PerAtom *) memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom"); } diff --git a/src/atom.h b/src/atom.h index 3a7335b796..c55821eea2 100644 --- a/src/atom.h +++ b/src/atom.h @@ -38,7 +38,7 @@ class Atom : protected Pointers { bigint nlines; // number of lines bigint ntris; // number of triangles bigint nbodies; // number of bodies - + // system properties bigint nbonds,nangles,ndihedrals,nimpropers; @@ -260,7 +260,7 @@ class Atom : protected Pointers { void peratom_create(); void add_peratom(const char *, void *, int, int, int threadflag=0); void add_peratom_change_columns(const char *, int); - void add_peratom_vary(const char *, void *, int, int *, + void add_peratom_vary(const char *, void *, int, int *, void *, int collength=0); void create_avec(const char *, int, char **, int); virtual class AtomVec *new_avec(const char *, int, int &); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 5799038667..1ce4bc9e42 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -280,7 +280,7 @@ void AtomVec::copy(int i, int j, int delflag) double **array = *((double ***) pdata); for (m = 0; m < cols; m++) array[j][m] = array[i][m]; - } else { + } else { double **array = *((double ***) pdata); collength = mcopy.collength[n]; plength = mcopy.plength[n]; @@ -913,7 +913,7 @@ int AtomVec::pack_border(int n, int *list, double *buf, int pbc_flag, int *pbc) /* ---------------------------------------------------------------------- */ -int AtomVec::pack_border_vel(int n, int *list, double *buf, +int AtomVec::pack_border_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { int i,j,m,mm,nn,datatype,cols; @@ -1207,7 +1207,7 @@ int AtomVec::pack_exchange(int i, double *buf) buf[m++] = ubuf(type[i]).d; buf[m++] = ubuf(mask[i]).d; buf[m++] = ubuf(image[i]).d; - + if (nexchange) { for (nn = 0; nn < nexchange; nn++) { pdata = mexchange.pdata[nn]; @@ -1252,7 +1252,7 @@ int AtomVec::pack_exchange(int i, double *buf) bigint *vec = *((bigint **) pdata); buf[m++] = ubuf(vec[i]).d; } else if (cols > 0) { - bigint **array = *((bigint ***) pdata); + bigint **array = *((bigint ***) pdata); for (mm = 0; mm < cols; mm++) buf[m++] = ubuf(array[i][mm]).d; } else { @@ -2438,7 +2438,7 @@ void AtomVec::setup_fields() size_data_atom = 0; for (n = 0; n < ndata_atom; n++) { cols = mdata_atom.cols[n]; - if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0) + if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0) xcol_data = size_data_atom + 1; if (cols == 0) size_data_atom++; else size_data_atom += cols; @@ -2471,7 +2471,7 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) int ndef = tokenize((char *) default_str,defwords,copy2); // process fields one by one, add to index vector - + Atom::PerAtom *peratom = atom->peratom; int nperatom = atom->nperatom; @@ -2479,7 +2479,7 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) int match; for (int i = 0; i < nfield; i++) { - + // find field in master Atom::peratom list for (match = 0; match < nperatom; match++) @@ -2495,18 +2495,18 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) for (match = 0; match < i; match++) if (index[i] == index[match]) { - char str[128]; - sprintf(str,"Peratom field %s is repeated",words[i]); - error->all(FLERR,str); + char str[128]; + sprintf(str,"Peratom field %s is repeated",words[i]); + error->all(FLERR,str); } // error if field is in default str for (match = 0; match < ndef; match++) if (strcmp(words[i],defwords[match]) == 0) { - char str[128]; - sprintf(str,"Peratom field %s is a default",words[i]); - error->all(FLERR,str); + char str[128]; + sprintf(str,"Peratom field %s is a default",words[i]); + error->all(FLERR,str); } } diff --git a/src/atom_vec.h b/src/atom_vec.h index b54e827995..f3a31caad3 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -74,7 +74,7 @@ class AtomVec : protected Pointers { virtual void force_clear(int, size_t) {} virtual bigint roundup(bigint); - + virtual void grow(int); virtual void grow_pointers() {} virtual void copy(int, int, int); diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index c262f1a5b6..89fe1681cb 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -282,7 +282,7 @@ int AtomVecBody::pack_border_bonus(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; } @@ -540,7 +540,7 @@ void AtomVecBody::data_atom_post(int ilocal) void AtomVecBody::data_body(int m, int ninteger, int ndouble, int *ivalues, double *dvalues) { - if (body[m]) + if (body[m]) error->one(FLERR,"Assigning body parameters to non-body atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); bonus[nlocal_bonus].ilocal = m; @@ -572,7 +572,7 @@ bigint AtomVecBody::memory_usage_bonus() ------------------------------------------------------------------------- */ void AtomVecBody::pack_data_pre(int ilocal) -{ +{ body_flag = body[ilocal]; if (body_flag < 0) body[ilocal] = 0; @@ -584,7 +584,7 @@ void AtomVecBody::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecBody::pack_data_post(int ilocal) -{ +{ body[ilocal] = body_flag; } diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 2537fe2538..4d83565c7a 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -452,7 +452,7 @@ void AtomVecEllipsoid::data_atom_post(int ilocal) ------------------------------------------------------------------------- */ void AtomVecEllipsoid::pack_data_pre(int ilocal) -{ +{ double *shape; ellipsoid_flag = atom->ellipsoid[ilocal]; @@ -472,7 +472,7 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecEllipsoid::pack_data_post(int ilocal) -{ +{ ellipsoid[ilocal] = ellipsoid_flag; rmass[ilocal] = rmass_one; } diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 965bfe8543..7f47f64d91 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) +AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) { nstyles = 0; styles = NULL; @@ -325,7 +325,7 @@ void AtomVecHybrid::data_atom_post(int ilocal) ------------------------------------------------------------------------- */ void AtomVecHybrid::pack_data_pre(int ilocal) -{ +{ for (int k = 0; k < nstyles; k++) styles[k]->pack_data_pre(ilocal); } @@ -335,7 +335,7 @@ void AtomVecHybrid::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecHybrid::pack_data_post(int ilocal) -{ +{ for (int k = 0; k < nstyles; k++) styles[k]->pack_data_post(ilocal); } @@ -494,7 +494,7 @@ void AtomVecHybrid::pack_property_atom(int multiindex, double *buf, so caller can check for problematic fields, call will free it ------------------------------------------------------------------------- */ -char *AtomVecHybrid::merge_fields(int inum, char *root, +char *AtomVecHybrid::merge_fields(int inum, char *root, int concat_flag, char *&concat_str) { // create concatenated string of length size from root + all substyles @@ -517,7 +517,7 @@ char *AtomVecHybrid::merge_fields(int inum, char *root, char **words; int nwords = tokenize(concat,words,copystr); int *unique = new int[nwords]; - + for (int i = 0; i < nwords; i++) { unique[i] = 1; for (int j = 0; j < i; j++) @@ -528,7 +528,7 @@ char *AtomVecHybrid::merge_fields(int inum, char *root, char *dedup = new char[size]; dedup[0] = '\0'; - + for (int i = 0; i < nwords; i++) { if (!unique[i]) continue; strcat(dedup,words[i]); @@ -541,7 +541,7 @@ char *AtomVecHybrid::merge_fields(int inum, char *root, else delete [] concat; // clean up - + delete [] copystr; delete [] words; delete [] unique; diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index e178d1f78a..88d02161d5 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -431,7 +431,7 @@ void AtomVecLine::data_atom_post(int ilocal) ------------------------------------------------------------------------- */ void AtomVecLine::pack_data_pre(int ilocal) -{ +{ line_flag = line[ilocal]; rmass_one = rmass[ilocal]; @@ -449,7 +449,7 @@ void AtomVecLine::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecLine::pack_data_post(int ilocal) -{ +{ line[ilocal] = line_flag; rmass[ilocal] = rmass_one; } diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 64a198c94d..e1d92c7a8d 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -61,7 +61,7 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSphere::process_args(int narg, char **arg) { - if (narg != 0 && narg != 1) + if (narg != 0 && narg != 1) error->all(FLERR,"Illegal atom_style sphere command"); radvary = 0; @@ -130,10 +130,10 @@ void AtomVecSphere::data_atom_post(int ilocal) { radius_one = 0.5 * atom->radius[ilocal]; radius[ilocal] = radius_one; - if (radius_one > 0.0) + if (radius_one > 0.0) rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; - if (rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); } @@ -147,8 +147,8 @@ void AtomVecSphere::pack_data_pre(int ilocal) rmass_one = rmass[ilocal]; radius[ilocal] *= 2.0; - if (radius_one!= 0.0) - rmass[ilocal] = + if (radius_one!= 0.0) + rmass[ilocal] = rmass_one / (4.0*MY_PI/3.0 * radius_one*radius_one*radius_one); } diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index b130198075..d5ca2342e8 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -655,7 +655,7 @@ void AtomVecTri::data_atom_post(int ilocal) ------------------------------------------------------------------------- */ void AtomVecTri::pack_data_pre(int ilocal) -{ +{ tri_flag = tri[ilocal]; rmass_one = rmass[ilocal]; @@ -680,7 +680,7 @@ void AtomVecTri::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecTri::pack_data_post(int ilocal) -{ +{ tri[ilocal] = tri_flag; rmass[ilocal] = rmass_one; } diff --git a/src/replicate.cpp b/src/replicate.cpp index 75f6aa61f4..50842ddd0c 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -355,7 +355,7 @@ void Replicate::command(int narg, char **arg) int *disp_buf_rnk; memory->create(disp_buf_rnk, nprocs, "replicate:disp_buf_rnk"); disp_buf_rnk[0] = 0; - for (i = 1; i < nprocs; i++) + for (i = 1; i < nprocs; i++) disp_buf_rnk[i] = disp_buf_rnk[i-1] + size_buf_rnk[i-1]; // allgather buf_all @@ -370,16 +370,16 @@ void Replicate::command(int narg, char **arg) double _orig_lo[3], _orig_hi[3]; if (triclinic) { - _orig_lo[0] = domain->boxlo[0] + + _orig_lo[0] = domain->boxlo[0] + _imagelo[0] * old_xprd + _imagelo[1] * old_xy + _imagelo[2] * old_xz; - _orig_lo[1] = domain->boxlo[1] + + _orig_lo[1] = domain->boxlo[1] + _imagelo[1] * old_yprd + _imagelo[2] * old_yz; _orig_lo[2] = domain->boxlo[2] + _imagelo[2] * old_zprd; - _orig_hi[0] = domain->boxlo[0] + - (_imagehi[0]+1) * old_xprd + + _orig_hi[0] = domain->boxlo[0] + + (_imagehi[0]+1) * old_xprd + (_imagehi[1]+1) * old_xy + (_imagehi[2]+1) * old_xz; - _orig_hi[1] = domain->boxlo[1] + + _orig_hi[1] = domain->boxlo[1] + (_imagehi[1]+1) * old_yprd + (_imagehi[2]+1) * old_yz; _orig_hi[2] = domain->boxlo[2] + (_imagehi[2]+1) * old_zprd; } else { diff --git a/src/verlet.cpp b/src/verlet.cpp index fe9645618a..8cd6fe940d 100644 --- a/src/verlet.cpp +++ b/src/verlet.cpp @@ -109,7 +109,7 @@ void Verlet::setup(int flag) domain->pbc(); domain->reset_box(); comm->setup(); - if (neighbor->style) neighbor->setup_bins(); + if (neighbor->style) neighbor->setup_bins(); comm->exchange(); if (atom->sortfreq > 0) atom->sort(); comm->borders(); From 4930389ea41d0083edd2f8c06f8bed7a3f109f2f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 1 May 2020 08:38:36 -0400 Subject: [PATCH 25/42] propagate bugfix in fix omp to OpenMP pragma --- src/USER-OMP/fix_omp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-OMP/fix_omp.cpp b/src/USER-OMP/fix_omp.cpp index 53ad46bc28..d7216a4571 100644 --- a/src/USER-OMP/fix_omp.cpp +++ b/src/USER-OMP/fix_omp.cpp @@ -351,7 +351,7 @@ void FixOMP::pre_force(int) double *drho = atom->drho; #if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(f,torque,erforce,de,drho) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(f,torque,erforce,desph,drho) #endif { const int tid = get_tid(); From 6659946de16c91742ab039262e7ee12b169e2c8c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 1 May 2020 08:50:07 -0400 Subject: [PATCH 26/42] fix more warnins and 64-bit issues --- src/USER-SMD/atom_vec_smd.h | 2 +- src/atom_vec.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/USER-SMD/atom_vec_smd.h b/src/USER-SMD/atom_vec_smd.h index c4d66c0b64..055ad795c4 100644 --- a/src/USER-SMD/atom_vec_smd.h +++ b/src/USER-SMD/atom_vec_smd.h @@ -45,7 +45,7 @@ class AtomVecSMD : public AtomVec { void data_atom_post(int); private: - int *molecule; + tagint *molecule; double *esph,*desph,*vfrac,*rmass,*radius,*contact_radius; double *eff_plastic_strain,*eff_plastic_strain_rate,*damage; double **x0,**smd_data_9,**smd_stress,**vest; diff --git a/src/atom_vec.h b/src/atom_vec.h index f3a31caad3..eaff5bd6f8 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -115,7 +115,7 @@ class AtomVec : protected Pointers { virtual void pack_restart_post(int) {} virtual void unpack_restart_init(int) {} - virtual int size_restart_bonus() {} + virtual int size_restart_bonus() {return 0;} virtual int pack_restart_bonus(int, double *) {return 0;} virtual int unpack_restart_bonus(int, double *) {return 0;} @@ -149,7 +149,7 @@ class AtomVec : protected Pointers { virtual void pack_property_atom(int, double *, int, int) {} virtual bigint memory_usage(); - virtual bigint memory_usage_bonus() {} + virtual bigint memory_usage_bonus() {return 0;} protected: int nmax; // local copy of atom->nmax From 807b0fce7e509e91a39b375b57bdd1459e646a1a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 1 May 2020 09:48:01 -0600 Subject: [PATCH 27/42] fix broken doc page links to new fix sph commands --- doc/src/fix_meso_move.rst | 39 ++++++++++++++++++++------------------ doc/src/fix_rigid_meso.rst | 24 ++++++++++++----------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/doc/src/fix_meso_move.rst b/doc/src/fix_meso_move.rst index a976c2de34..b97b029b9d 100644 --- a/doc/src/fix_meso_move.rst +++ b/doc/src/fix_meso_move.rst @@ -60,17 +60,19 @@ internal energy and extrapolated velocity are also updated. .. note:: - The particles affected by this fix should not be time integrated - by other fixes (e.g. :doc:`fix meso `, :doc:`fix meso/stationary `), since that will change their + The particles affected by this fix should not be time integrated by + other fixes (e.g. :doc:`fix sph `, :doc:`fix + sph/stationary `), since that will change their positions and velocities twice. .. note:: As particles move due to this fix, they will pass through periodic boundaries and be remapped to the other side of the simulation box, - just as they would during normal time integration (e.g. via the :doc:`fix meso ` command). It is up to you to decide whether periodic - boundaries are appropriate with the kind of particle motion you are - prescribing with this fix. + just as they would during normal time integration (e.g. via the + :doc:`fix sph ` command). It is up to you to decide + whether periodic boundaries are appropriate with the kind of + particle motion you are prescribing with this fix. .. note:: @@ -100,7 +102,7 @@ specified, *V* is the specified velocity vector with components specified. This style also sets the velocity of each particle to V = (Vx,Vy,Vz). If any of the velocity components is specified as NULL, then the position and velocity of that component is time integrated -the same as the :doc:`fix meso ` command would perform, using +the same as the :doc:`fix sph ` command would perform, using the corresponding force component on the particle. Note that the *linear* style is identical to using the *variable* @@ -128,7 +130,7 @@ elapsed since the fix was specified. This style also sets the velocity of each particle to the time derivative of this expression. If any of the amplitude components is specified as NULL, then the position and velocity of that component is time integrated the same as -the :doc:`fix meso ` command would perform, using the +the :doc:`fix sph ` command would perform, using the corresponding force component on the particle. Note that the *wiggle* style is identical to using the *variable* @@ -180,15 +182,15 @@ particle. Any of the 6 variables can be specified as NULL. If both the displacement and velocity variables for a particular x,y,z component are specified as NULL, then the position and velocity of that -component is time integrated the same as the :doc:`fix meso ` +component is time integrated the same as the :doc:`fix sph ` command would perform, using the corresponding force component on the -particle. If only the velocity variable for a component is specified as -NULL, then the displacement variable will be used to set the position -of the particle, and its velocity component will not be changed. If only -the displacement variable for a component is specified as NULL, then -the velocity variable will be used to set the velocity of the particle, -and the position of the particle will be time integrated using that -velocity. +particle. If only the velocity variable for a component is specified +as NULL, then the displacement variable will be used to set the +position of the particle, and its velocity component will not be +changed. If only the displacement variable for a component is +specified as NULL, then the velocity variable will be used to set the +velocity of the particle, and the position of the particle will be +time integrated using that velocity. The *units* keyword determines the meaning of the distance units used to define the *linear* velocity and *wiggle* amplitude and *rotate* @@ -236,17 +238,18 @@ Restrictions """""""""""" This fix is part of the USER-SDPD package. It is only enabled if -LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. +LAMMPS was built with that package. See the :doc:`Build package +` doc page for more info. This fix requires that atoms store density and internal energy as -defined by the :doc:`atom_style meso ` command. +defined by the :doc:`atom_style sph ` command. All particles in the group must be mesoscopic SPH/SDPD particles. Related commands """""""""""""""" -:doc:`fix move `, :doc:`fix meso `, +:doc:`fix move `, :doc:`fix sph `, :doc:`displace_atoms ` Default diff --git a/doc/src/fix_rigid_meso.rst b/doc/src/fix_rigid_meso.rst index c9a709175f..9961a871dc 100644 --- a/doc/src/fix_rigid_meso.rst +++ b/doc/src/fix_rigid_meso.rst @@ -75,19 +75,21 @@ internal energy and extrapolated velocity are also updated. .. note:: You should not update the particles in rigid bodies via other - time-integration fixes (e.g. :doc:`fix meso `, - :doc:`fix meso/stationary `), or you will have conflicting - updates to positions and velocities resulting in unphysical behavior in most - cases. When performing a hybrid simulation with some atoms in rigid bodies, - and some not, a separate time integration fix like :doc:`fix meso ` - should be used for the non-rigid particles. + time-integration fixes (e.g. :doc:`fix sph `, :doc:`fix + sph/stationary `), or you will have conflicting + updates to positions and velocities resulting in unphysical + behavior in most cases. When performing a hybrid simulation with + some atoms in rigid bodies, and some not, a separate time + integration fix like :doc:`fix sph ` should be used for + the non-rigid particles. .. note:: - These fixes are overkill if you simply want to hold a collection - of particles stationary or have them move with a constant velocity. To - hold particles stationary use :doc:`fix meso/stationary ` instead. If you would like to - move particles with a constant velocity use :doc:`fix meso/move `. + These fixes are overkill if you simply want to hold a collection of + particles stationary or have them move with a constant velocity. To + hold particles stationary use :doc:`fix sph/stationary + ` instead. If you would like to move particles + with a constant velocity use :doc:`fix meso/move `. .. warning:: @@ -346,7 +348,7 @@ package. It is only enabled if LAMMPS was built with both packages. See the :doc:`Build package ` doc page for more info. This fix requires that atoms store density and internal energy as -defined by the :doc:`atom_style meso ` command. +defined by the :doc:`atom_style sph ` command. All particles in the group must be mesoscopic SPH/SDPD particles. From 8e32f623f1d2d52654ed694f38c4111436fd6d96 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Fri, 1 May 2020 11:48:08 -0600 Subject: [PATCH 28/42] reformatted table for per-atom fields --- doc/src/read_data.rst | 102 +++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/doc/src/read_data.rst b/doc/src/read_data.rst index 4cd15ec7cc..79f0e08fcb 100644 --- a/doc/src/read_data.rst +++ b/doc/src/read_data.rst @@ -571,56 +571,56 @@ appended to it, which indicate which image of a periodic simulation box the atom is in. These may be important to include for some kinds of analysis. -+------------+---------------------------------------------------------------------------+ -| angle | atom-ID molecule-ID atom-type x y z | -+------------+---------------------------------------------------------------------------+ -| atomic | atom-ID atom-type x y z | -+------------+---------------------------------------------------------------------------+ -| body | atom-ID atom-type bodyflag mass x y z | -+------------+---------------------------------------------------------------------------+ -| bond | atom-ID molecule-ID atom-type x y z | -+------------+---------------------------------------------------------------------------+ -| charge | atom-ID atom-type q x y z | -+------------+---------------------------------------------------------------------------+ -| dipole | atom-ID atom-type q x y z mux muy muz | -+------------+---------------------------------------------------------------------------+ -| dpd | atom-ID atom-type theta x y z | -+------------+---------------------------------------------------------------------------+ -| edpd | atom-ID atom-type edpd_temp edpd_cv x y z | -+------------+---------------------------------------------------------------------------+ -| electron | atom-ID atom-type q spin eradius x y z | -+------------+---------------------------------------------------------------------------+ -| ellipsoid | atom-ID atom-type ellipsoidflag density x y z | -+------------+---------------------------------------------------------------------------+ -| full | atom-ID molecule-ID atom-type q x y z | -+------------+---------------------------------------------------------------------------+ -| line | atom-ID molecule-ID atom-type lineflag density x y z | -+------------+---------------------------------------------------------------------------+ -| mdpd | atom-ID atom-type rho x y z | -+------------+---------------------------------------------------------------------------+ -| meso | atom-ID atom-type rho e cv x y z | -+------------+---------------------------------------------------------------------------+ -| molecular | atom-ID molecule-ID atom-type x y z | -+------------+---------------------------------------------------------------------------+ -| peri | atom-ID atom-type volume density x y z | -+------------+---------------------------------------------------------------------------+ -| smd | atom-ID atom-type molecule volume mass kernel-radius -contact-radius x0 y0 z0 x y z | -+------------+---------------------------------------------------------------------------+ -| sphere | atom-ID atom-type diameter density x y z | -+------------+---------------------------------------------------------------------------+ -| spin | atom-ID atom-type x y z spx spy spz sp | -+------------+---------------------------------------------------------------------------+ -| tdpd | atom-ID atom-type x y z cc1 cc2 ... ccNspecies | -+------------+---------------------------------------------------------------------------+ -| template | atom-ID molecule-ID template-index template-atom atom-type x y z | -+------------+---------------------------------------------------------------------------+ -| tri | atom-ID molecule-ID atom-type triangleflag density x y z | -+------------+---------------------------------------------------------------------------+ -| wavepacket | atom-ID atom-type charge spin eradius etag cs_re cs_im x y z | -+------------+---------------------------------------------------------------------------+ -| hybrid | atom-ID atom-type x y z sub-style1 sub-style2 ... | -+------------+---------------------------------------------------------------------------+ +.. list-table:: + + * - angle + - atom-ID molecule-ID atom-type x y z + * - atomic + - atom-ID atom-type x y z + * - body + - atom-ID atom-type bodyflag mass x y z + * - bond + - atom-ID molecule-ID atom-type x y z + * - charge + - atom-type q x y z + * - dipole + - atom-ID atom-type q x y z mux muy muz + * - dpd + - atom-ID atom-type theta x y z + * - edpd + - atom-ID atom-type edpd_temp edpd_cv x y z + * - electron + - atom-ID atom-type q spin eradius x y z + * - ellipsoid + - atom-ID atom-type ellipsoidflag density x y z + * - full + - atom-ID molecule-ID atom-type q x y z + * - line + - atom-ID molecule-ID atom-type lineflag density x y z + * - mdpd + - atom-ID atom-type rho x y z + * - molecular + - atom-ID molecule-ID atom-type x y z + * - peri + - atom-ID atom-type volume density x y z + * - smd + - atom-ID atom-type molecule volume mass kernel-radius contact-radius x0 y0 z0 x y z + * - sph + - atom-ID atom-type rho esph cv x y z + * - sphere + - atom-ID atom-type diameter density x y z + * - spin + - atom-ID atom-type x y z spx spy spz sp + * - tdpd + - atom-ID atom-type x y z cc1 cc2 ... ccNspecies + * - template + - atom-ID molecule-ID template-index template-atom atom-type x y z + * - tri + - atom-ID molecule-ID atom-type triangleflag density x y z + * - wavepacket + - atom-ID atom-type charge spin eradius etag cs_re cs_im x y z + * - hybrid + - atom-ID atom-type x y z sub-style1 sub-style2 ... The per-atom values have these meanings and units, listed alphabetically: @@ -633,7 +633,7 @@ The per-atom values have these meanings and units, listed alphabetically: * cv = heat capacity (need units) for SPH particles * density = density of particle (mass/distance\^3 or mass/distance\^2 or mass/distance units, depending on dimensionality of particle) * diameter = diameter of spherical atom (distance units) -* e = energy (need units) for SPH particles +* esph = energy (need units) for SPH particles * edpd_temp = temperature for eDPD particles (temperature units) * edpd_cv = volumetric heat capacity for eDPD particles (energy/temperature/volume units) * ellipsoidflag = 1 for ellipsoidal particles, 0 for point particles From 5cb9d12538e6e3062b5bd57032dd496934bef005 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 1 May 2020 14:34:20 -0400 Subject: [PATCH 29/42] whitespace cleanup --- doc/src/atom_style.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index 44fac6c1f3..2f4f7412e2 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -19,8 +19,8 @@ Syntax bstyle = style of body particles bstyle-args = additional arguments specific to the bstyle see the :doc:`Howto body ` doc - page for details - *sphere* arg = 0/1 (optional) for static/dynamic particle radii + page for details + *sphere* arg = 0/1 (optional) for static/dynamic particle radii *tdpd* arg = Nspecies Nspecies = # of chemical species *template* arg = template-ID From 3ccab20e9e4628df0e754483011e4ac381188784 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 1 May 2020 14:34:27 -0400 Subject: [PATCH 30/42] add new false positives --- doc/utils/sphinx-config/false_positives.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 97b7f47503..9af3978223 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -327,6 +327,7 @@ ccache ccachepiecewise ccl ccmake +ccN ccNspecies CCu cd @@ -593,6 +594,7 @@ Derjaguin Derlet Deserno Destree +destructor detils Devanathan devel @@ -833,6 +835,7 @@ Espanol Eshelby eshelby eskm +esph esu esub esw From ab1ecdccfccfebd81ec1f1f6fcb083d5c08b40fe Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 1 May 2020 14:34:35 -0400 Subject: [PATCH 31/42] fix typo in comment --- src/atom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.cpp b/src/atom.cpp index bbdecc5b98..7c1b5ae6dc 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -596,7 +596,7 @@ void Atom::add_peratom(const char *name, void *address, } /* ---------------------------------------------------------------------- - change the column count fof an existing peratom array entry + change the column count of an existing peratom array entry allows atom_style to specify column count as an argument see atom_style tdpd as an example ------------------------------------------------------------------------- */ From 1225f7d1e015b2b518eb0d81146b7722df049c76 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 6 May 2020 15:28:27 -0600 Subject: [PATCH 32/42] small changes to examples scripts for regression purposes --- examples/ASPHERE/line/in.line | 6 ++++-- examples/ASPHERE/line/in.line.srd | 6 ++++-- examples/ASPHERE/tri/in.tri.srd | 4 +++- examples/USER/dpd/dpd-shardlow/in.dpd-shardlow | 2 +- examples/USER/dpd/dpd-vv/in.dpd-vv | 1 - examples/USER/dpd/dpde-shardlow/in.dpde-shardlow | 2 +- examples/USER/dpd/dpde-vv/in.dpde-vv | 1 - examples/USER/dpd/dpdh-shardlow/in.dpdh-shardlow | 2 +- examples/USER/dpd/dpdp-shardlow/in.dpdp-shardlow | 2 +- examples/USER/dpd/dpdrx-shardlow/in.dpdrx-shardlow | 1 - examples/USER/dpd/multi-lucy/in.multi-lucy | 2 +- .../USER/eff/Auger-Adamantane/in.adamantane_ionized.nve | 1 - examples/USER/eff/Be-solid/in.Be-solid.spe | 1 - examples/USER/eff/CH4/in.ch4.dynamics | 1 - examples/USER/eff/CH4/in.ch4.min | 1 - examples/USER/eff/CH4/in.ch4_ionized.dynamics | 2 +- examples/USER/eff/H/in.h_atom.spe.ang | 1 - examples/USER/eff/H/in.h_atom.spe.bohr | 1 - examples/USER/eff/H2/in.h2 | 3 +-- examples/USER/eff/H_plasma/in.h2bulk.npt | 4 ++-- examples/USER/eff/H_plasma/in.h2bulk.nve | 7 +++---- examples/USER/eff/H_plasma/in.h2bulk.nve.ang | 7 +++---- examples/USER/eff/Li-dendritic/in.Li-dendritic.min | 5 ++--- examples/USER/eff/Li-dendritic/in.Li-dendritic.nvt | 5 ++--- examples/USER/eff/Li-solid/in.Li.ang | 7 +++---- examples/USER/eff/Li-solid/in.Li.bohr | 7 +++---- examples/granular/in.pour.drum | 2 ++ examples/qeq/in.qeq.buck | 2 +- examples/streitz/in.streitz.wolf | 2 +- 29 files changed, 40 insertions(+), 48 deletions(-) diff --git a/examples/ASPHERE/line/in.line b/examples/ASPHERE/line/in.line index cd7fed1639..815eacfa35 100644 --- a/examples/ASPHERE/line/in.line +++ b/examples/ASPHERE/line/in.line @@ -10,7 +10,7 @@ velocity all create 1.44 320984 loop geom neighbor 0.3 bin neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule all +neigh_modify exclude molecule/intra all pair_style line/lj 2.5 pair_coeff * * 1.0 1.0 1.0 0.25 2.5 @@ -33,8 +33,10 @@ compute 2 all ke compute 3 all pe variable toteng equal (c_1+c_2+c_3)/atoms +compute_modify thermo_temp extra/dof -350 + thermo 1000 -thermo_style custom step temp f_2 pe ke c_1 c_2 c_3 v_toteng +thermo_style custom step f_2 pe ke c_1 c_2 c_3 v_toteng run 10000 diff --git a/examples/ASPHERE/line/in.line.srd b/examples/ASPHERE/line/in.line.srd index 4b89b14b4b..6ec1998d31 100644 --- a/examples/ASPHERE/line/in.line.srd +++ b/examples/ASPHERE/line/in.line.srd @@ -36,7 +36,7 @@ velocity small create 1.44 87287 loop geom neighbor 0.3 bin neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule big include big +neigh_modify exclude molecule/intra big include big comm_modify mode multi group big vel yes neigh_modify include big @@ -68,13 +68,15 @@ compute tbig big temp variable pebig equal pe*atoms/count(big) variable ebig equal etotal*atoms/count(big) +compute_modify tbig extra/dof -350 + compute 1 big erotate/asphere compute 2 all ke compute 3 all pe variable toteng equal (c_1+c_2+c_3)/atoms thermo 1000 -thermo_style custom step temp c_tsmall f_2[9] c_1 etotal & +thermo_style custom step c_tsmall f_2[9] c_1 etotal & v_pebig v_ebig press thermo_modify temp tbig diff --git a/examples/ASPHERE/tri/in.tri.srd b/examples/ASPHERE/tri/in.tri.srd index caff7f60dd..e7ef6ef59a 100644 --- a/examples/ASPHERE/tri/in.tri.srd +++ b/examples/ASPHERE/tri/in.tri.srd @@ -35,7 +35,7 @@ velocity small create 1.44 87287 loop geom neighbor 0.3 bin neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule big include big +neigh_modify exclude molecule/intra big include big comm_modify mode multi group big vel yes neigh_modify include big @@ -66,6 +66,8 @@ compute tbig big temp variable pebig equal pe*atoms/count(big) variable ebig equal etotal*atoms/count(big) +compute_modify tbig extra/dof -4500 + compute 1 big erotate/asphere compute 2 all ke compute 3 all pe diff --git a/examples/USER/dpd/dpd-shardlow/in.dpd-shardlow b/examples/USER/dpd/dpd-shardlow/in.dpd-shardlow index e6e46bc38c..6251623374 100644 --- a/examples/USER/dpd/dpd-shardlow/in.dpd-shardlow +++ b/examples/USER/dpd/dpd-shardlow/in.dpd-shardlow @@ -1,5 +1,5 @@ # Input File for DPD fluid under isothermal conditions using the VV-SSA integration scheme -log log.dpd-shardlow + boundary p p p units metal diff --git a/examples/USER/dpd/dpd-vv/in.dpd-vv b/examples/USER/dpd/dpd-vv/in.dpd-vv index 5360ca2431..6890c881d4 100644 --- a/examples/USER/dpd/dpd-vv/in.dpd-vv +++ b/examples/USER/dpd/dpd-vv/in.dpd-vv @@ -1,6 +1,5 @@ # INPUT FILE FOR DPD_Fluid -log log.dpd-vv boundary p p p units metal # ev, ps diff --git a/examples/USER/dpd/dpde-shardlow/in.dpde-shardlow b/examples/USER/dpd/dpde-shardlow/in.dpde-shardlow index 68361adfa5..c639bef9f2 100644 --- a/examples/USER/dpd/dpde-shardlow/in.dpde-shardlow +++ b/examples/USER/dpd/dpde-shardlow/in.dpde-shardlow @@ -1,5 +1,5 @@ # Input File for DPD fluid under isoenergetic conditions using the VV-SSA integration scheme -log log.dpde-shardlow + boundary p p p units metal # ev, ps diff --git a/examples/USER/dpd/dpde-vv/in.dpde-vv b/examples/USER/dpd/dpde-vv/in.dpde-vv index 3ffcf0ec07..52309682c3 100644 --- a/examples/USER/dpd/dpde-vv/in.dpde-vv +++ b/examples/USER/dpd/dpde-vv/in.dpde-vv @@ -1,6 +1,5 @@ # INPUT FILE FOR DPD_Fluid -log log.dpde-vv boundary p p p units metal # ev, ps diff --git a/examples/USER/dpd/dpdh-shardlow/in.dpdh-shardlow b/examples/USER/dpd/dpdh-shardlow/in.dpdh-shardlow index e403175e7a..5353085359 100644 --- a/examples/USER/dpd/dpdh-shardlow/in.dpdh-shardlow +++ b/examples/USER/dpd/dpdh-shardlow/in.dpdh-shardlow @@ -1,5 +1,5 @@ # Input File for DPD fluid under isoenthalpic conditions using the VV-SSA integration scheme -log log.dpdh-shardlow + boundary p p p units metal # ev, ps diff --git a/examples/USER/dpd/dpdp-shardlow/in.dpdp-shardlow b/examples/USER/dpd/dpdp-shardlow/in.dpdp-shardlow index 1d5eb5dd7d..93f26bd946 100644 --- a/examples/USER/dpd/dpdp-shardlow/in.dpdp-shardlow +++ b/examples/USER/dpd/dpdp-shardlow/in.dpdp-shardlow @@ -1,5 +1,5 @@ # Input File for DPD fluid under isobaric conditions using the VV-SSA integration scheme -log log.dpdp-shardlow + boundary p p p units metal diff --git a/examples/USER/dpd/dpdrx-shardlow/in.dpdrx-shardlow b/examples/USER/dpd/dpdrx-shardlow/in.dpdrx-shardlow index 815c974741..f93b316e14 100755 --- a/examples/USER/dpd/dpdrx-shardlow/in.dpdrx-shardlow +++ b/examples/USER/dpd/dpdrx-shardlow/in.dpdrx-shardlow @@ -1,6 +1,5 @@ # Example for running DPD-RX -log log.dpdrx-shardlow boundary p p p units metal # ev, ps atom_style dpd diff --git a/examples/USER/dpd/multi-lucy/in.multi-lucy b/examples/USER/dpd/multi-lucy/in.multi-lucy index 26d21f66ea..bb223e0a25 100644 --- a/examples/USER/dpd/multi-lucy/in.multi-lucy +++ b/examples/USER/dpd/multi-lucy/in.multi-lucy @@ -1,5 +1,5 @@ # RDX coarse-grain model -log log.multi-lucy + units metal # ev, ps atom_style dpd atom_modify map array diff --git a/examples/USER/eff/Auger-Adamantane/in.adamantane_ionized.nve b/examples/USER/eff/Auger-Adamantane/in.adamantane_ionized.nve index 77c7b0d465..edbe76beef 100644 --- a/examples/USER/eff/Auger-Adamantane/in.adamantane_ionized.nve +++ b/examples/USER/eff/Auger-Adamantane/in.adamantane_ionized.nve @@ -1,5 +1,4 @@ variable sname index adamantane_ionized -log ${sname}.nve.log units electron newton on diff --git a/examples/USER/eff/Be-solid/in.Be-solid.spe b/examples/USER/eff/Be-solid/in.Be-solid.spe index e7245cabbc..ce61a21f8c 100644 --- a/examples/USER/eff/Be-solid/in.Be-solid.spe +++ b/examples/USER/eff/Be-solid/in.Be-solid.spe @@ -1,5 +1,4 @@ variable sname index Be-solid -log ${sname}.spe.log units electron newton on diff --git a/examples/USER/eff/CH4/in.ch4.dynamics b/examples/USER/eff/CH4/in.ch4.dynamics index 2536fa8f48..cb06a1c8cf 100644 --- a/examples/USER/eff/CH4/in.ch4.dynamics +++ b/examples/USER/eff/CH4/in.ch4.dynamics @@ -1,5 +1,4 @@ variable sname index ch4 -log ${sname}.nve.log units electron newton on diff --git a/examples/USER/eff/CH4/in.ch4.min b/examples/USER/eff/CH4/in.ch4.min index 69b7c15bd4..df052c728e 100644 --- a/examples/USER/eff/CH4/in.ch4.min +++ b/examples/USER/eff/CH4/in.ch4.min @@ -1,5 +1,4 @@ variable sname index ch4 -log ${sname}.nve.log units electron newton on diff --git a/examples/USER/eff/CH4/in.ch4_ionized.dynamics b/examples/USER/eff/CH4/in.ch4_ionized.dynamics index 14f214296f..51ca071fc6 100644 --- a/examples/USER/eff/CH4/in.ch4_ionized.dynamics +++ b/examples/USER/eff/CH4/in.ch4_ionized.dynamics @@ -1,5 +1,4 @@ variable sname index ch4_ionized -log ${sname}.nvt.log units electron newton on @@ -15,6 +14,7 @@ pair_coeff * * comm_modify vel yes # minimize + min_style cg min_modify line quadratic minimize 0 1.0e-6 10000 100000 diff --git a/examples/USER/eff/H/in.h_atom.spe.ang b/examples/USER/eff/H/in.h_atom.spe.ang index 2493e273c4..85bedf5b59 100644 --- a/examples/USER/eff/H/in.h_atom.spe.ang +++ b/examples/USER/eff/H/in.h_atom.spe.ang @@ -1,5 +1,4 @@ variable sname index h_atom.ang -log ${sname}.spe.log units real newton on diff --git a/examples/USER/eff/H/in.h_atom.spe.bohr b/examples/USER/eff/H/in.h_atom.spe.bohr index 2f18ee4e43..91b39a70db 100644 --- a/examples/USER/eff/H/in.h_atom.spe.bohr +++ b/examples/USER/eff/H/in.h_atom.spe.bohr @@ -1,5 +1,4 @@ variable sname index h_atom.bohr -log ${sname}.spe.log units electron newton on diff --git a/examples/USER/eff/H2/in.h2 b/examples/USER/eff/H2/in.h2 index 8f4a63cc84..0c9dd620a3 100644 --- a/examples/USER/eff/H2/in.h2 +++ b/examples/USER/eff/H2/in.h2 @@ -1,5 +1,4 @@ variable sname index h2 -log ${sname}.spe.log units electron newton on @@ -47,4 +46,4 @@ unfix 3 #fix 1 all nve/eff -run 100000 +run 10000 diff --git a/examples/USER/eff/H_plasma/in.h2bulk.npt b/examples/USER/eff/H_plasma/in.h2bulk.npt index 6d9fc5d55f..55c3d9b16f 100644 --- a/examples/USER/eff/H_plasma/in.h2bulk.npt +++ b/examples/USER/eff/H_plasma/in.h2bulk.npt @@ -1,5 +1,4 @@ variable sname index h2bulk -log ${sname}.npt.log units electron newton on @@ -41,7 +40,8 @@ dump 2 all xyz 10000 ${sname}.npt.xyz compute 1 all property/atom spin eradius dump 3 all custom 10000 ${sname}.npt.lammpstrj id type x y z c_1[1] c_1[2] -run 10000000 +thermo 1 +run 10 unfix 1 undump 2 diff --git a/examples/USER/eff/H_plasma/in.h2bulk.nve b/examples/USER/eff/H_plasma/in.h2bulk.nve index 9786ff476f..32b724c539 100644 --- a/examples/USER/eff/H_plasma/in.h2bulk.nve +++ b/examples/USER/eff/H_plasma/in.h2bulk.nve @@ -1,5 +1,4 @@ variable sname index h2bulk -log ${sname}.nve.log units electron newton on @@ -18,13 +17,13 @@ comm_modify vel yes compute effTemp all temp/eff -thermo 1000 +thermo 10 thermo_style custom step pe temp press thermo_modify temp effTemp # structure minimization min_style cg -minimize 0 1.0e-4 1000 10000 +minimize 0 1.0e-4 10 10 timestep 0.001 @@ -41,7 +40,7 @@ dump 2 all xyz 1000 ${sname}.nve.xyz compute 1 all property/atom spin eradius dump 3 all custom 1000 ${sname}.nve.lammpstrj id type x y z c_1[1] c_1[2] c_peatom c_keatom -run 100000 +run 10 unfix 1 #unfix 2 diff --git a/examples/USER/eff/H_plasma/in.h2bulk.nve.ang b/examples/USER/eff/H_plasma/in.h2bulk.nve.ang index 4935e39be3..3377d63580 100644 --- a/examples/USER/eff/H_plasma/in.h2bulk.nve.ang +++ b/examples/USER/eff/H_plasma/in.h2bulk.nve.ang @@ -1,5 +1,4 @@ variable sname index h2bulk.ang -log ${sname}.nve.log units real newton on @@ -29,13 +28,13 @@ variable epauli equal c_energies[2] variable ecoul equal c_energies[3] variable erres equal c_energies[4] -thermo 100 +thermo 10 thermo_style custom step etotal pe ke v_eke v_epauli v_ecoul v_erres press v_press temp thermo_modify temp effTemp press effPress flush yes # structure minimization min_style cg -minimize 0 1.0e-4 1000 10000 +minimize 0 1.0e-4 10 10 timestep 0.001 @@ -52,7 +51,7 @@ dump 2 all xyz 1000 ${sname}.nve.xyz compute 1 all property/atom spin eradius dump 3 all custom 1000 ${sname}.nve.lammpstrj id type x y z c_1[1] c_1[2] c_peatom c_keatom -run 100000 +run 10 unfix 1 #unfix 2 diff --git a/examples/USER/eff/Li-dendritic/in.Li-dendritic.min b/examples/USER/eff/Li-dendritic/in.Li-dendritic.min index f791544e44..5dfa85e52c 100644 --- a/examples/USER/eff/Li-dendritic/in.Li-dendritic.min +++ b/examples/USER/eff/Li-dendritic/in.Li-dendritic.min @@ -1,5 +1,4 @@ variable sname index Li-dendritic -log ${sname}.min.log units electron newton on @@ -7,8 +6,8 @@ boundary p p p atom_style electron -#read_data data.${sname} -read_restart ${sname}.min.restart2 +read_data data.${sname} +#read_restart ${sname}.min.restart2 pair_style eff/cut 50.112 pair_coeff * * diff --git a/examples/USER/eff/Li-dendritic/in.Li-dendritic.nvt b/examples/USER/eff/Li-dendritic/in.Li-dendritic.nvt index 143e23cbc1..4203b50dde 100644 --- a/examples/USER/eff/Li-dendritic/in.Li-dendritic.nvt +++ b/examples/USER/eff/Li-dendritic/in.Li-dendritic.nvt @@ -1,5 +1,4 @@ variable sname index Li-dendritic -log ${sname}.min.log units electron newton on @@ -29,7 +28,7 @@ compute 1 all property/atom spin eradius #dump 1 all custom 100 ${sname}.min.lammpstrj id type x y z q c_1[1] c_1[2] #dump 2 all xyz 100 ${sname}.min.xyz min_modify line quadratic dmax 0.05 -minimize 0 1.0e-7 1000 2000 +minimize 0 1.0e-7 100 100 write_restart ${sname}.min.restart @@ -46,7 +45,7 @@ dump 1 all custom 100 ${sname}.nvt.lammpstrj id type x y z c_1[1] c_1 dump 2 all xyz 100 ${sname}.nvt.xyz restart 100 ${sname}.nvt.restart1 ${sname}.nvt.restart2 -run 10000 +run 100 undump 1 undump 2 diff --git a/examples/USER/eff/Li-solid/in.Li.ang b/examples/USER/eff/Li-solid/in.Li.ang index c9a726b88c..e4f5614c56 100644 --- a/examples/USER/eff/Li-solid/in.Li.ang +++ b/examples/USER/eff/Li-solid/in.Li.ang @@ -1,5 +1,4 @@ variable sname index Li.ang -log ${sname}.spe.log units real newton on @@ -46,13 +45,13 @@ fix 0 all temp/rescale/eff 1 10.0 3000.0 0.05 1.0 #fix 0 all langevin/eff 3000.0 3000.0 10.0 699483 fix 1 all nve/eff -run 1000 +run 200 unfix 0 unfix 1 fix 1 all nvt/eff temp 3000.0 3000.0 100.0 compute 1 all property/atom spin eradius ervel -dump 1 all custom 1000 ${sname}.nvt.lammpstrj id type q c_1[1] c_1[2] x y z vx vy vz c_1[3] +dump 1 all custom 500 ${sname}.nvt.lammpstrj id type q c_1[1] c_1[2] x y z vx vy vz c_1[3] -run 100000 +run 500 diff --git a/examples/USER/eff/Li-solid/in.Li.bohr b/examples/USER/eff/Li-solid/in.Li.bohr index 2843d3ca6a..2ff8b661d5 100644 --- a/examples/USER/eff/Li-solid/in.Li.bohr +++ b/examples/USER/eff/Li-solid/in.Li.bohr @@ -1,5 +1,4 @@ variable sname index Li.bohr -log ${sname}.spe.log units electron newton off @@ -35,15 +34,15 @@ thermo_style custom step etotal pe ke v_eke v_epauli v_estatics v_errestrain thermo_modify temp effTemp press effPress min_style cg -minimize 0 1e-6 100 2000 +minimize 0 1e-6 100 200 fix 0 all temp/rescale/eff 1 0.0 3000.0 0.02 0.5 fix 1 all npt/eff temp 3000.0 3000.0 0.1 iso 1e7 1e7 1.0 compute 1 all property/atom spin eradius -dump 1 all custom 1 ${sname}.spe.lammpstrj & +dump 1 all custom 100 ${sname}.spe.lammpstrj & id type q c_1[1] c_1[2] x y z -run 1000 +run 100 diff --git a/examples/granular/in.pour.drum b/examples/granular/in.pour.drum index c30f30b377..54372cd391 100644 --- a/examples/granular/in.pour.drum +++ b/examples/granular/in.pour.drum @@ -92,6 +92,8 @@ fix 5 all wall/gran/region granular hertz/material 1e5 0.1 0.3 tangential mindl # 'Turn' drum by switching the direction of gravity unfix grav +unfix ins1 +unfix ins2 fix grav all gravity 10 vector 0 -1 0 variable theta equal 2*PI*elapsed/20000.0 diff --git a/examples/qeq/in.qeq.buck b/examples/qeq/in.qeq.buck index f7ec2bb808..2258a9e2ae 100644 --- a/examples/qeq/in.qeq.buck +++ b/examples/qeq/in.qeq.buck @@ -24,7 +24,7 @@ compute charge2 type2 property/atom q compute q2 type2 reduce ave c_charge2 variable qtot equal count(type1)*c_q1+count(type2)*c_q2 -thermo_style custom step pe c_q1 c_q2 v_qtot spcpu +thermo_style custom step pe c_q1 c_q2 v_qtot thermo 10 timestep 0.0001 diff --git a/examples/streitz/in.streitz.wolf b/examples/streitz/in.streitz.wolf index ff4479448e..cdf7cf33c9 100644 --- a/examples/streitz/in.streitz.wolf +++ b/examples/streitz/in.streitz.wolf @@ -39,7 +39,7 @@ neigh_modify every 10 delay 0 check yes timestep 0.0004 thermo_style custom step temp etotal pe evdwl ecoul elong & - c_q1 c_q2 v_qsum press spcpu + c_q1 c_q2 v_qsum press thermo_modify norm yes thermo 10 From 7d9091cacc50bdddb1849741b8df4fa5f9928924 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 6 May 2020 15:49:44 -0600 Subject: [PATCH 33/42] Add back in old hybrid functions, needed by Kokkos package --- src/atom_vec.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/atom_vec.h b/src/atom_vec.h index eaff5bd6f8..148e2d4785 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -151,6 +151,21 @@ class AtomVec : protected Pointers { virtual bigint memory_usage(); virtual bigint memory_usage_bonus() {return 0;} + // old hybrid functions, needed by Kokkos package + + virtual int pack_comm_hybrid(int, int *, double *) {return 0;} + virtual int unpack_comm_hybrid(int, int, double *) {return 0;} + virtual int pack_reverse_hybrid(int, int, double *) {return 0;} + virtual int unpack_reverse_hybrid(int, int *, double *) {return 0;} + virtual int pack_border_hybrid(int, int *, double *) {return 0;} + virtual int unpack_border_hybrid(int, int, double *) {return 0;} + virtual int data_atom_hybrid(int, char **) {return 0;} + virtual int data_vel_hybrid(int, char **) {return 0;} + virtual int pack_data_hybrid(int, double *) {return 0;} + virtual int write_data_hybrid(FILE *, double *) {return 0;} + virtual int pack_vel_hybrid(int, double *) {return 0;} + virtual int write_vel_hybrid(FILE *, double *) {return 0;} + protected: int nmax; // local copy of atom->nmax int deform_vremap; // local copy of domain properties From 25632992f4379c4e25a8820950e5730d641f5b5c Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 6 May 2020 16:25:07 -0600 Subject: [PATCH 34/42] updates to USER-SPH example scripts --- examples/USER/sph/cavity_flow/cavity_flow.lmp | 12 +++++----- .../heatconduction/sph_heat_conduction_2d.lmp | 14 ++++++------ .../heatconduction/sph_heat_conduction_3d.lmp | 14 ++++++------ examples/USER/sph/shock_tube/shock2d.lmp | 22 +++++++++---------- examples/USER/sph/shock_tube/shock3d.lmp | 22 +++++++++---------- .../sph/water_collapse/water_collapse.lmp | 10 ++++----- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/examples/USER/sph/cavity_flow/cavity_flow.lmp b/examples/USER/sph/cavity_flow/cavity_flow.lmp index 5c1517687f..19d3a3c14f 100644 --- a/examples/USER/sph/cavity_flow/cavity_flow.lmp +++ b/examples/USER/sph/cavity_flow/cavity_flow.lmp @@ -1,6 +1,6 @@ dimension 2 units si -atom_style meso +atom_style sph # create simulation box region box block -0.050e-3 1.044e-3 -0.05e-3 1.044e-3 -1.0e-6 1.0e-6 units box @@ -28,7 +28,7 @@ group integrate_full union fluid driver mass 3 2.0e-7 mass 2 2.0e-7 mass 1 4.0e-7 -set group all meso/rho 1000.0 +set group all sph/rho 1000.0 # use Tait's EOS in combination with Morris' laminar viscosity. # We set rho_0 = 1000 kg/m^3, c = 0.1 m/s, h = 6.5e-5 m. @@ -37,8 +37,8 @@ pair_style hybrid sph/taitwater/morris pair_coeff * * sph/taitwater/morris 1000 0.1 1.0e-3 6.5e-5 pair_coeff 2 3 none # exclude interaction between walls and shear driver -compute rho_peratom all meso/rho/atom -compute e_peratom all meso/e/atom +compute rho_peratom all sph/rho/atom +compute e_peratom all sph/e/atom compute ke_peratom all ke/atom compute esph all reduce sum c_e_peratom compute ke all ke @@ -49,8 +49,8 @@ velocity driver set 0.001 0.0 0.0 units box fix freeze_fix driver setforce 0.0 0.0 0.0 # do full time integration for shear driver and fluid, but keep walls stationary -fix integrate_fix_full integrate_full meso -fix integrate_fix_stationary walls meso/stationary +fix integrate_fix_full integrate_full sph +fix integrate_fix_stationary walls sph/stationary dump dump_id all custom 100 dump.lammpstrj id type xs ys zs vx vy c_rho_peratom c_e_peratom dump_modify dump_id first yes diff --git a/examples/USER/sph/heatconduction/sph_heat_conduction_2d.lmp b/examples/USER/sph/heatconduction/sph_heat_conduction_2d.lmp index 808646059f..4d0db9c75a 100644 --- a/examples/USER/sph/heatconduction/sph_heat_conduction_2d.lmp +++ b/examples/USER/sph/heatconduction/sph_heat_conduction_2d.lmp @@ -1,4 +1,4 @@ -# mesoscopic heat conduction +# SPH heat conduction # heat flow from hot right region to cold left region # compare the temperature profile at the end opf the simulation, # contained in file dump.last, to analytic solution. @@ -6,7 +6,7 @@ # dimension 2 units si -atom_style meso +atom_style sph boundary f p p lattice sq 0.01 @@ -17,23 +17,23 @@ mass 1 1.0e-5 region left block EDGE 49.9 EDGE EDGE EDGE EDGE region right block 50 EDGE EDGE EDGE EDGE EDGE -set region left meso/e 1.0 # internal energies -set region right meso/e 2.0 -set group all meso/rho 0.1 # mesoscopic density is also needed for this pair style +set region left sph/e 1.0 # internal energies +set region right sph/e 2.0 +set group all sph/rho 0.1 # SPH density is also needed for this pair style # For correct temperature profiles, mescoscopic density and mass * number density must coincide! pair_style sph/heatconduction # i j diffusion coeff. cutoff pair_coeff 1 1 1.0e-4 2.0e-2 -compute ie_atom all meso/e/atom +compute ie_atom all sph/e/atom compute ie all reduce sum c_ie_atom thermo 10 thermo_style custom step temp c_ie timestep 0.25e-1 neighbor 0.2e-2 bin -fix integrate_fix all meso/stationary +fix integrate_fix all sph/stationary dump dump_fix all custom 10 dump.heat id type x y z c_ie_atom dump_modify dump_fix first yes diff --git a/examples/USER/sph/heatconduction/sph_heat_conduction_3d.lmp b/examples/USER/sph/heatconduction/sph_heat_conduction_3d.lmp index fc6fa07457..ee9a5a8661 100644 --- a/examples/USER/sph/heatconduction/sph_heat_conduction_3d.lmp +++ b/examples/USER/sph/heatconduction/sph_heat_conduction_3d.lmp @@ -1,11 +1,11 @@ -# mesoscopic heat conduction +# SPH heat conduction # heat flow from hot right region to cold left region # compare the temperature profile at the end opf the simulation, # contained in file dump.last, to analytic solution. # # units si -atom_style meso +atom_style sph newton on boundary f p p @@ -17,9 +17,9 @@ mass 1 1.0e-5 region left block EDGE 49.9 EDGE EDGE EDGE EDGE region right block 50 EDGE EDGE EDGE EDGE EDGE -set region left meso/e 1.0 # internal energies -set region right meso/e 2.0 -set group all meso/rho 10.0 # mesoscopic density is also needed for this pair style +set region left sph/e 1.0 # internal energies +set region right sph/e 2.0 +set group all sph/rho 10.0 # SPH density is also needed for this pair style # For correct temperature profiles, mescoscopic density and mass * number density must coincide! pair_style sph/heatconduction @@ -28,13 +28,13 @@ pair_coeff 1 1 1.0e-4 2.0e-2 neighbor 0.2e-2 bin neigh_modify every 20 delay 0 check no -compute ie_atom all meso/e/atom +compute ie_atom all sph/e/atom compute ie all reduce sum c_ie_atom thermo_style custom step temp c_ie thermo_modify norm no -fix integrate_fix all meso/stationary +fix integrate_fix all sph/stationary thermo 10 timestep 0.25e-1 diff --git a/examples/USER/sph/shock_tube/shock2d.lmp b/examples/USER/sph/shock_tube/shock2d.lmp index bd67362ca9..32cfd8067b 100755 --- a/examples/USER/sph/shock_tube/shock2d.lmp +++ b/examples/USER/sph/shock_tube/shock2d.lmp @@ -1,4 +1,4 @@ -atom_style meso +atom_style sph dimension 2 boundary s p p @@ -13,20 +13,20 @@ set region right type 2 mass 1 1 mass 2 0.25 -set type 1 meso/e 2.5 # internal energy corresponding to p=1, rho=1 -set type 2 meso/e 0.625 # internal energy corresponding to p=0.25, rho=0.25 -set type 1 meso/rho 1.0 -set type 2 meso/rho 0.25 +set type 1 sph/e 2.5 # internal energy corresponding to p=1, rho=1 +set type 2 sph/e 0.625 # internal energy corresponding to p=0.25, rho=0.25 +set type 1 sph/rho 1.0 +set type 2 sph/rho 0.25 pair_style hybrid/overlay sph/rhosum 1 sph/idealgas pair_coeff * * sph/rhosum 4.0 pair_coeff * * sph/idealgas 0.75 4.0 -compute rhoatom all meso/rho/atom -compute ieatom all meso/e/atom -compute emeso all reduce sum c_ieatom # total internal energy +compute rhoatom all shp/rho/atom +compute ieatom all sph/e/atom +compute esph all reduce sum c_ieatom # total internal energy compute ke all ke -variable etot equal c_ke+c_emeso # total energy +variable etot equal c_ke+c_esph # total energy # dump positions and local density dump dump_id all custom 100 dump.2d id type x z y c_rhoatom @@ -35,10 +35,10 @@ dump_modify dump_id first yes neighbor 0.5 bin neigh_modify every 5 delay 0 check yes thermo 10 -thermo_style custom step c_ke c_emeso v_etot +thermo_style custom step c_ke c_esph v_etot thermo_modify norm no -fix integration_fix all meso +fix integration_fix all sph fix 1 all setforce NULL 0.0 0.0 # treat as a quasi 1d problem timestep 0.05 log log.2d diff --git a/examples/USER/sph/shock_tube/shock3d.lmp b/examples/USER/sph/shock_tube/shock3d.lmp index 2da892d836..d82f081e85 100644 --- a/examples/USER/sph/shock_tube/shock3d.lmp +++ b/examples/USER/sph/shock_tube/shock3d.lmp @@ -1,4 +1,4 @@ -atom_style meso +atom_style sph boundary s p p region box block -100 150 -4 4 -4 4 units box @@ -12,20 +12,20 @@ set region right type 2 mass 1 1 mass 2 0.25 -set type 1 meso/e 2.5 # internal energy corresponding to p=1, rho=1 -set type 2 meso/e 0.625 # internal energy corresponding to p=0.25, rho=0.25 -set type 1 meso/rho 1.0 -set type 2 meso/rho 0.25 +set type 1 sph/e 2.5 # internal energy corresponding to p=1, rho=1 +set type 2 sph/e 0.625 # internal energy corresponding to p=0.25, rho=0.25 +set type 1 sph/rho 1.0 +set type 2 sph/rho 0.25 pair_style hybrid/overlay sph/rhosum 1 sph/idealgas pair_coeff * * sph/rhosum 4.0 pair_coeff * * sph/idealgas 0.75 4.0 -compute rhoatom all meso/rho/atom -compute ieatom all meso/e/atom -compute emeso all reduce sum c_ieatom # total internal energy +compute rhoatom all sph/rho/atom +compute ieatom all sph/e/atom +compute esph all reduce sum c_ieatom # total internal energy compute ke all ke -variable etot equal c_ke+c_emeso # total energy +variable etot equal c_ke+c_esph # total energy # dump positions and local density dump dump_id all custom 100 dump.3d id type x z y c_rhoatom @@ -34,10 +34,10 @@ dump_modify dump_id first yes neighbor 0.5 bin neigh_modify every 5 delay 0 check yes thermo 10 -thermo_style custom step c_ke c_emeso v_etot +thermo_style custom step c_ke c_esph v_etot thermo_modify norm no -fix integration_fix all meso +fix integration_fix all sph fix 1 all setforce NULL 0.0 0.0 # treat as a quasi 1d problem timestep 0.05 log log.3d diff --git a/examples/USER/sph/water_collapse/water_collapse.lmp b/examples/USER/sph/water_collapse/water_collapse.lmp index 5e1359dae5..c1f3815947 100644 --- a/examples/USER/sph/water_collapse/water_collapse.lmp +++ b/examples/USER/sph/water_collapse/water_collapse.lmp @@ -1,5 +1,5 @@ processors * 1 1 # manually assign processors to spatial regions -atom_style meso +atom_style sph dimension 2 newton on boundary f f p @@ -22,8 +22,8 @@ pair_coeff 1 1 sph/rhosum ${h} fix gfix water gravity -9.81 vector 0 1 0 # add gravity. This fix also computes potential energy of mass in gravity field. fix 2d_fix all enforce2d -compute rho_peratom all meso/rho/atom -compute e_peratom all meso/e/atom +compute rho_peratom all sph/rho/atom +compute e_peratom all sph/e/atom compute esph all reduce sum c_e_peratom compute ke all ke variable etot equal c_esph+c_ke+f_gfix @@ -32,10 +32,10 @@ variable etot equal c_esph+c_ke+f_gfix fix dtfix all dt/reset 1 NULL ${dt} 0.0005 units box # use a variable timestep # time-integrate position, velocities, internal energy and density of water particles -fix integrate_water_fix water meso +fix integrate_water_fix water sph # time-integrate only internal energy and density of boundary particles -fix integrate_bc_fix bc meso/stationary +fix integrate_bc_fix bc sph/stationary dump dump_id all custom 100 dump.lammpstrj id type xs ys zs c_rho_peratom c_e_peratom fx fy dump_modify dump_id first yes thermo 10 From 2b9a1a69821855a3b10d297f812d551de8c176ce Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 May 2020 10:35:08 -0600 Subject: [PATCH 35/42] Fix Kokkos runtime issue with special bonds --- src/special.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/special.cpp b/src/special.cpp index f859f4ff53..0bb27b9540 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -710,6 +710,7 @@ void Special::combine() atom->nmax,atom->maxspecial,"atom:special"); atomKK->modified(Device,SPECIAL_MASK); atomKK->sync(Host,SPECIAL_MASK); + atom->avec->grow_pointers(); } else { memory->destroy(atom->special); memory->create(atom->special,atom->nmax,atom->maxspecial,"atom:special"); From 71149768c6cbbcb8f6bb48bca24db61de45ef8d0 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 7 May 2020 10:42:40 -0600 Subject: [PATCH 36/42] fix atom_vec_hybrid bug --- src/atom_vec_hybrid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 7f47f64d91..51f484711c 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -214,7 +214,7 @@ void AtomVecHybrid::process_args(int narg, char **arg) for (int idup = 0; idup < ndupfield; idup++) { char *dup = (char *) dupfield[idup]; ptr = strstr(concat_grow,dup); - if (strstr(ptr+1,dup)) { + if (ptr && strstr(ptr+1,dup)) { char str[128]; sprintf(str,"Peratom %s is in multiple sub-styles - " "must be used consistently",dup); @@ -565,7 +565,7 @@ void AtomVecHybrid::build_styles() #undef ATOM_CLASS allstyles = new char*[nallstyles]; - + int n; nallstyles = 0; #define ATOM_CLASS From cc181771534092c0827ebf96fee9299153fcf10f Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 May 2020 10:46:32 -0600 Subject: [PATCH 37/42] Whitespace cleanup --- src/atom_vec_hybrid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 51f484711c..2f40e10fe3 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -565,7 +565,7 @@ void AtomVecHybrid::build_styles() #undef ATOM_CLASS allstyles = new char*[nallstyles]; - + int n; nallstyles = 0; #define ATOM_CLASS From d69009ac45502ac6a9faa0abba8fea894e845f46 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 May 2020 11:09:39 -0600 Subject: [PATCH 38/42] Fix pointer delete issue with Kokkos package --- src/atom_vec.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 1ce4bc9e42..194cf246ce 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -52,6 +52,7 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) nargcopy = 0; argcopy = NULL; + threads = NULL; nthreads = comm->nthreads; // peratom variables auto-included in corresponding child style fields string From 5db1e4fe8dd64fbc12d117ba87b84330ddc562a1 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 May 2020 13:18:45 -0600 Subject: [PATCH 39/42] Initialize variables since Kokkos doesn't call setup_fields --- src/atom_vec.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 194cf246ce..6baeaeacc3 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -55,6 +55,9 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) threads = NULL; nthreads = comm->nthreads; + ngrow = ncopy = ncomm = ncomm_vel = nreverse = nborder = nborder_vel = 0; + nexchange = nrestart = ncreate = ndata_atom = ndata_vel = 0; + // peratom variables auto-included in corresponding child style fields string // these fields cannot be specified in the fields string From 18c77db8c3989d8308d967a5c08bc5b69b51c374 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 May 2020 15:16:17 -0600 Subject: [PATCH 40/42] Add Kokkos vel methods --- src/KOKKOS/atom_vec_kokkos.cpp | 47 ++++++++++++++++++++++++++++++++++ src/KOKKOS/atom_vec_kokkos.h | 3 +++ src/atom_vec.cpp | 3 --- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 7d5df17544..c8fe6373b5 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -16,6 +16,7 @@ #include "comm_kokkos.h" #include "domain.h" #include "atom_masks.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -992,3 +993,49 @@ void AtomVecKokkos::unpack_reverse(int n, int *list, double *buf) if(n > 0) modified(Host,F_MASK); } + +/* ---------------------------------------------------------------------- + * unpack one line from Velocities section of data file + * ------------------------------------------------------------------------- */ + +void AtomVecKokkos::data_vel(int m, char **values) +{ + double **v = atom->v; + 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); + + modified(Host,V_MASK); +} + +/* ---------------------------------------------------------------------- + * pack velocity info for data file + * ------------------------------------------------------------------------- */ + +void AtomVecKokkos::pack_vel(double **buf) +{ + double **v = atom->v; + tagint *tag = atom->tag; + int nlocal = atom->nlocal; + + sync(Host,V_MASK|TAG_MASK); + + 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]; + } +} + +/* ---------------------------------------------------------------------- + * write velocity info to data file + * ------------------------------------------------------------------------- */ + +void AtomVecKokkos::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\n", + (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]); +} + diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 2111e73208..b93fb42e75 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -41,6 +41,9 @@ class AtomVecKokkos : public AtomVec { virtual void unpack_comm_vel(int, int, double *); virtual int pack_reverse(int, int, double *); virtual void unpack_reverse(int, int *, double *); + virtual void data_vel(int, char **); + virtual void pack_vel(double **); + virtual void write_vel(FILE *, int, double **); virtual void sync(ExecutionSpace space, unsigned int mask) = 0; virtual void modified(ExecutionSpace space, unsigned int mask) = 0; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 6baeaeacc3..194cf246ce 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -55,9 +55,6 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) threads = NULL; nthreads = comm->nthreads; - ngrow = ncopy = ncomm = ncomm_vel = nreverse = nborder = nborder_vel = 0; - nexchange = nrestart = ncreate = ndata_atom = ndata_vel = 0; - // peratom variables auto-included in corresponding child style fields string // these fields cannot be specified in the fields string From 9004b47251cf768abf3800bf8d531329f1818fb8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 8 May 2020 01:33:16 -0400 Subject: [PATCH 41/42] remove trailing whitespace --- src/KOKKOS/atom_vec_kokkos.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index c8fe6373b5..b0fca4e316 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -999,7 +999,7 @@ void AtomVecKokkos::unpack_reverse(int n, int *list, double *buf) * ------------------------------------------------------------------------- */ void AtomVecKokkos::data_vel(int m, char **values) -{ +{ double **v = atom->v; v[m][0] = utils::numeric(FLERR,values[0],true,lmp); v[m][1] = utils::numeric(FLERR,values[1],true,lmp); @@ -1013,13 +1013,13 @@ void AtomVecKokkos::data_vel(int m, char **values) * ------------------------------------------------------------------------- */ void AtomVecKokkos::pack_vel(double **buf) -{ +{ double **v = atom->v; tagint *tag = atom->tag; int nlocal = atom->nlocal; sync(Host,V_MASK|TAG_MASK); - + for (int i = 0; i < nlocal; i++) { buf[i][0] = ubuf(tag[i]).d; buf[i][1] = v[i][0]; From 366d3fe24997daba92e2a5fa5c27a2469e41dfdb Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 8 May 2020 14:09:59 -0400 Subject: [PATCH 42/42] update .gitignore and Purge.list --- src/.gitignore | 26 ++++++++++++++++++++++++-- src/Purge.list | 13 +++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index fabd3b4e4b..01d9a48e93 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -37,6 +37,7 @@ /kokkos_type.h /kokkos_few.h /kokkos_base.h +/kokkos_base_fft.h /manifold*.cpp /manifold*.h @@ -84,6 +85,15 @@ /intel_preprocess.h /intel_simd.h +/atom_vec_sph.cpp +/atom_vec_sph.h +/compute_sph_*.cpp +/compute_sph_*.h +/fix_sph.cpp +/fix_sph.h +/fix_sph_stationary.cpp +/fix_sph_stationary.h + /atom_vec_edpd.cpp /atom_vec_edpd.h /atom_vec_mdpd.cpp @@ -247,8 +257,6 @@ /atom_vec_full_hars.h /atom_vec_granular.cpp /atom_vec_granular.h -/atom_vec_meso.cpp -/atom_vec_meso.h /atom_vec_molecular.cpp /atom_vec_molecular.h /atom_vec_peri.cpp @@ -385,6 +393,8 @@ /compute_temp_rotate.h /compute_ti.cpp /compute_ti.h +/compute_viscosity_cos.cpp +/compute_viscosity_cos.h /compute_voronoi_atom.cpp /compute_voronoi_atom.h /dihedral_charmm.cpp @@ -465,6 +475,8 @@ /fft3d.h /fft3d_wrap.cpp /fft3d_wrap.h +/fix_accelerate_cos.cpp +/fix_accelerate_cos.h /fix_adapt_fep.cpp /fix_adapt_fep.h /fix_addtorque.cpp @@ -635,6 +647,8 @@ /fix_poems.h /fix_pour.cpp /fix_pour.h +/fix_propel_self.cpp +/fix_propel_self.h /fix_qeq_comb.cpp /fix_qeq_comb.h /fix_qeq_reax.cpp @@ -838,6 +852,10 @@ /pair_coul_msm.h /pair_coul_shield.cpp /pair_coul_shield.h +/pair_coul_slater_cut.cpp +/pair_coul_slater_cut.h +/pair_coul_slater_long.cpp +/pair_coul_slater_long.h /pair_dipole_cut.cpp /pair_dipole_cut.h /pair_dipole_sf.cpp @@ -1101,6 +1119,8 @@ /fix_python_invoke.h /pair_python.cpp /pair_python.h +/reader_adios.cpp +/reader_adios.h /reader_molfile.cpp /reader_molfile.h /reaxc_allocate.cpp @@ -1325,6 +1345,8 @@ /pair_lennard_mdf.h /pair_lj_cut_coul_long_cs.cpp /pair_lj_cut_coul_long_cs.h +/pair_lj_class2_coul_long_cs.cpp +/pair_lj_class2_coul_long_cs.h /pair_lj_mdf.cpp /pair_lj_mdf.h /pair_mgpt.cpp diff --git a/src/Purge.list b/src/Purge.list index 634c38c58d..ebe1a9c484 100644 --- a/src/Purge.list +++ b/src/Purge.list @@ -49,6 +49,19 @@ packages_ntopo.h # other auto-generated files lmpinstalledpkgs.h lmpgitversion.h +# renamed on 8 May 2020 +fix_meso.cpp +fix_meso.h +fix_meso_stationary.cpp +fix_meso_stationary.h +atom_vec_meso.cpp +atom_vec_meso.h +compute_meso_e_atom.cpp +compute_meso_e_atom.h +compute_meso_rho_atom.cpp +compute_meso_rho_atom.h +compute_meso_t_atom.cpp +compute_meso_t_atom.h # removed on 15 March 2019 fix_wall_gran_omp.h fix_wall_gran_omp.cpp