From 2c82ce8142cc3465dfeef70ac81d7571fbb02f24 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sun, 19 Jan 2025 16:06:33 -0700 Subject: [PATCH] library: update new function signatures to use void* instead of bigint --- doc/src/Library_objects.rst | 12 ++++++------ python/lammps/core.py | 20 +++++++++++--------- src/library.cpp | 24 ++++++++++++------------ src/library.h | 11 +++-------- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/doc/src/Library_objects.rst b/doc/src/Library_objects.rst index bea5dec167..86b6d253f0 100644 --- a/doc/src/Library_objects.rst +++ b/doc/src/Library_objects.rst @@ -13,9 +13,9 @@ fixes, or variables in LAMMPS using the following functions: - :cpp:func:`lammps_set_internal_variable` - :cpp:func:`lammps_variable_info` - :cpp:func:`lammps_eval` -- :cpp:func:`lammps_compute_clearstep` -- :cpp:func:`lammps_compute_addstep_all` -- :cpp:func:`lammps_compute_addstep` +- :cpp:func:`lammps_clearstep_compute` +- :cpp:func:`lammps_addstep_compute_all` +- :cpp:func:`lammps_addstep_compute` ----------------------- @@ -64,17 +64,17 @@ fixes, or variables in LAMMPS using the following functions: ----------------------- -.. doxygenfunction:: lammps_compute_clearstep +.. doxygenfunction:: lammps_clearstep_compute :project: progguide ----------------------- -.. doxygenfunction:: lammps_compute_addstep_all(void *handle, int nextstep) +.. doxygenfunction:: lammps_addstep_compute_all :project: progguide ----------------------- -.. doxygenfunction:: lammps_compute_addstep(void *handle, int nextstep) +.. doxygenfunction:: lammps_addstep_compute :project: progguide ----------------------- diff --git a/python/lammps/core.py b/python/lammps/core.py index 7e70b5392a..15968ee605 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -422,9 +422,9 @@ class lammps(object): self.lib.lammps_extract_variable_datatype.argtypes = [c_void_p, c_char_p] self.lib.lammps_extract_variable_datatype.restype = c_int - self.lib.lammps_compute_clearstep.argtype = [c_void_p] - self.lib.lammps_compute_addstep.argtype = [c_void_p, self.c_bigint] - self.lib.lammps_compute_addstep_all.argtype = [c_void_p, self.c_bigint] + self.lib.lammps_clearstep_compute.argtype = [c_void_p] + self.lib.lammps_addstep_compute.argtype = [c_void_p, c_void_p] + self.lib.lammps_addstep_compute_all.argtype = [c_void_p, c_void_p] self.lib.lammps_eval.argtypes = [c_void_p, c_char_p] self.lib.lammps_eval.restype = c_double @@ -1598,21 +1598,23 @@ class lammps(object): # ------------------------------------------------------------------------- - def compute_clearstep(self, nextstep): + def clearstep_compute(self, nextstep): with ExceptionCheck(self): - return self.lib.lammps_compute_clearstep(self.lmp) + return self.lib.lammps_clearstep_compute(self.lmp) # ------------------------------------------------------------------------- - def compute_addstep(self, nextstep): + def addstep_compute(self, nextstep): with ExceptionCheck(self): - return self.lib.lammps_compute_addstep(self.lmp, nextstep) + nextstep = self.c_bigint(nextstep) + return self.lib.lammps_addstep_compute(self.lmp, pointer(nextstep)) # ------------------------------------------------------------------------- - def compute_addstep_all(self, nextstep): + def addstep_compute_all(self, nextstep): with ExceptionCheck(self): - return self.lib.lammps_compute_addstep_all(self.lmp, nextstep) + nextstep = self.c_bigint(nextstep) + return self.lib.lammps_addstep_compute_all(self.lmp, pointer(nextstep)) # ------------------------------------------------------------------------- diff --git a/src/library.cpp b/src/library.cpp index 1bb589c2b2..4902236e98 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -2974,14 +2974,14 @@ double lammps_eval(void *handle, const char *expr) and to flag computes that store invocation times as having been invoked *See also* - :cpp:func:`lammps_compute_addstep_all` - :cpp:func:`lammps_compute_addstep` + :cpp:func:`lammps_addstep_compute_all` + :cpp:func:`lammps_addstep_compute` \endverbatim * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. */ -void lammps_compute_clearstep(void * handle) { +void lammps_clearstep_compute(void * handle) { auto lmp = (LAMMPS *) handle; lmp->modify->clearstep_compute(); } @@ -3000,17 +3000,17 @@ void lammps_compute_clearstep(void * handle) { do not loop only over n_timeflag, since may not be set yet *See also* - :cpp:func:`lammps_compute_clearstep` - :cpp:func:`lammps_compute_addstep` + :cpp:func:`lammps_clearstep_compute` + :cpp:func:`lammps_addstep_compute` \endverbatim * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. - * \param newstep next timestep the compute will be invoked + * \param newstep pointer to bigint of next timestep the compute will be invoked */ -void lammps_compute_addstep_all(void * handle, bigint newstep) { +void lammps_addstep_compute_all(void * handle, void * newstep) { auto lmp = (LAMMPS *) handle; - lmp->modify->addstep_compute_all(newstep); + lmp->modify->addstep_compute_all(*static_cast(newstep)); } /* ---------------------------------------------------------------------- */ @@ -3025,17 +3025,17 @@ void lammps_compute_addstep_all(void * handle, bigint newstep) { called everywhere that computes are used, after computes are invoked *See also* - :cpp:func:`lammps_compute_addstep_all` - :cpp:func:`lammps_compute_clearstep` + :cpp:func:`lammps_addstep_compute_all` + :cpp:func:`lammps_clearstep_compute` \endverbatim * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. * \param newstep next timestep the compute will be invoked */ -void lammps_compute_addstep(void * handle, bigint newstep) { +void lammps_addstep_compute(void * handle, void * newstep) { auto lmp = (LAMMPS *) handle; - lmp->modify->addstep_compute(newstep); + lmp->modify->addstep_compute(*static_cast(newstep)); } // ---------------------------------------------------------------------- diff --git a/src/library.h b/src/library.h index a2575db20a..99b251ee85 100644 --- a/src/library.h +++ b/src/library.h @@ -191,14 +191,9 @@ int lammps_set_internal_variable(void *handle, const char *name, double value); int lammps_variable_info(void *handle, int idx, char *buf, int bufsize); double lammps_eval(void *handle, const char *expr); -void lammps_compute_clearstep(void *handle); -#if defined(LAMMPS_SMALLSMALL) -void lammps_compute_addstep_all(void *handle, int nextstep); -void lammps_compute_addstep(void *handle, int nextstep); -#else -void lammps_compute_addstep_all(void *handle, int64_t nextstep); -void lammps_compute_addstep(void *handle, int64_t nextstep); -#endif +void lammps_clearstep_compute(void *handle); +void lammps_addstep_compute_all(void *handle, void * nextstep); +void lammps_addstep_compute(void *handle, void * nextstep); /* ---------------------------------------------------------------------- * Library functions for scatter/gather operations of data