From fbb3bb14af47b7c893ede7cb4dd39f33826946be Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 18 Mar 2021 17:08:49 -0400 Subject: [PATCH] synchronize interface to managing computes in Modify with that of fixes - add find_compute_by_style() - add delete_compute(int) --- src/modify.cpp | 21 ++++++++++++++++++++- src/modify.h | 11 +++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/modify.cpp b/src/modify.cpp index 2c0fd434d6..9cb90fc36f 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1326,7 +1326,12 @@ void Modify::delete_compute(const std::string &id) { int icompute = find_compute(id); if (icompute < 0) error->all(FLERR,"Could not find compute ID to delete"); - delete compute[icompute]; + delete_compute(icompute); +} + +void Modify::delete_compute(int icompute) +{ + if (compute[icompute]) delete compute[icompute]; // move other Computes down in list one slot @@ -1347,6 +1352,20 @@ int Modify::find_compute(const std::string &id) return -1; } +/* ---------------------------------------------------------------------- + find a compute by style + return index of compute or -1 if not found +------------------------------------------------------------------------- */ + +int Modify::find_compute_by_style(const char *style) +{ + int icompute; + for (icompute = 0; icompute < ncompute; icompute++) + if (utils::strmatch(compute[icompute]->style,style)) break; + if (icompute == ncompute) return -1; + return icompute; +} + /* ---------------------------------------------------------------------- clear invoked flag of all computes called everywhere that computes are used, before computes are invoked diff --git a/src/modify.h b/src/modify.h index ba8efd6525..0f4f7e32d2 100644 --- a/src/modify.h +++ b/src/modify.h @@ -109,21 +109,24 @@ class Modify : protected Pointers { void delete_fix(int); int find_fix(const std::string &); int find_fix_by_style(const char *); - int check_package(const char *); - int check_rigid_group_overlap(int); - int check_rigid_region_overlap(int, class Region *); - int check_rigid_list_overlap(int *); void add_compute(int, char **, int trysuffix=1); void add_compute(const std::string &, int trysuffix=1); void modify_compute(int, char **); void delete_compute(const std::string &); + void delete_compute(int); int find_compute(const std::string &); + int find_compute_by_style(const char *); void clearstep_compute(); void addstep_compute(bigint); void addstep_compute_all(bigint); + int check_package(const char *); + int check_rigid_group_overlap(int); + int check_rigid_region_overlap(int, class Region *); + int check_rigid_list_overlap(int *); + void write_restart(FILE *); int read_restart(FILE *); void restart_deallocate(int);