use get_(fix|compute)_by_id() instead of find_(fix|compute)()
This commit is contained in:
40
src/info.cpp
40
src/info.cpp
@ -566,16 +566,13 @@ void Info::command(int narg, char **arg)
|
||||
}
|
||||
|
||||
if (flags & COMPUTES) {
|
||||
int ncompute = modify->ncompute;
|
||||
Compute **compute = modify->compute;
|
||||
int i = 0;
|
||||
char **names = group->names;
|
||||
fputs("\nCompute information:\n",out);
|
||||
for (int i=0; i < ncompute; ++i) {
|
||||
fmt::print(out,"Compute[{:3d}]: {:16} style = {:16} group = {}\n",
|
||||
i, std::string(compute[i]->id)+',',
|
||||
std::string(compute[i]->style)+',',
|
||||
names[compute[i]->igroup]);
|
||||
}
|
||||
for (auto compute : modify->get_compute_list())
|
||||
fmt::print(out,"Compute[{:3d}]: {:16} style = {:16} group = {}\n", i++,
|
||||
std::string(compute->id)+',',std::string(compute->style)+',',
|
||||
names[compute->igroup]);
|
||||
}
|
||||
|
||||
if (flags & DUMPS) {
|
||||
@ -587,10 +584,8 @@ void Info::command(int narg, char **arg)
|
||||
fputs("\nDump information:\n",out);
|
||||
for (int i=0; i < ndump; ++i) {
|
||||
fmt::print(out,"Dump[{:3d}]: {:16} file = {:16} style = {:16} group = {:16} ",
|
||||
i, std::string(dump[i]->id)+',',
|
||||
std::string(dump[i]->filename)+',',
|
||||
std::string(dump[i]->style)+',',
|
||||
std::string(names[dump[i]->igroup])+',');
|
||||
i, std::string(dump[i]->id)+',',std::string(dump[i]->filename)+',',
|
||||
std::string(dump[i]->style)+',',std::string(names[dump[i]->igroup])+',');
|
||||
if (nevery[i]) {
|
||||
fmt::print(out,"every = {}\n", nevery[i]);
|
||||
} else {
|
||||
@ -600,16 +595,12 @@ void Info::command(int narg, char **arg)
|
||||
}
|
||||
|
||||
if (flags & FIXES) {
|
||||
int nfix = modify->nfix;
|
||||
Fix **fix = modify->fix;
|
||||
int i = 0;
|
||||
char **names = group->names;
|
||||
fputs("\nFix information:\n",out);
|
||||
for (int i=0; i < nfix; ++i) {
|
||||
fmt::print(out, "Fix[{:3d}]: {:16} style = {:16} group = {}\n",
|
||||
i,std::string(fix[i]->id)+',',
|
||||
std::string(fix[i]->style)+',',
|
||||
names[fix[i]->igroup]);
|
||||
}
|
||||
for (auto fix : modify->get_fix_list())
|
||||
fmt::print(out, "Fix[{:3d}]: {:16} style = {:16} group = {}\n",i++,
|
||||
std::string(fix->id)+',',std::string(fix->style)+',',names[fix->igroup]);
|
||||
}
|
||||
|
||||
if (flags & VARIABLES) {
|
||||
@ -621,8 +612,7 @@ void Info::command(int narg, char **arg)
|
||||
for (int i=0; i < nvar; ++i) {
|
||||
int ndata = 1;
|
||||
fmt::print(out,"Variable[{:3d}]: {:16} style = {:16} def =",
|
||||
i,std::string(names[i])+',',
|
||||
std::string(varstyles[style[i]])+',');
|
||||
i,std::string(names[i])+',',std::string(varstyles[style[i]])+',');
|
||||
if (style[i] == Variable::INTERNAL) {
|
||||
fmt::print(out,"{:.8}\n",input->variable->dvalue[i]);
|
||||
continue;
|
||||
@ -797,13 +787,13 @@ bool Info::is_active(const char *category, const char *name)
|
||||
|
||||
if (strcmp(category,"package") == 0) {
|
||||
if (strcmp(name,"gpu") == 0) {
|
||||
return (modify->find_fix("package_gpu") >= 0) ? true : false;
|
||||
return (modify->get_fix_by_id("package_gpu")) ? true : false;
|
||||
} else if (strcmp(name,"intel") == 0) {
|
||||
return (modify->find_fix("package_intel") >= 0) ? true : false;
|
||||
return (modify->get_fix_by_id("package_intel")) ? true : false;
|
||||
} else if (strcmp(name,"kokkos") == 0) {
|
||||
return (lmp->kokkos && lmp->kokkos->kokkos_exists) ? true : false;
|
||||
} else if (strcmp(name,"omp") == 0) {
|
||||
return (modify->find_fix("package_omp") >= 0) ? true : false;
|
||||
return (modify->get_fix_by_id("package_omp")) ? true : false;
|
||||
} else error->all(FLERR,"Unknown name for info package category: {}", name);
|
||||
|
||||
} else if (strcmp(category,"newton") == 0) {
|
||||
|
||||
366
src/library.cpp
366
src/library.cpp
@ -1689,9 +1689,8 @@ void *lammps_extract_compute(void *handle, const char *id, int style, int type)
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int icompute = lmp->modify->find_compute(id);
|
||||
if (icompute < 0) return nullptr;
|
||||
Compute *compute = lmp->modify->compute[icompute];
|
||||
auto compute = lmp->modify->get_compute_by_id(id);
|
||||
if (!compute) return nullptr;
|
||||
|
||||
if (style == LMP_STYLE_GLOBAL) {
|
||||
if (type == LMP_TYPE_SCALAR) {
|
||||
@ -1876,9 +1875,8 @@ void *lammps_extract_fix(void *handle, const char *id, int style, int type,
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0) return nullptr;
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) return nullptr;
|
||||
|
||||
if (style == LMP_STYLE_GLOBAL) {
|
||||
if (type == LMP_TYPE_SCALAR) {
|
||||
@ -2868,10 +2866,9 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
lmp->error->all(FLERR,"Library function lammps_gather"
|
||||
" not compatible with -DLAMMPS_BIGBIG");
|
||||
lmp->error->all(FLERR,"Library function lammps_gather not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,offset,fcid,ltype,icol;
|
||||
int i,j,offset,ltype;
|
||||
|
||||
// error if tags are not defined or not consecutive
|
||||
|
||||
@ -2892,76 +2889,72 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^f_")) {
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto fix = lmp->modify->get_fix_by_id(&name[2]);
|
||||
if (!fix) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (fix->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" fix does not return peratom data");
|
||||
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 ((count > 1) && (fix->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" count != values peratom for fix");
|
||||
lmp->error->warning(FLERR,"lammps_gather: count != values peratom for fix");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||
if (lmp->update->ntimestep % fix->peratom_freq) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->all(FLERR,"lammps_gather:"
|
||||
" fix not computed at compatible time");
|
||||
lmp->error->all(FLERR,"lammps_gather: fix not computed at compatible time");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) fix->vector_atom;
|
||||
else vptr = (void *) fix->array_atom;
|
||||
}
|
||||
|
||||
// compute
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^c_")) {
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto compute = lmp->modify->get_compute_by_id(&name[2]);
|
||||
if (!compute) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (compute->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" compute does not return peratom data");
|
||||
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 ((count > 1) && (compute->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather:"
|
||||
" count != values peratom for compute");
|
||||
lmp->error->warning(FLERR,"lammps_gather: count != values peratom for compute");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep)
|
||||
lmp->modify->compute[fcid]->compute_peratom();
|
||||
if (compute->invoked_peratom != lmp->update->ntimestep)
|
||||
compute->compute_peratom();
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) compute->vector_atom;
|
||||
else vptr = (void *) compute->array_atom;
|
||||
}
|
||||
|
||||
// custom fix property/atom vector or array
|
||||
|
||||
if ((vptr == nullptr) && utils::strmatch(name,"^[id]2?_")) {
|
||||
|
||||
if (utils::strmatch(name,"^[id]_")) fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
int idx,icol;
|
||||
if (utils::strmatch(name,"^[id]_")) idx = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else idx = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
|
||||
if (fcid < 0) {
|
||||
if (idx < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: unknown property/atom id");
|
||||
return;
|
||||
@ -2972,23 +2965,23 @@ void lammps_gather(void *handle, char *name, int type, int count, void *data)
|
||||
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count == 1 && icol != 0) {
|
||||
if ((count == 1) && (icol != 0)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather: mismatch property/atom count");
|
||||
return;
|
||||
}
|
||||
if (count > 1 && icol != count) {
|
||||
if ((count > 1) && (icol != count)) {
|
||||
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];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[idx];
|
||||
else vptr = (void *) lmp->atom->dvector[idx];
|
||||
} else {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||
else vptr = (void *) lmp->atom->darray[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[idx];
|
||||
else vptr = (void *) lmp->atom->darray[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -3111,7 +3104,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_concat"
|
||||
" not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,offset,fcid,ltype,icol;
|
||||
int i,offset,ltype;
|
||||
|
||||
// error if tags are not defined or not consecutive
|
||||
|
||||
@ -3131,70 +3124,71 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^f_")) {
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto fix = lmp->modify->get_fix_by_id(&name[2]);
|
||||
if (!fix) {
|
||||
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 (fix->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 ((count > 1) && (fix->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: count != values peratom for fix");
|
||||
return;
|
||||
}
|
||||
if (lmp->update->ntimestep % lmp->modify->fix[fcid]->peratom_freq) {
|
||||
if (lmp->update->ntimestep % fix->peratom_freq) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->all(FLERR,"lammps_gather_concat: fix not computed at compatible time");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) fix->vector_atom;
|
||||
else vptr = (void *) fix->array_atom;
|
||||
}
|
||||
|
||||
// compute
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^c_")) {
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto compute = lmp->modify->get_compute_by_id(&name[2]);
|
||||
if (!compute) {
|
||||
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 (compute->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 ((count > 1) && (compute->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: count != values peratom for compute");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep)
|
||||
lmp->modify->compute[fcid]->compute_peratom();
|
||||
if (compute->invoked_peratom != lmp->update->ntimestep)
|
||||
compute->compute_peratom();
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) compute->vector_atom;
|
||||
else vptr = (void *) compute->array_atom;
|
||||
}
|
||||
|
||||
// custom per-atom vector or array
|
||||
|
||||
if ((vptr==nullptr) && utils::strmatch(name,"^[id]2?_")) {
|
||||
|
||||
if (utils::strmatch(name,"^[id]_")) fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
int idx,icol;
|
||||
if (utils::strmatch(name,"^[id]_")) idx = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else idx = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
|
||||
if (fcid < 0) {
|
||||
if (idx < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: unknown property/atom id");
|
||||
return;
|
||||
@ -3205,23 +3199,23 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: mismatch property/atom type");
|
||||
return;
|
||||
}
|
||||
if (count == 1 && icol != 0) {
|
||||
if ((count == 1) && (icol != 0)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: mismatch property/atom count");
|
||||
return;
|
||||
}
|
||||
if (count > 1 && icol != count) {
|
||||
if ((count > 1) && (icol != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_concat: mismatch property/atom count");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[idx];
|
||||
else vptr = (void *) lmp->atom->dvector[idx];
|
||||
} else {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||
else vptr = (void *) lmp->atom->darray[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[idx];
|
||||
else vptr = (void *) lmp->atom->darray[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -3364,7 +3358,7 @@ void lammps_gather_subset(void *handle, char *name,
|
||||
lmp->error->all(FLERR,"Library function lammps_gather_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,m,offset,fcid,ltype,icol;
|
||||
int i,j,m,offset,ltype;
|
||||
tagint id;
|
||||
|
||||
// error if tags are not defined or not consecutive
|
||||
@ -3384,71 +3378,70 @@ void lammps_gather_subset(void *handle, char *name,
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^f_")) {
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto fix = lmp->modify->get_fix_by_id(&name[2]);
|
||||
if (!fix) {
|
||||
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 (fix->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset:"
|
||||
" fix does not return peratom data");
|
||||
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) {
|
||||
if ((count > 1) && (fix->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->update->ntimestep % fix->peratom_freq) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->all(FLERR,"lammps_gather_subset: fix not computed at compatible time");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) fix->vector_atom;
|
||||
else vptr = (void *) fix->array_atom;
|
||||
}
|
||||
|
||||
// compute
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^c_")) {
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto compute = lmp->modify->get_compute_by_id(&name[2]);
|
||||
if (!compute) {
|
||||
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 (compute->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 ((count > 1) && (compute->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: count != values peratom for compute");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep)
|
||||
lmp->modify->compute[fcid]->compute_peratom();
|
||||
if (compute->invoked_peratom != lmp->update->ntimestep)
|
||||
compute->compute_peratom();
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) compute->vector_atom;
|
||||
else vptr = (void *) compute->array_atom;
|
||||
}
|
||||
|
||||
// custom fix property/atom vector or array
|
||||
|
||||
if ((vptr == nullptr) && utils::strmatch(name,"^[id]2?_")) {
|
||||
|
||||
if (utils::strmatch(name,"^[id]_"))
|
||||
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
int idx,icol;
|
||||
if (utils::strmatch(name,"^[id]_")) idx = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else idx = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
|
||||
if (fcid < 0) {
|
||||
if (idx < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_gather_subset: unknown property/atom id");
|
||||
return;
|
||||
@ -3471,11 +3464,11 @@ void lammps_gather_subset(void *handle, char *name,
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[idx];
|
||||
else vptr = (void *) lmp->atom->dvector[idx];
|
||||
} else {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||
else vptr = (void *) lmp->atom->darray[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[idx];
|
||||
else vptr = (void *) lmp->atom->darray[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -3611,7 +3604,7 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,m,offset,fcid,ltype,icol;
|
||||
int i,j,m,offset,ltype;
|
||||
|
||||
// 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?
|
||||
@ -3634,70 +3627,66 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^f_")) {
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto fix = lmp->modify->get_fix_by_id(&name[2]);
|
||||
if (!fix) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown fix id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->fix[fcid]->peratom_flag == 0) {
|
||||
if (fix->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" fix does not return peratom data");
|
||||
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 ((count > 1) && (fix->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" count != values peratom for fix");
|
||||
lmp->error->warning(FLERR,"lammps_scatter: count != values peratom for fix");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) fix->vector_atom;
|
||||
else vptr = (void *) fix->array_atom;
|
||||
}
|
||||
|
||||
// compute
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^c_")) {
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto compute = lmp->modify->get_compute_by_id(&name[2]);
|
||||
if (!compute) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown compute id");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->peratom_flag == 0) {
|
||||
if (compute->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" compute does not return peratom data");
|
||||
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 ((count > 1) && (compute->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter:"
|
||||
" count != values peratom for compute");
|
||||
lmp->error->warning(FLERR,"lammps_scatter: count != values peratom for compute");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep)
|
||||
lmp->modify->compute[fcid]->compute_peratom();
|
||||
if (compute->invoked_peratom != lmp->update->ntimestep)
|
||||
compute->compute_peratom();
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) compute->vector_atom;
|
||||
else vptr = (void *) compute->array_atom;
|
||||
}
|
||||
|
||||
// custom fix property/atom vector or array
|
||||
|
||||
if ((vptr == nullptr) && utils::strmatch(name,"^[id]2?_")) {
|
||||
|
||||
if (utils::strmatch(name,"^[id]_"))
|
||||
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
int idx,icol;
|
||||
if (utils::strmatch(name,"^[id]_")) idx = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else idx = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
|
||||
if (fcid < 0) {
|
||||
if (idx < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter: unknown property/atom id");
|
||||
return;
|
||||
@ -3720,11 +3709,11 @@ void lammps_scatter(void *handle, char *name, int type, int count, void *data)
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[idx];
|
||||
else vptr = (void *) lmp->atom->dvector[idx];
|
||||
} else {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||
else vptr = (void *) lmp->atom->darray[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[idx];
|
||||
else vptr = (void *) lmp->atom->darray[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -3833,7 +3822,7 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
||||
lmp->error->all(FLERR,"Library function lammps_scatter_subset() "
|
||||
"is not compatible with -DLAMMPS_BIGBIG");
|
||||
#else
|
||||
int i,j,m,offset,fcid,ltype,icol;
|
||||
int i,j,m,offset,ltype;
|
||||
tagint id;
|
||||
|
||||
// error if tags are not defined or no atom map
|
||||
@ -3855,70 +3844,66 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^f_")) {
|
||||
|
||||
fcid = lmp->modify->find_fix(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto fix = lmp->modify->get_fix_by_id(&name[2]);
|
||||
if (!fix) {
|
||||
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 (fix->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" fix does not return peratom data");
|
||||
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 ((count > 1) && (fix->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" count != values peratom for fix");
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: count != values peratom for fix");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->fix[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->fix[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) fix->vector_atom;
|
||||
else vptr = (void *) fix->array_atom;
|
||||
}
|
||||
|
||||
// compute
|
||||
|
||||
if (vptr==nullptr && utils::strmatch(name,"^c_")) {
|
||||
|
||||
fcid = lmp->modify->find_compute(&name[2]);
|
||||
if (fcid < 0) {
|
||||
auto compute = lmp->modify->get_compute_by_id(&name[2]);
|
||||
if (!compute) {
|
||||
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 (compute->peratom_flag == 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" compute does not return peratom data");
|
||||
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 ((count > 1) && (compute->size_peratom_cols != count)) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset:"
|
||||
" count != values peratom for compute");
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: count != values peratom for compute");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lmp->modify->compute[fcid]->invoked_peratom != lmp->update->ntimestep)
|
||||
lmp->modify->compute[fcid]->compute_peratom();
|
||||
if (compute->invoked_peratom != lmp->update->ntimestep)
|
||||
compute->compute_peratom();
|
||||
|
||||
if (count==1) vptr = (void *) lmp->modify->compute[fcid]->vector_atom;
|
||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||
if (count==1) vptr = (void *) compute->vector_atom;
|
||||
else vptr = (void *) compute->array_atom;
|
||||
}
|
||||
|
||||
// custom fix property/atom vector or array
|
||||
|
||||
if ((vptr == nullptr) && utils::strmatch(name,"^[id]2?_")) {
|
||||
|
||||
if (utils::strmatch(name,"^[id]_"))
|
||||
fcid = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else fcid = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
int idx,icol;
|
||||
if (utils::strmatch(name,"^[id]_")) idx = lmp->atom->find_custom(&name[2],ltype,icol);
|
||||
else idx = lmp->atom->find_custom(&name[3],ltype,icol);
|
||||
|
||||
if (fcid < 0) {
|
||||
if (idx < 0) {
|
||||
if (lmp->comm->me == 0)
|
||||
lmp->error->warning(FLERR,"lammps_scatter_subset: unknown property/atom id");
|
||||
return;
|
||||
@ -3941,11 +3926,11 @@ void lammps_scatter_subset(void *handle, char *name,int type, int count,
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[fcid];
|
||||
else vptr = (void *) lmp->atom->dvector[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->ivector[idx];
|
||||
else vptr = (void *) lmp->atom->dvector[idx];
|
||||
} else {
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[fcid];
|
||||
else vptr = (void *) lmp->atom->darray[fcid];
|
||||
if (ltype==0) vptr = (void *) lmp->atom->iarray[idx];
|
||||
else vptr = (void *) lmp->atom->darray[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -4242,10 +4227,9 @@ int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int n
|
||||
|
||||
int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
const int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0) return -1;
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) return -1;
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
// find neigh list
|
||||
for (int i = 0; i < lmp->neighbor->nlist; i++) {
|
||||
NeighList *list = lmp->neighbor->lists[i];
|
||||
@ -4272,10 +4256,9 @@ int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) {
|
||||
|
||||
int lammps_find_compute_neighlist(void* handle, const char *id, int reqid) {
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
const int icompute = lmp->modify->find_compute(id);
|
||||
if (icompute < 0) return -1;
|
||||
auto compute = lmp->modify->get_compute_by_id(id);
|
||||
if (!compute) return -1;
|
||||
|
||||
Compute *compute = lmp->modify->compute[icompute];
|
||||
// find neigh list
|
||||
for (int i = 0; i < lmp->neighbor->nlist; i++) {
|
||||
NeighList * list = lmp->neighbor->lists[i];
|
||||
@ -5089,11 +5072,8 @@ void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalF
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Cannot find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Cannot find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style 'external'", id);
|
||||
@ -5153,16 +5133,14 @@ double **lammps_fix_external_get_force(void *handle, const char *id)
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
fexternal = (double **)fix->extract("fexternal",ifix);
|
||||
int tmp;
|
||||
fexternal = (double **)fix->extract("fexternal",tmp);
|
||||
}
|
||||
END_CAPTURE
|
||||
return fexternal;
|
||||
@ -5202,11 +5180,8 @@ void lammps_fix_external_set_energy_global(void *handle, const char *id, double
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
@ -5253,11 +5228,8 @@ void lammps_fix_external_set_virial_global(void *handle, const char *id, double
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
@ -5304,11 +5276,8 @@ void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
@ -5358,11 +5327,8 @@ void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
@ -5405,11 +5371,8 @@ void lammps_fix_external_set_vector_length(void *handle, const char *id, int len
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
@ -5462,11 +5425,8 @@ void lammps_fix_external_set_vector(void *handle, const char *id, int idx, doubl
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
if (ifix < 0)
|
||||
lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
if (!fix) lmp->error->all(FLERR,"Can not find fix with ID '{}'!", id);
|
||||
|
||||
if (strcmp("external",fix->style) != 0)
|
||||
lmp->error->all(FLERR,"Fix '{}' is not of style external!", id);
|
||||
|
||||
@ -157,8 +157,7 @@ void Min::init()
|
||||
|
||||
// detect if fix omp is present for clearing force arrays
|
||||
|
||||
int ifix = modify->find_fix("package_omp");
|
||||
if (ifix >= 0) external_force_clear = 1;
|
||||
if (modify->get_fix_by_id("package_omp")) external_force_clear = 1;
|
||||
|
||||
// set flags for arrays to clear in force_clear()
|
||||
|
||||
@ -230,9 +229,8 @@ void Min::setup(int flag)
|
||||
|
||||
// compute for potential energy
|
||||
|
||||
int id = modify->find_compute("thermo_pe");
|
||||
if (id < 0) error->all(FLERR,"Minimization could not find thermo_pe compute");
|
||||
pe_compute = modify->compute[id];
|
||||
pe_compute = modify->get_compute_by_id("thermo_pe");
|
||||
if (!pe_compute) error->all(FLERR,"Minimization could not find thermo_pe compute");
|
||||
|
||||
// style-specific setup does two tasks
|
||||
// setup extra global dof vectors
|
||||
|
||||
@ -807,8 +807,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
// since some fixes access domain settings in their constructor
|
||||
// nullptr must be last entry in this list
|
||||
|
||||
const char *exceptions[] =
|
||||
{"GPU", "OMP", "INTEL", "property/atom", "cmap", "cmap3", "rx",
|
||||
const char *exceptions[] = {"GPU", "OMP", "INTEL", "property/atom", "cmap", "cmap3", "rx",
|
||||
"deprecated", "STORE/KIM", nullptr};
|
||||
|
||||
if (domain->box_exist == 0) {
|
||||
@ -822,7 +821,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
// check group ID
|
||||
|
||||
int igroup = group->find(arg[1]);
|
||||
if (igroup == -1) error->all(FLERR,"Could not find fix group ID");
|
||||
if (igroup == -1) error->all(FLERR,"Could not find fix group ID {}", arg[1]);
|
||||
|
||||
// if fix ID exists:
|
||||
// set newflag = 0 so create new fix in same location in fix list
|
||||
@ -856,8 +855,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
if (estyle == fix[ifix]->style) match = 1;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
error->all(FLERR,"Replacing a fix, but new style != old style");
|
||||
if (!match) error->all(FLERR,"Replacing a fix, but new style != old style");
|
||||
|
||||
if (fix[ifix]->igroup != igroup && comm->me == 0)
|
||||
error->warning(FLERR,"Replacing a fix, but new group != old group");
|
||||
@ -907,9 +905,12 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
if (fix[ifix] == nullptr)
|
||||
error->all(FLERR,utils::check_packages_for_style("fix",arg[2],lmp));
|
||||
|
||||
// increment nfix (if new)
|
||||
// increment nfix and update fix_list vector (if new)
|
||||
|
||||
if (newflag) nfix++;
|
||||
if (newflag) {
|
||||
nfix++;
|
||||
fix_list = std::vector<Fix *>(fix, fix+nfix);
|
||||
}
|
||||
|
||||
// post_constructor() can call virtual methods in parent or child
|
||||
// which would otherwise not yet be visible in child class
|
||||
@ -983,25 +984,24 @@ Fix *Modify::add_fix(const std::string &fixcmd, int trysuffix)
|
||||
|
||||
Fix *Modify::replace_fix(const char *replaceID, int narg, char **arg, int trysuffix)
|
||||
{
|
||||
int ifix = find_fix(replaceID);
|
||||
if (ifix < 0) error->all(FLERR,"Modify replace_fix ID {} could not be found", replaceID);
|
||||
auto oldfix = get_fix_by_id(replaceID);
|
||||
if (!oldfix) error->all(FLERR,"Modify replace_fix ID {} could not be found", replaceID);
|
||||
|
||||
// change ID, igroup, style of fix being replaced to match new fix
|
||||
// requires some error checking on arguments for new fix
|
||||
|
||||
if (narg < 3) error->all(FLERR,"Illegal replace_fix invocation");
|
||||
int jfix = find_fix(arg[0]);
|
||||
if (jfix >= 0) error->all(FLERR,"Replace_fix ID is already in use");
|
||||
if (!get_fix_by_id(arg[0])) error->all(FLERR,"Replace_fix ID is already in use");
|
||||
|
||||
delete [] fix[ifix]->id;
|
||||
fix[ifix]->id = utils::strdup(arg[0]);
|
||||
delete[] oldfix->id;
|
||||
oldfix->id = utils::strdup(arg[0]);
|
||||
|
||||
int jgroup = group->find(arg[1]);
|
||||
if (jgroup == -1) error->all(FLERR,"Could not find replace_fix group ID");
|
||||
fix[ifix]->igroup = jgroup;
|
||||
if (jgroup == -1) error->all(FLERR,"Could not find replace_fix group ID {}", arg[1]);
|
||||
oldfix->igroup = jgroup;
|
||||
|
||||
delete [] fix[ifix]->style;
|
||||
fix[ifix]->style = utils::strdup(arg[2]);
|
||||
delete[] oldfix->style;
|
||||
oldfix->style = utils::strdup(arg[2]);
|
||||
|
||||
// invoke add_fix
|
||||
// it will find and overwrite the replaceID fix
|
||||
@ -1047,7 +1047,7 @@ void Modify::modify_fix(int narg, char **arg)
|
||||
int ifix;
|
||||
for (ifix = 0; ifix < nfix; ifix++)
|
||||
if (strcmp(arg[0],fix[ifix]->id) == 0) break;
|
||||
if (ifix == nfix) error->all(FLERR,"Could not find fix_modify ID");
|
||||
if (ifix == nfix) error->all(FLERR,"Could not find fix_modify ID {}", arg[0]);
|
||||
|
||||
fix[ifix]->modify_params(narg-1,&arg[1]);
|
||||
}
|
||||
@ -1060,7 +1060,7 @@ void Modify::modify_fix(int narg, char **arg)
|
||||
void Modify::delete_fix(const std::string &id)
|
||||
{
|
||||
int ifix = find_fix(id);
|
||||
if (ifix < 0) error->all(FLERR,"Could not find fix ID to delete");
|
||||
if (ifix < 0) error->all(FLERR,"Could not find fix ID {} to delete", id);
|
||||
delete_fix(ifix);
|
||||
}
|
||||
|
||||
@ -1076,6 +1076,7 @@ void Modify::delete_fix(int ifix)
|
||||
for (int i = ifix+1; i < nfix; i++) fix[i-1] = fix[i];
|
||||
for (int i = ifix+1; i < nfix; i++) fmask[i-1] = fmask[i];
|
||||
nfix--;
|
||||
fix_list = std::vector<Fix *>(fix, fix+nfix);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1252,8 +1253,7 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
|
||||
if (ncompute == maxcompute) {
|
||||
maxcompute += DELTA;
|
||||
compute = (Compute **)
|
||||
memory->srealloc(compute,maxcompute*sizeof(Compute *),"modify:compute");
|
||||
compute = (Compute **) memory->srealloc(compute,maxcompute*sizeof(Compute *),"modify:compute");
|
||||
}
|
||||
|
||||
// create the Compute
|
||||
@ -1291,6 +1291,7 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
if (compute[ncompute] == nullptr)
|
||||
error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp));
|
||||
|
||||
compute_list = std::vector<Compute *>(compute, compute+ncompute+1);
|
||||
return compute[ncompute++];
|
||||
}
|
||||
|
||||
@ -1334,7 +1335,7 @@ void Modify::modify_compute(int narg, char **arg)
|
||||
for (icompute = 0; icompute < ncompute; icompute++)
|
||||
if (strcmp(arg[0],compute[icompute]->id) == 0) break;
|
||||
if (icompute == ncompute)
|
||||
error->all(FLERR,"Could not find compute_modify ID");
|
||||
error->all(FLERR,"Could not find compute_modify ID {}", arg[0]);
|
||||
|
||||
compute[icompute]->modify_params(narg-1,&arg[1]);
|
||||
}
|
||||
@ -1346,7 +1347,7 @@ void Modify::modify_compute(int narg, char **arg)
|
||||
void Modify::delete_compute(const std::string &id)
|
||||
{
|
||||
int icompute = find_compute(id);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find compute ID to delete");
|
||||
if (icompute < 0) error->all(FLERR,"Could not find compute ID {} to delete", id);
|
||||
delete_compute(icompute);
|
||||
}
|
||||
|
||||
@ -1359,6 +1360,7 @@ void Modify::delete_compute(int icompute)
|
||||
delete compute[icompute];
|
||||
for (int i = icompute+1; i < ncompute; i++) compute[i-1] = compute[i];
|
||||
ncompute--;
|
||||
compute_list = std::vector<Compute *>(compute, compute+ncompute);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -267,14 +267,11 @@ void ReadData::command(int narg, char **arg)
|
||||
error->all(FLERR,"Illegal read_data command");
|
||||
memory->grow(fix_index,nfix+1,"read_data:fix_index");
|
||||
fix_header = (char **)
|
||||
memory->srealloc(fix_header,(nfix+1)*sizeof(char *),
|
||||
"read_data:fix_header");
|
||||
memory->srealloc(fix_header,(nfix+1)*sizeof(char *),"read_data:fix_header");
|
||||
fix_section = (char **)
|
||||
memory->srealloc(fix_section,(nfix+1)*sizeof(char *),
|
||||
"read_data:fix_section");
|
||||
memory->srealloc(fix_section,(nfix+1)*sizeof(char *),"read_data:fix_section");
|
||||
fix_index[nfix] = modify->find_fix(arg[iarg+1]);
|
||||
if (fix_index[nfix] < 0)
|
||||
error->all(FLERR,"Fix ID for read_data does not exist");
|
||||
if (fix_index[nfix] < 0) error->all(FLERR,"Fix ID for read_data does not exist");
|
||||
if (strcmp(arg[iarg+2],"NULL") == 0) fix_header[nfix] = nullptr;
|
||||
else fix_header[nfix] = utils::strdup(arg[iarg+2]);
|
||||
fix_section[nfix] = utils::strdup(arg[iarg+3]);
|
||||
|
||||
@ -445,8 +445,7 @@ void ReadRestart::command(int narg, char **arg)
|
||||
if (nextra) {
|
||||
memory->destroy(atom->extra);
|
||||
memory->create(atom->extra,atom->nmax,nextra,"atom:extra");
|
||||
int ifix = modify->find_fix("_read_restart");
|
||||
FixReadRestart *fix = (FixReadRestart *) modify->fix[ifix];
|
||||
auto fix = (FixReadRestart *) modify->get_fix_by_id("_read_restart");
|
||||
int *count = fix->count;
|
||||
double **extra = fix->extra;
|
||||
double **atom_extra = atom->extra;
|
||||
|
||||
@ -151,24 +151,14 @@ void ResetMolIDs::create_computes(char *fixid, char *groupid)
|
||||
// 'fixid' allows for creating independent instances of the computes
|
||||
|
||||
idfrag = fmt::format("{}_reset_mol_ids_FRAGMENT_ATOM",fixid);
|
||||
if (singleflag)
|
||||
modify->add_compute(fmt::format("{} {} fragment/atom single yes",idfrag,groupid));
|
||||
else
|
||||
modify->add_compute(fmt::format("{} {} fragment/atom single no",idfrag,groupid));
|
||||
auto use_single = singleflag ? "yes" : "no";
|
||||
cfa = (ComputeFragmentAtom *)
|
||||
modify->add_compute(fmt::format("{} {} fragment/atom single {}",idfrag,groupid,use_single));
|
||||
|
||||
idchunk = fmt::format("{}_reset_mol_ids_CHUNK_ATOM",fixid);
|
||||
if (compressflag)
|
||||
modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes",
|
||||
idchunk,groupid));
|
||||
|
||||
int icompute = modify->find_compute(idfrag);
|
||||
cfa = (ComputeFragmentAtom *) modify->compute[icompute];
|
||||
|
||||
|
||||
if (compressflag) {
|
||||
icompute = modify->find_compute(idchunk);
|
||||
cca = (ComputeChunkAtom *) modify->compute[icompute];
|
||||
}
|
||||
cca = (ComputeChunkAtom *)
|
||||
modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes",idchunk,groupid));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -322,8 +322,7 @@ void Respa::init()
|
||||
|
||||
// detect if fix omp is present and will clear force arrays
|
||||
|
||||
int ifix = modify->find_fix("package_omp");
|
||||
if (ifix >= 0) external_force_clear = 1;
|
||||
if (modify->get_fix_by_id("package_omp")) external_force_clear = 1;
|
||||
|
||||
// set flags for arrays to clear in force_clear()
|
||||
|
||||
|
||||
101
src/thermo.cpp
101
src/thermo.cpp
@ -267,23 +267,20 @@ void Thermo::init()
|
||||
|
||||
// find current ptr for each Compute ID
|
||||
|
||||
int icompute;
|
||||
for (i = 0; i < ncompute; i++) {
|
||||
icompute = modify->find_compute(id_compute[i]);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find thermo compute ID");
|
||||
computes[i] = modify->compute[icompute];
|
||||
computes[i] = modify->get_compute_by_id(id_compute[i]);
|
||||
if (!computes[i]) error->all(FLERR,"Could not find thermo compute with ID {}",id_compute[i]);
|
||||
}
|
||||
|
||||
// find current ptr for each Fix ID
|
||||
// check that fix frequency is acceptable with thermo output frequency
|
||||
|
||||
int ifix;
|
||||
for (i = 0; i < nfix; i++) {
|
||||
ifix = modify->find_fix(id_fix[i]);
|
||||
if (ifix < 0) error->all(FLERR,"Could not find thermo fix ID");
|
||||
fixes[i] = modify->fix[ifix];
|
||||
fixes[i] = modify->get_fix_by_id(id_fix[i]);
|
||||
if (!fixes[i]) error->all(FLERR,"Could not find thermo fix ID {}",id_fix[i]);
|
||||
|
||||
if (output->thermo_every % fixes[i]->global_freq)
|
||||
error->all(FLERR,"Thermo and fix not computed at compatible times");
|
||||
error->all(FLERR,"Thermo and fix {} not computed at compatible times",id_fix[i]);
|
||||
}
|
||||
|
||||
// find current ptr for each Variable ID
|
||||
@ -470,33 +467,30 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
delete[] id_compute[index_temp];
|
||||
id_compute[index_temp] = utils::strdup(arg[iarg+1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[iarg+1]);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Could not find thermo_modify temperature ID");
|
||||
temperature = modify->compute[icompute];
|
||||
temperature = modify->get_compute_by_id(arg[iarg+1]);
|
||||
if (!temperature)
|
||||
error->all(FLERR,"Could not find thermo_modify temperature compute {}",arg[iarg+1]);
|
||||
|
||||
if (temperature->tempflag == 0)
|
||||
error->all(FLERR,"Thermo_modify temperature ID does not "
|
||||
"compute temperature");
|
||||
error->all(FLERR,"Thermo_modify compute {} does not compute temperature",arg[iarg+1]);
|
||||
if (temperature->igroup != 0 && comm->me == 0)
|
||||
error->warning(FLERR,
|
||||
"Temperature for thermo pressure is not for group all");
|
||||
error->warning(FLERR,"Temperature for thermo pressure is not for group all");
|
||||
|
||||
// reset id_temp of pressure to new temperature ID
|
||||
// either pressure currently being used by thermo or "thermo_press"
|
||||
|
||||
Compute *pcompute;
|
||||
if (index_press_scalar >= 0) {
|
||||
icompute = modify->find_compute(id_compute[index_press_scalar]);
|
||||
if (icompute < 0) error->all(FLERR,
|
||||
"Pressure ID for thermo does not exist");
|
||||
pcompute = modify->get_compute_by_id(id_compute[index_press_scalar]);
|
||||
if (!pcompute) error->all(FLERR, "Pressure compute {} for thermo output does not exist",
|
||||
id_compute[index_press_scalar]);
|
||||
} else if (index_press_vector >= 0) {
|
||||
icompute = modify->find_compute(id_compute[index_press_vector]);
|
||||
if (icompute < 0) error->all(FLERR,
|
||||
"Pressure ID for thermo does not exist");
|
||||
} else icompute = modify->find_compute("thermo_press");
|
||||
|
||||
modify->compute[icompute]->reset_extra_compute_fix(arg[iarg+1]);
|
||||
pcompute = modify->get_compute_by_id(id_compute[index_press_vector]);
|
||||
if (!pcompute) error->all(FLERR,"Pressure compute {} for thermo output does not exist",
|
||||
id_compute[index_press_vector]);
|
||||
} else pcompute = modify->get_compute_by_id("thermo_press");
|
||||
|
||||
pcompute->reset_extra_compute_fix(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg],"press") == 0) {
|
||||
@ -513,13 +507,12 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
id_compute[index_press_vector] = utils::strdup(arg[iarg+1]);
|
||||
}
|
||||
|
||||
int icompute = modify->find_compute(arg[iarg+1]);
|
||||
if (icompute < 0) error->all(FLERR,
|
||||
"Could not find thermo_modify pressure ID");
|
||||
pressure = modify->compute[icompute];
|
||||
pressure = modify->get_compute_by_id(arg[iarg+1]);
|
||||
if (!pressure)
|
||||
error->all(FLERR,"Could not find thermo_modify pressure compute {}",arg[iarg+1]);
|
||||
|
||||
if (pressure->pressflag == 0)
|
||||
error->all(FLERR,"Thermo_modify pressure ID does not compute pressure");
|
||||
error->all(FLERR,"Thermo_modify compute {} does not compute pressure",arg[iarg+1]);
|
||||
|
||||
iarg += 2;
|
||||
|
||||
@ -912,24 +905,24 @@ void Thermo::parse_fields(char *str)
|
||||
argindex2[nfield] = (argi.get_dim() > 1) ? argi.get_index2() : 0;
|
||||
|
||||
if (argi.get_type() == ArgInfo::COMPUTE) {
|
||||
int n = modify->find_compute(argi.get_name());
|
||||
if (n < 0) error->all(FLERR,"Could not find thermo custom compute ID");
|
||||
if (argindex1[nfield] == 0 && modify->compute[n]->scalar_flag == 0)
|
||||
auto icompute = modify->get_compute_by_id(argi.get_name());
|
||||
if (!icompute) error->all(FLERR,"Could not find thermo custom compute ID");
|
||||
if (argindex1[nfield] == 0 && icompute->scalar_flag == 0)
|
||||
error->all(FLERR,"Thermo compute does not compute scalar");
|
||||
if (argindex1[nfield] > 0 && argindex2[nfield] == 0) {
|
||||
if (modify->compute[n]->vector_flag == 0)
|
||||
if (icompute->vector_flag == 0)
|
||||
error->all(FLERR,"Thermo compute does not compute vector");
|
||||
if (argindex1[nfield] > modify->compute[n]->size_vector &&
|
||||
modify->compute[n]->size_vector_variable == 0)
|
||||
if (argindex1[nfield] > icompute->size_vector &&
|
||||
icompute->size_vector_variable == 0)
|
||||
error->all(FLERR,"Thermo compute vector is accessed out-of-range");
|
||||
}
|
||||
if (argindex1[nfield] > 0 && argindex2[nfield] > 0) {
|
||||
if (modify->compute[n]->array_flag == 0)
|
||||
if (icompute->array_flag == 0)
|
||||
error->all(FLERR,"Thermo compute does not compute array");
|
||||
if (argindex1[nfield] > modify->compute[n]->size_array_rows &&
|
||||
modify->compute[n]->size_array_rows_variable == 0)
|
||||
if (argindex1[nfield] > icompute->size_array_rows &&
|
||||
icompute->size_array_rows_variable == 0)
|
||||
error->all(FLERR,"Thermo compute array is accessed out-of-range");
|
||||
if (argindex2[nfield] > modify->compute[n]->size_array_cols)
|
||||
if (argindex2[nfield] > icompute->size_array_cols)
|
||||
error->all(FLERR,"Thermo compute array is accessed out-of-range");
|
||||
}
|
||||
|
||||
@ -942,24 +935,24 @@ void Thermo::parse_fields(char *str)
|
||||
addfield(word.c_str(), &Thermo::compute_compute, FLOAT);
|
||||
|
||||
} else if (argi.get_type() == ArgInfo::FIX) {
|
||||
int n = modify->find_fix(argi.get_name());
|
||||
if (n < 0) error->all(FLERR,"Could not find thermo custom fix ID");
|
||||
if (argindex1[nfield] == 0 && modify->fix[n]->scalar_flag == 0)
|
||||
auto ifix = modify->get_fix_by_id(argi.get_name());
|
||||
if (!ifix) error->all(FLERR,"Could not find thermo custom fix ID");
|
||||
if (argindex1[nfield] == 0 && ifix->scalar_flag == 0)
|
||||
error->all(FLERR,"Thermo fix does not compute scalar");
|
||||
if (argindex1[nfield] > 0 && argindex2[nfield] == 0) {
|
||||
if (modify->fix[n]->vector_flag == 0)
|
||||
if (ifix->vector_flag == 0)
|
||||
error->all(FLERR,"Thermo fix does not compute vector");
|
||||
if (argindex1[nfield] > modify->fix[n]->size_vector &&
|
||||
modify->fix[n]->size_vector_variable == 0)
|
||||
if (argindex1[nfield] > ifix->size_vector &&
|
||||
ifix->size_vector_variable == 0)
|
||||
error->all(FLERR,"Thermo fix vector is accessed out-of-range");
|
||||
}
|
||||
if (argindex1[nfield] > 0 && argindex2[nfield] > 0) {
|
||||
if (modify->fix[n]->array_flag == 0)
|
||||
if (ifix->array_flag == 0)
|
||||
error->all(FLERR,"Thermo fix does not compute array");
|
||||
if (argindex1[nfield] > modify->fix[n]->size_array_rows &&
|
||||
modify->fix[n]->size_array_rows_variable == 0)
|
||||
if (argindex1[nfield] > ifix->size_array_rows &&
|
||||
ifix->size_array_rows_variable == 0)
|
||||
error->all(FLERR,"Thermo fix array is accessed out-of-range");
|
||||
if (argindex2[nfield] > modify->fix[n]->size_array_cols)
|
||||
if (argindex2[nfield] > ifix->size_array_cols)
|
||||
error->all(FLERR,"Thermo fix array is accessed out-of-range");
|
||||
}
|
||||
|
||||
@ -971,11 +964,9 @@ void Thermo::parse_fields(char *str)
|
||||
if (n < 0)
|
||||
error->all(FLERR,"Could not find thermo custom variable name");
|
||||
if (argindex1[nfield] == 0 && input->variable->equalstyle(n) == 0)
|
||||
error->all(FLERR,
|
||||
"Thermo custom variable is not equal-style variable");
|
||||
error->all(FLERR,"Thermo custom variable is not equal-style variable");
|
||||
if (argindex1[nfield] && input->variable->vectorstyle(n) == 0)
|
||||
error->all(FLERR,
|
||||
"Thermo custom variable is not vector-style variable");
|
||||
error->all(FLERR,"Thermo custom variable is not vector-style variable");
|
||||
if (argindex2[nfield])
|
||||
error->all(FLERR,"Thermo custom variable cannot have two indices");
|
||||
|
||||
|
||||
@ -583,12 +583,11 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
||||
// compute
|
||||
|
||||
if (word[0] == 'c') {
|
||||
int icompute = lmp->modify->find_compute(id);
|
||||
auto compute = lmp->modify->get_compute_by_id(id);
|
||||
|
||||
// check for global vector/array, peratom array, local array
|
||||
|
||||
if (icompute >= 0) {
|
||||
Compute *compute = lmp->modify->compute[icompute];
|
||||
if (compute) {
|
||||
if (mode == 0 && compute->vector_flag) {
|
||||
nmax = compute->size_vector;
|
||||
expandflag = 1;
|
||||
@ -607,13 +606,11 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
||||
// fix
|
||||
|
||||
} else if (word[0] == 'f') {
|
||||
int ifix = lmp->modify->find_fix(id);
|
||||
auto fix = lmp->modify->get_fix_by_id(id);
|
||||
|
||||
// check for global vector/array, peratom array, local array
|
||||
|
||||
if (ifix >= 0) {
|
||||
Fix *fix = lmp->modify->fix[ifix];
|
||||
|
||||
if (fix) {
|
||||
if (mode == 0 && fix->vector_flag) {
|
||||
nmax = fix->size_vector;
|
||||
expandflag = 1;
|
||||
|
||||
Reference in New Issue
Block a user