use new API, join loops, modernize
This commit is contained in:
@ -67,21 +67,23 @@ void RespaOMP::init()
|
|||||||
void RespaOMP::setup(int flag)
|
void RespaOMP::setup(int flag)
|
||||||
{
|
{
|
||||||
if (comm->me == 0 && screen) {
|
if (comm->me == 0 && screen) {
|
||||||
fprintf(screen,"Setting up r-RESPA/omp run ...\n");
|
std::string mesg = "Setting up r-RESPA/omp run ...\n";
|
||||||
if (flag) {
|
if (flag) {
|
||||||
fprintf(screen," Unit style : %s\n", update->unit_style);
|
mesg += fmt::format(" Unit style : {}\n", update->unit_style);
|
||||||
fprintf(screen," Current step : " BIGINT_FORMAT "\n", update->ntimestep);
|
mesg += fmt::format(" Current step : {}\n", update->ntimestep);
|
||||||
fprintf(screen," Time steps :");
|
|
||||||
for (int ilevel=0; ilevel < nlevels; ++ilevel)
|
mesg += " Time steps :";
|
||||||
fprintf(screen," %d:%g",ilevel+1, step[ilevel]);
|
for (int ilevel = 0; ilevel < nlevels; ++ilevel)
|
||||||
fprintf(screen,"\n r-RESPA fixes :");
|
mesg += fmt::format(" {}:{}", ilevel + 1, step[ilevel]);
|
||||||
for (int l=0; l < modify->n_post_force_respa; ++l) {
|
|
||||||
Fix *f = modify->fix[modify->list_post_force_respa[l]];
|
mesg += "\n r-RESPA fixes :";
|
||||||
|
for (int l = 0; l < modify->n_post_force_respa; ++l) {
|
||||||
|
Fix *f = modify->get_fix_by_index(modify->list_post_force_respa[l]);
|
||||||
if (f->respa_level >= 0)
|
if (f->respa_level >= 0)
|
||||||
fprintf(screen," %d:%s[%s]",
|
mesg += fmt::format(" {}:{}[{}]", MIN(f->respa_level + 1, nlevels), f->style, f->id);
|
||||||
MIN(f->respa_level+1,nlevels),f->style,f->id);
|
|
||||||
}
|
}
|
||||||
fprintf(screen,"\n");
|
mesg += "\n";
|
||||||
|
fputs(mesg.c_str(), screen);
|
||||||
timer->print_timeout(screen);
|
timer->print_timeout(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -243,10 +243,8 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (any_variable_length &&
|
if (any_variable_length &&
|
||||||
(nrepeat > 1 || ave == RUNNING || ave == WINDOW)) {
|
(nrepeat > 1 || ave == RUNNING || ave == WINDOW)) {
|
||||||
for (int i = 0; i < nvalues; i++)
|
for (int i = 0; i < nvalues; i++)
|
||||||
if (varlen[i] && which[i] == ArgInfo::COMPUTE) {
|
if (varlen[i] && which[i] == ArgInfo::COMPUTE)
|
||||||
int icompute = modify->find_compute(ids[i]);
|
modify->get_compute_by_id(ids[i])->lock_enable();
|
||||||
modify->compute[icompute]->lock_enable();
|
|
||||||
}
|
|
||||||
lockforever = 0;
|
lockforever = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,64 +65,54 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
// setup and error check
|
// setup and error check
|
||||||
// for fix inputs, check that fix frequency is acceptable
|
// for fix inputs, check that fix frequency is acceptable
|
||||||
|
|
||||||
for (int i = 0; i < nvalues; i++) {
|
|
||||||
if (which[i] == ArgInfo::COMPUTE) {
|
|
||||||
int icompute = modify->find_compute(ids[i]);
|
|
||||||
if (icompute < 0)
|
|
||||||
error->all(FLERR,"Compute ID for fix vector does not exist");
|
|
||||||
if (argindex[i] == 0 && modify->compute[icompute]->scalar_flag == 0)
|
|
||||||
error->all(FLERR,"Fix vector compute does not calculate a scalar");
|
|
||||||
if (argindex[i] && modify->compute[icompute]->vector_flag == 0)
|
|
||||||
error->all(FLERR,"Fix vector compute does not calculate a vector");
|
|
||||||
if (argindex[i] && argindex[i] > modify->compute[icompute]->size_vector)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Fix vector compute vector is accessed out-of-range");
|
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::FIX) {
|
|
||||||
int ifix = modify->find_fix(ids[i]);
|
|
||||||
if (ifix < 0)
|
|
||||||
error->all(FLERR,"Fix ID for fix vector does not exist");
|
|
||||||
if (argindex[i] == 0 && modify->fix[ifix]->scalar_flag == 0)
|
|
||||||
error->all(FLERR,"Fix vector fix does not calculate a scalar");
|
|
||||||
if (argindex[i] && modify->fix[ifix]->vector_flag == 0)
|
|
||||||
error->all(FLERR,"Fix vector fix does not calculate a vector");
|
|
||||||
if (argindex[i] && argindex[i] > modify->fix[ifix]->size_vector)
|
|
||||||
error->all(FLERR,"Fix vector fix vector is accessed out-of-range");
|
|
||||||
if (nevery % modify->fix[ifix]->global_freq)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Fix for fix vector not computed at compatible time");
|
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
|
||||||
int ivariable = input->variable->find(ids[i]);
|
|
||||||
if (ivariable < 0)
|
|
||||||
error->all(FLERR,"Variable name for fix vector does not exist");
|
|
||||||
if (argindex[i] == 0 && input->variable->equalstyle(ivariable) == 0)
|
|
||||||
error->all(FLERR,"Fix vector variable is not equal-style variable");
|
|
||||||
if (argindex[i] && input->variable->vectorstyle(ivariable) == 0)
|
|
||||||
error->all(FLERR,"Fix vector variable is not vector-style variable");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this fix produces either a global vector or array
|
// this fix produces either a global vector or array
|
||||||
// intensive/extensive flags set by compute,fix,variable that produces value
|
// intensive/extensive flags set by compute,fix,variable that produces value
|
||||||
|
|
||||||
int value,finalvalue;
|
int value,finalvalue;
|
||||||
for (int i = 0; i < nvalues; i++) {
|
for (int i = 0; i < nvalues; i++) {
|
||||||
if (which[i] == ArgInfo::COMPUTE) {
|
if (which[i] == ArgInfo::COMPUTE) {
|
||||||
Compute *compute = modify->compute[modify->find_compute(ids[i])];
|
auto icompute = modify->get_compute_by_id(ids[i]);
|
||||||
if (argindex[0] == 0) value = compute->extscalar;
|
if (!icompute) error->all(FLERR,"Compute ID {} for fix vector does not exist",ids[i]);
|
||||||
else if (compute->extvector >= 0) value = compute->extvector;
|
if (argindex[i] == 0 && icompute->scalar_flag == 0)
|
||||||
else value = compute->extlist[argindex[0]-1];
|
error->all(FLERR,"Fix vector compute {} does not calculate a scalar",ids[i]);
|
||||||
|
if (argindex[i] && icompute->vector_flag == 0)
|
||||||
|
error->all(FLERR,"Fix vector compute {} does not calculate a vector",ids[i]);
|
||||||
|
if (argindex[i] && argindex[i] > icompute->size_vector)
|
||||||
|
error->all(FLERR,"Fix vector compute {} vector is accessed out-of-range",ids[i]);
|
||||||
|
|
||||||
|
if (argindex[i] == 0) value = icompute->extscalar;
|
||||||
|
else if (icompute->extvector >= 0) value = icompute->extvector;
|
||||||
|
else value = icompute->extlist[argindex[i]-1];
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::FIX) {
|
} else if (which[i] == ArgInfo::FIX) {
|
||||||
Fix *fix = modify->fix[modify->find_fix(ids[i])];
|
auto ifix = modify->get_fix_by_id(ids[i]);
|
||||||
if (argindex[i] == 0) value = fix->extvector;
|
if (!ifix) error->all(FLERR,"Fix ID {} for fix vector does not exist",ids[i]);
|
||||||
else value = fix->extarray;
|
if (argindex[i] == 0 && ifix->scalar_flag == 0)
|
||||||
} else if (which[i] == ArgInfo::VARIABLE) value = 0;
|
error->all(FLERR,"Fix vector fix {} does not calculate a scalar",ids[i]);
|
||||||
|
if (argindex[i] && ifix->vector_flag == 0)
|
||||||
|
error->all(FLERR,"Fix vector fix {} does not calculate a vector",ids[i]);
|
||||||
|
if (argindex[i] && argindex[i] > ifix->size_vector)
|
||||||
|
error->all(FLERR,"Fix vector fix {} vector is accessed out-of-range",ids[i]);
|
||||||
|
if (nevery % ifix->global_freq)
|
||||||
|
error->all(FLERR,"Fix for fix {} vector not computed at compatible time",ids[i]);
|
||||||
|
|
||||||
|
if (argindex[i] == 0) value = ifix->extvector;
|
||||||
|
else value = ifix->extarray;
|
||||||
|
|
||||||
|
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||||
|
int ivariable = input->variable->find(ids[i]);
|
||||||
|
if (ivariable < 0)
|
||||||
|
error->all(FLERR,"Variable name {} for fix vector does not exist",ids[i]);
|
||||||
|
if (argindex[i] == 0 && input->variable->equalstyle(ivariable) == 0)
|
||||||
|
error->all(FLERR,"Fix vector variable {} is not equal-style variable",ids[i]);
|
||||||
|
if (argindex[i] && input->variable->vectorstyle(ivariable) == 0)
|
||||||
|
error->all(FLERR,"Fix vector variable {} is not vector-style variable",ids[i]);
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == 0) finalvalue = value;
|
if (i == 0) finalvalue = value;
|
||||||
else if (value != finalvalue)
|
else if (value != finalvalue)
|
||||||
error->all(FLERR,"Fix vector cannot set output array "
|
error->all(FLERR,"Fix vector cannot set output array intensive/extensive from these inputs");
|
||||||
"intensive/extensive from these inputs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvalues == 1) {
|
if (nvalues == 1) {
|
||||||
@ -191,14 +181,12 @@ void FixVector::init()
|
|||||||
for (int i = 0; i < nvalues; i++) {
|
for (int i = 0; i < nvalues; i++) {
|
||||||
if (which[i] == ArgInfo::COMPUTE) {
|
if (which[i] == ArgInfo::COMPUTE) {
|
||||||
int icompute = modify->find_compute(ids[i]);
|
int icompute = modify->find_compute(ids[i]);
|
||||||
if (icompute < 0)
|
if (icompute < 0) error->all(FLERR,"Compute ID {} for fix vector does not exist",id[i]);
|
||||||
error->all(FLERR,"Compute ID for fix vector does not exist");
|
|
||||||
value2index[i] = icompute;
|
value2index[i] = icompute;
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::FIX) {
|
} else if (which[i] == ArgInfo::FIX) {
|
||||||
int ifix = modify->find_fix(ids[i]);
|
int ifix = modify->find_fix(ids[i]);
|
||||||
if (ifix < 0)
|
if (ifix < 0) error->all(FLERR,"Fix ID {} for fix vector does not exist",id[i]);
|
||||||
error->all(FLERR,"Fix ID for fix vector does not exist");
|
|
||||||
value2index[i] = ifix;
|
value2index[i] = ifix;
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||||
@ -254,7 +242,7 @@ void FixVector::end_of_step()
|
|||||||
// invoke compute if not previously invoked
|
// invoke compute if not previously invoked
|
||||||
|
|
||||||
if (which[i] == ArgInfo::COMPUTE) {
|
if (which[i] == ArgInfo::COMPUTE) {
|
||||||
Compute *compute = modify->compute[m];
|
auto compute = modify->get_compute_by_index(m);
|
||||||
|
|
||||||
if (argindex[i] == 0) {
|
if (argindex[i] == 0) {
|
||||||
if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) {
|
if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) {
|
||||||
@ -274,9 +262,9 @@ void FixVector::end_of_step()
|
|||||||
|
|
||||||
} else if (which[i] == ArgInfo::FIX) {
|
} else if (which[i] == ArgInfo::FIX) {
|
||||||
if (argindex[i] == 0)
|
if (argindex[i] == 0)
|
||||||
result[i] = modify->fix[m]->compute_scalar();
|
result[i] = modify->get_fix_by_index(m)->compute_scalar();
|
||||||
else
|
else
|
||||||
result[i] = modify->fix[m]->compute_vector(argindex[i]-1);
|
result[i] = modify->get_fix_by_index(m)->compute_vector(argindex[i]-1);
|
||||||
|
|
||||||
// evaluate equal-style or vector-style variable
|
// evaluate equal-style or vector-style variable
|
||||||
|
|
||||||
|
|||||||
@ -113,6 +113,7 @@ class Modify : protected Pointers {
|
|||||||
int find_fix(const std::string &);
|
int find_fix(const std::string &);
|
||||||
// new API
|
// new API
|
||||||
Fix *get_fix_by_id(const std::string &) const;
|
Fix *get_fix_by_id(const std::string &) const;
|
||||||
|
Fix *get_fix_by_index(int idx) const { return fix[idx]; }
|
||||||
const std::vector<Fix *> get_fix_by_style(const std::string &) const;
|
const std::vector<Fix *> get_fix_by_style(const std::string &) const;
|
||||||
const std::vector<Fix *> &get_fix_list();
|
const std::vector<Fix *> &get_fix_list();
|
||||||
|
|
||||||
@ -126,6 +127,7 @@ class Modify : protected Pointers {
|
|||||||
int find_compute(const std::string &);
|
int find_compute(const std::string &);
|
||||||
// new API
|
// new API
|
||||||
Compute *get_compute_by_id(const std::string &) const;
|
Compute *get_compute_by_id(const std::string &) const;
|
||||||
|
Compute *get_compute_by_index(int idx) const { return compute[idx]; }
|
||||||
const std::vector<Compute *> get_compute_by_style(const std::string &) const;
|
const std::vector<Compute *> get_compute_by_style(const std::string &) const;
|
||||||
const std::vector<Compute *> &get_compute_list();
|
const std::vector<Compute *> &get_compute_list();
|
||||||
|
|
||||||
|
|||||||
@ -373,7 +373,7 @@ void Respa::setup(int flag)
|
|||||||
|
|
||||||
mesg += "\n r-RESPA fixes :";
|
mesg += "\n r-RESPA fixes :";
|
||||||
for (int l = 0; l < modify->n_post_force_respa; ++l) {
|
for (int l = 0; l < modify->n_post_force_respa; ++l) {
|
||||||
Fix *f = modify->fix[modify->list_post_force_respa[l]];
|
Fix *f = modify->get_fix_by_index(modify->list_post_force_respa[l]);
|
||||||
if (f->respa_level >= 0)
|
if (f->respa_level >= 0)
|
||||||
mesg += fmt::format(" {}:{}[{}]", MIN(f->respa_level + 1, nlevels), f->style, f->id);
|
mesg += fmt::format(" {}:{}[{}]", MIN(f->respa_level + 1, nlevels), f->style, f->id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1290,9 +1290,8 @@ int Special::rendezvous_pairs(int n, char *inbuf, int &flag, int *&proclist,
|
|||||||
|
|
||||||
void Special::fix_alteration()
|
void Special::fix_alteration()
|
||||||
{
|
{
|
||||||
for (int ifix = 0; ifix < modify->nfix; ifix++)
|
for (const auto &ifix : modify->get_fix_list())
|
||||||
if (modify->fix[ifix]->special_alter_flag)
|
if (ifix->special_alter_flag) ifix->rebuild_special();
|
||||||
modify->fix[ifix]->rebuild_special();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -488,41 +488,29 @@ void Update::reset_timestep(bigint newstep)
|
|||||||
|
|
||||||
output->reset_timestep(ntimestep);
|
output->reset_timestep(ntimestep);
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++) {
|
for (const auto &ifix : modify->get_fix_list())
|
||||||
if (modify->fix[i]->time_depend)
|
if (ifix->time_depend)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Cannot reset timestep with time-dependent fix {} defined",ifix->style);
|
||||||
"Cannot reset timestep with a time-dependent fix defined");
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset eflag/vflag global so no commands will think eng/virial are current
|
// reset eflag/vflag global so no commands will think eng/virial are current
|
||||||
|
|
||||||
eflag_global = vflag_global = -1;
|
eflag_global = vflag_global = -1;
|
||||||
|
|
||||||
// reset invoked flags of computes,
|
// reset invoked flags of computes, so no commands will think they are current between runs
|
||||||
// so no commands will think they are current between runs
|
|
||||||
|
|
||||||
for (int i = 0; i < modify->ncompute; i++) {
|
|
||||||
modify->compute[i]->invoked_scalar = -1;
|
|
||||||
modify->compute[i]->invoked_vector = -1;
|
|
||||||
modify->compute[i]->invoked_array = -1;
|
|
||||||
modify->compute[i]->invoked_peratom = -1;
|
|
||||||
modify->compute[i]->invoked_local = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear timestep list of computes that store future invocation times
|
// clear timestep list of computes that store future invocation times
|
||||||
|
|
||||||
for (int i = 0; i < modify->ncompute; i++)
|
for (const auto &icompute : modify->get_compute_list()) {
|
||||||
if (modify->compute[i]->timeflag) modify->compute[i]->clearstep();
|
icompute->invoked_scalar = -1;
|
||||||
|
icompute->invoked_vector = -1;
|
||||||
|
icompute->invoked_array = -1;
|
||||||
|
icompute->invoked_peratom = -1;
|
||||||
|
icompute->invoked_local = -1;
|
||||||
|
if (icompute->timeflag) icompute->clearstep();
|
||||||
|
}
|
||||||
|
|
||||||
// Neighbor Bin/Stencil/Pair classes store timestamps that need to be cleared
|
// Neighbor Bin/Stencil/Pair classes store timestamps that need to be cleared
|
||||||
|
|
||||||
neighbor->reset_timestep(ntimestep);
|
neighbor->reset_timestep(ntimestep);
|
||||||
|
|
||||||
// NOTE: 7Jun12, adding rerun command, don't think this is required
|
|
||||||
|
|
||||||
//for (int i = 0; i < domain->nregion; i++)
|
|
||||||
// if (domain->regions[i]->dynamic_check())
|
|
||||||
// error->all(FLERR,"Cannot reset timestep with a dynamic region defined");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user