From c77960c02cf4bf0bb634be4eef5e9a725f45fff5 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 31 Mar 2015 14:53:37 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13336 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/RIGID/fix_rigid.cpp | 40 +++++++++++++++++++++++++++++++++++ src/RIGID/fix_rigid_small.cpp | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 5cac49be92..30cd1eb1f8 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -2297,6 +2297,16 @@ void FixRigid::grow_arrays(int nmax) if (orientflag) memory->grow(orient,nmax,orientflag,"rigid:orient"); if (dorientflag) memory->grow(dorient,nmax,3,"rigid:dorient"); } + + // check for regrow of vatom + // must be done whether per-atom virial is accumulated on this step or not + // b/c this is only time grow_array() may be called + // need to regrow b/c vatom is calculated before and after atom migration + + if (nmax > maxvatom) { + maxvatom = atom->nmax; + memory->grow(vatom,maxvatom,6,"fix:vatom"); + } } /* ---------------------------------------------------------------------- @@ -2320,6 +2330,13 @@ void FixRigid::copy_arrays(int i, int j, int delflag) dorient[j][2] = dorient[i][2]; } } + + // must also copy vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + vatom[j][k] = vatom[i][k]; } /* ---------------------------------------------------------------------- @@ -2333,6 +2350,13 @@ void FixRigid::set_arrays(int i) displace[i][0] = 0.0; displace[i][1] = 0.0; displace[i][2] = 0.0; + + // must also zero vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + vatom[i][k] = 0.0; } /* ---------------------------------------------------------------------- @@ -2357,6 +2381,14 @@ int FixRigid::pack_exchange(int i, double *buf) buf[m++] = dorient[i][1]; buf[m++] = dorient[i][2]; } + + // must also pack vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + buf[m++] = vatom[i][k]; + return m; } @@ -2382,6 +2414,14 @@ int FixRigid::unpack_exchange(int nlocal, double *buf) dorient[nlocal][1] = buf[m++]; dorient[nlocal][2] = buf[m++]; } + + // must also unpack vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + vatom[nlocal][k] = buf[m++]; + return m; } diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 42f9089170..216d61ef27 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -2540,6 +2540,16 @@ void FixRigidSmall::grow_arrays(int nmax) if (orientflag) memory->grow(orient,nmax,orientflag,"rigid/small:orient"); if (dorientflag) memory->grow(dorient,nmax,3,"rigid/small:dorient"); } + + // check for regrow of vatom + // must be done whether per-atom virial is accumulated on this step or not + // b/c this is only time grow_array() may be called + // since vatom is calculated before and after atom migration + + if (nmax > maxvatom) { + maxvatom = atom->nmax; + memory->grow(vatom,maxvatom,6,"fix:vatom"); + } } /* ---------------------------------------------------------------------- @@ -2565,6 +2575,13 @@ void FixRigidSmall::copy_arrays(int i, int j, int delflag) } } + // must also copy vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + vatom[j][k] = vatom[i][k]; + // if deleting atom J via delflag and J owns a body, then delete it if (delflag && bodyown[j] >= 0) { @@ -2593,6 +2610,13 @@ void FixRigidSmall::set_arrays(int i) displace[i][0] = 0.0; displace[i][1] = 0.0; displace[i][2] = 0.0; + + // must also zero vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + vatom[i][k] = 0.0; } /* ---------------------------------------------------------------------- @@ -2706,6 +2730,13 @@ int FixRigidSmall::pack_exchange(int i, double *buf) if (!bodytag[i]) return m; + // must also pack vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + buf[m++] = vatom[i][k]; + // atom does not own its rigid body if (bodyown[i] < 0) { @@ -2754,6 +2785,13 @@ int FixRigidSmall::unpack_exchange(int nlocal, double *buf) return m; } + // must also unpack vatom if per-atom virial calculated on this timestep + // since vatom is calculated before and after atom migration + + if (vflag_atom) + for (int k = 0; k < 6; k++) + vatom[nlocal][k] = buf[m++]; + // atom does not own its rigid body bodyown[nlocal] = static_cast (buf[m++]);