From 7dc380b113d8b8955c0c55db0cf601fe4fa7b31d Mon Sep 17 00:00:00 2001
From: Steve Plimpton <sjplimp@sandia.gov>
Date: Wed, 21 Jun 2017 12:44:35 -0600
Subject: [PATCH] insure compute pair/property local will use a copy of
 granular neigh list

---
 src/compute_pair_local.cpp     |  4 ++++
 src/compute_property_local.cpp |  4 ++++
 src/neighbor.cpp               | 19 +++++++++++++++++++
 src/neighbor.h                 |  1 +
 4 files changed, 28 insertions(+)

diff --git a/src/compute_pair_local.cpp b/src/compute_pair_local.cpp
index 4595175503..adac486bef 100644
--- a/src/compute_pair_local.cpp
+++ b/src/compute_pair_local.cpp
@@ -126,11 +126,15 @@ void ComputePairLocal::init()
                  " requested by compute pair/local");
 
   // need an occasional half neighbor list
+  // set size to same value as request made by force->pair
+  // this should enable it to always be a copy list (e.g. for granular pstyle)
 
   int irequest = neighbor->request(this,instance_me);
   neighbor->requests[irequest]->pair = 0;
   neighbor->requests[irequest]->compute = 1;
   neighbor->requests[irequest]->occasional = 1;
+  NeighRequest *pairrequest = neighbor->find_request((void *) force->pair);
+  if (pairrequest) neighbor->requests[irequest]->size = pairrequest->size;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp
index 90faa88921..27b31979c9 100644
--- a/src/compute_property_local.cpp
+++ b/src/compute_property_local.cpp
@@ -280,12 +280,16 @@ void ComputePropertyLocal::init()
   }
 
   // for NEIGH/PAIR need an occasional half neighbor list
+  // set size to same value as request made by force->pair
+  // this should enable it to always be a copy list  (e.g. for granular pstyle)
 
   if (kindflag == NEIGH || kindflag == PAIR) {
     int irequest = neighbor->request(this,instance_me);
     neighbor->requests[irequest]->pair = 0;
     neighbor->requests[irequest]->compute = 1;
     neighbor->requests[irequest]->occasional = 1;
+    NeighRequest *pairrequest = neighbor->find_request((void *) force->pair);
+    if (pairrequest) neighbor->requests[irequest]->size = pairrequest->size;
   }
 
   // do initial memory allocation so that memory_usage() is correct
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 62a9143226..60b1bc7ee0 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -1268,6 +1268,10 @@ void Neighbor::morph_copy()
 
       if (irq->ghost && !jrq->ghost) continue;
 
+      // do not copy from a history list
+
+      if (jrq->history) continue;
+
       // these flags must be same,
       //   else 2 lists do not store same pairs
       //   or their data structures are different
@@ -1619,6 +1623,21 @@ void Neighbor::requests_new2old()
   old_oneatom = oneatom;
 }
 
+/* ----------------------------------------------------------------------
+   find and return request made by classptr
+   if not found or classpt = NULL, return NULL
+------------------------------------------------------------------------- */
+
+NeighRequest *Neighbor::find_request(void *classptr)
+{
+  if (classptr == NULL) return NULL;
+
+  for (int i = 0; i < nrequest; i++)
+    if (requests[i]->requestor == classptr) return requests[i];
+
+  return NULL;
+}
+
 /* ----------------------------------------------------------------------
    assign NBin class to a NeighList
    use neigh request settings to build mask
diff --git a/src/neighbor.h b/src/neighbor.h
index 16a80b5991..64bced2293 100644
--- a/src/neighbor.h
+++ b/src/neighbor.h
@@ -122,6 +122,7 @@ class Neighbor : protected Pointers {
 
   void exclusion_group_group_delete(int, int);  // rm a group-group exclusion
   int exclude_setting();            // return exclude value to accelerator pkg
+  class NeighRequest *find_request(void *);  // find a neighbor request
 
   bigint memory_usage();
 
-- 
GitLab