From b016b135fa836547994e8615b922e5fd666836be Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 23 Jan 2025 04:51:12 -0500 Subject: [PATCH] added Compute::modify_param() function. This way individual computes can add custom keywords to compute_modify in a similar fashion as fixes --- doc/src/Modify_compute.rst | 2 ++ src/compute.cpp | 7 ++++++- src/compute.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/src/Modify_compute.rst b/doc/src/Modify_compute.rst index bf580a6561..ea603985dd 100644 --- a/doc/src/Modify_compute.rst +++ b/doc/src/Modify_compute.rst @@ -45,6 +45,8 @@ class. See compute.h for details. +-----------------------+------------------------------------------------------------------+ | pair_tally_callback | callback function for *tally*\ -style computes (optional). | +-----------------------+------------------------------------------------------------------+ +| modify_param | called when a compute_modify request is executed (optional) | ++-----------------------+------------------------------------------------------------------+ | memory_usage | tally memory usage (optional) | +-----------------------+------------------------------------------------------------------+ diff --git a/src/compute.cpp b/src/compute.cpp index d703cbfe6a..255e4ba1f2 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -149,7 +149,12 @@ void Compute::modify_params(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal compute_modify command"); dynamic_user = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; - } else error->all(FLERR,"Illegal compute_modify command"); + } else { + int n = modify_param(narg-iarg, &arg[iarg]); + if (n== 0) + error->all(FLERR, iarg + 1, "Compute {} {} does not support compute_modify {} command", + id, style, arg[iarg]); + } } } diff --git a/src/compute.h b/src/compute.h index 0b077d7695..870d9ae088 100644 --- a/src/compute.h +++ b/src/compute.h @@ -113,6 +113,7 @@ class Compute : protected Pointers { Compute(class LAMMPS *, int, char **); ~Compute() override; void modify_params(int, char **); + virtual int modify_param(int, char **) { return 0; } virtual void reset_extra_dof(); void init_flags();