Commit 7dfc6b7e authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #688 from lammps/history

refactoring of neighbor history
parents f8f13d92 17c17ac4
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -225,10 +225,10 @@ void PairLJCutCoulLongCS::compute_inner()
  int newton_pair = force->newton_pair;
  double qqrd2e = force->qqrd2e;

  inum = listinner->inum;
  ilist = listinner->ilist;
  numneigh = listinner->numneigh;
  firstneigh = listinner->firstneigh;
  inum = list->inum_inner;
  ilist = list->ilist_inner;
  numneigh = list->numneigh_inner;
  firstneigh = list->firstneigh_inner;

  double cut_out_on = cut_respa[0];
  double cut_out_off = cut_respa[1];
@@ -311,10 +311,10 @@ void PairLJCutCoulLongCS::compute_middle()
  int newton_pair = force->newton_pair;
  double qqrd2e = force->qqrd2e;

  inum = listmiddle->inum;
  ilist = listmiddle->ilist;
  numneigh = listmiddle->numneigh;
  firstneigh = listmiddle->firstneigh;
  inum = list->inum_middle;
  ilist = list->ilist_middle;
  numneigh = list->numneigh_middle;
  firstneigh = list->firstneigh_middle;

  double cut_in_off = cut_respa[0];
  double cut_in_on = cut_respa[1];
@@ -412,10 +412,10 @@ void PairLJCutCoulLongCS::compute_outer(int eflag, int vflag)
  int newton_pair = force->newton_pair;
  double qqrd2e = force->qqrd2e;

  inum = listouter->inum;
  ilist = listouter->ilist;
  numneigh = listouter->numneigh;
  firstneigh = listouter->firstneigh;
  inum = list->inum;
  ilist = list->ilist;
  numneigh = list->numneigh;
  firstneigh = list->firstneigh;

  double cut_in_off = cut_respa[2];
  double cut_in_on = cut_respa[3];
+0 −16
Original line number Diff line number Diff line
@@ -263,22 +263,6 @@ void PairLJLongDipoleLong::init_style()
  if (force->kspace) g_ewald = force->kspace->g_ewald;
}

/* ----------------------------------------------------------------------
   neighbor callback to inform pair style of neighbor list to use
   regular or rRESPA
------------------------------------------------------------------------- */

void PairLJLongDipoleLong::init_list(int id, NeighList *ptr)
{
  if (id == 0) list = ptr;
  else if (id == 1) listinner = ptr;
  else if (id == 2) listmiddle = ptr;
  else if (id == 3) listouter = ptr;

  if (id)
    error->all(FLERR,"Pair style lj/long/dipole/long does not currently support respa");
}

/* ----------------------------------------------------------------------
   init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
+0 −1
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ class PairLJLongDipoleLong : public Pair {
  virtual void settings(int, char **);
  void coeff(int, char **);
  void init_style();
  void init_list(int, class NeighList *);
  double init_one(int, int);
  void write_restart(FILE *);
  void read_restart(FILE *);
+4 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "update.h"
#include "force.h"
#include "fix.h"
#include "fix_neigh_history.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "comm.h"
@@ -95,8 +96,8 @@ void PairGranHertzHistory::compute(int eflag, int vflag)
  ilist = list->ilist;
  numneigh = list->numneigh;
  firstneigh = list->firstneigh;
  firsttouch = list->listhistory->firstneigh;
  firstshear = list->listhistory->firstdouble;
  firsttouch = fix_history->firstflag;
  firstshear = fix_history->firstvalue;

  // loop over neighbors of my atoms

@@ -407,7 +408,7 @@ double PairGranHertzHistory::single(int i, int j, int itype, int jtype,

  int jnum = list->numneigh[i];
  int *jlist = list->firstneigh[i];
  double *allshear = list->listhistory->firstdouble[i];
  double *allshear = fix_history->firstvalue[i];

  for (int jj = 0; jj < jnum; jj++) {
    neighprev++;
+14 −43
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include "update.h"
#include "modify.h"
#include "fix.h"
#include "fix_shear_history.h"
#include "fix_neigh_history.h"
#include "comm.h"
#include "neighbor.h"
#include "neigh_list.h"
@@ -64,7 +64,7 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp)
PairGranHookeHistory::~PairGranHookeHistory()
{
  delete [] svector;
  if (fix_history) modify->delete_fix("SHEAR_HISTORY");
  if (fix_history) modify->delete_fix("NEIGH_HISTORY");

  if (allocated) {
    memory->destroy(setflag);
@@ -137,8 +137,8 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
  ilist = list->ilist;
  numneigh = list->numneigh;
  firstneigh = list->firstneigh;
  firsttouch = listhistory->firstneigh;
  firstshear = listhistory->firstdouble;
  firsttouch = fix_history->firstflag;
  firstshear = fix_history->firstvalue;

  // loop over neighbors of my atoms

@@ -400,35 +400,28 @@ void PairGranHookeHistory::init_style()
  if (comm->ghost_velocity == 0)
    error->all(FLERR,"Pair granular requires ghost atoms store velocity");

  // need a granular neigh list and optionally a granular history neigh list
  // need a granular neigh list

  int irequest = neighbor->request(this,instance_me);
  neighbor->requests[irequest]->size = 1;
  if (history) {
    irequest = neighbor->request(this,instance_me);
    neighbor->requests[irequest]->id = 1;
    neighbor->requests[irequest]->history = 1;
    neighbor->requests[irequest]->dnum = 3;
  }
  if (history) neighbor->requests[irequest]->history = 1;

  dt = update->dt;

  // if shear history is stored:
  // if first init, create Fix needed for storing shear history

  if (history && fix_history == NULL) {
    char dnumstr[16];
    sprintf(dnumstr,"%d",3);
    char **fixarg = new char*[4];
    fixarg[0] = (char *) "SHEAR_HISTORY";
    fixarg[0] = (char *) "NEIGH_HISTORY";
    fixarg[1] = (char *) "all";
    fixarg[2] = (char *) "SHEAR_HISTORY";
    fixarg[2] = (char *) "NEIGH_HISTORY";
    fixarg[3] = dnumstr;
    modify->add_fix(4,fixarg);
    modify->add_fix(4,fixarg,1);
    delete [] fixarg;
    fix_history = (FixShearHistory *) modify->fix[modify->nfix-1];
    fix_history = (FixNeighHistory *) modify->fix[modify->nfix-1];
    fix_history->pair = this;
    neighbor->requests[irequest]->fix_history = fix_history;
  }

  // check for FixFreeze and set freeze_group_bit
@@ -494,23 +487,12 @@ void PairGranHookeHistory::init_style()
  // set fix which stores history info

  if (history) {
    int ifix = modify->find_fix("SHEAR_HISTORY");
    if (ifix < 0) error->all(FLERR,"Could not find pair fix ID");
    fix_history = (FixShearHistory *) modify->fix[ifix];
    int ifix = modify->find_fix("NEIGH_HISTORY");
    if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID");
    fix_history = (FixNeighHistory *) modify->fix[ifix];
  }
}

/* ----------------------------------------------------------------------
   neighbor callback to inform pair style of neighbor list to use
   optional granular history list
------------------------------------------------------------------------- */

void PairGranHookeHistory::init_list(int id, NeighList *ptr)
{
  if (id == 0) list = ptr;
  else if (id == 1) listhistory = ptr;
}

/* ----------------------------------------------------------------------
   init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
@@ -704,7 +686,7 @@ double PairGranHookeHistory::single(int i, int j, int itype, int jtype,

  int jnum = list->numneigh[i];
  int *jlist = list->firstneigh[i];
  double *allshear = list->listhistory->firstdouble[i];
  double *allshear = fix_history->firstvalue[i];

  for (int jj = 0; jj < jnum; jj++) {
    neighprev++;
@@ -797,14 +779,3 @@ double PairGranHookeHistory::memory_usage()
  double bytes = nmax * sizeof(double);
  return bytes;
}

/* ----------------------------------------------------------------------
   return ptr to FixShearHistory class
   called by Neighbor when setting up neighbor lists
------------------------------------------------------------------------- */

void *PairGranHookeHistory::extract(const char *str, int &dim)
{
  if (strcmp(str,"history") == 0) return (void *) fix_history;
  return NULL;
}
Loading