From d41d5960e49eaf375fed10b89ed610b59299929f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 11 Aug 2022 04:07:49 -0400 Subject: [PATCH] simplify and modernize --- src/H5MD/dump_h5md.cpp | 13 ++++--------- src/H5MD/dump_h5md.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/H5MD/dump_h5md.cpp b/src/H5MD/dump_h5md.cpp index 1ee2bd2a54..2bb5af3043 100644 --- a/src/H5MD/dump_h5md.cpp +++ b/src/H5MD/dump_h5md.cpp @@ -73,7 +73,7 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) format_default = nullptr; flush_flag = 0; unwrap_flag = 0; - datafile_from_dump = -1; + other_dump = nullptr; author_name = nullptr; every_dump = utils::inumeric(FLERR,arg[3],false,lmp); @@ -141,11 +141,8 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) } if (box_is_set||create_group_is_set) error->all(FLERR, "Cannot set file_from in dump h5md after box or create_group"); - int idump; - for (idump = 0; idump < output->ndump; idump++) - if (strcmp(arg[iarg+1],output->dump[idump]->id) == 0) break; - if (idump == output->ndump) error->all(FLERR,"Cound not find dump_modify ID"); - datafile_from_dump = idump; + other_dump = dynamic_cast(output->get_dump_by_id(arg[iarg+1])); + if (!other_dump) error->all(FLERR,"Cound not find dump_modify H5MD dump ID {}", arg[iarg+1]); do_box=false; create_group=false; iarg+=2; @@ -262,7 +259,7 @@ void DumpH5MD::openfile() } if (me == 0) { - if (datafile_from_dump<0) { + if (!other_dump) { if (author_name==nullptr) { datafile = h5md_create_file(filename, "N/A", nullptr, "lammps", LAMMPS_VERSION); } else { @@ -296,8 +293,6 @@ void DumpH5MD::openfile() h5md_write_string_attribute(particles_data.group, "charge", "type", "effective"); } } else { - DumpH5MD* other_dump; - other_dump=(DumpH5MD*)output->dump[datafile_from_dump]; datafile = other_dump->datafile; group_name_length = strlen(group->names[igroup]); group_name = new char[group_name_length]; diff --git a/src/H5MD/dump_h5md.h b/src/H5MD/dump_h5md.h index 6634cdb8ae..e33f64f54a 100644 --- a/src/H5MD/dump_h5md.h +++ b/src/H5MD/dump_h5md.h @@ -35,9 +35,9 @@ class DumpH5MD : public Dump { int natoms, ntotal; int unwrap_flag; // 1 if atom coords are unwrapped, 0 if no h5md_file datafile; - int datafile_from_dump; h5md_particles_group particles_data; char *author_name; + DumpH5MD *other_dump; bool do_box; bool create_group;