simplify
This commit is contained in:
37
src/info.cpp
37
src/info.cpp
@ -887,42 +887,17 @@ bool Info::is_defined(const char *category, const char *name)
|
||||
if ((category == nullptr) || (name == nullptr)) return false;
|
||||
|
||||
if (strcmp(category,"compute") == 0) {
|
||||
int ncompute = modify->ncompute;
|
||||
Compute **compute = modify->compute;
|
||||
for (int i=0; i < ncompute; ++i) {
|
||||
if (strcmp(compute[i]->id,name) == 0)
|
||||
return true;
|
||||
}
|
||||
if (modify->get_compute_by_id(name)) return true;
|
||||
} else if (strcmp(category,"dump") == 0) {
|
||||
int ndump = output->ndump;
|
||||
Dump **dump = output->dump;
|
||||
for (int i=0; i < ndump; ++i) {
|
||||
if (strcmp(dump[i]->id,name) == 0)
|
||||
return true;
|
||||
}
|
||||
if (output->get_dump_by_id(name)) return true;
|
||||
} else if (strcmp(category,"fix") == 0) {
|
||||
for (const auto &fix : modify->get_fix_list()) {
|
||||
if (strcmp(fix->id,name) == 0)
|
||||
return true;
|
||||
}
|
||||
if (modify->get_fix_by_id(name)) return true;
|
||||
} else if (strcmp(category,"group") == 0) {
|
||||
int ngroup = group->ngroup;
|
||||
char **names = group->names;
|
||||
for (int i=0; i < ngroup; ++i) {
|
||||
if (strcmp(names[i],name) == 0)
|
||||
return true;
|
||||
}
|
||||
if (group->find(name) >= 0) return true;
|
||||
} else if (strcmp(category,"region") == 0) {
|
||||
for (auto ® : domain->get_region_list())
|
||||
if (strcmp(reg->id,name) == 0) return true;
|
||||
if (domain->get_region_by_id(name)) return true;
|
||||
} else if (strcmp(category,"variable") == 0) {
|
||||
int nvar = input->variable->nvar;
|
||||
char **names = input->variable->names;
|
||||
|
||||
for (int i=0; i < nvar; ++i) {
|
||||
if (strcmp(names[i],name) == 0)
|
||||
return true;
|
||||
}
|
||||
if (input->variable->find(name) >= 0) return true;
|
||||
} else error->all(FLERR,"Unknown category for info is_defined(): {}", category);
|
||||
|
||||
return false;
|
||||
|
||||
@ -4841,6 +4841,7 @@ set to an empty string, otherwise 1.
|
||||
*/
|
||||
int lammps_id_name(void *handle, const char *category, int idx, char *buffer, int buf_size) {
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
if (idx < 0) return 0;
|
||||
|
||||
if (strcmp(category,"compute") == 0) {
|
||||
auto icompute = lmp->modify->get_compute_by_index(idx);
|
||||
@ -4849,8 +4850,9 @@ int lammps_id_name(void *handle, const char *category, int idx, char *buffer, in
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"dump") == 0) {
|
||||
if ((idx >=0) && (idx < lmp->output->ndump)) {
|
||||
strncpy(buffer, lmp->output->dump[idx]->id, buf_size);
|
||||
auto idump = lmp->output->get_dump_by_index(idx);
|
||||
if (idump) {
|
||||
strncpy(buffer, idump->id, buf_size);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(category,"fix") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user