modernize and simplify

This commit is contained in:
Axel Kohlmeyer
2022-08-11 03:45:36 -04:00
parent aab62d5ed9
commit 91b98484ad
4 changed files with 41 additions and 68 deletions

View File

@ -125,19 +125,19 @@ void CommKokkos::init()
if (force->pair && (force->pair->execution_space == Host))
check_reverse += force->pair->comm_reverse;
for (int i = 0; i < modify->nfix; i++) {
check_forward += modify->fix[i]->comm_forward;
check_reverse += modify->fix[i]->comm_reverse;
for (const auto &fix : modify->get_fix_list()) {
check_forward += fix->comm_forward;
check_reverse += fix->comm_reverse;
}
for (int i = 0; i < modify->ncompute; i++) {
check_forward += modify->compute[i]->comm_forward;
check_reverse += modify->compute[i]->comm_reverse;
for (const auto &compute : modify->get_compute_list()) {
check_forward += compute->comm_forward;
check_reverse += compute->comm_reverse;
}
for (int i = 0; i < output->ndump; i++) {
check_forward += output->dump[i]->comm_forward;
check_reverse += output->dump[i]->comm_reverse;
for (const auto &dump : output->get_dump_list()) {
check_forward += dump->comm_forward;
check_reverse += dump->comm_reverse;
}
if (force->newton == 0) check_reverse = 0;

View File

@ -226,14 +226,14 @@ void Comm::init()
maxreverse = MAX(maxreverse, fix->comm_reverse);
}
for (int i = 0; i < modify->ncompute; i++) {
maxforward = MAX(maxforward,modify->compute[i]->comm_forward);
maxreverse = MAX(maxreverse,modify->compute[i]->comm_reverse);
for (const auto &compute : modify->get_compute_list()) {
maxforward = MAX(maxforward,compute->comm_forward);
maxreverse = MAX(maxreverse,compute->comm_reverse);
}
for (int i = 0; i < output->ndump; i++) {
maxforward = MAX(maxforward,output->dump[i]->comm_forward);
maxreverse = MAX(maxreverse,output->dump[i]->comm_reverse);
for (const auto &dump: output->get_dump_list()) {
maxforward = MAX(maxforward,dump->comm_forward);
maxreverse = MAX(maxreverse,dump->comm_reverse);
}
if (force->newton == 0) maxreverse = 0;
@ -247,8 +247,7 @@ void Comm::init()
maxexchange_atom = atom->avec->maxexchange;
maxexchange_fix_dynamic = 0;
for (const auto &fix : fix_list)
if (fix->maxexchange_dynamic) maxexchange_fix_dynamic = 1;
for (const auto &fix : fix_list) if (fix->maxexchange_dynamic) maxexchange_fix_dynamic = 1;
if ((mode == Comm::MULTI) && (neighbor->style != Neighbor::MULTI))
error->all(FLERR,"Cannot use comm mode multi without multi-style neighbor lists");
@ -270,8 +269,7 @@ void Comm::init()
void Comm::init_exchange()
{
maxexchange_fix = 0;
for (const auto &fix : modify->get_fix_list())
maxexchange_fix += fix->maxexchange;
for (const auto &fix : modify->get_fix_list()) maxexchange_fix += fix->maxexchange;
maxexchange = maxexchange_atom + maxexchange_fix;
bufextra = maxexchange + BUFEXTRA;

View File

@ -101,22 +101,21 @@ void Group::assign(int narg, char **arg)
// clear mask of each atom assigned to this group
if (strcmp(arg[1],"delete") == 0) {
if (narg != 2) error->all(FLERR,"Illegal group command");
if (narg != 2) error->all(FLERR,"Illegal group command: too many arguments");
int igroup = find(arg[0]);
if (igroup == -1) error->all(FLERR,"Could not find group delete group ID");
if (igroup == -1) error->all(FLERR,"Could not find group delete group ID {}",arg[0]);
if (igroup == 0) error->all(FLERR,"Cannot delete group all");
for (const auto &fix : modify->get_fix_list())
if (fix->igroup == igroup)
error->all(FLERR,"Cannot delete group currently used by a fix");
for (i = 0; i < modify->ncompute; i++)
if (modify->compute[i]->igroup == igroup)
error->all(FLERR,"Cannot delete group currently used by a compute");
for (i = 0; i < output->ndump; i++)
if (output->dump[i]->igroup == igroup)
error->all(FLERR,"Cannot delete group currently used by a dump");
for (const auto &i : modify->get_fix_list())
if (i->igroup == igroup)
error->all(FLERR,"Cannot delete group {} currently used by fix ID {}",arg[0],i->id);
for (const auto &i : modify->get_compute_list())
if (i->igroup == igroup)
error->all(FLERR,"Cannot delete group {} currently used by compute ID {}",arg[0],i->id);
for (const auto &i : output->get_dump_list())
if (i->igroup == igroup)
error->all(FLERR,"Cannot delete group {} currently used by dump ID {}",arg[0],i->id);
if (atom->firstgroupname && strcmp(arg[0],atom->firstgroupname) == 0)
error->all(FLERR,
"Cannot delete group currently used by atom_modify first");
error->all(FLERR,"Cannot delete group {} currently used by atom_modify first",arg[0]);
int *mask = atom->mask;
int nlocal = atom->nlocal;

View File

@ -4761,43 +4761,19 @@ int lammps_has_id(void *handle, const char *category, const char *name) {
auto lmp = (LAMMPS *) handle;
if (strcmp(category,"compute") == 0) {
int ncompute = lmp->modify->ncompute;
Compute **compute = lmp->modify->compute;
for (int i=0; i < ncompute; ++i) {
if (strcmp(name,compute[i]->id) == 0) return 1;
}
if (lmp->modify->get_compute_by_id(name)) return 1;
} else if (strcmp(category,"dump") == 0) {
int ndump = lmp->output->ndump;
Dump **dump = lmp->output->dump;
for (int i=0; i < ndump; ++i) {
if (strcmp(name,dump[i]->id) == 0) return 1;
}
if (lmp->output->get_dump_by_id(name)) return 1;
} else if (strcmp(category,"fix") == 0) {
for (auto &ifix : lmp->modify->get_fix_list()) {
if (strcmp(name,ifix->id) == 0) return 1;
}
if (lmp->modify->get_fix_by_id(name)) return 1;
} else if (strcmp(category,"group") == 0) {
int ngroup = lmp->group->ngroup;
char **groups = lmp->group->names;
for (int i=0; i < ngroup; ++i) {
if (strcmp(groups[i],name) == 0) return 1;
}
if (lmp->group->find(name) >= 0) return 1;
} else if (strcmp(category,"molecule") == 0) {
int nmolecule = lmp->atom->nmolecule;
Molecule **molecule = lmp->atom->molecules;
for (int i=0; i < nmolecule; ++i) {
if (strcmp(name,molecule[i]->id) == 0) return 1;
}
if (lmp->atom->find_molecule(name) >= 0) return 1;
} else if (strcmp(category,"region") == 0) {
for (auto &reg : lmp->domain->get_region_list()) {
if (strcmp(name,reg->id) == 0) return 1;
}
if (lmp->domain->get_region_by_id(name)) return 1;
} else if (strcmp(category,"variable") == 0) {
int nvariable = lmp->input->variable->nvar;
char **varnames = lmp->input->variable->names;
for (int i=0; i < nvariable; ++i) {
if (strcmp(name,varnames[i]) == 0) return 1;
}
if (lmp->input->variable->find(name) >= 0) return 1;
}
return 0;
}
@ -4823,11 +4799,11 @@ categories.
int lammps_id_count(void *handle, const char *category) {
auto lmp = (LAMMPS *) handle;
if (strcmp(category,"compute") == 0) {
return lmp->modify->ncompute;
return lmp->modify->get_compute_list().size();
} else if (strcmp(category,"dump") == 0) {
return lmp->output->ndump;
return lmp->output->get_dump_list().size();
} else if (strcmp(category,"fix") == 0) {
return lmp->modify->nfix;
return lmp->modify->get_fix_list().size();
} else if (strcmp(category,"group") == 0) {
return lmp->group->ngroup;
} else if (strcmp(category,"molecule") == 0) {