From 5187cb97e5f15db89405df77a8355b9f59fd46b3 Mon Sep 17 00:00:00 2001
From: Tim Mattox <timothy.mattox@engilitycorp.com>
Date: Fri, 9 Dec 2016 15:42:27 -0600
Subject: [PATCH] USER-DPD: Make fix_shardlow request its own SSA-specific
 neighbor list, instead of having pair_dpd_fdt* make the SSA-neighbor list
 request for it. Forces an "extra" list to be built, but now skip lists work
 properly. Maybe we can detect if skip lists won't be used, and squash the
 extra list.

---
 src/USER-DPD/fix_shardlow.cpp        | 23 +++++++++++++++++++----
 src/USER-DPD/fix_shardlow.h          |  4 ++++
 src/USER-DPD/pair_dpd_fdt.cpp        |  2 --
 src/USER-DPD/pair_dpd_fdt_energy.cpp |  2 --
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/USER-DPD/fix_shardlow.cpp b/src/USER-DPD/fix_shardlow.cpp
index 2253b11932..28c5382237 100644
--- a/src/USER-DPD/fix_shardlow.cpp
+++ b/src/USER-DPD/fix_shardlow.cpp
@@ -47,6 +47,7 @@
 #include "comm.h"
 #include "neighbor.h"
 #include "neigh_list.h"
+#include "neigh_request.h"
 #include "random_mars.h"
 #include "memory.h"
 #include "domain.h"
@@ -139,6 +140,23 @@ int FixShardlow::setmask()
 
 /* ---------------------------------------------------------------------- */
 
+void FixShardlow::init()
+{
+  int irequest = neighbor->request(this,instance_me);
+  neighbor->requests[irequest]->pair = 0;
+  neighbor->requests[irequest]->fix  = 1;
+  neighbor->requests[irequest]->ssa  = 1;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void FixShardlow::init_list(int id, NeighList *ptr)
+{
+  list = ptr;
+}
+
+/* ---------------------------------------------------------------------- */
+
 void FixShardlow::pre_exchange()
 {
   memset(atom->ssaAIR, 0, sizeof(int)*atom->nlocal);
@@ -410,7 +428,6 @@ void FixShardlow::initial_integrate(int vflag)
   int nghost = atom->nghost;
 
   int airnum;
-  class NeighList *list; // points to list in pairDPD or pairDPDE
   class RanMars *pRNG;
 
   // NOTE: this logic is specific to orthogonal boxes, not triclinic
@@ -431,12 +448,10 @@ void FixShardlow::initial_integrate(int vflag)
   // Allocate memory for v_t0 to hold the initial velocities for the ghosts
   v_t0 = (double (*)[3]) memory->smalloc(sizeof(double)*3*nghost, "FixShardlow:v_t0");
 
-  // Define pointers to access the neighbor list and RNG
+  // Define pointers to access the RNG
   if(pairDPDE){
-    list = pairDPDE->list;
     pRNG = pairDPDE->random;
   } else {
-    list = pairDPD->list;
     pRNG = pairDPD->random;
   }
   inum = list->inum;
diff --git a/src/USER-DPD/fix_shardlow.h b/src/USER-DPD/fix_shardlow.h
index ede0ef4e0b..45a7b030b9 100644
--- a/src/USER-DPD/fix_shardlow.h
+++ b/src/USER-DPD/fix_shardlow.h
@@ -26,9 +26,13 @@ namespace LAMMPS_NS {
 
 class FixShardlow : public Fix {
  public:
+  class NeighList *list; // The SSA specific neighbor list
+
   FixShardlow(class LAMMPS *, int, char **);
   ~FixShardlow();
   int setmask();
+  virtual void init();
+  virtual void init_list(int, class NeighList *);
   virtual void setup(int);
   virtual void initial_integrate(int);
   void setup_pre_exchange();
diff --git a/src/USER-DPD/pair_dpd_fdt.cpp b/src/USER-DPD/pair_dpd_fdt.cpp
index 3b5804ff8e..cea5b87404 100644
--- a/src/USER-DPD/pair_dpd_fdt.cpp
+++ b/src/USER-DPD/pair_dpd_fdt.cpp
@@ -320,11 +320,9 @@ void PairDPDfdt::init_style()
 
   splitFDT_flag = false;
   int irequest = neighbor->request(this,instance_me);
-  neighbor->requests[irequest]->ssa = 0;
   for (int i = 0; i < modify->nfix; i++)
     if (strcmp(modify->fix[i]->style,"shardlow") == 0){
       splitFDT_flag = true;
-      neighbor->requests[irequest]->ssa = 1;
     }
 }
 
diff --git a/src/USER-DPD/pair_dpd_fdt_energy.cpp b/src/USER-DPD/pair_dpd_fdt_energy.cpp
index 99ba4de582..2041405467 100644
--- a/src/USER-DPD/pair_dpd_fdt_energy.cpp
+++ b/src/USER-DPD/pair_dpd_fdt_energy.cpp
@@ -408,11 +408,9 @@ void PairDPDfdtEnergy::init_style()
 
   splitFDT_flag = false;
   int irequest = neighbor->request(this,instance_me);
-  neighbor->requests[irequest]->ssa = 0;
   for (int i = 0; i < modify->nfix; i++)
     if (strcmp(modify->fix[i]->style,"shardlow") == 0){
       splitFDT_flag = true;
-      neighbor->requests[irequest]->ssa = 1;
     }
 
   bool eos_flag = false;
-- 
GitLab