27 const int _numParticles) :
29 numLookupTimeSlices(_numLookupTimeSlices)
36 for (
int i = 0; i <
NDIM; i++)
37 hashSize[i] = numNNGrid[i];
38 hashSize[
NDIM] = numLookupTimeSlices;
39 hashSize[
NDIM+1] =
static_cast<int>(_numParticles/totNumGridBoxes) + 5;
42 hash.resize(hashSize);
76 void LookupTable::setupNNGrid() {
81 for (
int i = 0; i <
NDIM; i++) {
89 sizeNNGrid[i] =
boxPtr->
side[i] / (1.0 * numNNGrid[i]);
92 totNumGridBoxes *= numNNGrid[i];
96 TinyVector <int,NDIM+1> initNumLabels;
97 for (
int i = 0; i <
NDIM; i++)
98 initNumLabels[i] = numNNGrid[i];
100 numLabels.resize(initNumLabels);
108 TinyVector <int,NDIM+1> init;
111 for (
int i = 0; i <
NDIM; i++)
112 init[i] = numNNGrid[i];
117 gridNNReduced.resize(init);
123 Array <iVec,1> nnShift(
numNN);
126 TinyVector<int,3> shift;
133 for (
int n = 0; n <
numNN; n++) {
134 for (
int i = 0; i <
NDIM; i++) {
135 int index = ((int) floor(1.0*n/pow(3.0,1.0*(
NDIM-1-i)) +
EPS)) % 3;
136 nnShift(m)[i] = shift[index];
142 for (
int n = 0; n < totNumGridBoxes; n++) {
148 for (
int i = 0; i <
NDIM; i++)
149 nnIndex[i] = gIndex[i];
153 for (m = 0; m <
numNN; m++) {
155 gridNN(nnIndex) = gIndex + nnShift(m);
159 for (
int i = 0; i <
NDIM; i++) {
160 if (gridNN(nnIndex)[i] == numNNGrid[i])
162 else if (gridNN(nnIndex)[i] == -1)
163 gridNN(nnIndex)[i] =
static_cast<int>(
boxPtr->
periodic[i]*numNNGrid[i] - 1);
177 for (
int n = 0; n < totNumGridBoxes; n++) {
179 for (
int i = 0; i <
NDIM; i++)
180 nnIndex[i] = gIndex[i];
184 for (m =
numNN-1; m >= 0; m--) {
186 dup = gridNN(nnIndex);
187 for (
int p = m-1; p >= 0; p--) {
190 if (all(gridNN(nnIndex)==dup))
191 gridNN(nnIndex) = neg;
198 gridNNReduced = gridNN;
207 for (
int n = 0; n < totNumGridBoxes; n++) {
213 for (
int i = 0; i <
NDIM; i++)
214 nnIndex[i] = gIndex[i];
218 dup = gridNNReduced(nnIndex);
221 if (!any(dup == -1)) {
223 for (
int i = 0; i <
NDIM; i++)
231 if (all(gridNNReduced(nnIndex) == gIndex))
232 gridNNReduced(nnIndex) = neg;
249 for (
int n = 0; n < totNumGridBoxes; n++) {
252 for (
int i = 0; i <
NDIM; i++)
258 for (
int n = 0; n < totNumGridBoxes; n++)
262 for (
int m = 0; m <
numNN; m++) {
264 for (
int n = 0; n < totNumGridBoxes; n++) {
267 for (
int i = 0; i <
NDIM; i++)
268 nnIndex[i] = tIndex[i];
270 for (
int i = 0; i <
NDIM; i++) {
271 if (gridNNReduced(nnIndex)[i] == -1)
274 cout << gridNNReduced(nnIndex)[i];
291 for (
int n = 0; n < fixedPos.extent(firstDim); ++n) {
295 grid(beadIndex) =
gridIndex(fixedPos(n));
298 int label = numLabels(numLabelIndex(beadIndex));
302 if (hashSize[
NDIM+1]==label) {
304 hash.resizeAndPreserve(hashSize);
308 hash(hashIndex(beadIndex,label)) = beadIndex[1];
311 beadLabel(beadIndex) = label;
314 numLabels(numLabelIndex(beadIndex))++;
328 for (beadIndex[1] = 0; beadIndex[1] < path.
getNumParticles(); ++beadIndex[1]) {
333 grid(beadIndex) =
gridIndex(path(beadIndex));
336 int label = numLabels(numLabelIndex(beadIndex));
340 if (hashSize[
NDIM+1]==label) {
342 hash.resizeAndPreserve(hashSize);
346 hash(hashIndex(beadIndex,label)) = beadIndex[1];
349 beadLabel(beadIndex) = label;
352 numLabels(numLabelIndex(beadIndex))++;
370 if (!all(gIndex==grid(beadIndex))) {
378 grid(beadIndex) = gIndex;
381 nI = numLabelIndex(beadIndex);
384 int label = numLabels(nI);
388 if (hashSize[
NDIM+1]==label) {
390 hash.resizeAndPreserve(hashSize);
394 hash(hashIndex(beadIndex,label)) = beadIndex[1];
397 beadLabel(beadIndex) = label;
414 nI = numLabelIndex(beadIndex);
417 int label = numLabels(nI);
421 if (hashSize[
NDIM+1]==label) {
423 hash.resizeAndPreserve(hashSize);
427 hash(hashIndex(beadIndex,label)) = beadIndex[1];
430 beadLabel(beadIndex) = label;
441 swap[0] = beadIndex[0];
445 int label = beadLabel(beadIndex);
446 nI = numLabelIndex(beadIndex);
447 int lastLabel = numLabels(nI)-1;
450 hI = hashIndex(beadIndex,lastLabel);
451 if (label < lastLabel) {
456 beadLabel(swap) = label;
462 beadLabel(beadIndex) =
XXX;
463 grid(beadIndex) =
XXX;
481 for (
int i = 0; i <
NDIM; i++)
482 nnIndex[i] = grid(bead1)[i];
488 for (
int n = 0; n <
numNN; n++) {
492 gIndex = gridNN(nnIndex);
495 if (!any(gIndex == -1)) {
497 int maxNL = numLabels(numLabelIndex(gIndex,bead1[0]));
498 hI = hashIndex(gIndex,bead1[0],0);
500 for (
int label = 0; label < maxNL; label++) {
507 if (!all(bead1 == bead2)) {
513 if (dot(sep,sep) < rc2) {
535 for (
int i = 0; i <
NDIM; i++)
536 nnIndex[i] = grid(beadIndex)[i];
542 for (
int nn = 0; nn <
numNN; nn++) {
546 gIndex = gridNN(nnIndex);
548 if (!any(gIndex == -1)) {
551 int maxNL = numLabels(numLabelIndex(gIndex,slice));
552 hI = hashIndex(gIndex,slice,0);
554 for (
int label = 0; label < maxNL; label++) {
578 for (
int i = 0; i <
NDIM; i++)
579 nnIndex[i] = gIndex[i];
585 for (
int nn = 0; nn <
numNN; nn++) {
589 gIndex = gridNN(nnIndex);
591 if (!any(gIndex == -1)) {
594 int maxNL = numLabels(numLabelIndex(gIndex,slice));
595 hI = hashIndex(gIndex,slice,0);
597 for (
int label = 0; label < maxNL; label++) {
618 for (
int i = 0; i <
NDIM; i++)
619 nnIndex[i] = grid(bead1)[i];
622 gIndex = grid(bead2);
626 for (
int nn = 0; nn <
numNN; nn++) {
628 if (all(gIndex == gridNN(nnIndex))) {
int numTimeSlices()
Get number of time slices.
double rc2() const
Get potential cutoff squared.
The base class which holds details on the generalized box that our system will be simulated inside of...
TinyVector< unsigned int, NDIM > periodic
Determines which dimensions have periodic bc.
dVec side
The linear dimensions of the box.
int fullNumBeads
The full number of active beads in beadList;.
int numUniqueNN
The number of unique nearest neighbors of each box.
int numNN
The total number of nearest neighbors of each box.
iVec gridIndex(const dVec &)
Given a particle position, return the grid index for the nearest neighbor lookup table.
void updateGrid(const Path &)
We update the full nearest neighbor grid by filling up all data arrays at all time slices.
Array< beadLocator, 1 > beadList
The cutoff dynamic list of interacting beads.
void updateFullInteractionList(const beadLocator &, const int)
Fill up the fullBeadList array with a list of beads in the same grid box as the supplied beadIndex an...
void updateInteractionList(const Path &, const beadLocator &)
Update the NN lookup table and the array of beadLocators containing all beads which 'interact' with t...
void resizeList(int _numParticles)
Resize the bead and grid lists.
LookupTable(const Container *, const int, const int)
Initilialize the nearest neighbor lookup table.
void addBead(const beadLocator &, const dVec &)
Add a single bead to the NN grid and position pos.
Array< dVec, 1 > beadSep
The separation between beads.
bool gridNeighbors(const beadLocator &, const beadLocator &)
Given two beadIndices, determine if the beads lie in neighboring grid boxes.
int numBeads
The cutoff number of active beads in beadList;.
~LookupTable()
Free all blitz arrays.
Array< beadLocator, 1 > fullBeadList
The full dynamic list of interacting beads.
const Container * boxPtr
The simulation cell.
void updateBead(const beadLocator &, const dVec &)
Update the NN grid with a new bead position.
void delBead(const beadLocator &)
Remove a single bead from the NN grid.
void printGrid()
Print the NN Lookup table.
The space-time trajectories.
int getNumParticles() const
Get the size of the worldline array.
dVec getSeparation(const beadLocator &, const beadLocator &) const
Return the separation vector between two particles in the same timeslice.
Worm worm
Details on the worm.
int beadOn(int, int) const
Safely get a bead (int indexed)
#define NDIM
Number of spatial dimnsions.
int ipow(int base, int power)
Return the integer value of a number raised to a power.
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
#define EPS
A small number.
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
#define XXX
Used to refer to a nonsense beadIndex.
Class definitions for all file input/output.
ConstantParameters * constants()
Global public access to the constants.
LookupTable class definition.