I’d like to test some neighborhood detection algorithms in LAMMPS but I’m
a bit confused about how should I approach it. I see that neighbor.h has a
lot of stuff defined, and that its implementations are separated in files
neigh_full.cpp, neigh_gran.cpp, neigh_half_bin.cpp, neigh_half_bin.cpp,
the neighbor list (management) code in LAMMPS is one of the most complex
parts in LAMMPS, and making modifications there is not for the faint of
heart. more importantly, it requires a lot of reading and understanding of
the mechanisms at work.
Should I just add my methods in neighbor.h and a separated file? ie. if I
want to implement Multi Step, I’d do something
like Neighbor::full_multi_step, Neighbor::half_multi_step?
what do you mean by "Multi Step"? what would be the expected benefit or
new functionality that you want to achieve, that none of the existing
routines can do?
before making a recommendation on an implementation strategy, please see
my comments below.
And can you point me to a detailed explanation of these codes? If there is
the source code *is* the detailed explanation.
the basic flow of control is the following:
- pair styles, fixes, computes and commands that need a neighbor list
create an instance of the NeighRequest class through calling
neighbor->request(), those requests are stored in neighbor->requests
- the required properties and flags for the neighbor list are set by
changing public flag variables in the neighbor list request
- during the "init" phase of a run or minimization, the neighbor list code
adjust internal flags and determines which low-level routine is to be
called to satisfy the individual request. the selected routine is assigned
to a function pointer. at this point conditions like newton on/off, r-RESPA
vs. verlet, GPU, KOKKOS, USER-CUDA, USER-OMP, PERI, GRANULAR support and
whether a given neighbor list can be constructed as a subset of another are
evaluated and flagged.
- when a neighborlist build is triggered, the corresponding build function
pointer is called.
you can place the implementation of your new functions wherever you want.
it would be consistent with the rest to have those in a separate file. if
your new functions would be part of a package, you need to create
corresponding dummies (check out how it is done for the USER-OMP package
for example), so that the code will link correctly, if the package is not
installed. you have to decide how the new build routines are going to be
triggered and then change or augment the code in the NeighRequest class
and/or Neighbor::init() accordingly.