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
for (i = 0; i < ncompute; i++) {
int icompute = modify->find_compute(id_compute[i]);
if (icompute < 0) error->all(FLERR,"Could not find dump custom compute ID");
compute[i] = modify->compute[icompute];
compute[i] = modify->get_compute_by_id(id_compute[i]);
if (!compute[i]) error->all(FLERR,"Could not find dump custom compute ID {}",id_compute[i]);
}
for (i = 0; i < nfix; i++) {
int ifix = modify->find_fix(id_fix[i]);
if (ifix < 0) error->all(FLERR,"Could not find dump custom fix ID");
fix[i] = modify->fix[ifix];
if (nevery % modify->fix[ifix]->peratom_freq)
fix[i] = modify->get_fix_by_id(id_fix[i]);
if (!fix[i]) error->all(FLERR,"Could not find dump custom fix ID {}", id_fix[i]);
if (nevery % fix[i]->peratom_freq)
error->all(FLERR,"Dump custom and fix not computed at compatible times");
}
for (i = 0; i < nvariable; i++) {
int ivariable = input->variable->find(id_variable[i]);
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;
}
@ -1446,10 +1444,12 @@ int DumpCustom::parse_fields(int narg, char **arg)
} else {
int n,flag,cols;
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|ArgInfo::DNAME|ArgInfo::INAME);
ArgInfo argi(arg[iarg], ArgInfo::COMPUTE | ArgInfo::FIX | ArgInfo::VARIABLE |
ArgInfo::DNAME | ArgInfo::INAME);
argindex[iarg] = argi.get_index1();
auto name = argi.get_name();
Compute *icompute = nullptr;
Fix *ifix = nullptr;
switch (argi.get_type()) {
@ -1464,16 +1464,15 @@ int DumpCustom::parse_fields(int narg, char **arg)
pack_choice[iarg] = &DumpCustom::pack_compute;
vtype[iarg] = Dump::DOUBLE;
n = modify->find_compute(name);
if (n < 0) error->all(FLERR,"Could not find dump custom 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 custom compute ID: {}",name);
if (icompute->peratom_flag == 0)
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);
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);
if (argi.get_dim() > 0 &&
argi.get_index1() > modify->compute[n]->size_peratom_cols)
if (argi.get_dim() > 0 && argi.get_index1() > icompute->size_peratom_cols)
error->all(FLERR,"Dump custom compute {} vector is accessed out-of-range",name);
field2index[iarg] = add_compute(name);
@ -1486,16 +1485,15 @@ int DumpCustom::parse_fields(int narg, char **arg)
pack_choice[iarg] = &DumpCustom::pack_fix;
vtype[iarg] = Dump::DOUBLE;
n = modify->find_fix(name);
if (n < 0) error->all(FLERR,"Could not find dump custom 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 custom fix ID: {}",name);
if (ifix->peratom_flag == 0)
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);
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);
if (argi.get_dim() > 0 &&
argi.get_index1() > modify->fix[n]->size_peratom_cols)
if (argi.get_dim() > 0 && argi.get_index1() > ifix->size_peratom_cols)
error->all(FLERR,"Dump custom fix {} vector is accessed out-of-range",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");
int n,flag,cols;
ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|ArgInfo::DNAME|ArgInfo::INAME);
ArgInfo argi(arg[1], ArgInfo::COMPUTE | ArgInfo::FIX | ArgInfo::VARIABLE |
ArgInfo::DNAME | ArgInfo::INAME);
argindex[nfield+nthresh] = argi.get_index1();
auto name = argi.get_name();
Compute *icompute = nullptr;
Fix *ifix = nullptr;
switch (argi.get_type()) {
@ -1894,17 +1894,16 @@ int DumpCustom::modify_param(int narg, char **arg)
case ArgInfo::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);
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);
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);
if (argi.get_index1() > 0 &&
argi.get_index1() > modify->compute[n]->size_peratom_cols)
if (argi.get_index1() > 0 && argi.get_index1() > icompute->size_peratom_cols)
error->all(FLERR,"Dump modify compute ID {} vector is not large enough",name);
field2index[nfield+nthresh] = add_compute(name);
@ -1915,16 +1914,17 @@ int DumpCustom::modify_param(int narg, char **arg)
case ArgInfo::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);
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);
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);
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);
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 (fixflag) {
int ifix = modify->find_fix(fixID);
if (ifix < 0) error->all(FLERR,"Fix ID for dump image does not exist");
fixptr = modify->fix[ifix];
fixptr = modify->get_fix_by_id(fixID);
if (!fixptr) error->all(FLERR,"Fix ID {} for dump image does not exist", fixID);
}
// 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
for (i = 0; i < ncompute; i++) {
int icompute = modify->find_compute(id_compute[i]);
if (icompute < 0) error->all(FLERR,"Could not find dump local compute ID");
compute[i] = modify->compute[icompute];
compute[i] = modify->get_compute_by_id(id_compute[i]);
if (!compute[i]) error->all(FLERR,"Could not find dump local compute ID {}",id_compute[i]);
}
for (i = 0; i < nfix; i++) {
int ifix = modify->find_fix(id_fix[i]);
if (ifix < 0) error->all(FLERR,"Could not find dump local fix ID");
fix[i] = modify->fix[ifix];
if (nevery % modify->fix[ifix]->local_freq)
error->all(FLERR,"Dump local and fix not computed at compatible times");
fix[i] = modify->get_fix_by_id(id_fix[i]);
if (!fix[i]) error->all(FLERR,"Could not find dump local fix ID {}", id_fix[i]);
if (nevery % fix[i]->local_freq)
error->all(FLERR,"Dump local and fix {} not computed at compatible times", id_fix[i]);
}
// open single file, one time only
@ -442,6 +440,9 @@ void DumpLocal::parse_fields(int narg, char **arg)
computefixflag = 1;
vtype[iarg] = Dump::DOUBLE;
argindex[iarg] = argi.get_index1();
auto name = argi.get_name();
Compute *icompute = nullptr;
Fix *ifix = nullptr;
switch (argi.get_type()) {
@ -451,19 +452,18 @@ void DumpLocal::parse_fields(int narg, char **arg)
case ArgInfo::COMPUTE:
pack_choice[iarg] = &DumpLocal::pack_compute;
n = modify->find_compute(argi.get_name());
if (n < 0) error->all(FLERR,"Could not find dump local compute ID");
if (modify->compute[n]->local_flag == 0)
error->all(FLERR,"Dump local compute does not compute local info");
if (argi.get_dim() == 0 && modify->compute[n]->size_local_cols > 0)
error->all(FLERR,"Dump local compute does not calculate local vector");
if (argi.get_index1() > 0 && modify->compute[n]->size_local_cols == 0)
error->all(FLERR,"Dump local compute does not calculate local array");
if (argi.get_index1() > 0 &&
argi.get_index1() > modify->compute[n]->size_local_cols)
error->all(FLERR,"Dump local compute vector is accessed out-of-range");
icompute = modify->get_compute_by_id(name);
if (!icompute) error->all(FLERR,"Could not find dump local compute ID {}",name);
if (icompute->local_flag == 0)
error->all(FLERR,"Dump local compute {} does not compute local info", name);
if (argi.get_dim() == 0 && icompute->size_local_cols > 0)
error->all(FLERR,"Dump local compute {} does not calculate local vector", name);
if (argi.get_index1() > 0 && icompute->size_local_cols == 0)
error->all(FLERR,"Dump local compute {} does not calculate local array", name);
if (argi.get_index1() > 0 && argi.get_index1() > icompute->size_local_cols)
error->all(FLERR,"Dump local compute {} vector is accessed out-of-range", name);
field2index[iarg] = add_compute(argi.get_name());
field2index[iarg] = add_compute(name);
break;
// fix value = f_ID
@ -472,25 +472,24 @@ void DumpLocal::parse_fields(int narg, char **arg)
case ArgInfo::FIX:
pack_choice[iarg] = &DumpLocal::pack_fix;
n = modify->find_fix(argi.get_name());
if (n < 0) error->all(FLERR,"Could not find dump local fix ID");
if (modify->fix[n]->local_flag == 0)
error->all(FLERR,"Dump local fix does not compute local info");
if (argi.get_dim() == 0 && modify->fix[n]->size_local_cols > 0)
error->all(FLERR,"Dump local fix does not compute local vector");
if (argi.get_index1() > 0 && modify->fix[n]->size_local_cols == 0)
error->all(FLERR,"Dump local fix does not compute local array");
if (argi.get_index1() > 0 &&
argi.get_index1() > modify->fix[n]->size_local_cols)
error->all(FLERR,"Dump local fix vector is accessed out-of-range");
ifix = modify->get_fix_by_id(name);
if (!ifix) error->all(FLERR,"Could not find dump local fix ID {}", name);
if (ifix->local_flag == 0)
error->all(FLERR,"Dump local fix {} does not compute local info", name);
if (argi.get_dim() == 0 && ifix->size_local_cols > 0)
error->all(FLERR,"Dump local fix {} does not compute local vector", name);
if (argi.get_index1() > 0 && ifix->size_local_cols == 0)
error->all(FLERR,"Dump local fix {} does not compute local array", name);
if (argi.get_index1() > 0 && argi.get_index1() > ifix->size_local_cols)
error->all(FLERR,"Dump local fix {} vector is accessed out-of-range", name);
field2index[iarg] = add_fix(argi.get_name());
field2index[iarg] = add_fix(name);
break;
case ArgInfo::NONE: // fallthrough
case ArgInfo::UNKNOWN: // fallthrough
default:
error->all(FLERR,"Invalid attribute in dump local command");
error->all(FLERR,"Invalid attribute {} in dump local command",arg[iarg]);
break;
}
}