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)) if (force->pair && (force->pair->execution_space == Host))
check_reverse += force->pair->comm_reverse; check_reverse += force->pair->comm_reverse;
for (int i = 0; i < modify->nfix; i++) { for (const auto &fix : modify->get_fix_list()) {
check_forward += modify->fix[i]->comm_forward; check_forward += fix->comm_forward;
check_reverse += modify->fix[i]->comm_reverse; check_reverse += fix->comm_reverse;
} }
for (int i = 0; i < modify->ncompute; i++) { for (const auto &compute : modify->get_compute_list()) {
check_forward += modify->compute[i]->comm_forward; check_forward += compute->comm_forward;
check_reverse += modify->compute[i]->comm_reverse; check_reverse += compute->comm_reverse;
} }
for (int i = 0; i < output->ndump; i++) { for (const auto &dump : output->get_dump_list()) {
check_forward += output->dump[i]->comm_forward; check_forward += dump->comm_forward;
check_reverse += output->dump[i]->comm_reverse; check_reverse += dump->comm_reverse;
} }
if (force->newton == 0) check_reverse = 0; if (force->newton == 0) check_reverse = 0;

View File

@ -222,18 +222,18 @@ void Comm::init()
if (force->bond) maxreverse = MAX(maxreverse,force->bond->comm_reverse); if (force->bond) maxreverse = MAX(maxreverse,force->bond->comm_reverse);
for (const auto &fix : fix_list) { for (const auto &fix : fix_list) {
maxforward = MAX(maxforward,fix->comm_forward); maxforward = MAX(maxforward, fix->comm_forward);
maxreverse = MAX(maxreverse,fix->comm_reverse); maxreverse = MAX(maxreverse, fix->comm_reverse);
} }
for (int i = 0; i < modify->ncompute; i++) { for (const auto &compute : modify->get_compute_list()) {
maxforward = MAX(maxforward,modify->compute[i]->comm_forward); maxforward = MAX(maxforward,compute->comm_forward);
maxreverse = MAX(maxreverse,modify->compute[i]->comm_reverse); maxreverse = MAX(maxreverse,compute->comm_reverse);
} }
for (int i = 0; i < output->ndump; i++) { for (const auto &dump: output->get_dump_list()) {
maxforward = MAX(maxforward,output->dump[i]->comm_forward); maxforward = MAX(maxforward,dump->comm_forward);
maxreverse = MAX(maxreverse,output->dump[i]->comm_reverse); maxreverse = MAX(maxreverse,dump->comm_reverse);
} }
if (force->newton == 0) maxreverse = 0; if (force->newton == 0) maxreverse = 0;
@ -247,8 +247,7 @@ void Comm::init()
maxexchange_atom = atom->avec->maxexchange; maxexchange_atom = atom->avec->maxexchange;
maxexchange_fix_dynamic = 0; maxexchange_fix_dynamic = 0;
for (const auto &fix : fix_list) for (const auto &fix : fix_list) if (fix->maxexchange_dynamic) maxexchange_fix_dynamic = 1;
if (fix->maxexchange_dynamic) maxexchange_fix_dynamic = 1;
if ((mode == Comm::MULTI) && (neighbor->style != Neighbor::MULTI)) if ((mode == Comm::MULTI) && (neighbor->style != Neighbor::MULTI))
error->all(FLERR,"Cannot use comm mode multi without multi-style neighbor lists"); error->all(FLERR,"Cannot use comm mode multi without multi-style neighbor lists");
@ -270,8 +269,7 @@ void Comm::init()
void Comm::init_exchange() void Comm::init_exchange()
{ {
maxexchange_fix = 0; maxexchange_fix = 0;
for (const auto &fix : modify->get_fix_list()) for (const auto &fix : modify->get_fix_list()) maxexchange_fix += fix->maxexchange;
maxexchange_fix += fix->maxexchange;
maxexchange = maxexchange_atom + maxexchange_fix; maxexchange = maxexchange_atom + maxexchange_fix;
bufextra = maxexchange + BUFEXTRA; 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 // clear mask of each atom assigned to this group
if (strcmp(arg[1],"delete") == 0) { 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]); 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"); if (igroup == 0) error->all(FLERR,"Cannot delete group all");
for (const auto &fix : modify->get_fix_list()) for (const auto &i : modify->get_fix_list())
if (fix->igroup == igroup) if (i->igroup == igroup)
error->all(FLERR,"Cannot delete group currently used by a fix"); error->all(FLERR,"Cannot delete group {} currently used by fix ID {}",arg[0],i->id);
for (i = 0; i < modify->ncompute; i++) for (const auto &i : modify->get_compute_list())
if (modify->compute[i]->igroup == igroup) if (i->igroup == igroup)
error->all(FLERR,"Cannot delete group currently used by a compute"); error->all(FLERR,"Cannot delete group {} currently used by compute ID {}",arg[0],i->id);
for (i = 0; i < output->ndump; i++) for (const auto &i : output->get_dump_list())
if (output->dump[i]->igroup == igroup) if (i->igroup == igroup)
error->all(FLERR,"Cannot delete group currently used by a dump"); error->all(FLERR,"Cannot delete group {} currently used by dump ID {}",arg[0],i->id);
if (atom->firstgroupname && strcmp(arg[0],atom->firstgroupname) == 0) if (atom->firstgroupname && strcmp(arg[0],atom->firstgroupname) == 0)
error->all(FLERR, error->all(FLERR,"Cannot delete group {} currently used by atom_modify first",arg[0]);
"Cannot delete group currently used by atom_modify first");
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; 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; auto lmp = (LAMMPS *) handle;
if (strcmp(category,"compute") == 0) { if (strcmp(category,"compute") == 0) {
int ncompute = lmp->modify->ncompute; if (lmp->modify->get_compute_by_id(name)) return 1;
Compute **compute = lmp->modify->compute;
for (int i=0; i < ncompute; ++i) {
if (strcmp(name,compute[i]->id) == 0) return 1;
}
} else if (strcmp(category,"dump") == 0) { } else if (strcmp(category,"dump") == 0) {
int ndump = lmp->output->ndump; if (lmp->output->get_dump_by_id(name)) return 1;
Dump **dump = lmp->output->dump;
for (int i=0; i < ndump; ++i) {
if (strcmp(name,dump[i]->id) == 0) return 1;
}
} else if (strcmp(category,"fix") == 0) { } else if (strcmp(category,"fix") == 0) {
for (auto &ifix : lmp->modify->get_fix_list()) { if (lmp->modify->get_fix_by_id(name)) return 1;
if (strcmp(name,ifix->id) == 0) return 1;
}
} else if (strcmp(category,"group") == 0) { } else if (strcmp(category,"group") == 0) {
int ngroup = lmp->group->ngroup; if (lmp->group->find(name) >= 0) return 1;
char **groups = lmp->group->names;
for (int i=0; i < ngroup; ++i) {
if (strcmp(groups[i],name) == 0) return 1;
}
} else if (strcmp(category,"molecule") == 0) { } else if (strcmp(category,"molecule") == 0) {
int nmolecule = lmp->atom->nmolecule; if (lmp->atom->find_molecule(name) >= 0) return 1;
Molecule **molecule = lmp->atom->molecules;
for (int i=0; i < nmolecule; ++i) {
if (strcmp(name,molecule[i]->id) == 0) return 1;
}
} else if (strcmp(category,"region") == 0) { } else if (strcmp(category,"region") == 0) {
for (auto &reg : lmp->domain->get_region_list()) { if (lmp->domain->get_region_by_id(name)) return 1;
if (strcmp(name,reg->id) == 0) return 1;
}
} else if (strcmp(category,"variable") == 0) { } else if (strcmp(category,"variable") == 0) {
int nvariable = lmp->input->variable->nvar; if (lmp->input->variable->find(name) >= 0) return 1;
char **varnames = lmp->input->variable->names;
for (int i=0; i < nvariable; ++i) {
if (strcmp(name,varnames[i]) == 0) return 1;
}
} }
return 0; return 0;
} }
@ -4823,11 +4799,11 @@ categories.
int lammps_id_count(void *handle, const char *category) { int lammps_id_count(void *handle, const char *category) {
auto lmp = (LAMMPS *) handle; auto lmp = (LAMMPS *) handle;
if (strcmp(category,"compute") == 0) { if (strcmp(category,"compute") == 0) {
return lmp->modify->ncompute; return lmp->modify->get_compute_list().size();
} else if (strcmp(category,"dump") == 0) { } else if (strcmp(category,"dump") == 0) {
return lmp->output->ndump; return lmp->output->get_dump_list().size();
} else if (strcmp(category,"fix") == 0) { } else if (strcmp(category,"fix") == 0) {
return lmp->modify->nfix; return lmp->modify->get_fix_list().size();
} else if (strcmp(category,"group") == 0) { } else if (strcmp(category,"group") == 0) {
return lmp->group->ngroup; return lmp->group->ngroup;
} else if (strcmp(category,"molecule") == 0) { } else if (strcmp(category,"molecule") == 0) {