simplify code. print warnings only on MPI rank 0. update parameter names
This commit is contained in:
291
src/library.cpp
291
src/library.cpp
@ -1938,25 +1938,16 @@ int lammps_set_variable(void *handle, char *name, char *str)
|
||||
Allreduce to sum vector into data across all procs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_gather_atoms(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_atoms() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_gather_atoms(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int i,j,offset;
|
||||
|
||||
// error if tags are not defined or not consecutive
|
||||
@ -1976,6 +1967,7 @@ void lammps_gather_atoms(void *handle, char *name, int type, int count, void *da
|
||||
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
if (vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_atoms: unknown property name");
|
||||
return;
|
||||
}
|
||||
@ -2051,13 +2043,14 @@ void lammps_gather_atoms(void *handle, char *name, int type, int count, void *da
|
||||
MPI_Allreduce(copy,data,count*natoms,MPI_DOUBLE,MPI_SUM,lmp->world);
|
||||
lmp->memory->destroy(copy);
|
||||
} else {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_atoms: unsupported data type");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
gather the named atom-based entity for all atoms
|
||||
@ -2080,25 +2073,16 @@ void lammps_gather_atoms(void *handle, char *name, int type, int count, void *da
|
||||
Allgather Nlocal atoms from each proc into data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_atoms_concat() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int i,offset;
|
||||
|
||||
// error if tags are not defined
|
||||
@ -2117,6 +2101,7 @@ void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, v
|
||||
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
if (vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_atoms: unknown property name");
|
||||
return;
|
||||
}
|
||||
@ -2209,10 +2194,10 @@ void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, v
|
||||
|
||||
lmp->memory->destroy(recvcounts);
|
||||
lmp->memory->destroy(displs);
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
gather the named atom-based entity for a subset of atoms
|
||||
@ -2237,7 +2222,6 @@ void lammps_gather_atoms_concat(void *handle, char *name, int type, int count, v
|
||||
Allreduce to sum vector into data across all procs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_gather_atoms_subset(void *handle, char *name, int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
@ -2245,20 +2229,10 @@ void lammps_gather_atoms_subset(void *handle, char *name, int type, int count,
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_atoms_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_gather_atoms_subset(void *handle, char *name,
|
||||
int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int i,j,m,offset;
|
||||
tagint id;
|
||||
|
||||
@ -2276,6 +2250,7 @@ void lammps_gather_atoms_subset(void *handle, char *name,
|
||||
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
if (vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_atoms_subset: "
|
||||
"unknown property name");
|
||||
return;
|
||||
@ -2365,10 +2340,10 @@ void lammps_gather_atoms_subset(void *handle, char *name,
|
||||
MPI_Allreduce(copy,data,count*ndata,MPI_DOUBLE,MPI_SUM,lmp->world);
|
||||
lmp->memory->destroy(copy);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
scatter the named atom-based entity in data to all atoms
|
||||
@ -2386,26 +2361,16 @@ void lammps_gather_atoms_subset(void *handle, char *name,
|
||||
loop over Natoms, if I own atom ID, set its values from data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_scatter_atoms(void *handle, char * name, int type, int count, void *data)
|
||||
void lammps_scatter_atoms(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter_atoms() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_scatter_atoms(void *handle, char *name,
|
||||
int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int i,j,m,offset;
|
||||
|
||||
// error if tags are not defined or not consecutive or no atom map
|
||||
@ -2426,6 +2391,7 @@ void lammps_scatter_atoms(void *handle, char *name,
|
||||
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
if(vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,
|
||||
"lammps_scatter_atoms: unknown property name");
|
||||
return;
|
||||
@ -2490,10 +2456,10 @@ void lammps_scatter_atoms(void *handle, char *name,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
scatter the named atom-based entity in data to a subset of atoms
|
||||
@ -2513,29 +2479,17 @@ void lammps_scatter_atoms(void *handle, char *name,
|
||||
loop over Ndata, if I own atom ID, set its values from data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_scatter_atoms_subset(void *handle, char * /*name */,
|
||||
int /*type*/, int /*count*/,
|
||||
int /*ndata*/, int * /*ids*/, void * /*data*/)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter_atoms_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_scatter_atoms_subset(void *handle, char *name,
|
||||
int type, int count,
|
||||
void lammps_scatter_atoms_subset(void *handle, char *name, int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter_atoms_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,m,offset;
|
||||
tagint id;
|
||||
|
||||
@ -2554,6 +2508,7 @@ void lammps_scatter_atoms_subset(void *handle, char *name,
|
||||
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
if(vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,
|
||||
"lammps_scatter_atoms_subset: unknown property name");
|
||||
return;
|
||||
@ -2627,10 +2582,10 @@ void lammps_scatter_atoms_subset(void *handle, char *name,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Thomas Swinburne (CNRS & CINaM, Marseille, France)
|
||||
@ -2656,26 +2611,17 @@ void lammps_scatter_atoms_subset(void *handle, char *name,
|
||||
loop over Nlocal to fill vector with my values
|
||||
Allreduce to sum vector into data across all procs
|
||||
------------------------------------------------------------------------- */
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_gather(void *ptr, char * /*name*/, int /*type*/,
|
||||
int /*count*/, void * /*data*/)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->error->all(FLERR,"Library function lammps_gather"
|
||||
" not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather"
|
||||
" not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,offset,fcid,ltype;
|
||||
|
||||
// error if tags are not defined or not consecutive
|
||||
@ -2697,22 +2643,26 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" fix does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" count != values peratom for fix");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->all(FLERR,"lammps_gather:"
|
||||
" fix not computed at compatible time");
|
||||
return;
|
||||
@ -2720,24 +2670,25 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
|
||||
if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" compute does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->compute[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" count != values peratom for compute");
|
||||
return;
|
||||
@ -2754,28 +2705,28 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
// property / atom
|
||||
if ( (vptr == nullptr) && ((strstr(name,"d_") == name)
|
||||
|| (strstr(name,"i_") == name)) ) {
|
||||
|
||||
|
||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown property/atom id");
|
||||
return;
|
||||
}
|
||||
if (ltype != type) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count != 1) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: property/atom has count=1");
|
||||
return;
|
||||
}
|
||||
if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown property name");
|
||||
return;
|
||||
}
|
||||
@ -2850,10 +2801,10 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
MPI_Allreduce(copy,data,count*natoms,MPI_DOUBLE,MPI_SUM,lmp->world);
|
||||
lmp->memory->destroy(copy);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Thomas Swinburne (CNRS & CINaM, Marseille, France)
|
||||
@ -2879,26 +2830,17 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
loop over Nlocal to fill vector with my values
|
||||
Allreduce to sum vector into data across all procs
|
||||
------------------------------------------------------------------------- */
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_gather_concat(void *ptr, 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 *) ptr;
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_concat"
|
||||
" not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int i,offset,fcid,ltype;
|
||||
|
||||
// error if tags are not defined or not consecutive
|
||||
@ -2920,16 +2862,19 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat:"
|
||||
" fix does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat:"
|
||||
" count != values peratom for fix");
|
||||
return;
|
||||
@ -2937,6 +2882,7 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
|
||||
|
||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->all(FLERR,"lammps_gather_concat:"
|
||||
" fix not computed at compatible time");
|
||||
return;
|
||||
@ -2944,24 +2890,25 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
|
||||
if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat:"
|
||||
" compute does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->compute[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat:"
|
||||
" count != values peratom for compute");
|
||||
return;
|
||||
@ -2980,16 +2927,19 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
|
||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||
"unknown property/atom id");
|
||||
return;
|
||||
}
|
||||
if (ltype != type) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||
"mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count != 1) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: "
|
||||
"property/atom has count=1");
|
||||
return;
|
||||
@ -3000,6 +2950,7 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
}
|
||||
|
||||
if (vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: unknown property name");
|
||||
return;
|
||||
}
|
||||
@ -3092,10 +3043,10 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
|
||||
lmp->memory->destroy(recvcounts);
|
||||
lmp->memory->destroy(displs);
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Thomas Swinburne (CNRS & CINaM, Marseille, France)
|
||||
@ -3121,29 +3072,19 @@ void lammps_gather_concat(void *ptr, char *name, int type, int count, void *data
|
||||
loop over Nlocal to fill vector with my values
|
||||
Allreduce to sum vector into data across all procs
|
||||
------------------------------------------------------------------------- */
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_gather_subset(void *ptr, char * /*name */,
|
||||
int /*type*/, int /*count*/,
|
||||
int /*ndata*/, int * /*ids*/, void * /*data*/)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_gather_subset(void *ptr, char *name,
|
||||
void lammps_gather_subset(void *handle, char *name,
|
||||
int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,m,offset,fcid,ltype;
|
||||
tagint id;
|
||||
|
||||
@ -3163,23 +3104,26 @@ void lammps_gather_subset(void *ptr, char *name,
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
||||
" fix does not return peratom data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
||||
" count != values peratom for fix");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->all(FLERR,"lammps_gather_subset:"
|
||||
" fix not computed at compatible time");
|
||||
return;
|
||||
@ -3187,24 +3131,25 @@ void lammps_gather_subset(void *ptr, char *name,
|
||||
|
||||
if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
||||
" compute does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->compute[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
||||
" count != values peratom for compute");
|
||||
return;
|
||||
@ -3223,26 +3168,29 @@ void lammps_gather_subset(void *ptr, char *name,
|
||||
|
||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||
"unknown property/atom id");
|
||||
return;
|
||||
}
|
||||
if (ltype != type) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||
"mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count != 1) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||
"property/atom has count=1");
|
||||
return;
|
||||
}
|
||||
if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
|
||||
}
|
||||
|
||||
if (vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: "
|
||||
"unknown property name");
|
||||
return;
|
||||
@ -3360,27 +3308,16 @@ void lammps_gather_subset(void *ptr, char *name,
|
||||
Allreduce to sum vector into data across all procs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_scatter(void *ptr, char * /*name */,
|
||||
int /*type*/, int /*count*/, void * /*data*/)
|
||||
void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_scatter(void *ptr, char *name,
|
||||
int type, int count, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int i,j,m,offset,fcid,ltype;
|
||||
|
||||
// error if tags are not defined or not consecutive or no atom map
|
||||
@ -3405,16 +3342,19 @@ void lammps_scatter(void *ptr, char *name,
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" fix does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" count != values peratom for fix");
|
||||
return;
|
||||
@ -3422,24 +3362,25 @@ void lammps_scatter(void *ptr, char *name,
|
||||
|
||||
if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" compute does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->compute[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" count != values peratom for compute");
|
||||
return;
|
||||
@ -3458,14 +3399,17 @@ void lammps_scatter(void *ptr, char *name,
|
||||
|
||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown property/atom id");
|
||||
return;
|
||||
}
|
||||
if (ltype != type) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count != 1) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: property/atom has count=1");
|
||||
return;
|
||||
}
|
||||
@ -3475,6 +3419,7 @@ void lammps_scatter(void *ptr, char *name,
|
||||
}
|
||||
|
||||
if(vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown property name");
|
||||
return;
|
||||
}
|
||||
@ -3538,10 +3483,10 @@ void lammps_scatter(void *ptr, char *name,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Thomas Swinburne (CNRS & CINaM, Marseille, France)
|
||||
@ -3562,29 +3507,17 @@ void lammps_scatter(void *ptr, char *name,
|
||||
loop over Ndata, if I own atom ID, set its values from data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
void lammps_scatter_subset(void *ptr, char * /*name */,
|
||||
int /*type*/, int /*count*/,
|
||||
int /*ndata*/, int * /*ids*/, void * /*data*/)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#else
|
||||
void lammps_scatter_subset(void *ptr, char *name,
|
||||
int type, int count,
|
||||
void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
||||
int ndata, int *ids, void *data)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,m,offset,fcid,ltype;
|
||||
tagint id;
|
||||
|
||||
@ -3607,16 +3540,19 @@ void lammps_scatter_subset(void *ptr, char *name,
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" fix does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->fix[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" count != values peratom for fix");
|
||||
return;
|
||||
@ -3624,24 +3560,25 @@ void lammps_scatter_subset(void *ptr, char *name,
|
||||
|
||||
if(count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (vptr==nullptr && strstr(name,"c_") == name) { // compute
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" compute does not return peratom data");
|
||||
return;
|
||||
}
|
||||
if (count>1 && lmp->modify->compute[fcid]->size_peratom_cols != count) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" count != values peratom for compute");
|
||||
return;
|
||||
@ -3652,34 +3589,35 @@ void lammps_scatter_subset(void *ptr, char *name,
|
||||
|
||||
if(count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (vptr==nullptr && strstr(name,"d_") == name) { // property / atom
|
||||
|
||||
fcid = lmp->atom->find_custom(&name[2], ltype);
|
||||
if (fcid < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
||||
"unknown property/atom id");
|
||||
return;
|
||||
}
|
||||
if (ltype != type) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
||||
"mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count != 1) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: "
|
||||
"property/atom has count=1");
|
||||
return;
|
||||
}
|
||||
if(ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
|
||||
}
|
||||
|
||||
if(vptr == nullptr) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_atoms_subset: "
|
||||
"unknown property name");
|
||||
return;
|
||||
@ -3753,10 +3691,10 @@ void lammps_scatter_subset(void *ptr, char *name,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
END_CAPTURE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -3835,7 +3773,7 @@ int lammps_create_atoms(void *handle, int n, tagint *id, int *type,
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (lmp->comm->me == 0) lmp->error->warning(FLERR,msg.c_str());
|
||||
if (lmp->comm->me == 0) lmp->error->warning(FLERR,msg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3926,8 +3864,8 @@ int lammps_create_atoms(void *handle, int n, tagint *id, int *type,
|
||||
* \param request request index that specifies which neighbor list should be
|
||||
* returned, in case there are multiple neighbor lists requests
|
||||
* for the found pair style
|
||||
* \return return neighbor list index if found, otherwise -1
|
||||
*/
|
||||
* \return return neighbor list index if found, otherwise -1 */
|
||||
|
||||
int lammps_find_pair_neighlist(void* handle, char * style, int exact, int nsub, int request) {
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
Pair* pair = lmp->force->pair_match(style, exact, nsub);
|
||||
@ -3954,9 +3892,9 @@ int lammps_find_pair_neighlist(void* handle, char * style, int exact, int nsub,
|
||||
* \param id Identifier of fix instance
|
||||
* \param request request index that specifies which request should be returned,
|
||||
* in case there are multiple neighbor lists for this fix
|
||||
* \return return neighbor list index if found, otherwise -1
|
||||
*/
|
||||
int lammps_find_fix_neighlist(void* handle, char * id, int request) {
|
||||
* \return return neighbor list index if found, otherwise -1 */
|
||||
|
||||
int lammps_find_fix_neighlist(void* handle, char *id, int request) {
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
Fix* fix = nullptr;
|
||||
const int nfix = lmp->modify->nfix;
|
||||
@ -3991,9 +3929,9 @@ int lammps_find_fix_neighlist(void* handle, char * id, int request) {
|
||||
* \param id Identifier of fix instance
|
||||
* \param request request index that specifies which request should be returned,
|
||||
* in case there are multiple neighbor lists for this fix
|
||||
* \return return neighbor list index if found, otherwise -1
|
||||
*/
|
||||
int lammps_find_compute_neighlist(void* handle, char * id, int request) {
|
||||
* \return return neighbor list index if found, otherwise -1 */
|
||||
|
||||
int lammps_find_compute_neighlist(void* handle, char *id, int request) {
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
Compute* compute = nullptr;
|
||||
const int ncompute = lmp->modify->ncompute;
|
||||
@ -4029,7 +3967,7 @@ int lammps_find_compute_neighlist(void* handle, char * id, int request) {
|
||||
* \return return number of entries in neighbor list, -1 if idx is
|
||||
* not a valid index
|
||||
*/
|
||||
int lammps_neighlist_num_elements(void * handle, int idx) {
|
||||
int lammps_neighlist_num_elements(void *handle, int idx) {
|
||||
LAMMPS * lmp = (LAMMPS *) handle;
|
||||
Neighbor * neighbor = lmp->neighbor;
|
||||
|
||||
@ -4052,10 +3990,9 @@ int lammps_neighlist_num_elements(void * handle, int idx) {
|
||||
* \param[out] iatom local atom index (i.e. in the range [0, nlocal + nghost), -1 if
|
||||
invalid idx or element value
|
||||
* \param[out] numneigh number of neighbors of atom iatom or 0
|
||||
* \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) {
|
||||
* \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;
|
||||
Neighbor * neighbor = lmp->neighbor;
|
||||
*iatom = -1;
|
||||
|
||||
@ -171,11 +171,11 @@ int lammps_create_atoms(void *handle, int n, int64_t *id, int *type,
|
||||
* Library functions for accessing neighbor lists
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
int lammps_find_pair_neighlist(void*, char *, int, int, int);
|
||||
int lammps_find_fix_neighlist(void*, char *, int);
|
||||
int lammps_find_compute_neighlist(void*, char *, int);
|
||||
int lammps_neighlist_num_elements(void*, int);
|
||||
void lammps_neighlist_element_neighbors(void *, int, int, int *, int *, int ** );
|
||||
int lammps_find_pair_neighlist(void *handle, char *style, int exact, int nsub, int request);
|
||||
int lammps_find_fix_neighlist(void *handle, char *id, int request);
|
||||
int lammps_find_compute_neighlist(void *handle, char *id, int request);
|
||||
int lammps_neighlist_num_elements(void *handle, int idx);
|
||||
void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int *iatom, int *numneigh, int **neighbors);
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Library functions for retrieving configuration information
|
||||
|
||||
Reference in New Issue
Block a user