rename reset_ids command to reset_atom_ids

This commit is contained in:
Axel Kohlmeyer 2020-07-07 13:25:24 -04:00
parent de7f02e48b
commit 94e9b3bc82
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
12 changed files with 45 additions and 43 deletions

View File

@ -101,7 +101,7 @@ An alphabetic list of all general LAMMPS commands.
* :doc:`region <region>`
* :doc:`replicate <replicate>`
* :doc:`rerun <rerun>`
* :doc:`reset_ids <reset_ids>`
* :doc:`reset_atom_ids <reset_atom_ids>`
* :doc:`reset_mol_ids <reset_mol_ids>`
* :doc:`reset_timestep <reset_timestep>`
* :doc:`restart <restart>`

View File

@ -88,7 +88,7 @@ Commands
region
replicate
rerun
reset_ids
reset_atom_ids
reset_mol_ids
reset_timestep
restart

View File

@ -89,7 +89,7 @@ number of atoms in the system. Note that this is not done for
molecular systems (see the :doc:`atom_style <atom_style>` command),
regardless of the *compress* setting, since it would foul up the bond
connectivity that has already been assigned. However, the
:doc:`reset_ids <reset_ids>` command can be used after this command to
:doc:`reset_atom_ids <reset_atom_ids>` command can be used after this command to
accomplish the same thing.
Note that the re-assignment of IDs is not really a compression, where
@ -157,7 +157,7 @@ using molecule template files via the :doc:`molecule <molecule>` and
Related commands
""""""""""""""""
:doc:`create_atoms <create_atoms>`, :doc:`reset_ids <reset_ids>`
:doc:`create_atoms <create_atoms>`, :doc:`reset_atom_ids <reset_atom_ids>`
Default
"""""""

View File

@ -1,14 +1,14 @@
.. index:: reset_ids
.. index:: reset_atom_ids
reset_ids command
=================
reset_atom_ids command
======================
Syntax
""""""
.. code-block:: LAMMPS
reset_ids keyword values ...
reset_atom_ids keyword values ...
* zero or more keyword/value pairs may be appended
* keyword = *sort*
@ -22,8 +22,8 @@ Examples
.. code-block:: LAMMPS
reset_ids
reset_ids sort yes
reset_atom_ids
reset_atom_ids sort yes
Description
"""""""""""
@ -77,7 +77,7 @@ processor have consecutive IDs, as the :doc:`create_atoms
that are owned by other processors. The :doc:`comm_modify cutoff <comm_modify>` command can be used to correct this issue.
Or you can define a pair style before using this command. If you do
the former, you should unset the comm_modify cutoff after using
reset_ids so that subsequent communication is not inefficient.
reset_atom_ids so that subsequent communication is not inefficient.
Restrictions
""""""""""""

View File

@ -46,7 +46,7 @@ none
Related commands
""""""""""""""""
:doc:`reset_ids <reset_ids>`, :doc:`fix bond/react <fix_bond_react>`,
:doc:`reset_atom_ids <reset_atom_ids>`, :doc:`fix bond/react <fix_bond_react>`,
:doc:`fix bond/create <fix_bond_create>`,
:doc:`fix bond/break <fix_bond_break>`,
:doc:`fix evaporate <fix_evaporate>`,

View File

@ -16,19 +16,17 @@
------------------------------------------------------------------------- */
#include "deprecated.h"
#include <cstring>
#include <string>
#include "comm.h"
#include "error.h"
#include "input.h"
#include "utils.h"
using namespace LAMMPS_NS;
static void writemsg(LAMMPS *lmp, const char *msg, int abend=1)
static void writemsg(LAMMPS *lmp, const std::string &msg, int abend=1)
{
if (lmp->comm->me == 0) {
if (lmp->screen) fputs(msg,lmp->screen);
if (lmp->logfile) fputs(msg,lmp->logfile);
}
if (lmp->comm->me == 0) utils::logmesg(lmp,msg);
if (abend)
lmp->error->all(FLERR,"This command is no longer available");
}
@ -37,8 +35,11 @@ static void writemsg(LAMMPS *lmp, const char *msg, int abend=1)
void Deprecated::command(int /* narg */, char ** /* arg */)
{
if (strcmp(input->command,"DEPRECATED") == 0) {
writemsg(lmp,"\nCommand 'DEPRECATED' is a dummy command\n\n",0);
const std::string cmd = input->command;
if (cmd == "DEPRECATED") {
writemsg(lmp,"\nCommand 'DEPRECATED' is a dummy command\n\n",0);
} else if (cmd == "reset_ids") {
writemsg(lmp,"\n'reset_ids' has been renamed to 'reset_atom_ids'\n\n");
}
}

View File

@ -14,6 +14,7 @@
#ifdef COMMAND_CLASS
CommandStyle(DEPRECATED,Deprecated)
CommandStyle(reset_ids,Deprecated)
#else

View File

@ -11,7 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "reset_ids.h"
#include "reset_atom_ids.h"
#include <mpi.h>
#include <cstring>
#include "atom.h"
@ -53,11 +53,11 @@ void ResetIDs::command(int narg, char **arg)
if (domain->box_exist == 0)
error->all(FLERR,"Reset_ids command before simulation box is defined");
if (atom->tag_enable == 0)
error->all(FLERR,"Cannot use reset_ids unless atoms have IDs");
error->all(FLERR,"Cannot use reset_atom_ids unless atoms have IDs");
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->stores_ids)
error->all(FLERR,"Cannot use reset_ids when a fix exists that stores atom IDs");
error->all(FLERR,"Cannot use reset_atom_ids when a fix exists that stores atom IDs");
if (comm->me == 0) utils::logmesg(lmp,"Resetting atom IDs ...\n");
@ -68,12 +68,12 @@ void ResetIDs::command(int narg, char **arg)
int iarg = 0;
while (iarg < narg) {
if (strcmp(arg[iarg],"sort") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_ids command");
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_atom_ids command");
if (strcmp(arg[iarg+1],"yes") == 0) sortflag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) sortflag = 0;
else error->all(FLERR,"Illegal reset_ids command");
else error->all(FLERR,"Illegal reset_atom_ids command");
iarg += 2;
} else error->all(FLERR,"Illegal reset_ids command");
} else error->all(FLERR,"Illegal reset_atom_ids command");
}
// create an atom map if one doesn't exist already
@ -110,7 +110,7 @@ void ResetIDs::command(int narg, char **arg)
int nall = nlocal + atom->nghost;
tagint *oldIDs;
memory->create(oldIDs,nlocal,"reset_ids:oldIDs");
memory->create(oldIDs,nlocal,"reset_atom_ids:oldIDs");
for (int i = 0; i < nlocal; i++) {
oldIDs[i] = tag[i];
@ -129,7 +129,7 @@ void ResetIDs::command(int narg, char **arg)
// forward_comm_array acquires new IDs for ghost atoms
double **newIDs;
memory->create(newIDs,nall,1,"reset_ids:newIDs");
memory->create(newIDs,nall,1,"reset_atom_ids:newIDs");
for (int i = 0; i < nlocal; i++) {
newIDs[i][0] = ubuf(tag[i]).d;
@ -468,7 +468,7 @@ int ResetIDs::sort_bins(int n, char *inbuf,
if (in[i].ibin < binlo || in[i].ibin >= binhi) {
//printf("BAD me %d i %d %d ibin %d binlohi %d %d\n",
// rptr->comm->me,i,n,in[i].ibin,binlo,binhi);
error->one(FLERR,"Bad spatial bin assignment in reset_ids sort");
error->one(FLERR,"Bad spatial bin assignment in reset_atom_ids sort");
}
ibin = in[i].ibin - binlo;
if (head[ibin] < 0) head[ibin] = i;

View File

@ -13,7 +13,7 @@
#ifdef COMMAND_CLASS
CommandStyle(reset_ids,ResetIDs)
CommandStyle(reset_atom_ids,ResetIDs)
#else
@ -70,7 +70,7 @@ E: Illegal ... command
UNDOCUMENTED
E: Cannot use reset_ids unless atoms have IDs
E: Cannot use reset_atom_ids unless atoms have IDs
UNDOCUMENTED

View File

@ -3,7 +3,7 @@ add_executable(test_simple_commands test_simple_commands.cpp)
target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock GTest::GTest)
add_test(NAME SimpleCommands COMMAND test_simple_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_reset_mol_ids test_reset_mol_ids.cpp)
target_compile_definitions(test_reset_mol_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(test_reset_mol_ids PRIVATE lammps GTest::GMock GTest::GTest)
add_test(NAME ResetMolIDs COMMAND test_reset_mol_ids WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_executable(test_reset_ids test_reset_ids.cpp)
target_compile_definitions(test_reset_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock GTest::GTest)
add_test(NAME ResetIDs COMMAND test_reset_ids WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -45,13 +45,13 @@ using ::testing::MatchesRegex;
#define STRINGIFY(val) XSTR(val)
#define XSTR(val) #val
class ResetMolIDsTest : public ::testing::Test {
class ResetIDsTest : public ::testing::Test {
protected:
LAMMPS *lmp;
void SetUp() override
{
const char *args[] = {"ResetMolIDsTest", "-log", "none", "-nocite", "-echo", "screen"};
const char *args[] = {"ResetIDsTest", "-log", "none", "-nocite", "-echo", "screen"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (!verbose) ::testing::internal::CaptureStdout();
@ -72,7 +72,7 @@ protected:
}
};
TEST_F(ResetMolIDsTest, Plain)
TEST_F(ResetIDsTest, MolIDAll)
{
if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -144,7 +144,7 @@ TEST_F(ResetMolIDsTest, Plain)
ASSERT_EQ(molid[GETIDX(29)], 5);
}
TEST_F(ResetMolIDsTest, DeletePlusAtomID)
TEST_F(ResetIDsTest, DeletePlusAtomID)
{
if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -214,7 +214,7 @@ TEST_F(ResetMolIDsTest, DeletePlusAtomID)
EXPECT_GE(GETIDX(26), 0);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_ids");
lmp->input->one("reset_atom_ids");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->map_tag_max, 23);

View File

@ -415,7 +415,7 @@ TEST_F(AtomStyleTest, atomic)
ASSERT_EQ(lmp->atom->map_user, 1);
ASSERT_EQ(lmp->atom->map_tag_max, 3);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_ids");
lmp->input->one("reset_atom_ids");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->map_tag_max, 2);
ASSERT_EQ(lmp->atom->tag_consecutive(), 1);
@ -802,7 +802,7 @@ TEST_F(AtomStyleTest, charge)
ASSERT_EQ(lmp->atom->mass_setflag[2], 1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("reset_ids");
lmp->input->one("reset_atom_ids");
lmp->input->one("replicate 2 2 2");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_EQ(lmp->atom->map_tag_max, 16);
@ -1129,7 +1129,7 @@ TEST_F(AtomStyleTest, sphere)
EXPECT_THAT(std::string(lmp->atom->atom_style), Eq("atomic"));
lmp->input->one("read_restart test_atom_styles.restart");
lmp->input->one("replicate 1 1 2");
lmp->input->one("reset_ids");
lmp->input->one("reset_atom_ids");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("sphere"));
ASSERT_NE(lmp->atom->avec, nullptr);