Unverified Commit 01214de6 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add support for adding an ITEM: TIME output to some dump files

parent 6cd46007
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ void DumpAtomGZ::write_header(bigint ndump)
      ++unit_count;
      gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style);
    }
    if (time_flag) gzprintf(gzFp,"ITEM: TIME\n%.16g\n",compute_time());

    gzprintf(gzFp,"ITEM: TIMESTEP\n");
    gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
    gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
+2 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ void DumpCustomGZ::write_header(bigint ndump)
      ++unit_count;
      gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style);
    }
    if (time_flag) gzprintf(gzFp,"ITEM: TIME\n%.16g\n",compute_time());

    gzprintf(gzFp,"ITEM: TIMESTEP\n");
    gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
    gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
+2 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ void DumpLocalGZ::write_header(bigint ndump)
      ++unit_count;
      gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style);
    }
    if (time_flag) gzprintf(gzFp,"ITEM: TIME\n%.16g\n",compute_time());

    gzprintf(gzFp,"ITEM: TIMESTEP\n");
    gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
    gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
+14 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
  buffer_flag = 0;
  padflag = 0;
  pbcflag = 0;
  time_flag = 0;
  unit_flag = 0;
  unit_count = 0;
  delay_flag = 0;
@@ -1123,6 +1124,13 @@ void Dump::modify_params(int narg, char **arg)
      }
      iarg += 2;

    } else if (strcmp(arg[iarg],"time") == 0) {
      if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");
      if (strcmp(arg[iarg+1],"yes") == 0) time_flag = 1;
      else if (strcmp(arg[iarg+1],"no") == 0) time_flag = 0;
      else error->all(FLERR,"Illegal dump_modify command");
      iarg += 2;

    } else if (strcmp(arg[iarg],"units") == 0) {
      if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");
      if (strcmp(arg[iarg+1],"yes") == 0) unit_flag = 1;
@@ -1138,6 +1146,12 @@ void Dump::modify_params(int narg, char **arg)
  }
}

/* ---------------------------------------------------------------------- */

double Dump::compute_time()
{
  return update->atime + (update->ntimestep - update->atimestep)*update->dt;
}
/* ----------------------------------------------------------------------
   return # of bytes of allocated memory
------------------------------------------------------------------------- */
+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ class Dump : protected Pointers {
  int sortcol;               // 0 to sort on ID, 1-N on columns
  int sortcolm1;             // sortcol - 1
  int sortorder;             // ASCEND or DESCEND
  int time_flag;             // 1 if output accumulated time
  int unit_flag;             // 1 if dump should contain unit information
  int unit_count;            // # of times the unit information was written
  int delay_flag;            // 1 if delay output until delaystep
@@ -145,6 +146,7 @@ class Dump : protected Pointers {
  virtual int convert_string(int, double *) {return 0;}
  virtual void write_data(int, double *) = 0;
  void pbc_allocate();
  double compute_time();

  void sort();
#if defined(LMP_QSORT)
Loading