library: add API for compute clearstep and addstep
This commit is contained in:
@ -339,6 +339,10 @@ 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_fix_external_get_force.argtypes = [c_void_p, c_char_p]
|
||||
self.lib.lammps_fix_external_get_force.restype = POINTER(POINTER(c_double))
|
||||
|
||||
@ -1453,6 +1457,24 @@ class lammps(object):
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def compute_clearstep(self, nextstep):
|
||||
with ExceptionCheck(self):
|
||||
return self.lib.lammps_compute_clearstep(self.lmp)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def compute_addstep(self, nextstep):
|
||||
with ExceptionCheck(self):
|
||||
return self.lib.lammps_compute_addstep(self.lmp, nextstep)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def compute_addstep_all(self, nextstep):
|
||||
with ExceptionCheck(self):
|
||||
return self.lib.lammps_compute_addstep_all(self.lmp, nextstep)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def flush_buffers(self):
|
||||
"""Flush output buffers
|
||||
|
||||
|
||||
@ -2904,6 +2904,87 @@ int lammps_variable_info(void *handle, int idx, char *buffer, int buf_size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Clear whether a compute has been invoked.
|
||||
*
|
||||
\verbatim embed:rst
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
This function clears the invoked flag of all computes.
|
||||
Called everywhere that computes are used, before computes are invoked.
|
||||
The invoked flag is used to avoid re-invoking same compute multiple times
|
||||
and to flag computes that store invocation times as having been invoked
|
||||
|
||||
\endverbatim
|
||||
|
||||
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
||||
*/
|
||||
void lammps_compute_clearstep(void * handle) {
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->modify->clearstep_compute();
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Add next timestep to all computes
|
||||
*
|
||||
\verbatim embed:rst
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
loop over all computes
|
||||
schedule next invocation for those that store invocation times
|
||||
called when not sure what computes will be needed on newstep
|
||||
do not loop only over n_timeflag, since may not be set yet
|
||||
|
||||
\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_all(void * handle, bigint newstep) {
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->modify->addstep_compute_all(newstep);
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Add next timestep to compute if it has been invoked in the current timestep
|
||||
*
|
||||
\verbatim embed:rst
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
loop over computes that store invocation times
|
||||
if its invoked flag set on this timestep, schedule next invocation
|
||||
called everywhere that computes are used, after computes are invoked
|
||||
|
||||
\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) {
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->modify->addstep_compute(newstep);
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Library functions for scatter/gather operations of data
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -190,6 +190,15 @@ int lammps_set_string_variable(void *handle, const char *name, const char *str);
|
||||
int lammps_set_internal_variable(void *handle, const char *name, double value);
|
||||
int lammps_variable_info(void *handle, int idx, char *buf, int bufsize);
|
||||
|
||||
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
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Library functions for scatter/gather operations of data
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user