make neighbor list searches optionally check for the request ID

This commit is contained in:
Axel Kohlmeyer
2022-05-19 23:37:55 -04:00
parent 07e93a643a
commit bfb126ec7c
2 changed files with 12 additions and 8 deletions

View File

@ -1742,15 +1742,15 @@ void Neighbor::requests_new2old()
/* ----------------------------------------------------------------------
find and return request made by classptr
if not found or classptr = nullptr, return nullptr
TODO: should have optional argument "id" to match ID if multiple requests
id is optional and defaults to 0, which is the request id value unless set explicitly
------------------------------------------------------------------------- */
NeighRequest *Neighbor::find_request(void *classptr) const
NeighRequest *Neighbor::find_request(void *classptr, const int id) const
{
if (classptr == nullptr) return nullptr;
for (int i = 0; i < nrequest; i++)
if (requests[i]->requestor == classptr) return requests[i];
if ((requests[i]->requestor == classptr) && (requests[i]->id == id)) return requests[i];
return nullptr;
}
@ -1770,15 +1770,15 @@ const std::vector<NeighRequest *> Neighbor::get_pair_requests() const
/* ----------------------------------------------------------------------
find and return list requested by classptr
if not found or classptr = nullptr, return nullptr
TODO: should have optional argument "id" to match ID if multiple requests
id is optional and defaults to 0, which is the request id value unless set explicitly
------------------------------------------------------------------------- */
NeighList *Neighbor::find_list(void *classptr) const
NeighList *Neighbor::find_list(void *classptr, const int id) const
{
if (classptr == nullptr) return nullptr;
for (int i = 0; i < nlist; i++)
if (lists[i]->requestor == classptr) return lists[i];
if ((requests[i]->requestor == classptr) && (requests[i]->id == id)) return lists[i];
return nullptr;
}

View File

@ -153,8 +153,12 @@ 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
NeighList *find_list(void *) const; // find a neighbor list based on requestor
NeighRequest *find_request(void *) const; // find a neighbor request based on requestor
// find a neighbor list based on requestor
NeighList *find_list(void *, const int id = 0) const;
// find a neighbor request based on requestor
NeighRequest *find_request(void *, const int id = 0) const;
const std::vector<NeighRequest *> get_pair_requests() const;
int any_full(); // Check if any old requests had full neighbor lists
void build_collection(int); // build peratom collection array starting at the given index