diff --git a/src/comm.cpp b/src/comm.cpp index bf20d61fd0..df8b73110e 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -559,6 +559,11 @@ int Comm::coord2proc(double *x, int &igx, int &igy, int &igz) double *prd = domain->prd; double *boxlo = domain->boxlo; + // initialize triclinic b/c coord2proc can be called before Comm::init() + // via Irregular::migrate_atoms() + + triclinic = domain->triclinic; + if (layout == LAYOUT_UNIFORM) { if (triclinic == 0) { igx = static_cast (procgrid[0] * (x[0]-boxlo[0]) / prd[0]); diff --git a/src/read_data.cpp b/src/read_data.cpp index 7fe63f1cc1..6f8322f828 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -589,6 +589,27 @@ void ReadData::command(int narg, char **arg) // in case data file re-defined them if (atom->molecular == 2) atom->avec->onemols[0]->check_attributes(1); + + // shrink-wrap the box if necessary and move atoms to new procs + // if atoms are lost is b/c data file box was far from shrink-wrapped + // do not use irregular() comm, which would not lose atoms, + // b/c then user could specify data file box as far too big and empty + + if (domain->nonperiodic == 2) { + if (domain->triclinic) domain->x2lamda(atom->nlocal); + domain->reset_box(); + comm->init(); + comm->setup(); + comm->exchange(); + if (domain->triclinic) domain->lamda2x(atom->nlocal); + + bigint natoms; + bigint nblocal = atom->nlocal; + MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world); + if (natoms != atom->natoms) + error->all(FLERR, + "Read_data shrink wrap did not assign all atoms correctly"); + } } /* ----------------------------------------------------------------------