From 94e9b3bc82e6e565316e17ca91afc9eaf1ec7bce Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 7 Jul 2020 13:25:24 -0400 Subject: [PATCH] rename reset_ids command to reset_atom_ids --- doc/src/Commands_all.rst | 2 +- doc/src/commands_list.rst | 2 +- doc/src/delete_atoms.rst | 4 ++-- doc/src/{reset_ids.rst => reset_atom_ids.rst} | 14 +++++++------- doc/src/reset_mol_ids.rst | 2 +- src/deprecated.cpp | 17 +++++++++-------- src/deprecated.h | 1 + src/{reset_ids.cpp => reset_atom_ids.cpp} | 18 +++++++++--------- src/{reset_ids.h => reset_atom_ids.h} | 4 ++-- unittest/commands/CMakeLists.txt | 8 ++++---- ...st_reset_mol_ids.cpp => test_reset_ids.cpp} | 10 +++++----- unittest/formats/test_atom_styles.cpp | 6 +++--- 12 files changed, 45 insertions(+), 43 deletions(-) rename doc/src/{reset_ids.rst => reset_atom_ids.rst} (92%) rename src/{reset_ids.cpp => reset_atom_ids.cpp} (96%) rename src/{reset_ids.h => reset_atom_ids.h} (94%) rename unittest/commands/{test_reset_mol_ids.cpp => test_reset_ids.cpp} (96%) diff --git a/doc/src/Commands_all.rst b/doc/src/Commands_all.rst index 068545564a..a38bd5f0db 100644 --- a/doc/src/Commands_all.rst +++ b/doc/src/Commands_all.rst @@ -101,7 +101,7 @@ An alphabetic list of all general LAMMPS commands. * :doc:`region ` * :doc:`replicate ` * :doc:`rerun ` - * :doc:`reset_ids ` + * :doc:`reset_atom_ids ` * :doc:`reset_mol_ids ` * :doc:`reset_timestep ` * :doc:`restart ` diff --git a/doc/src/commands_list.rst b/doc/src/commands_list.rst index 49cf7ea588..2ec20ac220 100644 --- a/doc/src/commands_list.rst +++ b/doc/src/commands_list.rst @@ -88,7 +88,7 @@ Commands region replicate rerun - reset_ids + reset_atom_ids reset_mol_ids reset_timestep restart diff --git a/doc/src/delete_atoms.rst b/doc/src/delete_atoms.rst index d695603ded..127518535f 100644 --- a/doc/src/delete_atoms.rst +++ b/doc/src/delete_atoms.rst @@ -89,7 +89,7 @@ number of atoms in the system. Note that this is not done for molecular systems (see the :doc:`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 ` command can be used after this command to +:doc:`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 ` and Related commands """""""""""""""" -:doc:`create_atoms `, :doc:`reset_ids ` +:doc:`create_atoms `, :doc:`reset_atom_ids ` Default """"""" diff --git a/doc/src/reset_ids.rst b/doc/src/reset_atom_ids.rst similarity index 92% rename from doc/src/reset_ids.rst rename to doc/src/reset_atom_ids.rst index bc7ad31927..e83d65d546 100644 --- a/doc/src/reset_ids.rst +++ b/doc/src/reset_atom_ids.rst @@ -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 ` 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 """""""""""" diff --git a/doc/src/reset_mol_ids.rst b/doc/src/reset_mol_ids.rst index 8d2d6eeab5..9f2cc8db8a 100644 --- a/doc/src/reset_mol_ids.rst +++ b/doc/src/reset_mol_ids.rst @@ -46,7 +46,7 @@ none Related commands """""""""""""""" -:doc:`reset_ids `, :doc:`fix bond/react `, +:doc:`reset_atom_ids `, :doc:`fix bond/react `, :doc:`fix bond/create `, :doc:`fix bond/break `, :doc:`fix evaporate `, diff --git a/src/deprecated.cpp b/src/deprecated.cpp index 86af54fbfd..8cd3fc8cb1 100644 --- a/src/deprecated.cpp +++ b/src/deprecated.cpp @@ -16,19 +16,17 @@ ------------------------------------------------------------------------- */ #include "deprecated.h" -#include +#include #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"); } } diff --git a/src/deprecated.h b/src/deprecated.h index 97a77591c5..4a7fbc44cf 100644 --- a/src/deprecated.h +++ b/src/deprecated.h @@ -14,6 +14,7 @@ #ifdef COMMAND_CLASS CommandStyle(DEPRECATED,Deprecated) +CommandStyle(reset_ids,Deprecated) #else diff --git a/src/reset_ids.cpp b/src/reset_atom_ids.cpp similarity index 96% rename from src/reset_ids.cpp rename to src/reset_atom_ids.cpp index 6a7a8e8b2a..7e493ca28e 100644 --- a/src/reset_ids.cpp +++ b/src/reset_atom_ids.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "reset_ids.h" +#include "reset_atom_ids.h" #include #include #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; diff --git a/src/reset_ids.h b/src/reset_atom_ids.h similarity index 94% rename from src/reset_ids.h rename to src/reset_atom_ids.h index 902fe51519..7c5c53e2ba 100644 --- a/src/reset_ids.h +++ b/src/reset_atom_ids.h @@ -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 diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index d0793b707f..275e4b973f 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -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}) diff --git a/unittest/commands/test_reset_mol_ids.cpp b/unittest/commands/test_reset_ids.cpp similarity index 96% rename from unittest/commands/test_reset_mol_ids.cpp rename to unittest/commands/test_reset_ids.cpp index bc38c6404c..198d7d3af2 100644 --- a/unittest/commands/test_reset_mol_ids.cpp +++ b/unittest/commands/test_reset_ids.cpp @@ -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); diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index a405a240aa..491504d804 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -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);