additional changes needed to merge with current master
This commit is contained in:
283
src/library.cpp
283
src/library.cpp
@ -2650,9 +2650,10 @@ void lammps_scatter_atoms_subset(void *handle, char *name, int type, int count,
|
|||||||
see gather_concat() to return data for all atoms, unordered
|
see gather_concat() to return data for all atoms, unordered
|
||||||
see gather_subset() to return data for only a subset of atoms
|
see gather_subset() to return data for only a subset of atoms
|
||||||
name = "x" , "f" or other atom properties
|
name = "x" , "f" or other atom properties
|
||||||
"d_name" or "i_name" for fix property/atom quantities
|
"f_fix", "c_compute" for fixes / computes
|
||||||
"f_fix", "c_compute" for fixes / computes
|
"d_name" or "i_name" for fix property/atom vectors with count = 1
|
||||||
will return error if fix/compute doesn't isn't atom-based
|
"d2_name" or "i2_name" for fix property/atom arrays with count > 1
|
||||||
|
will return error if fix/compute isn't atom-based
|
||||||
type = 0 for integer values, 1 for double values
|
type = 0 for integer values, 1 for double values
|
||||||
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
||||||
use count = 3 with "image" if want single image flag unpacked into xyz
|
use count = 3 with "image" if want single image flag unpacked into xyz
|
||||||
@ -2673,12 +2674,13 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
|||||||
BEGIN_CAPTURE
|
BEGIN_CAPTURE
|
||||||
{
|
{
|
||||||
#if defined(LAMMPS_BIGBIG)
|
#if defined(LAMMPS_BIGBIG)
|
||||||
lmp->error->all(FLERR,"Library function lammps_gather"
|
lmp->error->all(FLERR,"Library function lammps_gather"
|
||||||
" not compatible with -DLAMMPS_BIGBIG");
|
" not compatible with -DLAMMPS_BIGBIG");
|
||||||
#else
|
#else
|
||||||
int i,j,offset,fcid,ltype;
|
int i,j,offset,fcid,ltype,icol;
|
||||||
|
|
||||||
// error if tags are not defined or not consecutive
|
// error if tags are not defined or not consecutive
|
||||||
|
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0)
|
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0)
|
||||||
flag = 1;
|
flag = 1;
|
||||||
@ -2690,10 +2692,11 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||||
|
|
||||||
void *vptr = lmp->atom->extract(name);
|
void *vptr = lmp->atom->extract(name);
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"f_") == name) { // fix
|
// fix
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"f_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_fix(&name[2]);
|
fcid = lmp->modify->find_fix(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -2726,7 +2729,9 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
|||||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
// compute
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"c_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_compute(&name[2]);
|
fcid = lmp->modify->find_compute(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -2753,41 +2758,58 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
|||||||
|
|
||||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// property / atom
|
|
||||||
if ( (vptr == nullptr) && ((strstr(name,"d_") == name)
|
// property/atom
|
||||||
|| (strstr(name,"i_") == name))) {
|
|
||||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
if ((vptr == nullptr) &&
|
||||||
|
((strstr(name,"d_") == name) || (strstr(name,"i_") == name) ||
|
||||||
|
(strstr(name,"d2_") == name) || (strstr(name,"i2_") == name))) {
|
||||||
|
|
||||||
|
if ((strstr(name,"d_") == name) || (strstr(name,"i_") == name))
|
||||||
|
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||||
|
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather: unknown property/atom id");
|
lmp->error->warning(FLERR,"lammps_gather: unknown property/atom id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltype != type) {
|
if (ltype != type) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom type");
|
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count != 1) {
|
if (count == 1 && icol != 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather: property/atom has count=1");
|
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom count");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
if (count > 1 && icol != count) {
|
||||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
if (lmp->comm->me == 0)
|
||||||
|
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||||
|
} else {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->darray[fcid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr == nullptr) {
|
if (vptr == nullptr) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather: unknown property name");
|
lmp->error->warning(FLERR,"lammps_gather: undefined property name");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy = Natom length vector of per-atom values
|
// copy = Natom length vector of per-atom values
|
||||||
// use atom ID to insert each atom's values into copy
|
// use atom ID to insert each atom's values into copy
|
||||||
// MPI_Allreduce with MPI_SUM to merge into data, ordered by atom ID
|
// MPI_Allreduce with MPI_SUM to merge into data, ordered by atom ID
|
||||||
|
|
||||||
if (type==0) {
|
if (type==0) {
|
||||||
int *vector = nullptr;
|
int *vector = nullptr;
|
||||||
int **array = nullptr;
|
int **array = nullptr;
|
||||||
@ -2829,7 +2851,6 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
|||||||
lmp->memory->destroy(copy);
|
lmp->memory->destroy(copy);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
double *vector = nullptr;
|
double *vector = nullptr;
|
||||||
double **array = nullptr;
|
double **array = nullptr;
|
||||||
if (count == 1) vector = (double *) vptr;
|
if (count == 1) vector = (double *) vptr;
|
||||||
@ -2869,9 +2890,10 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
|||||||
see gather() to return data ordered by consecutive atom IDs
|
see gather() to return data ordered by consecutive atom IDs
|
||||||
see gather_subset() to return data for only a subset of atoms
|
see gather_subset() to return data for only a subset of atoms
|
||||||
name = "x" , "f" or other atom properties
|
name = "x" , "f" or other atom properties
|
||||||
"d_name" or "i_name" for fix property/atom quantities
|
"f_fix", "c_compute" for fixes / computes
|
||||||
"f_fix", "c_compute" for fixes / computes
|
"d_name" or "i_name" for fix property/atom vectors with count = 1
|
||||||
will return error if fix/compute doesn't isn't atom-based
|
"d2_name" or "i2_name" for fix property/atom arrays with count > 1
|
||||||
|
will return error if fix/compute isn't atom-based
|
||||||
type = 0 for integer values, 1 for double values
|
type = 0 for integer values, 1 for double values
|
||||||
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
||||||
use count = 3 with "image" if want single image flag unpacked into xyz
|
use count = 3 with "image" if want single image flag unpacked into xyz
|
||||||
@ -2895,9 +2917,10 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
lmp->error->all(FLERR,"Library function lammps_gather_concat"
|
lmp->error->all(FLERR,"Library function lammps_gather_concat"
|
||||||
" not compatible with -DLAMMPS_BIGBIG");
|
" not compatible with -DLAMMPS_BIGBIG");
|
||||||
#else
|
#else
|
||||||
int i,offset,fcid,ltype;
|
int i,offset,fcid,ltype,icol;
|
||||||
|
|
||||||
// error if tags are not defined or not consecutive
|
// error if tags are not defined or not consecutive
|
||||||
|
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (lmp->atom->tag_enable == 0) flag = 1;
|
if (lmp->atom->tag_enable == 0) flag = 1;
|
||||||
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
|
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
|
||||||
@ -2907,12 +2930,12 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||||
|
|
||||||
void *vptr = lmp->atom->extract(name);
|
void *vptr = lmp->atom->extract(name);
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"f_") == name) { // fix
|
// fix
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"f_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_fix(&name[2]);
|
fcid = lmp->modify->find_fix(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -2933,8 +2956,6 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
" count != values peratom for fix");
|
" count != values peratom for fix");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->all(FLERR,"lammps_gather_concat:"
|
lmp->error->all(FLERR,"lammps_gather_concat:"
|
||||||
@ -2946,7 +2967,9 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
// compute
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"c_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_compute(&name[2]);
|
fcid = lmp->modify->find_compute(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -2973,39 +2996,55 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
|
|
||||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"d_") == name) { // property / atom
|
// property/atom
|
||||||
|
|
||||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
if ((vptr==nullptr) &&
|
||||||
|
((strstr(name,"d_") == name) || (strstr(name,"i_") == name) ||
|
||||||
|
(strstr(name,"d2_") == name) || (strstr(name,"i2_") == name))) {
|
||||||
|
|
||||||
|
if ((strstr(name,"d_") == name) || (strstr(name,"i_") == name))
|
||||||
|
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||||
|
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||||
"unknown property/atom id");
|
"unknown property/atom id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltype != type) {
|
if (ltype != type) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||||
"mismatch property/atom type");
|
"mismatch property/atom type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count != 1) {
|
if (count == 1 && icol != 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||||
"property/atom has count=1");
|
"mismatch property/atom count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (count > 1 && icol != count) {
|
||||||
|
if (lmp->comm->me == 0)
|
||||||
|
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||||
|
"mismatch property/atom count");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
|
||||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||||
|
} else {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->darray[fcid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr == nullptr) {
|
if (vptr == nullptr) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_concat: unknown property name");
|
lmp->error->warning(FLERR,"lammps_gather_concat: undefined property name");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3020,6 +3059,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
int *vector = nullptr;
|
int *vector = nullptr;
|
||||||
int **array = nullptr;
|
int **array = nullptr;
|
||||||
|
|
||||||
const int imgunpack = (count == 3) && (strcmp(name,"image") == 0);
|
const int imgunpack = (count == 3) && (strcmp(name,"image") == 0);
|
||||||
|
|
||||||
if ((count == 1) || imgunpack) vector = (int *) vptr;
|
if ((count == 1) || imgunpack) vector = (int *) vptr;
|
||||||
@ -3111,9 +3151,10 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
see gather() to return data ordered by consecutive atom IDs
|
see gather() to return data ordered by consecutive atom IDs
|
||||||
see gather_concat() to return data for all atoms, unordered
|
see gather_concat() to return data for all atoms, unordered
|
||||||
name = "x" , "f" or other atom properties
|
name = "x" , "f" or other atom properties
|
||||||
"d_name" or "i_name" for fix property/atom quantities
|
"f_fix", "c_compute" for fixes / computes
|
||||||
"f_fix", "c_compute" for fixes / computes
|
"d_name" or "i_name" for fix property/atom vectors with count = 1
|
||||||
will return error if fix/compute doesn't isn't atom-based
|
"d2_name" or "i2_name" for fix property/atom arrays with count > 1
|
||||||
|
will return error if fix/compute isn't atom-based
|
||||||
type = 0 for integer values, 1 for double values
|
type = 0 for integer values, 1 for double values
|
||||||
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
||||||
use count = 3 with "image" if want single image flag unpacked into xyz
|
use count = 3 with "image" if want single image flag unpacked into xyz
|
||||||
@ -3136,13 +3177,14 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
BEGIN_CAPTURE
|
BEGIN_CAPTURE
|
||||||
{
|
{
|
||||||
#if defined(LAMMPS_BIGBIG)
|
#if defined(LAMMPS_BIGBIG)
|
||||||
lmp->error->all(FLERR,"Library function lammps_gather_subset() "
|
lmp->error->all(FLERR,"Library function lammps_gather_subset() "
|
||||||
"is not compatible with -DLAMMPS_BIGBIG");
|
"is not compatible with -DLAMMPS_BIGBIG");
|
||||||
#else
|
#else
|
||||||
int i,j,m,offset,fcid,ltype;
|
int i,j,m,offset,fcid,ltype,icol;
|
||||||
tagint id;
|
tagint id;
|
||||||
|
|
||||||
// error if tags are not defined or not consecutive
|
// error if tags are not defined or not consecutive
|
||||||
|
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (lmp->atom->tag_enable == 0) flag = 1;
|
if (lmp->atom->tag_enable == 0) flag = 1;
|
||||||
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
|
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
|
||||||
@ -3154,7 +3196,9 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
|
|
||||||
void *vptr = lmp->atom->extract(name);
|
void *vptr = lmp->atom->extract(name);
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"f_") == name) { // fix
|
// fix
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"f_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_fix(&name[2]);
|
fcid = lmp->modify->find_fix(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3169,13 +3213,11 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
" fix does not return peratom data");
|
" fix does not return peratom data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
||||||
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
||||||
" count != values peratom for fix");
|
" count != values peratom for fix");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->all(FLERR,"lammps_gather_subset:"
|
lmp->error->all(FLERR,"lammps_gather_subset:"
|
||||||
@ -3187,7 +3229,9 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
// compute
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"c_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_compute(&name[2]);
|
fcid = lmp->modify->find_compute(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3214,39 +3258,56 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
|
|
||||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"d_") == name) { // property / atom
|
// property/atom
|
||||||
|
|
||||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
if ((vptr == nullptr) &&
|
||||||
|
((strstr(name,"d_") == name) || (strstr(name,"i_") == name) ||
|
||||||
|
(strstr(name,"d2_") == name) || (strstr(name,"i2_") == name))) {
|
||||||
|
|
||||||
|
if ((strstr(name,"d_") == name) || (strstr(name,"i_") == name))
|
||||||
|
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||||
|
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||||
"unknown property/atom id");
|
"unknown property/atom id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltype != type) {
|
if (ltype != type) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||||
"mismatch property/atom type");
|
"mismatch property/atom type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count != 1) {
|
if (count == 1 && icol != 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||||
"property/atom has count=1");
|
"mismatch property/atom count");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
if (count > 1 && icol != count) {
|
||||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
if (lmp->comm->me == 0)
|
||||||
|
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||||
|
"mismatch property/atom count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||||
|
} else {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->darray[fcid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (vptr == nullptr) {
|
if (vptr == nullptr) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
lmp->error->warning(FLERR,"lammps_gather_subset: undefined property name");
|
||||||
"unknown property name");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3304,6 +3365,7 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
} else {
|
} else {
|
||||||
double *vector = nullptr;
|
double *vector = nullptr;
|
||||||
double **array = nullptr;
|
double **array = nullptr;
|
||||||
|
|
||||||
if (count == 1) vector = (double *) vptr;
|
if (count == 1) vector = (double *) vptr;
|
||||||
else array = (double **) vptr;
|
else array = (double **) vptr;
|
||||||
|
|
||||||
@ -3346,9 +3408,10 @@ void lammps_gather_subset(void *handle, char *name,
|
|||||||
requirement for consecutive atom IDs (1 to N)
|
requirement for consecutive atom IDs (1 to N)
|
||||||
see scatter_subset() to scatter data for some (or all) atoms, unordered
|
see scatter_subset() to scatter data for some (or all) atoms, unordered
|
||||||
name = "x" , "f" or other atom properties
|
name = "x" , "f" or other atom properties
|
||||||
"d_name" or "i_name" for fix property/atom quantities
|
"f_fix", "c_compute" for fixes / computes
|
||||||
"f_fix", "c_compute" for fixes / computes
|
"d_name" or "i_name" for fix property/atom vectors with count = 1
|
||||||
will return error if fix/compute doesn't isn't atom-based
|
"d2_name" or "i2_name" for fix property/atom arrays with count > 1
|
||||||
|
will return error if fix/compute isn't atom-based
|
||||||
type = 0 for integer values, 1 for double values
|
type = 0 for integer values, 1 for double values
|
||||||
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
||||||
use count = 3 with "image" if want single image flag unpacked into xyz
|
use count = 3 with "image" if want single image flag unpacked into xyz
|
||||||
@ -3372,7 +3435,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
|||||||
lmp->error->all(FLERR,"Library function lammps_scatter() "
|
lmp->error->all(FLERR,"Library function lammps_scatter() "
|
||||||
"is not compatible with -DLAMMPS_BIGBIG");
|
"is not compatible with -DLAMMPS_BIGBIG");
|
||||||
#else
|
#else
|
||||||
int i,j,m,offset,fcid,ltype;
|
int i,j,m,offset,fcid,ltype,icol;
|
||||||
|
|
||||||
// error if tags are not defined or not consecutive or no atom map
|
// error if tags are not defined or not consecutive or no atom map
|
||||||
// NOTE: test that name = image or ids is not a 64-bit int in code?
|
// NOTE: test that name = image or ids is not a 64-bit int in code?
|
||||||
@ -3389,10 +3452,11 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||||
|
|
||||||
void *vptr = lmp->atom->extract(name);
|
void *vptr = lmp->atom->extract(name);
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"f_") == name) { // fix
|
// fix
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"f_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_fix(&name[2]);
|
fcid = lmp->modify->find_fix(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3418,7 +3482,9 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
|||||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
// compute
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"c_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_compute(&name[2]);
|
fcid = lmp->modify->find_compute(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3445,31 +3511,46 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
|||||||
|
|
||||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"d_") == name) { // property / atom
|
// property/atom
|
||||||
|
|
||||||
|
if ((vptr == nullptr) &&
|
||||||
|
((strstr(name,"d_") == name) || (strstr(name,"i_") == name) ||
|
||||||
|
(strstr(name,"d2_") == name) || (strstr(name,"i2_") == name))) {
|
||||||
|
|
||||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
if ((strstr(name,"d_") == name) || (strstr(name,"i_") == name))
|
||||||
|
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||||
|
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_scatter: unknown property/atom id");
|
lmp->error->warning(FLERR,"lammps_scatter: unknown property/atom id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltype != type) {
|
if (ltype != type) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_scatter: mismatch property/atom type");
|
lmp->error->warning(FLERR,"lammps_scatter: mismatch property/atom type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count != 1) {
|
if (count == 1 && icol != 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_scatter: property/atom has count=1");
|
lmp->error->warning(FLERR,"lammps_scatter: mismatch property/atom count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (count > 1 && icol != count) {
|
||||||
|
if (lmp->comm->me == 0)
|
||||||
|
lmp->error->warning(FLERR,"lammps_scatter: mismatch property/atom count");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
|
||||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||||
|
} else {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->darray[fcid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr == nullptr) {
|
if (vptr == nullptr) {
|
||||||
@ -3548,7 +3629,10 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
|||||||
data is ordered by provided atom IDs
|
data is ordered by provided atom IDs
|
||||||
no requirement for consecutive atom IDs (1 to N)
|
no requirement for consecutive atom IDs (1 to N)
|
||||||
see scatter_atoms() to scatter data for all atoms, ordered by consecutive IDs
|
see scatter_atoms() to scatter data for all atoms, ordered by consecutive IDs
|
||||||
name = desired quantity, e.g. x or charge
|
name = "x" , "f" or other atom properties
|
||||||
|
"d_name" or "i_name" for fix property/atom quantities
|
||||||
|
"f_fix", "c_compute" for fixes / computes
|
||||||
|
will return error if fix/compute doesn't isn't atom-based
|
||||||
type = 0 for integer values, 1 for double values
|
type = 0 for integer values, 1 for double values
|
||||||
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
count = # of per-atom values, e.g. 1 for type or charge, 3 for x or f
|
||||||
use count = 3 with "image" for xyz to be packed into single image flag
|
use count = 3 with "image" for xyz to be packed into single image flag
|
||||||
@ -3572,7 +3656,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
|||||||
lmp->error->all(FLERR,"Library function lammps_scatter_subset() "
|
lmp->error->all(FLERR,"Library function lammps_scatter_subset() "
|
||||||
"is not compatible with -DLAMMPS_BIGBIG");
|
"is not compatible with -DLAMMPS_BIGBIG");
|
||||||
#else
|
#else
|
||||||
int i,j,m,offset,fcid,ltype;
|
int i,j,m,offset,fcid,ltype,icol;
|
||||||
tagint id;
|
tagint id;
|
||||||
|
|
||||||
// error if tags are not defined or no atom map
|
// error if tags are not defined or no atom map
|
||||||
@ -3590,7 +3674,9 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
|||||||
|
|
||||||
void *vptr = lmp->atom->extract(name);
|
void *vptr = lmp->atom->extract(name);
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"f_") == name) { // fix
|
// fix
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"f_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_fix(&name[2]);
|
fcid = lmp->modify->find_fix(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3616,7 +3702,9 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
|||||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
// compute
|
||||||
|
|
||||||
|
if (vptr==nullptr && strstr(name,"c_") == name) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_compute(&name[2]);
|
fcid = lmp->modify->find_compute(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3645,29 +3733,46 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
|||||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr==nullptr && strstr(name,"d_") == name) { // property / atom
|
// property/atom
|
||||||
|
|
||||||
|
if ((vptr == nullptr) &&
|
||||||
|
((strstr(name,"d_") == name) || (strstr(name,"i_") == name) ||
|
||||||
|
(strstr(name,"d2_") == name) || (strstr(name,"i2_") == name))) {
|
||||||
|
|
||||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
if ((strstr(name,"d_") == name) || (strstr(name,"i_") == name))
|
||||||
|
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||||
|
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
||||||
"unknown property/atom id");
|
"unknown property/atom id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltype != type) {
|
if (ltype != type) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
||||||
"mismatch property/atom type");
|
"mismatch property/atom type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count != 1) {
|
if (count == 1 && icol != 0) {
|
||||||
if (lmp->comm->me == 0)
|
if (lmp->comm->me == 0)
|
||||||
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom count");
|
||||||
"property/atom has count=1");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
if (count > 1 && icol != count) {
|
||||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
if (lmp->comm->me == 0)
|
||||||
|
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 1) {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||||
|
} else {
|
||||||
|
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||||
|
else vptr = (void *) lmp->atom->darray[fcid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vptr == nullptr) {
|
if (vptr == nullptr) {
|
||||||
|
|||||||
@ -579,8 +579,8 @@ void Set::command(int narg, char **arg)
|
|||||||
int which = 0;
|
int which = 0;
|
||||||
if (arg[iarg][0] == 'd') which = 1;
|
if (arg[iarg][0] == 'd') which = 1;
|
||||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1);
|
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1);
|
||||||
else if (!which) ivalue = force->inumeric(FLERR,arg[iarg+1]);
|
else if (!which) ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
else dvalue = force->numeric(FLERR,arg[iarg+1]);
|
else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
|
|
||||||
int flag,cols;
|
int flag,cols;
|
||||||
index_custom = atom->find_custom(&arg[iarg][2],flag,cols);
|
index_custom = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||||
@ -599,8 +599,8 @@ void Set::command(int narg, char **arg)
|
|||||||
int which = 0;
|
int which = 0;
|
||||||
if (arg[iarg][0] == 'd') which = 1;
|
if (arg[iarg][0] == 'd') which = 1;
|
||||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1);
|
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) varparse(arg[iarg+1],1);
|
||||||
else if (!which) ivalue = force->inumeric(FLERR,arg[iarg+1]);
|
else if (!which) ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
else dvalue = force->numeric(FLERR,arg[iarg+1]);
|
else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
|
|
||||||
int n = strlen(arg[iarg]);
|
int n = strlen(arg[iarg]);
|
||||||
char *suffix = new char[n];
|
char *suffix = new char[n];
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include "atom.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "compute.h"
|
#include "compute.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
@ -503,7 +504,7 @@ int utils::expand_args(const char *file, int line, int narg, char **arg,
|
|||||||
} else if (arg[iarg][0] == 'i') {
|
} else if (arg[iarg][0] == 'i') {
|
||||||
*ptr1 = '\0';
|
*ptr1 = '\0';
|
||||||
int flag,cols;
|
int flag,cols;
|
||||||
int icustom = atom->find_custom(&arg[iarg][3],flag,cols);
|
int icustom = lmp->atom->find_custom(&arg[iarg][3],flag,cols);
|
||||||
*ptr1 = '[';
|
*ptr1 = '[';
|
||||||
|
|
||||||
// check for custom per-atom integer array
|
// check for custom per-atom integer array
|
||||||
@ -518,7 +519,7 @@ int utils::expand_args(const char *file, int line, int narg, char **arg,
|
|||||||
} else if (arg[iarg][0] == 'd') {
|
} else if (arg[iarg][0] == 'd') {
|
||||||
*ptr1 = '\0';
|
*ptr1 = '\0';
|
||||||
int flag,cols;
|
int flag,cols;
|
||||||
int icustom = atom->find_custom(&arg[iarg][3],flag,cols);
|
int icustom = lmp->atom->find_custom(&arg[iarg][3],flag,cols);
|
||||||
*ptr1 = '[';
|
*ptr1 = '[';
|
||||||
|
|
||||||
// check for custom per-atom floating point array
|
// check for custom per-atom floating point array
|
||||||
|
|||||||
Reference in New Issue
Block a user