diff --git a/doc/src/Developer_notes.rst b/doc/src/Developer_notes.rst index 33209abae7..63c95c2e6f 100644 --- a/doc/src/Developer_notes.rst +++ b/doc/src/Developer_notes.rst @@ -124,7 +124,7 @@ access the requesting class instance to store the assembled neighbor list with that instance by calling its ``init_list()`` member function. The second argument contains a bitmask of flags that determines the kind of neighbor list, i.e. a perpetual "half" neighbor list here. - + To adjust a neighbor list request to the specific needs of a style usually just a different additional request flag is needed. The :doc:`tersoff ` pair style, for example, needs a "full" neighbor list: @@ -155,7 +155,16 @@ from pair style lj/cut: neighbor->add_request(this, list_style); // [...] } - + +Granular pair styles need neighbor lists based on particle sizes and not cutoff +and also may require to have the list of previous neighbors available ("history"). +For example with: + +.. code-block:: C++ + + if (use_history) neighbor->add_request(this, NeighConst::REQ_SIZE|NeighConst::REQ_HISTORY); + else neighbor->add_request(this, NeighConst::REQ_SIZE); + In case a class would need to make multiple neighbor list requests with different settings each request can set an id which is then used in the corresponding ``init_list()`` function to assign it to the suitable pointer variable. This is @@ -173,7 +182,7 @@ done for example by the :doc:`pair style meam `: { if (id == 1) listfull = ptr; else if (id == 2) listhalf = ptr; - } + } Fixes may require a neighbor list that is only build occasionally (or just once) and this can also be indicated by a flag. As an example here @@ -206,7 +215,7 @@ command: .. code-block:: C++ neighbor->add_request(this, "delete_atoms", NeighConst::REQ_FULL); - + Fix contributions to instantaneous energy, virial, and cumulative energy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/GRANULAR/pair_gran_hertz_history.cpp b/src/GRANULAR/pair_gran_hertz_history.cpp index 151644bb83..2320b7a8fb 100644 --- a/src/GRANULAR/pair_gran_hertz_history.cpp +++ b/src/GRANULAR/pair_gran_hertz_history.cpp @@ -17,18 +17,20 @@ ------------------------------------------------------------------------- */ #include "pair_gran_hertz_history.h" -#include -#include + #include "atom.h" -#include "update.h" -#include "force.h" +#include "comm.h" +#include "error.h" #include "fix.h" #include "fix_neigh_history.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "comm.h" +#include "force.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neighbor.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; diff --git a/src/GRANULAR/pair_gran_hooke_history.cpp b/src/GRANULAR/pair_gran_hooke_history.cpp index 4d2dc441a5..49eb1be89b 100644 --- a/src/GRANULAR/pair_gran_hooke_history.cpp +++ b/src/GRANULAR/pair_gran_hooke_history.cpp @@ -431,11 +431,10 @@ void PairGranHookeHistory::init_style() if (comm->ghost_velocity == 0) error->all(FLERR, "Pair granular requires ghost atoms store velocity"); - // need a granular neigh list + // need a granular neighbor list - int irequest = neighbor->request(this, instance_me); - neighbor->requests[irequest]->size = 1; - if (history) neighbor->requests[irequest]->history = 1; + if (history) neighbor->add_request(this, NeighConst::REQ_SIZE|NeighConst::REQ_HISTORY); + else neighbor->add_request(this, NeighConst::REQ_SIZE); dt = update->dt; diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index 0559ca4c84..e1719853a4 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -1110,9 +1110,8 @@ void PairGranular::init_style() break; } - int irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->size = 1; - if (use_history) neighbor->requests[irequest]->history = 1; + if (use_history) neighbor->add_request(this, NeighConst::REQ_SIZE|NeighConst::REQ_HISTORY); + else neighbor->add_request(this, NeighConst::REQ_SIZE); dt = update->dt; diff --git a/src/neighbor.h b/src/neighbor.h index 4b78522000..3c392feb0a 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -125,7 +125,7 @@ class Neighbor : protected Pointers { virtual void init(); // old API for creating neighbor list requests - int request(void *, int instance_me = 0); + int request(void *, int instance = 0); // new API for creating neighbor list requests NeighRequest *add_request(class Pair *, int);