Merge branch 'develop' into mliappy_unified
This commit is contained in:
178
src/library.cpp
178
src/library.cpp
@ -290,7 +290,7 @@ multiple LAMMPS instances concurrently or sequentially. See
|
||||
|
||||
void lammps_close(void *handle)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
delete lmp;
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ and :cpp:func:`Input::file()<void LAMMPS_NS::Input::file()>`.
|
||||
|
||||
void lammps_file(void *handle, const char *filename)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -477,7 +477,7 @@ passing a string without a command.
|
||||
|
||||
char *lammps_command(void *handle, const char *cmd)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
char *result = nullptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -548,7 +548,7 @@ executing.
|
||||
|
||||
void lammps_commands_string(void *handle, const char *str)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
// copy str and convert from CR-LF (DOS-style) to LF (Unix style) line
|
||||
int n = strlen(str);
|
||||
@ -624,9 +624,9 @@ the size of a ``bigint`` integer.
|
||||
|
||||
double lammps_get_natoms(void *handle)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
double natoms = static_cast<double>(lmp->atom->natoms);
|
||||
auto natoms = static_cast<double>(lmp->atom->natoms);
|
||||
if (natoms > 9.0e15) return 0; // TODO:XXX why not -1?
|
||||
return natoms;
|
||||
}
|
||||
@ -650,7 +650,7 @@ a ``double``, so it can also return information that is computed on-the-fly.
|
||||
|
||||
double lammps_get_thermo(void *handle, const char *keyword)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
double dval = 0.0;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -690,7 +690,7 @@ void lammps_extract_box(void *handle, double *boxlo, double *boxhi,
|
||||
double *xy, double *yz, double *xz,
|
||||
int *pflags, int *boxflag)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Domain *domain = lmp->domain;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -752,7 +752,7 @@ are created.
|
||||
void lammps_reset_box(void *handle, double *boxlo, double *boxhi,
|
||||
double xy, double yz, double xz)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Domain *domain = lmp->domain;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -813,7 +813,7 @@ system it will be set to zero.
|
||||
|
||||
void lammps_memory_usage(void *handle, double *meminfo)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Info info(lmp);
|
||||
info.get_memory_info(meminfo);
|
||||
}
|
||||
@ -950,6 +950,14 @@ not recognized, the function returns -1.
|
||||
- number of dihedral types
|
||||
* - nimpropertypes
|
||||
- number of improper types
|
||||
* - nellipsoids
|
||||
- number of atoms that have ellipsoid data
|
||||
* - nlines
|
||||
- number of atoms that have line data (see :doc:`pair style line/lj <pair_line_lj>`)
|
||||
* - ntris
|
||||
- number of atoms that have triangle data (see :doc:`pair style tri/lj <pair_tri_lj>`)
|
||||
* - nbodies
|
||||
- number of atoms that have body data (see :doc:`the Body particle HowTo <Howto_body>`)
|
||||
|
||||
.. _extract_atom_flags:
|
||||
|
||||
@ -993,7 +1001,7 @@ not recognized, the function returns -1.
|
||||
|
||||
int lammps_extract_setting(void *handle, const char *keyword)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
// This can be customized by adding keywords and documenting them in the section above.
|
||||
if (strcmp(keyword,"bigint") == 0) return sizeof(bigint);
|
||||
@ -1021,6 +1029,10 @@ int lammps_extract_setting(void *handle, const char *keyword)
|
||||
if (strcmp(keyword,"nangletypes") == 0) return lmp->atom->nangletypes;
|
||||
if (strcmp(keyword,"ndihedraltypes") == 0) return lmp->atom->ndihedraltypes;
|
||||
if (strcmp(keyword,"nimpropertypes") == 0) return lmp->atom->nimpropertypes;
|
||||
if (strcmp(keyword,"nellipsoids") == 0) return lmp->atom->nellipsoids;
|
||||
if (strcmp(keyword,"nlines") == 0) return lmp->atom->nlines;
|
||||
if (strcmp(keyword,"ntris") == 0) return lmp->atom->ntris;
|
||||
if (strcmp(keyword,"nbodies") == 0) return lmp->atom->nbodies;
|
||||
|
||||
if (strcmp(keyword,"molecule_flag") == 0) return lmp->atom->molecule_flag;
|
||||
if (strcmp(keyword,"q_flag") == 0) return lmp->atom->q_flag;
|
||||
@ -1438,7 +1450,7 @@ report the "native" data type. The following tables are provided:
|
||||
|
||||
void *lammps_extract_global(void *handle, const char *name)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
if (strcmp(name,"units") == 0) return (void *) lmp->update->unit_style;
|
||||
if (strcmp(name,"dt") == 0) return (void *) &lmp->update->dt;
|
||||
@ -1450,7 +1462,7 @@ void *lammps_extract_global(void *handle, const char *name)
|
||||
if (strcmp(name,"atimestep") == 0) return (void *) &lmp->update->atimestep;
|
||||
|
||||
if (utils::strmatch(lmp->update->integrate_style,"^respa")) {
|
||||
Respa *respa = (Respa *)lmp->update->integrate;
|
||||
auto respa = dynamic_cast<Respa *>(lmp->update->integrate);
|
||||
if (strcmp(name,"respa_levels") == 0) return (void *) &respa->nlevels;
|
||||
if (strcmp(name,"respa_dt") == 0) return (void *) respa->step;
|
||||
}
|
||||
@ -1537,7 +1549,7 @@ to then decide how to cast the (void*) pointer and access the data.
|
||||
|
||||
int lammps_extract_atom_datatype(void *handle, const char *name)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
return lmp->atom->extract_datatype(name);
|
||||
}
|
||||
|
||||
@ -1571,7 +1583,7 @@ of the :cpp:func:`Atom::extract() <LAMMPS_NS::Atom::extract>` function.
|
||||
|
||||
void *lammps_extract_atom(void *handle, const char *name)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
return lmp->atom->extract(name);
|
||||
}
|
||||
|
||||
@ -1685,7 +1697,7 @@ lists the available options.
|
||||
|
||||
void *lammps_extract_compute(void *handle, const char *id, int style, int type)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -1871,7 +1883,7 @@ The following table lists the available options.
|
||||
void *lammps_extract_fix(void *handle, const char *id, int style, int type,
|
||||
int nrow, int ncol)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -1881,19 +1893,19 @@ void *lammps_extract_fix(void *handle, const char *id, int style, int type,
|
||||
if (style == LMP_STYLE_GLOBAL) {
|
||||
if (type == LMP_TYPE_SCALAR) {
|
||||
if (!fix->scalar_flag) return nullptr;
|
||||
double *dptr = (double *) malloc(sizeof(double));
|
||||
auto dptr = (double *) malloc(sizeof(double));
|
||||
*dptr = fix->compute_scalar();
|
||||
return (void *) dptr;
|
||||
}
|
||||
if (type == LMP_TYPE_VECTOR) {
|
||||
if (!fix->vector_flag) return nullptr;
|
||||
double *dptr = (double *) malloc(sizeof(double));
|
||||
auto dptr = (double *) malloc(sizeof(double));
|
||||
*dptr = fix->compute_vector(nrow);
|
||||
return (void *) dptr;
|
||||
}
|
||||
if (type == LMP_TYPE_ARRAY) {
|
||||
if (!fix->array_flag) return nullptr;
|
||||
double *dptr = (double *) malloc(sizeof(double));
|
||||
auto dptr = (double *) malloc(sizeof(double));
|
||||
*dptr = fix->compute_array(nrow,ncol);
|
||||
return (void *) dptr;
|
||||
}
|
||||
@ -1995,7 +2007,7 @@ a char pointer.
|
||||
|
||||
void *lammps_extract_variable(void *handle, const char *name, const char *group)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -2003,7 +2015,7 @@ void *lammps_extract_variable(void *handle, const char *name, const char *group)
|
||||
if (ivar < 0) return nullptr;
|
||||
|
||||
if (lmp->input->variable->equalstyle(ivar)) {
|
||||
double *dptr = (double *) malloc(sizeof(double));
|
||||
auto dptr = (double *) malloc(sizeof(double));
|
||||
*dptr = lmp->input->variable->compute_equal(ivar);
|
||||
return (void *) dptr;
|
||||
} else if (lmp->input->variable->atomstyle(ivar)) {
|
||||
@ -2011,7 +2023,7 @@ void *lammps_extract_variable(void *handle, const char *name, const char *group)
|
||||
int igroup = lmp->group->find(group);
|
||||
if (igroup < 0) return nullptr;
|
||||
int nlocal = lmp->atom->nlocal;
|
||||
double *vector = (double *) malloc(nlocal*sizeof(double));
|
||||
auto vector = (double *) malloc(nlocal*sizeof(double));
|
||||
lmp->input->variable->compute_atom(ivar,igroup,vector,1,0);
|
||||
return (void *) vector;
|
||||
} else {
|
||||
@ -2039,7 +2051,7 @@ void *lammps_extract_variable(void *handle, const char *name, const char *group)
|
||||
*/
|
||||
int lammps_set_variable(void *handle, char *name, char *str)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
int err = -1;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -2078,7 +2090,7 @@ int lammps_set_variable(void *handle, char *name, char *str)
|
||||
|
||||
void lammps_gather_atoms(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -2213,7 +2225,7 @@ void lammps_gather_atoms(void *handle, char *name, int type, int count, void *da
|
||||
|
||||
void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -2362,7 +2374,7 @@ void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, v
|
||||
void lammps_gather_atoms_subset(void *handle, char *name, int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -2500,7 +2512,7 @@ void lammps_gather_atoms_subset(void *handle, char *name, int type, int count,
|
||||
|
||||
void lammps_scatter_atoms(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -2576,7 +2588,7 @@ void lammps_scatter_atoms(void *handle, char *name, int type, int count, void *d
|
||||
double **array = nullptr;
|
||||
if (count == 1) vector = (double *) vptr;
|
||||
else array = (double **) vptr;
|
||||
double *dptr = (double *) data;
|
||||
auto dptr = (double *) data;
|
||||
|
||||
if (count == 1) {
|
||||
for (i = 0; i < natoms; i++)
|
||||
@ -2619,7 +2631,7 @@ void lammps_scatter_atoms(void *handle, char *name, int type, int count, void *d
|
||||
void lammps_scatter_atoms_subset(void *handle, char *name, int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -2699,7 +2711,7 @@ void lammps_scatter_atoms_subset(void *handle, char *name, int type, int count,
|
||||
double **array = nullptr;
|
||||
if (count == 1) vector = (double *) vptr;
|
||||
else array = (double **) vptr;
|
||||
double *dptr = (double *) data;
|
||||
auto dptr = (double *) data;
|
||||
|
||||
if (count == 1) {
|
||||
for (i = 0; i < ndata; i++) {
|
||||
@ -2800,7 +2812,7 @@ Below is a brief C code demonstrating accessing this collected bond information.
|
||||
|
||||
void lammps_gather_bonds(void *handle, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *)handle;
|
||||
auto lmp = (LAMMPS *)handle;
|
||||
BEGIN_CAPTURE {
|
||||
void *val = lammps_extract_global(handle,"nbonds");
|
||||
bigint nbonds = *(bigint *)val;
|
||||
@ -2861,7 +2873,7 @@ void lammps_gather_bonds(void *handle, void *data)
|
||||
|
||||
void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -3096,7 +3108,7 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
|
||||
void lammps_gather_concat(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -3350,7 +3362,7 @@ void lammps_gather_subset(void *handle, char *name,
|
||||
int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -3596,7 +3608,7 @@ void lammps_gather_subset(void *handle, char *name,
|
||||
|
||||
void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -3767,7 +3779,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
double **array = nullptr;
|
||||
if (count == 1) vector = (double *) vptr;
|
||||
else array = (double **) vptr;
|
||||
double *dptr = (double *) data;
|
||||
auto dptr = (double *) data;
|
||||
|
||||
if (count == 1) {
|
||||
for (i = 0; i < natoms; i++)
|
||||
@ -3814,7 +3826,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -3991,7 +4003,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
||||
double **array = nullptr;
|
||||
if (count == 1) vector = (double *) vptr;
|
||||
else array = (double **) vptr;
|
||||
double *dptr = (double *) data;
|
||||
auto dptr = (double *) data;
|
||||
|
||||
if (count == 1) {
|
||||
for (i = 0; i < ndata; i++) {
|
||||
@ -4074,7 +4086,7 @@ int lammps_create_atoms(void *handle, int n, const tagint *id, const int *type,
|
||||
const double *x, const double *v, const imageint *image,
|
||||
int bexpand)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
bigint natoms_prev = lmp->atom->natoms;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -4196,7 +4208,7 @@ int lammps_create_atoms(void *handle, int n, const tagint *id, const int *type,
|
||||
* \return return neighbor list index if found, otherwise -1 */
|
||||
|
||||
int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int nsub, int reqid) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Pair *pair = lmp->force->pair_match(style, exact, nsub);
|
||||
|
||||
if (pair != nullptr) {
|
||||
@ -4226,7 +4238,7 @@ int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int n
|
||||
* \return return neighbor list index if found, otherwise -1 */
|
||||
|
||||
int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) return -1;
|
||||
|
||||
@ -4255,7 +4267,7 @@ int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) {
|
||||
* \return return neighbor list index if found, otherwise -1 */
|
||||
|
||||
int lammps_find_compute_neighlist(void* handle, const char *id, int reqid) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
auto compute = lmp->modify->get_compute_by_id(id);
|
||||
if (!compute) return -1;
|
||||
|
||||
@ -4279,7 +4291,7 @@ int lammps_find_compute_neighlist(void* handle, const char *id, int reqid) {
|
||||
* not a valid index
|
||||
*/
|
||||
int lammps_neighlist_num_elements(void *handle, int idx) {
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Neighbor * neighbor = lmp->neighbor;
|
||||
|
||||
if (idx < 0 || idx >= neighbor->nlist) {
|
||||
@ -4304,7 +4316,7 @@ int lammps_neighlist_num_elements(void *handle, int idx) {
|
||||
* \param[out] neighbors pointer to array of neighbor atom local indices or NULL */
|
||||
|
||||
void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int *iatom, int *numneigh, int **neighbors) {
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Neighbor * neighbor = lmp->neighbor;
|
||||
*iatom = -1;
|
||||
*numneigh = 0;
|
||||
@ -4348,7 +4360,7 @@ growing with every new LAMMPS release.
|
||||
|
||||
int lammps_version(void *handle)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
return lmp->num_ver;
|
||||
}
|
||||
|
||||
@ -4662,7 +4674,7 @@ Valid categories are: *atom*\ , *integrate*\ , *minimize*\ ,
|
||||
* \return 1 if included, 0 if not.
|
||||
*/
|
||||
int lammps_has_style(void *handle, const char *category, const char *name) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Info info(lmp);
|
||||
return info.has_style(category, name) ? 1 : 0;
|
||||
}
|
||||
@ -4683,7 +4695,7 @@ categories.
|
||||
* \return number of styles in category
|
||||
*/
|
||||
int lammps_style_count(void *handle, const char *category) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Info info(lmp);
|
||||
return info.get_available_styles(category).size();
|
||||
}
|
||||
@ -4709,7 +4721,7 @@ int lammps_style_count(void *handle, const char *category) {
|
||||
*/
|
||||
int lammps_style_name(void *handle, const char *category, int idx,
|
||||
char *buffer, int buf_size) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
Info info(lmp);
|
||||
auto styles = info.get_available_styles(category);
|
||||
|
||||
@ -4741,7 +4753,7 @@ the given *name* exists. Valid categories are: *compute*\ , *dump*\ ,
|
||||
* \return 1 if included, 0 if not.
|
||||
*/
|
||||
int lammps_has_id(void *handle, const char *category, const char *name) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
if (strcmp(category,"compute") == 0) {
|
||||
int ncompute = lmp->modify->ncompute;
|
||||
@ -4772,10 +4784,8 @@ int lammps_has_id(void *handle, const char *category, const char *name) {
|
||||
if (strcmp(name,molecule[i]->id) == 0) return 1;
|
||||
}
|
||||
} else if (strcmp(category,"region") == 0) {
|
||||
int nregion = lmp->domain->nregion;
|
||||
Region **region = lmp->domain->regions;
|
||||
for (int i=0; i < nregion; ++i) {
|
||||
if (strcmp(name,region[i]->id) == 0) return 1;
|
||||
for (auto ® : lmp->domain->get_region_list()) {
|
||||
if (strcmp(name,reg->id) == 0) return 1;
|
||||
}
|
||||
} else if (strcmp(category,"variable") == 0) {
|
||||
int nvariable = lmp->input->variable->nvar;
|
||||
@ -4806,7 +4816,7 @@ categories.
|
||||
* \return number of IDs in category
|
||||
*/
|
||||
int lammps_id_count(void *handle, const char *category) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
if (strcmp(category,"compute") == 0) {
|
||||
return lmp->modify->ncompute;
|
||||
} else if (strcmp(category,"dump") == 0) {
|
||||
@ -4818,7 +4828,7 @@ int lammps_id_count(void *handle, const char *category) {
|
||||
} else if (strcmp(category,"molecule") == 0) {
|
||||
return lmp->atom->nmolecule;
|
||||
} else if (strcmp(category,"region") == 0) {
|
||||
return lmp->domain->nregion;
|
||||
return lmp->domain->get_region_list().size();
|
||||
} else if (strcmp(category,"variable") == 0) {
|
||||
return lmp->input->variable->nvar;
|
||||
}
|
||||
@ -4848,13 +4858,13 @@ set to an empty string, otherwise 1.
|
||||
* \param buf_size size of the provided string buffer
|
||||
* \return 1 if successful, otherwise 0
|
||||
*/
|
||||
int lammps_id_name(void *handle, const char *category, int idx,
|
||||
char *buffer, int buf_size) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
int lammps_id_name(void *handle, const char *category, int idx, char *buffer, int buf_size) {
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
if (strcmp(category,"compute") == 0) {
|
||||
if ((idx >=0) && (idx < lmp->modify->ncompute)) {
|
||||
strncpy(buffer, lmp->modify->compute[idx]->id, buf_size);
|
||||
auto icompute = lmp->modify->get_compute_by_index(idx);
|
||||
if (icompute) {
|
||||
strncpy(buffer, icompute->id, buf_size);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"dump") == 0) {
|
||||
@ -4863,8 +4873,9 @@ int lammps_id_name(void *handle, const char *category, int idx,
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"fix") == 0) {
|
||||
if ((idx >=0) && (idx < lmp->modify->nfix)) {
|
||||
strncpy(buffer, lmp->modify->fix[idx]->id, buf_size);
|
||||
auto ifix = lmp->modify->get_fix_by_index(idx);
|
||||
if (ifix) {
|
||||
strncpy(buffer, ifix->id, buf_size);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"group") == 0) {
|
||||
@ -4878,8 +4889,9 @@ int lammps_id_name(void *handle, const char *category, int idx,
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"region") == 0) {
|
||||
if ((idx >=0) && (idx < lmp->domain->nregion)) {
|
||||
strncpy(buffer, lmp->domain->regions[idx]->id, buf_size);
|
||||
auto regions = lmp->domain->get_region_list();
|
||||
if ((idx >=0) && (idx < (int) regions.size())) {
|
||||
strncpy(buffer, regions[idx]->id, buf_size);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"variable") == 0) {
|
||||
@ -5065,8 +5077,8 @@ external code.
|
||||
|
||||
void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalFnPtr funcptr, void *ptr)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
FixExternal::FnPtr callback = (FixExternal::FnPtr) funcptr;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
auto callback = (FixExternal::FnPtr) funcptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5076,7 +5088,7 @@ void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalF
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style 'external'", id);
|
||||
|
||||
FixExternal *fext = (FixExternal *) fix;
|
||||
auto fext = dynamic_cast<FixExternal *>( fix);
|
||||
fext->set_callback(callback, ptr);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5126,7 +5138,7 @@ external code.
|
||||
|
||||
double **lammps_fix_external_get_force(void *handle, const char *id)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
double **fexternal = nullptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
@ -5174,7 +5186,7 @@ external code.
|
||||
|
||||
void lammps_fix_external_set_energy_global(void *handle, const char *id, double eng)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5184,7 +5196,7 @@ void lammps_fix_external_set_energy_global(void *handle, const char *id, double
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
FixExternal *fext = (FixExternal*) fix;
|
||||
auto fext = dynamic_cast<FixExternal*>( fix);
|
||||
fext->set_energy_global(eng);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5222,7 +5234,7 @@ external code.
|
||||
|
||||
void lammps_fix_external_set_virial_global(void *handle, const char *id, double *virial)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5232,7 +5244,7 @@ void lammps_fix_external_set_virial_global(void *handle, const char *id, double
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
FixExternal * fext = (FixExternal*) fix;
|
||||
auto fext = dynamic_cast<FixExternal*>( fix);
|
||||
fext->set_virial_global(virial);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5270,7 +5282,7 @@ external code.
|
||||
|
||||
void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double *eng)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5280,7 +5292,7 @@ void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
FixExternal *fext = (FixExternal*) fix;
|
||||
auto fext = dynamic_cast<FixExternal*>( fix);
|
||||
fext->set_energy_peratom(eng);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5321,7 +5333,7 @@ external code.
|
||||
|
||||
void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double **virial)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5331,7 +5343,7 @@ void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
FixExternal * fext = (FixExternal*) fix;
|
||||
auto fext = dynamic_cast<FixExternal*>( fix);
|
||||
fext->set_virial_peratom(virial);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5365,7 +5377,7 @@ external code.
|
||||
|
||||
void lammps_fix_external_set_vector_length(void *handle, const char *id, int len)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5375,7 +5387,7 @@ void lammps_fix_external_set_vector_length(void *handle, const char *id, int len
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
FixExternal *fext = (FixExternal*) fix;
|
||||
auto fext = dynamic_cast<FixExternal*>( fix);
|
||||
fext->set_vector_length(len);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5419,7 +5431,7 @@ external code.
|
||||
|
||||
void lammps_fix_external_set_vector(void *handle, const char *id, int idx, double val)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
@ -5429,7 +5441,7 @@ void lammps_fix_external_set_vector(void *handle, const char *id, int idx, doubl
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
FixExternal * fext = (FixExternal*) fix;
|
||||
auto fext = dynamic_cast<FixExternal*>( fix);
|
||||
fext->set_vector(idx, val);
|
||||
}
|
||||
END_CAPTURE
|
||||
@ -5482,7 +5494,7 @@ void lammps_free(void *ptr)
|
||||
|
||||
int lammps_is_running(void *handle)
|
||||
{
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
return lmp->update->whichflag;
|
||||
}
|
||||
|
||||
@ -5495,7 +5507,7 @@ int lammps_is_running(void *handle)
|
||||
|
||||
void lammps_force_timeout(void *handle)
|
||||
{
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
return lmp->timer->force_timeout();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user