From ac68f70e20ed64bf13ae4910f8b4572731c67fee Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 9 Jan 2025 21:23:56 -0500 Subject: [PATCH] three more --- src/fix_nh.cpp | 10 +++------- src/fix_recenter.cpp | 13 +++++-------- src/fix_spring.cpp | 10 +++------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index b56033d6d6..73f3908a6f 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -271,7 +271,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : delete[] id_dilate; id_dilate = utils::strdup(arg[iarg+1]); int idilate = group->find(id_dilate); - if (idilate == -1) + if (idilate < 0) error->all(FLERR,"Fix {} dilate group ID {} does not exist", style, id_dilate); } iarg += 2; @@ -629,12 +629,8 @@ void FixNH::init() { // recheck that dilate group has not been deleted - if (allremap == 0) { - int idilate = group->find(id_dilate); - if (idilate == -1) - error->all(FLERR,"Fix {} dilate group ID {} does not exist", style, id_dilate); - dilate_group_bit = group->bitmask[idilate]; - } + if (allremap == 0) + dilate_group_bit = group->get_bitmask_by_id(FLERR, id_dilate, fmt::format("fix {}", style)); // ensure no conflict with fix deform diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index 4da8c4787b..2e9803870a 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -41,7 +41,7 @@ enum{BOX,LATTICE,FRACTION}; FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg < 6) error->all(FLERR,"Illegal fix recenter command"); + if (narg < 6) utils::missing_cmd_args(FLERR,"fix recenter", error); xcom = ycom = zcom = 0.0; xflag = yflag = zflag = 1; @@ -74,17 +74,15 @@ FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) : int iarg = 6; while (iarg < narg) { if (strcmp(arg[iarg],"shift") == 0) { - int igroup2 = group->find(arg[iarg+1]); - if (igroup2 < 0) error->all(FLERR,"Could not find fix recenter group ID"); - group2bit = group->bitmask[igroup2]; + group2bit = group->get_bitmask_by_id(FLERR, arg[iarg+1], "fix recenter"); iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { if (strcmp(arg[iarg+1],"box") == 0) scaleflag = BOX; else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = LATTICE; else if (strcmp(arg[iarg+1],"fraction") == 0) scaleflag = FRACTION; - else error->all(FLERR,"Illegal fix recenter command"); + else error->all(FLERR,"Unknown fix recenter units argument {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal fix recenter command"); + } else error->all(FLERR,"Unknown fix recenter keyword {}", arg[iarg]); } // scale xcom,ycom,zcom @@ -103,8 +101,7 @@ FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) : // cannot have 0 atoms in group - if (group->count(igroup) == 0) - error->all(FLERR,"Fix recenter group has no atoms"); + if (group->count(igroup) == 0) error->all(FLERR,"Fix recenter group {} has no atoms", arg[1]); } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp index 93c1f7867d..829073179d 100644 --- a/src/fix_spring.cpp +++ b/src/fix_spring.cpp @@ -73,11 +73,9 @@ FixSpring::FixSpring(LAMMPS *lmp, int narg, char **arg) : group2 = utils::strdup(arg[4]); igroup2 = group->find(arg[4]); - if (igroup2 == -1) - error->all(FLERR,"Fix spring couple group ID does not exist"); if (igroup2 == igroup) - error->all(FLERR,"Two groups cannot be the same in fix spring couple"); - group2bit = group->bitmask[igroup2]; + error->all(FLERR,"The two groups cannot be the same in fix spring couple"); + group2bit = group->get_bitmask_by_id(FLERR, arg[4], "fix spring"); k_spring = utils::numeric(FLERR,arg[5],false,lmp); xflag = yflag = zflag = 1; @@ -121,9 +119,7 @@ void FixSpring::init() if (group2) { igroup2 = group->find(group2); - if (igroup2 == -1) - error->all(FLERR,"Fix spring couple group ID does not exist"); - group2bit = group->bitmask[igroup2]; + group2bit = group->get_bitmask_by_id(FLERR, group2, "fix spring"); } masstotal = group->mass(igroup);