fix bug in lammps_reset_box() no-box check and error out when atoms exist
This commit is contained in:
@ -673,7 +673,8 @@ void lammps_extract_box(void *handle, double *boxlo, double *boxhi,
|
|||||||
|
|
||||||
This function sets the simulation box dimensions (upper and lower bounds
|
This function sets the simulation box dimensions (upper and lower bounds
|
||||||
and tilt factors) from the provided data and then re-initializes the box
|
and tilt factors) from the provided data and then re-initializes the box
|
||||||
information and all derived settings.
|
information and all derived settings. It may only be called before atoms
|
||||||
|
are created.
|
||||||
|
|
||||||
\endverbatim
|
\endverbatim
|
||||||
*
|
*
|
||||||
@ -692,12 +693,16 @@ void lammps_reset_box(void *handle, double *boxlo, double *boxhi,
|
|||||||
|
|
||||||
BEGIN_CAPTURE
|
BEGIN_CAPTURE
|
||||||
{
|
{
|
||||||
// error if box does not exist
|
if (lmp->atom->natoms > 0)
|
||||||
if ((lmp->domain->box_exist == 0)
|
lmp->error->all(FLERR,"Calling lammps_reset_box not supported when atoms exist");
|
||||||
&& (lmp->comm->me == 0)) {
|
|
||||||
lmp->error->warning(FLERR,"Calling lammps_reset_box without a box");
|
// warn and do nothing if no box exists
|
||||||
|
if (lmp->domain->box_exist == 0) {
|
||||||
|
if (lmp->comm->me == 0)
|
||||||
|
lmp->error->warning(FLERR,"Ignoring call to lammps_reset_box without a box");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
domain->boxlo[0] = boxlo[0];
|
domain->boxlo[0] = boxlo[0];
|
||||||
domain->boxlo[1] = boxlo[1];
|
domain->boxlo[1] = boxlo[1];
|
||||||
domain->boxlo[2] = boxlo[2];
|
domain->boxlo[2] = boxlo[2];
|
||||||
|
|||||||
@ -161,6 +161,8 @@ TEST_F(LibraryProperties, box)
|
|||||||
boxhi[1] = 7.3;
|
boxhi[1] = 7.3;
|
||||||
xy = 0.1;
|
xy = 0.1;
|
||||||
if (!verbose) ::testing::internal::CaptureStdout();
|
if (!verbose) ::testing::internal::CaptureStdout();
|
||||||
|
// lammps_reset_box() may only be called without atoms
|
||||||
|
lammps_command(lmp, "delete_atoms group all bond yes");
|
||||||
lammps_reset_box(lmp, boxlo, boxhi, xy, yz, xz);
|
lammps_reset_box(lmp, boxlo, boxhi, xy, yz, xz);
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
|
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
|
||||||
|
|||||||
Reference in New Issue
Block a user