|
|
|
|
@ -4049,86 +4049,12 @@ int lammps_style_name(void *handle, const char *category, int idx,
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/** Check if a group with a given name has been defined
|
|
|
|
|
*
|
|
|
|
|
\verbatim embed:rst
|
|
|
|
|
This function checks if a group with the provided *name* is defined
|
|
|
|
|
in the current LAMMPS instance.
|
|
|
|
|
\endverbatim
|
|
|
|
|
*
|
|
|
|
|
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
|
|
|
|
* \param name name of the style
|
|
|
|
|
* \return 1 if defined, 0 if not.
|
|
|
|
|
*/
|
|
|
|
|
int lammps_has_group(void *handle, const char *name)
|
|
|
|
|
{
|
|
|
|
|
LAMMPS *lmp = (LAMMPS *)handle;
|
|
|
|
|
|
|
|
|
|
int ngroup = lmp->group->ngroup;
|
|
|
|
|
char **groups = lmp->group->names;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i < ngroup; ++i)
|
|
|
|
|
if (strcmp(groups[i],name) == 0) return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/** Count the number of currently defined groups
|
|
|
|
|
*
|
|
|
|
|
* This function counts how many groups are defined in the
|
|
|
|
|
* current LAMMPS instance.
|
|
|
|
|
*
|
|
|
|
|
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
|
|
|
|
* \return number of styles in category
|
|
|
|
|
*/
|
|
|
|
|
int lammps_group_count(void *handle)
|
|
|
|
|
{
|
|
|
|
|
LAMMPS *lmp = (LAMMPS *)handle;
|
|
|
|
|
|
|
|
|
|
return lmp->group->ngroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/** Look up the name of a group by index in the list of groups.
|
|
|
|
|
*
|
|
|
|
|
* This function copies the name of the group with the index *idx* into
|
|
|
|
|
* the provided C-style string buffer. The length of the buffer must be
|
|
|
|
|
* provided as *buf_size* argument. If the name of the group exceeds the
|
|
|
|
|
* length of the buffer, it will be truncated accordingly. If the index
|
|
|
|
|
* is out of range, the function returns 0 and *buffer* is set to an empty
|
|
|
|
|
* string, otherwise 1 is returned.
|
|
|
|
|
*
|
|
|
|
|
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
|
|
|
|
* \param idx index of the group in the list of groups (0 <= idx < group count)
|
|
|
|
|
* \param buffer string buffer to copy the name of the style to
|
|
|
|
|
* \param buf_size size of the provided string buffer
|
|
|
|
|
* \return 1 if successful, otherwise 0
|
|
|
|
|
*/
|
|
|
|
|
int lammps_group_name(void *handle, int idx, char *buffer, int buf_size) {
|
|
|
|
|
LAMMPS *lmp = (LAMMPS *)handle;
|
|
|
|
|
|
|
|
|
|
int ngroup = lmp->group->ngroup;
|
|
|
|
|
char **groups = lmp->group->names;
|
|
|
|
|
if ((idx >=0) && (idx < ngroup)) {
|
|
|
|
|
strncpy(buffer, groups[idx], buf_size);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/** Check if a specific ID exists in the current LAMMPS instance
|
|
|
|
|
*
|
|
|
|
|
\verbatim embed:rst
|
|
|
|
|
This function checks if the current LAMMPS instance a *category* ID of
|
|
|
|
|
the given *name* exists. Valid categories are: *compute*\ , *dump*\ ,
|
|
|
|
|
*fix*\ , *molecule*\ , *region*\ , and *variable*\ .
|
|
|
|
|
*fix*\ , *group*\ , *molecule*\ , *region*\ , and *variable*\ .
|
|
|
|
|
\endverbatim
|
|
|
|
|
*
|
|
|
|
|
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
|
|
|
|
@ -4157,6 +4083,12 @@ int lammps_has_id(void *handle, const char *category, const char *name) {
|
|
|
|
|
for (int i=0; i < nfix; ++i) {
|
|
|
|
|
if (strcmp(name,fix[i]->id) == 0) return 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (strcmp(category,"group") == 0) {
|
|
|
|
|
int ngroup = lmp->group->ngroup;
|
|
|
|
|
char **groups = lmp->group->names;
|
|
|
|
|
for (int i=0; i < ngroup; ++i) {
|
|
|
|
|
if (strcmp(groups[i],name) == 0) return 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (strcmp(category,"molecule") == 0) {
|
|
|
|
|
int nmolecule = lmp->atom->nmolecule;
|
|
|
|
|
Molecule **molecule = lmp->atom->molecules;
|
|
|
|
|
@ -4202,6 +4134,8 @@ int lammps_id_count(void *handle, const char *category) {
|
|
|
|
|
return lmp->output->ndump;
|
|
|
|
|
} else if (strcmp(category,"fix") == 0) {
|
|
|
|
|
return lmp->modify->nfix;
|
|
|
|
|
} else if (strcmp(category,"group") == 0) {
|
|
|
|
|
return lmp->group->ngroup;
|
|
|
|
|
} else if (strcmp(category,"molecule") == 0) {
|
|
|
|
|
return lmp->atom->nmolecule;
|
|
|
|
|
} else if (strcmp(category,"region") == 0) {
|
|
|
|
|
@ -4249,6 +4183,11 @@ int lammps_id_name(void *handle, const char *category, int idx,
|
|
|
|
|
strncpy(buffer, lmp->modify->fix[idx]->id, buf_size);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (strcmp(category,"group") == 0) {
|
|
|
|
|
if ((idx >=0) && (idx < lmp->group->ngroup)) {
|
|
|
|
|
strncpy(buffer, lmp->group->names[idx], buf_size);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
} else if (strcmp(category,"molecule") == 0) {
|
|
|
|
|
if ((idx >=0) && (idx < lmp->atom->nmolecule)) {
|
|
|
|
|
strncpy(buffer, lmp->atom->molecules[idx]->id, buf_size);
|
|
|
|
|
|