use newer APIs to get access to fixes and computes

This commit is contained in:
Axel Kohlmeyer
2022-03-18 13:16:18 -04:00
parent cc2ba3c350
commit 8fe7b928a7
3 changed files with 75 additions and 76 deletions

View File

@ -322,23 +322,21 @@ void DumpCustom::init_style()
// check that fix frequency is acceptable // check that fix frequency is acceptable
for (i = 0; i < ncompute; i++) { for (i = 0; i < ncompute; i++) {
int icompute = modify->find_compute(id_compute[i]); compute[i] = modify->get_compute_by_id(id_compute[i]);
if (icompute < 0) error->all(FLERR,"Could not find dump custom compute ID"); if (!compute[i]) error->all(FLERR,"Could not find dump custom compute ID {}",id_compute[i]);
compute[i] = modify->compute[icompute];
} }
for (i = 0; i < nfix; i++) { for (i = 0; i < nfix; i++) {
int ifix = modify->find_fix(id_fix[i]); fix[i] = modify->get_fix_by_id(id_fix[i]);
if (ifix < 0) error->all(FLERR,"Could not find dump custom fix ID"); if (!fix[i]) error->all(FLERR,"Could not find dump custom fix ID {}", id_fix[i]);
fix[i] = modify->fix[ifix]; if (nevery % fix[i]->peratom_freq)
if (nevery % modify->fix[ifix]->peratom_freq)
error->all(FLERR,"Dump custom and fix not computed at compatible times"); error->all(FLERR,"Dump custom and fix not computed at compatible times");
} }
for (i = 0; i < nvariable; i++) { for (i = 0; i < nvariable; i++) {
int ivariable = input->variable->find(id_variable[i]); int ivariable = input->variable->find(id_variable[i]);
if (ivariable < 0) if (ivariable < 0)
error->all(FLERR,"Could not find dump custom variable name"); error->all(FLERR,"Could not find dump custom variable name {}", id_variable[i]);
variable[i] = ivariable; variable[i] = ivariable;
} }
@ -1446,10 +1444,12 @@ int DumpCustom::parse_fields(int narg, char **arg)
} else { } else {
int n,flag,cols; int n,flag,cols;
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE ArgInfo argi(arg[iarg], ArgInfo::COMPUTE | ArgInfo::FIX | ArgInfo::VARIABLE |
|ArgInfo::DNAME|ArgInfo::INAME); ArgInfo::DNAME | ArgInfo::INAME);
argindex[iarg] = argi.get_index1(); argindex[iarg] = argi.get_index1();
auto name = argi.get_name(); auto name = argi.get_name();
Compute *icompute = nullptr;
Fix *ifix = nullptr;
switch (argi.get_type()) { switch (argi.get_type()) {
@ -1464,16 +1464,15 @@ int DumpCustom::parse_fields(int narg, char **arg)
pack_choice[iarg] = &DumpCustom::pack_compute; pack_choice[iarg] = &DumpCustom::pack_compute;
vtype[iarg] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
n = modify->find_compute(name); icompute = modify->get_compute_by_id(name);
if (n < 0) error->all(FLERR,"Could not find dump custom compute ID: {}",name); if (!icompute) error->all(FLERR,"Could not find dump custom compute ID: {}",name);
if (modify->compute[n]->peratom_flag == 0) if (icompute->peratom_flag == 0)
error->all(FLERR,"Dump custom compute {} does not compute per-atom info",name); error->all(FLERR,"Dump custom compute {} does not compute per-atom info",name);
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0) if (argi.get_dim() == 0 && icompute->size_peratom_cols > 0)
error->all(FLERR,"Dump custom compute {} does not calculate per-atom vector",name); error->all(FLERR,"Dump custom compute {} does not calculate per-atom vector",name);
if (argi.get_dim() > 0 && modify->compute[n]->size_peratom_cols == 0) if (argi.get_dim() > 0 && icompute->size_peratom_cols == 0)
error->all(FLERR,"Dump custom compute {} does not calculate per-atom array",name); error->all(FLERR,"Dump custom compute {} does not calculate per-atom array",name);
if (argi.get_dim() > 0 && if (argi.get_dim() > 0 && argi.get_index1() > icompute->size_peratom_cols)
argi.get_index1() > modify->compute[n]->size_peratom_cols)
error->all(FLERR,"Dump custom compute {} vector is accessed out-of-range",name); error->all(FLERR,"Dump custom compute {} vector is accessed out-of-range",name);
field2index[iarg] = add_compute(name); field2index[iarg] = add_compute(name);
@ -1486,16 +1485,15 @@ int DumpCustom::parse_fields(int narg, char **arg)
pack_choice[iarg] = &DumpCustom::pack_fix; pack_choice[iarg] = &DumpCustom::pack_fix;
vtype[iarg] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
n = modify->find_fix(name); ifix = modify->get_fix_by_id(name);
if (n < 0) error->all(FLERR,"Could not find dump custom fix ID: {}",name); if (!ifix) error->all(FLERR,"Could not find dump custom fix ID: {}",name);
if (modify->fix[n]->peratom_flag == 0) if (ifix->peratom_flag == 0)
error->all(FLERR,"Dump custom fix {} does not compute per-atom info",name); error->all(FLERR,"Dump custom fix {} does not compute per-atom info",name);
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0) if (argi.get_dim() == 0 && ifix->size_peratom_cols > 0)
error->all(FLERR,"Dump custom fix {} does not compute per-atom vector",name); error->all(FLERR,"Dump custom fix {} does not compute per-atom vector",name);
if (argi.get_dim() > 0 && modify->fix[n]->size_peratom_cols == 0) if (argi.get_dim() > 0 && ifix->size_peratom_cols == 0)
error->all(FLERR,"Dump custom fix {} does not compute per-atom array",name); error->all(FLERR,"Dump custom fix {} does not compute per-atom array",name);
if (argi.get_dim() > 0 && if (argi.get_dim() > 0 && argi.get_index1() > ifix->size_peratom_cols)
argi.get_index1() > modify->fix[n]->size_peratom_cols)
error->all(FLERR,"Dump custom fix {} vector is accessed out-of-range",name); error->all(FLERR,"Dump custom fix {} vector is accessed out-of-range",name);
field2index[iarg] = add_fix(name); field2index[iarg] = add_fix(name);
@ -1878,10 +1876,12 @@ int DumpCustom::modify_param(int narg, char **arg)
memory->grow(argindex,nfield+nthresh+1,"dump:argindex"); memory->grow(argindex,nfield+nthresh+1,"dump:argindex");
int n,flag,cols; int n,flag,cols;
ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE ArgInfo argi(arg[1], ArgInfo::COMPUTE | ArgInfo::FIX | ArgInfo::VARIABLE |
|ArgInfo::DNAME|ArgInfo::INAME); ArgInfo::DNAME | ArgInfo::INAME);
argindex[nfield+nthresh] = argi.get_index1(); argindex[nfield+nthresh] = argi.get_index1();
auto name = argi.get_name(); auto name = argi.get_name();
Compute *icompute = nullptr;
Fix *ifix = nullptr;
switch (argi.get_type()) { switch (argi.get_type()) {
@ -1894,17 +1894,16 @@ int DumpCustom::modify_param(int narg, char **arg)
case ArgInfo::COMPUTE: case ArgInfo::COMPUTE:
thresh_array[nthresh] = COMPUTE; thresh_array[nthresh] = COMPUTE;
n = modify->find_compute(name);
if (n < 0) error->all(FLERR,"Could not find dump modify compute ID: {}",name);
if (modify->compute[n]->peratom_flag == 0) icompute = modify->get_compute_by_id(name);
if (!icompute) error->all(FLERR,"Could not find dump modify compute ID {}",name);
if (icompute->peratom_flag == 0)
error->all(FLERR,"Dump modify compute ID {} does not compute per-atom info",name); error->all(FLERR,"Dump modify compute ID {} does not compute per-atom info",name);
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0) if (argi.get_dim() == 0 && icompute->size_peratom_cols > 0)
error->all(FLERR,"Dump modify compute ID {} does not compute per-atom vector",name); error->all(FLERR,"Dump modify compute ID {} does not compute per-atom vector",name);
if (argi.get_index1() > 0 && modify->compute[n]->size_peratom_cols == 0) if (argi.get_index1() > 0 && icompute->size_peratom_cols == 0)
error->all(FLERR,"Dump modify compute ID {} does not compute per-atom array",name); error->all(FLERR,"Dump modify compute ID {} does not compute per-atom array",name);
if (argi.get_index1() > 0 && if (argi.get_index1() > 0 && argi.get_index1() > icompute->size_peratom_cols)
argi.get_index1() > modify->compute[n]->size_peratom_cols)
error->all(FLERR,"Dump modify compute ID {} vector is not large enough",name); error->all(FLERR,"Dump modify compute ID {} vector is not large enough",name);
field2index[nfield+nthresh] = add_compute(name); field2index[nfield+nthresh] = add_compute(name);
@ -1915,16 +1914,17 @@ int DumpCustom::modify_param(int narg, char **arg)
case ArgInfo::FIX: case ArgInfo::FIX:
thresh_array[nthresh] = FIX; thresh_array[nthresh] = FIX;
n = modify->find_fix(name);
if (n < 0) error->all(FLERR,"Could not find dump modify fix ID: {}",name);
if (modify->fix[n]->peratom_flag == 0) ifix = modify->get_fix_by_id(name);
if (!ifix) error->all(FLERR,"Could not find dump modify fix ID: {}",name);
if (ifix->peratom_flag == 0)
error->all(FLERR,"Dump modify fix ID {} does not compute per-atom info",name); error->all(FLERR,"Dump modify fix ID {} does not compute per-atom info",name);
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0) if (argi.get_dim() == 0 && ifix->size_peratom_cols > 0)
error->all(FLERR,"Dump modify fix ID {} does not compute per-atom vector",name); error->all(FLERR,"Dump modify fix ID {} does not compute per-atom vector",name);
if (argi.get_index1() > 0 && modify->fix[n]->size_peratom_cols == 0) if (argi.get_index1() > 0 && ifix->size_peratom_cols == 0)
error->all(FLERR,"Dump modify fix ID {} does not compute per-atom array",name); error->all(FLERR,"Dump modify fix ID {} does not compute per-atom array",name);
if (argi.get_index1() > 0 && argi.get_index1() > modify->fix[n]->size_peratom_cols) if (argi.get_index1() > 0 && argi.get_index1() > ifix->size_peratom_cols)
error->all(FLERR,"Dump modify fix ID {} vector is not large enough",name); error->all(FLERR,"Dump modify fix ID {} vector is not large enough",name);
field2index[nfield+nthresh] = add_fix(name); field2index[nfield+nthresh] = add_fix(name);

View File

@ -351,9 +351,9 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
if (lineflag || triflag || bodyflag) extraflag = 1; if (lineflag || triflag || bodyflag) extraflag = 1;
if (fixflag) { if (fixflag) {
int ifix = modify->find_fix(fixID); fixptr = modify->get_fix_by_id(fixID);
if (ifix < 0) error->all(FLERR,"Fix ID for dump image does not exist"); if (!fixptr) error->all(FLERR,"Fix ID {} for dump image does not exist", fixID);
fixptr = modify->fix[ifix];
} }
// allocate image buffer now that image size is known // allocate image buffer now that image size is known

View File

@ -197,17 +197,15 @@ void DumpLocal::init_style()
// check that fix frequency is acceptable // check that fix frequency is acceptable
for (i = 0; i < ncompute; i++) { for (i = 0; i < ncompute; i++) {
int icompute = modify->find_compute(id_compute[i]); compute[i] = modify->get_compute_by_id(id_compute[i]);
if (icompute < 0) error->all(FLERR,"Could not find dump local compute ID"); if (!compute[i]) error->all(FLERR,"Could not find dump local compute ID {}",id_compute[i]);
compute[i] = modify->compute[icompute];
} }
for (i = 0; i < nfix; i++) { for (i = 0; i < nfix; i++) {
int ifix = modify->find_fix(id_fix[i]); fix[i] = modify->get_fix_by_id(id_fix[i]);
if (ifix < 0) error->all(FLERR,"Could not find dump local fix ID"); if (!fix[i]) error->all(FLERR,"Could not find dump local fix ID {}", id_fix[i]);
fix[i] = modify->fix[ifix]; if (nevery % fix[i]->local_freq)
if (nevery % modify->fix[ifix]->local_freq) error->all(FLERR,"Dump local and fix {} not computed at compatible times", id_fix[i]);
error->all(FLERR,"Dump local and fix not computed at compatible times");
} }
// open single file, one time only // open single file, one time only
@ -442,6 +440,9 @@ void DumpLocal::parse_fields(int narg, char **arg)
computefixflag = 1; computefixflag = 1;
vtype[iarg] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
argindex[iarg] = argi.get_index1(); argindex[iarg] = argi.get_index1();
auto name = argi.get_name();
Compute *icompute = nullptr;
Fix *ifix = nullptr;
switch (argi.get_type()) { switch (argi.get_type()) {
@ -451,19 +452,18 @@ void DumpLocal::parse_fields(int narg, char **arg)
case ArgInfo::COMPUTE: case ArgInfo::COMPUTE:
pack_choice[iarg] = &DumpLocal::pack_compute; pack_choice[iarg] = &DumpLocal::pack_compute;
n = modify->find_compute(argi.get_name()); icompute = modify->get_compute_by_id(name);
if (n < 0) error->all(FLERR,"Could not find dump local compute ID"); if (!icompute) error->all(FLERR,"Could not find dump local compute ID {}",name);
if (modify->compute[n]->local_flag == 0) if (icompute->local_flag == 0)
error->all(FLERR,"Dump local compute does not compute local info"); error->all(FLERR,"Dump local compute {} does not compute local info", name);
if (argi.get_dim() == 0 && modify->compute[n]->size_local_cols > 0) if (argi.get_dim() == 0 && icompute->size_local_cols > 0)
error->all(FLERR,"Dump local compute does not calculate local vector"); error->all(FLERR,"Dump local compute {} does not calculate local vector", name);
if (argi.get_index1() > 0 && modify->compute[n]->size_local_cols == 0) if (argi.get_index1() > 0 && icompute->size_local_cols == 0)
error->all(FLERR,"Dump local compute does not calculate local array"); error->all(FLERR,"Dump local compute {} does not calculate local array", name);
if (argi.get_index1() > 0 && if (argi.get_index1() > 0 && argi.get_index1() > icompute->size_local_cols)
argi.get_index1() > modify->compute[n]->size_local_cols) error->all(FLERR,"Dump local compute {} vector is accessed out-of-range", name);
error->all(FLERR,"Dump local compute vector is accessed out-of-range");
field2index[iarg] = add_compute(argi.get_name()); field2index[iarg] = add_compute(name);
break; break;
// fix value = f_ID // fix value = f_ID
@ -472,25 +472,24 @@ void DumpLocal::parse_fields(int narg, char **arg)
case ArgInfo::FIX: case ArgInfo::FIX:
pack_choice[iarg] = &DumpLocal::pack_fix; pack_choice[iarg] = &DumpLocal::pack_fix;
n = modify->find_fix(argi.get_name()); ifix = modify->get_fix_by_id(name);
if (n < 0) error->all(FLERR,"Could not find dump local fix ID"); if (!ifix) error->all(FLERR,"Could not find dump local fix ID {}", name);
if (modify->fix[n]->local_flag == 0) if (ifix->local_flag == 0)
error->all(FLERR,"Dump local fix does not compute local info"); error->all(FLERR,"Dump local fix {} does not compute local info", name);
if (argi.get_dim() == 0 && modify->fix[n]->size_local_cols > 0) if (argi.get_dim() == 0 && ifix->size_local_cols > 0)
error->all(FLERR,"Dump local fix does not compute local vector"); error->all(FLERR,"Dump local fix {} does not compute local vector", name);
if (argi.get_index1() > 0 && modify->fix[n]->size_local_cols == 0) if (argi.get_index1() > 0 && ifix->size_local_cols == 0)
error->all(FLERR,"Dump local fix does not compute local array"); error->all(FLERR,"Dump local fix {} does not compute local array", name);
if (argi.get_index1() > 0 && if (argi.get_index1() > 0 && argi.get_index1() > ifix->size_local_cols)
argi.get_index1() > modify->fix[n]->size_local_cols) error->all(FLERR,"Dump local fix {} vector is accessed out-of-range", name);
error->all(FLERR,"Dump local fix vector is accessed out-of-range");
field2index[iarg] = add_fix(argi.get_name()); field2index[iarg] = add_fix(name);
break; break;
case ArgInfo::NONE: // fallthrough case ArgInfo::NONE: // fallthrough
case ArgInfo::UNKNOWN: // fallthrough case ArgInfo::UNKNOWN: // fallthrough
default: default:
error->all(FLERR,"Invalid attribute in dump local command"); error->all(FLERR,"Invalid attribute {} in dump local command",arg[iarg]);
break; break;
} }
} }