Commit 01051e4c authored by Steve Plimpton's avatar Steve Plimpton
Browse files

refactoring of neighbor history

parent 93c9a927
Loading
Loading
Loading
Loading
+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;
}
+1 −3
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ class PairGranHookeHistory : 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 *);
@@ -43,7 +42,6 @@ class PairGranHookeHistory : public Pair {
  int pack_forward_comm(int, int *, double *, int, int *);
  void unpack_forward_comm(int, int, double *);
  double memory_usage();
  void *extract(const char *, int &);

 protected:
  double kn,kt,gamman,gammat,xmu;
@@ -56,7 +54,7 @@ class PairGranHookeHistory : public Pair {
  double *onerad_dynamic,*onerad_frozen;
  double *maxrad_dynamic,*maxrad_frozen;

  class FixShearHistory *fix_history;
  class FixNeighHistory *fix_history;

  // storage of rigid body masses for use in granular interactions

+24 −19
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ class Fix : protected Pointers {
  virtual void setup(int) {}
  virtual void setup_pre_exchange() {}
  virtual void setup_pre_neighbor() {}
  virtual void setup_post_neighbor() {}
  virtual void setup_pre_force(int) {}
  virtual void setup_pre_reverse(int, int) {}
  virtual void min_setup(int) {}
@@ -120,6 +121,7 @@ class Fix : protected Pointers {
  virtual void post_integrate() {}
  virtual void pre_exchange() {}
  virtual void pre_neighbor() {}
  virtual void post_neighbor() {}
  virtual void pre_force(int) {}
  virtual void pre_reverse(int,int) {}
  virtual void post_force(int) {}
@@ -155,6 +157,7 @@ class Fix : protected Pointers {

  virtual void min_pre_exchange() {}
  virtual void min_pre_neighbor() {}
  virtual void min_post_neighbor() {}
  virtual void min_pre_force(int) {}
  virtual void min_pre_reverse(int,int) {}
  virtual void min_post_force(int) {}
@@ -244,25 +247,27 @@ namespace FixConst {
  static const int POST_INTEGRATE =          1<<1;
  static const int PRE_EXCHANGE =            1<<2;
  static const int PRE_NEIGHBOR =            1<<3;
  static const int PRE_FORCE =               1<<4;
  static const int PRE_REVERSE =             1<<5;
  static const int POST_FORCE =              1<<6;
  static const int FINAL_INTEGRATE =         1<<7;
  static const int END_OF_STEP =             1<<8;
  static const int POST_RUN =                1<<9;
  static const int THERMO_ENERGY =           1<<10;
  static const int INITIAL_INTEGRATE_RESPA = 1<<11;
  static const int POST_INTEGRATE_RESPA =    1<<12;
  static const int PRE_FORCE_RESPA =         1<<13;
  static const int POST_FORCE_RESPA =        1<<14;
  static const int FINAL_INTEGRATE_RESPA =   1<<15;
  static const int MIN_PRE_EXCHANGE =        1<<16;
  static const int MIN_PRE_NEIGHBOR =        1<<17;
  static const int MIN_PRE_FORCE =           1<<18;
  static const int MIN_PRE_REVERSE =         1<<19;
  static const int MIN_POST_FORCE =          1<<20;
  static const int MIN_ENERGY =              1<<21;
  static const int FIX_CONST_LAST =          1<<22;
  static const int POST_NEIGHBOR =           1<<4;
  static const int PRE_FORCE =               1<<5;
  static const int PRE_REVERSE =             1<<6;
  static const int POST_FORCE =              1<<7;
  static const int FINAL_INTEGRATE =         1<<8;
  static const int END_OF_STEP =             1<<9;
  static const int POST_RUN =                1<<10;
  static const int THERMO_ENERGY =           1<<11;
  static const int INITIAL_INTEGRATE_RESPA = 1<<12;
  static const int POST_INTEGRATE_RESPA =    1<<13;
  static const int PRE_FORCE_RESPA =         1<<14;
  static const int POST_FORCE_RESPA =        1<<15;
  static const int FINAL_INTEGRATE_RESPA =   1<<16;
  static const int MIN_PRE_EXCHANGE =        1<<17;
  static const int MIN_PRE_NEIGHBOR =        1<<18;
  static const int MIN_POST_NEIGHBOR =       1<<19;
  static const int MIN_PRE_FORCE =           1<<20;
  static const int MIN_PRE_REVERSE =         1<<21;
  static const int MIN_POST_FORCE =          1<<22;
  static const int MIN_ENERGY =              1<<23;
  static const int FIX_CONST_LAST =          1<<24;
}

}
+315 −183

File changed and moved.

Preview size limit exceeded, changes collapsed.

Loading