refactor dump code to no longer need access to internal Modify class data
This commit is contained in:
@ -2096,7 +2096,7 @@ int DumpVTK::modify_param(int narg, char **arg)
|
|||||||
if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh");
|
if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh");
|
||||||
|
|
||||||
refreshflag = 1;
|
refreshflag = 1;
|
||||||
refresh = argi.copy_name();
|
idrefresh = argi.copy_name();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
src/dump.cpp
37
src/dump.cpp
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -38,16 +37,16 @@ using namespace LAMMPS_NS;
|
|||||||
Dump *Dump::dumpptr;
|
Dump *Dump::dumpptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BIG 1.0e20
|
static constexpr double BIG = 1.0e20;
|
||||||
#define EPSILON 1.0e-6
|
static constexpr double EPSILON = 1.0e-6;
|
||||||
|
|
||||||
enum { ASCEND, DESCEND };
|
enum { ASCEND, DESCEND };
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) :
|
Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) :
|
||||||
Pointers(lmp), multiname(nullptr), refresh(nullptr), skipvar(nullptr), format(nullptr),
|
Pointers(lmp), multiname(nullptr), idrefresh(nullptr), irefresh(nullptr), skipvar(nullptr),
|
||||||
format_default(nullptr), format_line_user(nullptr), format_float_user(nullptr),
|
format(nullptr), format_default(nullptr), format_line_user(nullptr), format_float_user(nullptr),
|
||||||
format_int_user(nullptr), format_bigint_user(nullptr), format_column_user(nullptr), fp(nullptr),
|
format_int_user(nullptr), format_bigint_user(nullptr), format_column_user(nullptr), fp(nullptr),
|
||||||
nameslist(nullptr), buf(nullptr), sbuf(nullptr), ids(nullptr), bufsort(nullptr),
|
nameslist(nullptr), buf(nullptr), sbuf(nullptr), ids(nullptr), bufsort(nullptr),
|
||||||
idsort(nullptr), index(nullptr), proclist(nullptr), xpbc(nullptr), vpbc(nullptr),
|
idsort(nullptr), index(nullptr), proclist(nullptr), xpbc(nullptr), vpbc(nullptr),
|
||||||
@ -119,21 +118,21 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) :
|
|||||||
fileproc = 0;
|
fileproc = 0;
|
||||||
|
|
||||||
char *ptr;
|
char *ptr;
|
||||||
if ((ptr = strchr(filename,'%'))) {
|
if ((ptr = strchr(filename, '%'))) {
|
||||||
multiproc = 1;
|
multiproc = 1;
|
||||||
nclusterprocs = 1;
|
nclusterprocs = 1;
|
||||||
filewriter = 1;
|
filewriter = 1;
|
||||||
fileproc = me;
|
fileproc = me;
|
||||||
MPI_Comm_split(world,me,0,&clustercomm);
|
MPI_Comm_split(world, me, 0, &clustercomm);
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr+1));
|
multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr + 1));
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr(filename,'*')) multifile = 1;
|
if (strchr(filename, '*')) multifile = 1;
|
||||||
|
|
||||||
if (utils::strmatch(filename, "\\.bin$")
|
if (utils::strmatch(filename, "\\.bin$") || utils::strmatch(filename, "\\.lammpsbin$"))
|
||||||
|| utils::strmatch(filename, "\\.lammpsbin$")) binary = 1;
|
binary = 1;
|
||||||
if (platform::has_compress_extension(filename)) compressed = 1;
|
if (platform::has_compress_extension(filename)) compressed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +152,7 @@ Dump::~Dump()
|
|||||||
delete[] format_int_user;
|
delete[] format_int_user;
|
||||||
delete[] format_bigint_user;
|
delete[] format_bigint_user;
|
||||||
|
|
||||||
delete[] refresh;
|
delete[] idrefresh;
|
||||||
delete[] skipvar;
|
delete[] skipvar;
|
||||||
|
|
||||||
// format_column_user is deallocated by child classes that use it
|
// format_column_user is deallocated by child classes that use it
|
||||||
@ -179,8 +178,7 @@ Dump::~Dump()
|
|||||||
// delete storage for caching file names
|
// delete storage for caching file names
|
||||||
|
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
for (int idx=0; idx < numfiles; ++idx)
|
for (int idx = 0; idx < numfiles; ++idx) delete[] nameslist[idx];
|
||||||
delete[] nameslist[idx];
|
|
||||||
delete[] nameslist;
|
delete[] nameslist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +194,8 @@ Dump::~Dump()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Dump::init()
|
void Dump::init()
|
||||||
@ -288,11 +288,8 @@ void Dump::init()
|
|||||||
// search for refresh compute specified by dump_modify refresh
|
// search for refresh compute specified by dump_modify refresh
|
||||||
|
|
||||||
if (refreshflag) {
|
if (refreshflag) {
|
||||||
int icompute;
|
irefresh = modify->get_compute_by_id(idrefresh);
|
||||||
for (icompute = 0; icompute < modify->ncompute; icompute++)
|
if (!irefresh) error->all(FLERR,"Dump could not find refresh compute ID {}", idrefresh);
|
||||||
if (strcmp(refresh,modify->compute[icompute]->id) == 0) break;
|
|
||||||
if (icompute < modify->ncompute) irefresh = icompute;
|
|
||||||
else error->all(FLERR,"Dump could not find refresh compute ID");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if skipflag, check skip variable
|
// if skipflag, check skip variable
|
||||||
@ -531,7 +528,7 @@ void Dump::write()
|
|||||||
// trigger post-dump refresh by specified compute
|
// trigger post-dump refresh by specified compute
|
||||||
// currently used for incremental dump files
|
// currently used for incremental dump files
|
||||||
|
|
||||||
if (refreshflag) modify->compute[irefresh]->refresh();
|
if (refreshflag) irefresh->refresh();
|
||||||
|
|
||||||
if (filewriter && fp != nullptr) write_footer();
|
if (filewriter && fp != nullptr) write_footer();
|
||||||
|
|
||||||
|
|||||||
27
src/dump.h
27
src/dump.h
@ -19,6 +19,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
class Compute;
|
||||||
|
|
||||||
class Dump : protected Pointers {
|
class Dump : protected Pointers {
|
||||||
friend class Output;
|
friend class Output;
|
||||||
@ -45,15 +46,9 @@ class Dump : protected Pointers {
|
|||||||
void init();
|
void init();
|
||||||
virtual void write();
|
virtual void write();
|
||||||
|
|
||||||
virtual int pack_forward_comm(int, int *, double *, int, int *)
|
virtual int pack_forward_comm(int, int *, double *, int, int *) { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual void unpack_forward_comm(int, int, double *) {}
|
virtual void unpack_forward_comm(int, int, double *) {}
|
||||||
virtual int pack_reverse_comm(int, int, double *)
|
virtual int pack_reverse_comm(int, int, double *) { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual void unpack_reverse_comm(int, int *, double *) {}
|
virtual void unpack_reverse_comm(int, int *, double *) {}
|
||||||
|
|
||||||
void modify_params(int, char **);
|
void modify_params(int, char **);
|
||||||
@ -94,9 +89,9 @@ class Dump : protected Pointers {
|
|||||||
|
|
||||||
bigint delaystep;
|
bigint delaystep;
|
||||||
|
|
||||||
int refreshflag; // 1 if dump_modify refresh specified
|
int refreshflag; // 1 if dump_modify refresh specified
|
||||||
char *refresh; // compute ID to invoke refresh() on
|
char *idrefresh; // compute ID to invoke refresh() on
|
||||||
int irefresh; // index of compute
|
Compute *irefresh; // index of compute
|
||||||
|
|
||||||
int skipflag; // 1 if skip condition defined
|
int skipflag; // 1 if skip condition defined
|
||||||
char *skipvar; // name of variable to check for skip condition
|
char *skipvar; // name of variable to check for skip condition
|
||||||
@ -158,17 +153,11 @@ class Dump : protected Pointers {
|
|||||||
|
|
||||||
virtual void init_style() = 0;
|
virtual void init_style() = 0;
|
||||||
virtual void openfile();
|
virtual void openfile();
|
||||||
virtual int modify_param(int, char **)
|
virtual int modify_param(int, char **) { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual void write_header(bigint) = 0;
|
virtual void write_header(bigint) = 0;
|
||||||
virtual int count();
|
virtual int count();
|
||||||
virtual void pack(tagint *) = 0;
|
virtual void pack(tagint *) = 0;
|
||||||
virtual int convert_string(int, double *)
|
virtual int convert_string(int, double *) { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual void write_data(int, double *) = 0;
|
virtual void write_data(int, double *) = 0;
|
||||||
virtual void write_footer() {}
|
virtual void write_footer() {}
|
||||||
|
|
||||||
|
|||||||
@ -1768,7 +1768,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh");
|
if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh");
|
||||||
|
|
||||||
refreshflag = 1;
|
refreshflag = 1;
|
||||||
refresh = argi.copy_name();
|
idrefresh = argi.copy_name();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user