From 89d82fde22eb625bcf42cdba8d8b5d489ffddba2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 16 Jul 2023 15:20:36 -0400 Subject: [PATCH] modernize access to list of fixes --- src/fix_wall_reflect.cpp | 9 ++++----- src/reset_atoms_id.cpp | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/fix_wall_reflect.cpp b/src/fix_wall_reflect.cpp index 60a055fbd6..00ef968828 100644 --- a/src/fix_wall_reflect.cpp +++ b/src/fix_wall_reflect.cpp @@ -176,12 +176,11 @@ void FixWallReflect::init() } int nrigid = 0; - for (int i = 0; i < modify->nfix; i++) - if (modify->fix[i]->rigid_flag) nrigid++; + for (const auto &ifix : modify->get_fix_list()) + if (ifix->rigid_flag) nrigid++; - if (nrigid && comm->me == 0) - error->warning(FLERR,"Should not allow rigid bodies to bounce off " - "relecting walls"); + if (nrigid && (comm->me == 0)) + error->warning(FLERR,"Should not use reflecting walls with rigid bodies"); } /* ---------------------------------------------------------------------- */ diff --git a/src/reset_atoms_id.cpp b/src/reset_atoms_id.cpp index c0fce95326..9e8ba3630d 100644 --- a/src/reset_atoms_id.cpp +++ b/src/reset_atoms_id.cpp @@ -55,9 +55,9 @@ void ResetAtomsID::command(int narg, char **arg) error->all(FLERR, "Reset_atoms id command before simulation box is defined"); if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms id unless atoms have IDs"); - for (int i = 0; i < modify->nfix; i++) - if (modify->fix[i]->stores_ids) - error->all(FLERR, "Cannot use reset_atoms id when a fix exists that stores atom IDs"); + for (const auto &ifix : modify->get_fix_list()) + if (ifix->stores_ids) + error->all(FLERR, "Cannot use reset_atoms id with a fix {} storing atom IDs", ifix->style); if (comm->me == 0) utils::logmesg(lmp, "Resetting atom IDs ...\n");