diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 261eeef816..53568571d9 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -72,7 +72,6 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : virial_flag = 1; create_attribute = 1; - MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); @@ -291,6 +290,20 @@ void FixRigidSmall::init() step_respa = ((Respa *) update->integrate)->step; } +/* ---------------------------------------------------------------------- + one-time initialization of rigid body attributes via local comm + extended flags, mass, COM, inertia tensor, displacement of each atom + require communication stencil have been setup by comm->borders() +------------------------------------------------------------------------- */ + +void FixRigidSmall::setup_pre_neighbor() +{ + if (firstflag) { + firstflag = 0; + setup_bodies(); + } +} + /* ---------------------------------------------------------------------- */ void FixRigidSmall::setup(int vflag) @@ -298,14 +311,6 @@ void FixRigidSmall::setup(int vflag) int i,n,ibody; double massone,radone; - // one-time initialization of rigid body attributes via local comm - // extended flags, mass, COM, inertia tensor, displacement of each atom - - if (firstflag) { - firstflag = 0; - setup_bodies(); - } - //check(1); // sum vcm, fcm, angmom, torque across all rigid bodies @@ -722,11 +727,6 @@ void FixRigidSmall::final_integrate_respa(int ilevel, int iloop) void FixRigidSmall::pre_neighbor() { - // do nothing if bodies are not yet initialized - // i.e. pre_neighbor() is being called from Verlet::setup() - - if (firstflag) return; - // remap xcm and image flags of each body as needed tagint original,oldimage,newimage; @@ -812,13 +812,6 @@ int FixRigidSmall::dof(int tgroup) int tgroupbit = group->bitmask[tgroup]; - // if firstflag, just return 0 - // is being called by first run init() - // local comm stencil is not setup and rigid body inertia is not calculated - // will be called again by temperature compute setup() - - if (firstflag) return 0; - // counts = 3 values per rigid body I own // 0 = # of point particles in rigid body and in temperature group // 1 = # of finite-size particles in rigid body and in temperature group @@ -1545,7 +1538,6 @@ void FixRigidSmall::setup_bodies() reset_atom2body(); // compute mass & center-of-mass of each rigid body - // error if image flag is not 0 in a non-periodic dim double **x = atom->x; tagint *image = atom->image; @@ -2084,7 +2076,10 @@ int FixRigidSmall::unpack_exchange(int nlocal, double *buf) // atom not in a rigid body - if (!bodytag[nlocal]) return m; + if (!bodytag[nlocal]) { + bodyown[nlocal] = -1; + return m; + } // atom does not own its rigid body diff --git a/src/RIGID/fix_rigid_small.h b/src/RIGID/fix_rigid_small.h index 7ddd49139d..8e84144a62 100644 --- a/src/RIGID/fix_rigid_small.h +++ b/src/RIGID/fix_rigid_small.h @@ -55,6 +55,7 @@ class FixRigidSmall : public Fix { int pack_reverse_comm(int, int, double *); void unpack_reverse_comm(int, int *, double *); + void setup_pre_neighbor(); void pre_neighbor(); int dof(int); void deform(int); diff --git a/src/modify.cpp b/src/modify.cpp index 8bea090df0..7e573cefd6 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -158,10 +158,10 @@ void Modify::init() list_init(MIN_ENERGY,n_min_energy,list_min_energy); // init each fix - // needs to come before compute init - // this is b/c some computes call fix->dof() - // FixRigid::dof() depends on its own init having been called - // NOTE: 2/13, this may no longer be needed b/c computes do dof in setup() + // not sure if now needs to come before compute init + // used to b/c temperature computes called fix->dof() in their init, + // and fix rigid required its own init before its dof() could be called, + // but computes now do their DOF in setup() for (i = 0; i < nfix; i++) fix[i]->init(); @@ -228,8 +228,9 @@ void Modify::init() void Modify::setup(int vflag) { - // invoke computes before fixes - // this is b/c NH fixes need temperature compute DOF + // setup each compute + // needs to come before fix setup + // this is b/c NH fixes need use DOF of temperature computes for (int i = 0; i < ncompute; i++) compute[i]->setup();