dummy implementation of single neighbor list build

This commit is contained in:
Axel Kohlmeyer
2025-04-22 16:02:51 -04:00
parent dbe98e2cfb
commit 9e9caf7d14
2 changed files with 49 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include "atom.h"
#include "atom_vec.h"
#include "comm.h"
#include "command.h"
#include "compute.h"
#include "domain.h"
#include "dump.h"
@ -6119,6 +6120,53 @@ int lammps_find_compute_neighlist(void *handle, const char *id, int reqid) {
/* ---------------------------------------------------------------------- */
// helper Command class for a single neighbor list build
class NeighProxy : protected Command
{
public:
NeighProxy(class LAMMPS *lmp) : Command(lmp), neigh_idx(-1) {};
void command(int, char **) override {
fprintf(stderr, "called NeighProxy::command()\n");
}
int get_index() const { return neigh_idx; }
protected:
int neigh_idx;
};
/** Build a single neighbor list in between runs and return its index
*
* A neighbor list request is created and the neighbor list built from a
* proxy command. The request ID is typically 0, but will be
* > 0 in case a compute has multiple neighbor list requests.
*
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
* \param id Identifier of neighbor list request
* \param flags Neighbor list flags
* \param cutoff Custom neighbor list cutoff if > 0, use default cutoff if < 0
* \return return neighbor list index if valid, otherwise -1 */
int lammps_request_single_neighlist(void *handle, const char *id, int flags, double cutoff) {
auto lmp = (LAMMPS *)handle;
int idx = -1;
if (!lmp || !lmp->error || !lmp->neighbor) {
lammps_last_global_errormessage = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
return -1;
}
BEGIN_CAPTURE
{
NeighProxy proxy(lmp);
proxy.command(0, nullptr);
idx = proxy.get_index();
}
END_CAPTURE
return idx;
}
/* ---------------------------------------------------------------------- */
/** Return the number of entries in the neighbor list with given index
*
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.

View File

@ -235,6 +235,7 @@ int lammps_create_atoms(void *handle, int n, const int64_t *id, const int *type,
int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int nsub, int request);
int lammps_find_fix_neighlist(void *handle, const char *id, int request);
int lammps_find_compute_neighlist(void *handle, const char *id, int request);
int lammps_request_single_neighlist(void *handle, const char *id, int request, int flags, double cutoff);
int lammps_neighlist_num_elements(void *handle, int idx);
void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int *iatom,
int *numneigh, int **neighbors);