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);