Merge branch 'develop' into consolidate-sphere-omega-flag
# Conflicts: # src/compute_temp_sphere.cpp
This commit is contained in:
100
src/library.cpp
100
src/library.cpp
@ -2449,19 +2449,69 @@ int lammps_extract_variable_datatype(void *handle, const char *name)
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
// for printing obsolete function call warning only once
|
||||
static int set_variable_deprecated_flag = 1;
|
||||
|
||||
/** Set the value of a string-style variable.
|
||||
*
|
||||
* This function assigns a new value from the string str to the
|
||||
* string-style variable name. Returns -1 if a variable of that
|
||||
* name does not exist or is not a string-style variable, otherwise 0.
|
||||
*
|
||||
\verbatim embed:rst
|
||||
|
||||
.. deprecated:: TBD
|
||||
|
||||
This function assigns a new value from the string str to the
|
||||
string-style variable *name*. This is a way to directly change the
|
||||
string value of a LAMMPS variable that was previous defined with a
|
||||
:doc:`variable name string <variable>` command without using any
|
||||
LAMMPS commands to delete and redefine the variable.
|
||||
|
||||
Returns -1 if a variable of that name does not exist or if it is not
|
||||
a string-style variable, otherwise 0.
|
||||
|
||||
.. warning::
|
||||
|
||||
This function is deprecated and :cpp:func:`lammps_set_string_variable`
|
||||
should be used instead.
|
||||
|
||||
\endverbatim
|
||||
|
||||
* \param handle pointer to a previously created LAMMPS instance
|
||||
* \param name name of the variable
|
||||
* \param str new value of the variable
|
||||
* \return 0 on success or -1 on failure */
|
||||
|
||||
int lammps_set_variable(void *handle, const char *name, const char *str)
|
||||
{
|
||||
if (set_variable_deprecated_flag) {
|
||||
fprintf(stderr,"Using the 'lammps_set_variable()' function is deprecated. "
|
||||
"Please use 'lammps_set_string_variable()' instead.\n");
|
||||
set_variable_deprecated_flag = 0;
|
||||
}
|
||||
return lammps_set_string_variable(handle, name, str);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Set the value of a string-style variable.
|
||||
\verbatim embed:rst
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
This function assigns a new value from the string str to the
|
||||
string-style variable *name*. This is a way to directly change the
|
||||
string value of a LAMMPS variable that was previous defined with a
|
||||
:doc:`variable name string <variable>` command without using any
|
||||
LAMMPS commands to delete and redefine the variable.
|
||||
|
||||
Returns -1 if a variable of that name does not exist or if it is not
|
||||
a string-style variable, otherwise 0.
|
||||
|
||||
\endverbatim
|
||||
|
||||
* \param handle pointer to a previously created LAMMPS instance
|
||||
* \param name name of the variable
|
||||
* \param str new value of the variable
|
||||
* \return 0 on success or -1 on failure
|
||||
*/
|
||||
int lammps_set_variable(void *handle, char *name, char *str)
|
||||
int lammps_set_string_variable(void *handle, const char *name, const char *str)
|
||||
{
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
int err = -1;
|
||||
@ -2475,6 +2525,44 @@ int lammps_set_variable(void *handle, char *name, char *str)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Set the value of an internal-style variable.
|
||||
*
|
||||
\verbatim embed:rst
|
||||
|
||||
This function assigns a new value from the floating point number *value*
|
||||
to the internal-style variable *name*. This is a way to directly change
|
||||
the numerical value of such a LAMMPS variable that was previous defined
|
||||
with a :doc:`variable name internal <variable>` command without using
|
||||
any LAMMPS commands to delete and redefine the variable.
|
||||
|
||||
Returns -1 if a variable of that name does not exist or is not an
|
||||
internal-style variable, otherwise 0.
|
||||
|
||||
\endverbatim
|
||||
|
||||
* \param handle pointer to a previously created LAMMPS instance
|
||||
* \param name name of the variable
|
||||
* \param value new value of the variable
|
||||
* \return 0 on success or -1 on failure
|
||||
*/
|
||||
int lammps_set_internal_variable(void *handle, const char *name, double value)
|
||||
{
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ivar = lmp->input->variable->find(name);
|
||||
if (ivar < 0) return -1;
|
||||
if (lmp->input->variable->internalstyle(ivar)) {
|
||||
lmp->input->variable->internal_set(ivar, value);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
END_CAPTURE
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user