diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 85fea0735b..2b94516b7e 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -576,7 +576,7 @@ int AtomVecDipole::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = q[i]; buf[m++] = mu[i][0]; @@ -609,7 +609,7 @@ int AtomVecDipole::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); q[nlocal] = buf[m++]; mu[nlocal][0] = buf[m++]; @@ -661,7 +661,7 @@ int AtomVecDipole::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -700,7 +700,7 @@ int AtomVecDipole::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 8b9b4dbfa0..ceac39e34c 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -528,7 +528,7 @@ int AtomVecAngle::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = molecule[i]; @@ -578,7 +578,7 @@ int AtomVecAngle::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); molecule[nlocal] = static_cast (buf[m++]); @@ -650,7 +650,7 @@ int AtomVecAngle::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -701,7 +701,7 @@ int AtomVecAngle::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 60f6882cba..16a2577bda 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -507,7 +507,7 @@ int AtomVecBond::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = molecule[i]; @@ -549,7 +549,7 @@ int AtomVecBond::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); molecule[nlocal] = static_cast (buf[m++]); @@ -613,7 +613,7 @@ int AtomVecBond::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -656,7 +656,7 @@ int AtomVecBond::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index 51717cbea6..2e180714b0 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -597,7 +597,7 @@ int AtomVecFull::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = q[i]; buf[m++] = molecule[i]; @@ -666,7 +666,7 @@ int AtomVecFull::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); q[nlocal] = buf[m++]; molecule[nlocal] = static_cast (buf[m++]); @@ -758,7 +758,7 @@ int AtomVecFull::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -828,7 +828,7 @@ int AtomVecFull::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index 668f7551bb..5d5cb0df21 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -585,7 +585,7 @@ int AtomVecMolecular::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = molecule[i]; @@ -653,7 +653,7 @@ int AtomVecMolecular::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); molecule[nlocal] = static_cast (buf[m++]); @@ -744,7 +744,7 @@ int AtomVecMolecular::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -813,7 +813,7 @@ int AtomVecMolecular::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 27f7c65cec..6c3992d774 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -567,7 +567,7 @@ int AtomVecPeri::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = vfrac[i]; buf[m++] = rmass[i]; @@ -601,7 +601,7 @@ int AtomVecPeri::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); vfrac[nlocal] = buf[m++]; rmass[nlocal] = buf[m++]; @@ -655,7 +655,7 @@ int AtomVecPeri::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -695,7 +695,7 @@ int AtomVecPeri::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index b56fce6202..ff1c472741 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -576,7 +576,7 @@ int AtomVecElectron::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = q[i]; buf[m++] = spin[i]; buf[m++] = eradius[i]; @@ -607,7 +607,7 @@ int AtomVecElectron::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); q[nlocal] = buf[m++]; spin[nlocal] = static_cast (buf[m++]); eradius[nlocal] = buf[m++]; @@ -657,7 +657,7 @@ int AtomVecElectron::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -695,7 +695,7 @@ int AtomVecElectron::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_meso.cpp index 177d49262b..6ca52f0f84 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_meso.cpp @@ -28,843 +28,843 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ AtomVecMeso::AtomVecMeso(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) { - molecular = 0; - mass_type = 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; + AtomVec(lmp, narg, arg) { + molecular = 0; + mass_type = 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; } /* ---------------------------------------------------------------------- - grow atom arrays - n = 0 grows arrays by DELTA - n > 0 allocates arrays to size n - ------------------------------------------------------------------------- */ + grow atom arrays + n = 0 grows arrays by DELTA + n > 0 allocates arrays to size n + ------------------------------------------------------------------------- */ void AtomVecMeso::grow(int n) { - if (n == 0) - nmax += DELTA; - 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); + if (n == 0) + nmax += DELTA; + 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 - ------------------------------------------------------------------------- */ + 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; + 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); + //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); } /* ---------------------------------------------------------------------- */ 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; + //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; + //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; + //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; + //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; + //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; + //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 *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; + 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++]; - } + //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++]; - } + //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; + //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++]; - } + //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++] = tag[j]; - buf[m++] = type[j]; - buf[m++] = mask[j]; - 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++] = tag[j]; - buf[m++] = type[j]; - buf[m++] = mask[j]; - 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]; - } - } - return m; + 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++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + 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++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + 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]; + } + } + return m; } /* ---------------------------------------------------------------------- */ int AtomVecMeso::pack_border_vel(int n, int *list, double *buf, int pbc_flag, - int *pbc) { - //printf("in AtomVecMeso::pack_border_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++] = tag[j]; - buf[m++] = type[j]; - buf[m++] = mask[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - 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++] = tag[j]; - buf[m++] = type[j]; - buf[m++] = mask[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; - 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]; - } - } - return m; + int *pbc) { + //printf("in AtomVecMeso::pack_border_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++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + 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++] = tag[j]; + buf[m++] = type[j]; + buf[m++] = mask[j]; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + 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]; + } + } + 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] = static_cast (buf[m++]); - type[i] = static_cast (buf[m++]); - mask[i] = static_cast (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] = buf[m++]; - } + //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] = static_cast (buf[m++]); + type[i] = static_cast (buf[m++]); + mask[i] = static_cast (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] = 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] = static_cast (buf[m++]); - type[i] = static_cast (buf[m++]); - mask[i] = static_cast (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] = buf[m++]; - } + //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] = static_cast (buf[m++]); + type[i] = static_cast (buf[m++]); + mask[i] = static_cast (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] = 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 - ------------------------------------------------------------------------- */ + 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++] = tag[i]; - buf[m++] = type[i]; - buf[m++] = mask[i]; - buf[m++] = image[i]; - 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; + //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++] = tag[i]; + buf[m++] = type[i]; + buf[m++] = mask[i]; + *((tagint *) &buf[m++]) = image[i]; + 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] = static_cast (buf[m++]); - type[nlocal] = static_cast (buf[m++]); - mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (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++]; - - 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; + //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] = static_cast (buf[m++]); + type[nlocal] = static_cast (buf[m++]); + mask[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &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++]; + + 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 - ------------------------------------------------------------------------- */ + 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; + 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 - ------------------------------------------------------------------------- */ + 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++] = tag[i]; - buf[m++] = type[i]; - buf[m++] = mask[i]; - buf[m++] = image[i]; - 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; + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = tag[i]; + buf[m++] = type[i]; + buf[m++] = mask[i]; + *((tagint *) &buf[m++]) = image[i]; + 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 - ------------------------------------------------------------------------- */ + 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] = static_cast (buf[m++]); - type[nlocal] = static_cast (buf[m++]); - mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); - 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; + 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] = static_cast (buf[m++]); + type[nlocal] = static_cast (buf[m++]); + mask[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); + 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 - ------------------------------------------------------------------------- */ + 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] = ((tagint) IMGMAX << IMG2BITS) | - ((tagint) 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++; + 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] = ((tagint) IMGMAX << IMG2BITS) | + ((tagint) 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 - ------------------------------------------------------------------------- */ + unpack one line from Atoms section of data file + initialize other atom quantities + ------------------------------------------------------------------------- */ void AtomVecMeso::data_atom(double *coord, tagint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) - grow(0); - - tag[nlocal] = atoi(values[0]); - if (tag[nlocal] <= 0) - error->one(FLERR,"Invalid atom ID in Atoms section of data file"); - - type[nlocal] = atoi(values[1]); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR,"Invalid atom type in Atoms section of data file"); - - rho[nlocal] = atof(values[2]); - e[nlocal] = atof(values[3]); - cv[nlocal] = atof(values[4]); - - 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++; + int nlocal = atom->nlocal; + if (nlocal == nmax) + grow(0); + + tag[nlocal] = atoi(values[0]); + if (tag[nlocal] <= 0) + error->one(FLERR,"Invalid atom ID in Atoms section of data file"); + + type[nlocal] = atoi(values[1]); + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + + rho[nlocal] = atof(values[2]); + e[nlocal] = atof(values[3]); + cv[nlocal] = atof(values[4]); + + 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 - ------------------------------------------------------------------------- */ + 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] = atof(values[0]); - e[nlocal] = atof(values[1]); - cv[nlocal] = atof(values[2]); - - return 3; + + rho[nlocal] = atof(values[0]); + e[nlocal] = atof(values[1]); + cv[nlocal] = atof(values[2]); + + return 3; } /* ---------------------------------------------------------------------- - return # of bytes of allocated memory - ------------------------------------------------------------------------- */ + 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; + 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/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index 740319a6f8..f9fe188e12 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -438,7 +438,7 @@ int AtomVecAtomic::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) @@ -465,7 +465,7 @@ int AtomVecAtomic::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) @@ -511,7 +511,7 @@ int AtomVecAtomic::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -544,7 +544,7 @@ int AtomVecAtomic::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/atom_vec_charge.cpp b/src/atom_vec_charge.cpp index bdd90b42dc..322bf71296 100644 --- a/src/atom_vec_charge.cpp +++ b/src/atom_vec_charge.cpp @@ -480,6 +480,7 @@ int AtomVecCharge::pack_exchange(int i, double *buf) buf[m++] = type[i]; buf[m++] = mask[i]; buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = q[i]; @@ -508,7 +509,7 @@ int AtomVecCharge::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); q[nlocal] = buf[m++]; @@ -556,7 +557,7 @@ int AtomVecCharge::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -591,7 +592,7 @@ int AtomVecCharge::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 1b57a52b6f..da6bb87cce 100755 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -872,7 +872,7 @@ int AtomVecEllipsoid::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = rmass[i]; buf[m++] = angmom[i][0]; @@ -919,7 +919,7 @@ int AtomVecEllipsoid::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); rmass[nlocal] = buf[m++]; angmom[nlocal][0] = buf[m++]; @@ -990,7 +990,7 @@ int AtomVecEllipsoid::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -1041,7 +1041,7 @@ int AtomVecEllipsoid::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 151d34719d..e1a3bc4bef 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -752,7 +752,7 @@ int AtomVecLine::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = molecule[i]; buf[m++] = rmass[i]; @@ -793,7 +793,7 @@ int AtomVecLine::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); molecule[nlocal] = static_cast (buf[m++]); rmass[nlocal] = buf[m++]; @@ -858,7 +858,7 @@ int AtomVecLine::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -905,7 +905,7 @@ int AtomVecLine::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 18dffdcab4..5d085c0cfa 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -761,7 +761,7 @@ int AtomVecSphere::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = radius[i]; buf[m++] = rmass[i]; @@ -794,7 +794,7 @@ int AtomVecSphere::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); radius[nlocal] = buf[m++]; rmass[nlocal] = buf[m++]; @@ -846,7 +846,7 @@ int AtomVecSphere::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -885,7 +885,7 @@ int AtomVecSphere::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++]; diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index d133951453..7cfe3d1e7a 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -1027,7 +1027,7 @@ int AtomVecTri::pack_exchange(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = molecule[i]; buf[m++] = rmass[i]; @@ -1087,7 +1087,7 @@ int AtomVecTri::unpack_exchange(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); molecule[nlocal] = static_cast (buf[m++]); rmass[nlocal] = buf[m++]; @@ -1171,7 +1171,7 @@ int AtomVecTri::pack_restart(int i, double *buf) buf[m++] = tag[i]; buf[m++] = type[i]; buf[m++] = mask[i]; - buf[m++] = image[i]; + *((tagint *) &buf[m++]) = image[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; @@ -1237,7 +1237,7 @@ int AtomVecTri::unpack_restart(double *buf) tag[nlocal] = static_cast (buf[m++]); type[nlocal] = static_cast (buf[m++]); mask[nlocal] = static_cast (buf[m++]); - image[nlocal] = static_cast (buf[m++]); + image[nlocal] = *((tagint *) &buf[m++]); v[nlocal][0] = buf[m++]; v[nlocal][1] = buf[m++]; v[nlocal][2] = buf[m++];