new neighbor list changes
This commit is contained in:
143
src/nbin.cpp
Normal file
143
src/nbin.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "nbin.h"
|
||||
#include "neighbor.h"
|
||||
#include "domain.h"
|
||||
#include "update.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
NBin::NBin(LAMMPS *lmp) : Pointers(lmp)
|
||||
{
|
||||
last_setup = last_bin = last_bin_memory = -1;
|
||||
maxbin = maxatom = 0;
|
||||
binhead = NULL;
|
||||
bins = NULL;
|
||||
|
||||
// geometry settings
|
||||
|
||||
dimension = domain->dimension;
|
||||
triclinic = domain->triclinic;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
NBin::~NBin()
|
||||
{
|
||||
memory->destroy(binhead);
|
||||
memory->destroy(bins);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy needed info from Neighbor class
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void NBin::copy_neighbor_info()
|
||||
{
|
||||
includegroup = neighbor->includegroup;
|
||||
cutneighmin = neighbor->cutneighmin;
|
||||
cutneighmax = neighbor->cutneighmax;
|
||||
binsizeflag = neighbor->binsizeflag;
|
||||
binsize_user = neighbor->binsize_user;
|
||||
bboxlo = neighbor->bboxlo;
|
||||
bboxhi = neighbor->bboxhi;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
setup for bin_atoms()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void NBin::bin_atoms_setup(int nall)
|
||||
{
|
||||
// binhead = per-bin vector, mbins in length
|
||||
// add 1 bin for USER-INTEL package
|
||||
|
||||
if (mbins > maxbin) {
|
||||
maxbin = mbins;
|
||||
memory->destroy(binhead);
|
||||
memory->create(binhead,maxbin,"neigh:binhead");
|
||||
last_bin_memory = update->ntimestep;
|
||||
}
|
||||
|
||||
// bins = per-atom vector
|
||||
|
||||
if (nall > maxatom) {
|
||||
maxatom = nall;
|
||||
memory->destroy(bins);
|
||||
memory->create(bins,maxatom,"neigh:bins");
|
||||
last_bin_memory = update->ntimestep;
|
||||
}
|
||||
|
||||
last_bin = update->ntimestep;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert atom coords into local bin #
|
||||
for orthogonal, only ghost atoms will have coord >= bboxhi or coord < bboxlo
|
||||
take special care to insure ghosts are in correct bins even w/ roundoff
|
||||
hi ghost atoms = nbin,nbin+1,etc
|
||||
owned atoms = 0 to nbin-1
|
||||
lo ghost atoms = -1,-2,etc
|
||||
this is necessary so that both procs on either side of PBC
|
||||
treat a pair of atoms straddling the PBC in a consistent way
|
||||
for triclinic, doesn't matter since stencil & neigh list built differently
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int NBin::coord2bin(double *x)
|
||||
{
|
||||
int ix,iy,iz;
|
||||
|
||||
if (!ISFINITE(x[0]) || !ISFINITE(x[1]) || !ISFINITE(x[2]))
|
||||
error->one(FLERR,"Non-numeric positions - simulation unstable");
|
||||
|
||||
if (x[0] >= bboxhi[0])
|
||||
ix = static_cast<int> ((x[0]-bboxhi[0])*bininvx) + nbinx;
|
||||
else if (x[0] >= bboxlo[0]) {
|
||||
ix = static_cast<int> ((x[0]-bboxlo[0])*bininvx);
|
||||
ix = MIN(ix,nbinx-1);
|
||||
} else
|
||||
ix = static_cast<int> ((x[0]-bboxlo[0])*bininvx) - 1;
|
||||
|
||||
if (x[1] >= bboxhi[1])
|
||||
iy = static_cast<int> ((x[1]-bboxhi[1])*bininvy) + nbiny;
|
||||
else if (x[1] >= bboxlo[1]) {
|
||||
iy = static_cast<int> ((x[1]-bboxlo[1])*bininvy);
|
||||
iy = MIN(iy,nbiny-1);
|
||||
} else
|
||||
iy = static_cast<int> ((x[1]-bboxlo[1])*bininvy) - 1;
|
||||
|
||||
if (x[2] >= bboxhi[2])
|
||||
iz = static_cast<int> ((x[2]-bboxhi[2])*bininvz) + nbinz;
|
||||
else if (x[2] >= bboxlo[2]) {
|
||||
iz = static_cast<int> ((x[2]-bboxlo[2])*bininvz);
|
||||
iz = MIN(iz,nbinz-1);
|
||||
} else
|
||||
iz = static_cast<int> ((x[2]-bboxlo[2])*bininvz) - 1;
|
||||
|
||||
return (iz-mbinzlo)*mbiny*mbinx + (iy-mbinylo)*mbinx + (ix-mbinxlo);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
bigint NBin::memory_usage()
|
||||
{
|
||||
bigint bytes = 0;
|
||||
bytes += maxbin*sizeof(int);
|
||||
bytes += maxatom*sizeof(int);
|
||||
return bytes;
|
||||
}
|
||||
Reference in New Issue
Block a user