Unverified Commit 4243af30 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

properly store 64-bit integers for next_reneighbor into double type buffers for restarts of fixes

also store number of attemps and number of successes in restart and retrieve those from it
parent daac3f71
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -771,10 +771,12 @@ double FixAtomSwap::memory_usage()
void FixAtomSwap::write_restart(FILE *fp)
{
  int n = 0;
  double list[4];
  double list[6];
  list[n++] = random_equal->state();
  list[n++] = random_unequal->state();
  list[n++] = next_reneighbor;
  list[n++] = ubuf(next_reneighbor).d;
  list[n++] = nswap_attempts;
  list[n++] = nswap_successes;

  if (comm->me == 0) {
    int size = n * sizeof(double);
@@ -798,5 +800,8 @@ void FixAtomSwap::restart(char *buf)
  seed = static_cast<int> (list[n++]);
  random_unequal->reset(seed);

  next_reneighbor = static_cast<int> (list[n++]);
  next_reneighbor = (bigint) ubuf(list[n++]).i;

  nswap_attempts = static_cast<int>(list[n++]);
  nswap_successes = static_cast<int>(list[n++]);
}
+21 −3
Original line number Diff line number Diff line
@@ -2531,10 +2531,19 @@ double FixGCMC::memory_usage()
void FixGCMC::write_restart(FILE *fp)
{
  int n = 0;
  double list[4];
  double list[12];
  list[n++] = random_equal->state();
  list[n++] = random_unequal->state();
  list[n++] = next_reneighbor;
  list[n++] = ubuf(next_reneighbor).d;
  list[n++] = ntranslation_attempts;
  list[n++] = ntranslation_successes;
  list[n++] = nrotation_attempts;
  list[n++] = nrotation_successes;
  list[n++] = ndeletion_attempts;
  list[n++] = ndeletion_successes;
  list[n++] = ninsertion_attempts;
  list[n++] = ninsertion_successes;


  if (comm->me == 0) {
    int size = n * sizeof(double);
@@ -2558,7 +2567,16 @@ void FixGCMC::restart(char *buf)
  seed = static_cast<int> (list[n++]);
  random_unequal->reset(seed);

  next_reneighbor = static_cast<int> (list[n++]);
  next_reneighbor = (bigint) ubuf(list[n++]).i;

  ntranslation_attempts  = list[n++];
  ntranslation_successes = list[n++];
  nrotation_attempts     = list[n++];
  nrotation_successes    = list[n++];
  ndeletion_attempts     = list[n++];
  ndeletion_successes    = list[n++];
  ninsertion_attempts    = list[n++];
  ninsertion_successes   = list[n++];
}

void FixGCMC::grow_molecule_arrays(int nmolatoms) {
+2 −2
Original line number Diff line number Diff line
@@ -802,7 +802,7 @@ void FixDeposit::write_restart(FILE *fp)
  list[n++] = random->state();
  list[n++] = ninserted;
  list[n++] = nfirst;
  list[n++] = next_reneighbor;
  list[n++] = ubuf(next_reneighbor).d;

  if (comm->me == 0) {
    int size = n * sizeof(double);
@@ -823,7 +823,7 @@ void FixDeposit::restart(char *buf)
  seed = static_cast<int> (list[n++]);
  ninserted = static_cast<int> (list[n++]);
  nfirst = static_cast<int> (list[n++]);
  next_reneighbor = static_cast<int> (list[n++]);
  next_reneighbor = (bigint) ubuf(list[n++]).i;

  random->reset(seed);
}