CoMD
A Mini-app for Co-Design of Classical Molecular Dynamics.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
linkCells.h
Go to the documentation of this file.
1 /// \file
2 /// Functions to maintain link cell structures for fast pair finding.
3 
4 #ifndef __LINK_CELLS_H_
5 #define __LINK_CELLS_H_
6 
7 #include "mytype.h"
8 
9 /// The maximum number of atoms that can be stored in a link cell.
10 #define MAXATOMS 64
11 
12 struct DomainSt;
13 struct AtomsSt;
14 
15 /// Link cell data. For convenience, we keep a copy of the localMin and
16 /// localMax coordinates that are also found in the DomainsSt.
17 typedef struct LinkCellSt
18 {
19  int gridSize[3]; //!< number of boxes in each dimension on processor
20  int nLocalBoxes; //!< total number of local boxes on processor
21  int nHaloBoxes; //!< total number of remote halo/ghost boxes on processor
22  int nTotalBoxes; //!< total number of boxes on processor
23  //!< nLocalBoxes + nHaloBoxes
24  real3 localMin; //!< minimum local bounds on processor
25  real3 localMax; //!< maximum local bounds on processor
26  real3 boxSize; //!< size of box in each dimension
27  real3 invBoxSize; //!< inverse size of box in each dimension
28 
29  int* nAtoms; //!< total number of atoms in each box
30 } LinkCell;
31 
32 LinkCell* initLinkCells(const struct DomainSt* domain, real_t cutoff);
33 void destroyLinkCells(LinkCell** boxes);
34 
35 int getNeighborBoxes(LinkCell* boxes, int iBox, int* nbrBoxes);
36 void putAtomInBox(LinkCell* boxes, struct AtomsSt* atoms,
37  const int gid, const int iType,
38  const real_t x, const real_t y, const real_t z,
39  const real_t px, const real_t py, const real_t pz);
40 int getBoxFromTuple(LinkCell* boxes, int x, int y, int z);
41 
42 void moveAtom(LinkCell* boxes, struct AtomsSt* atoms, int iId, int iBox, int jBox);
43 
44 /// Update link cell data structures when the atoms have moved.
45 void updateLinkCells(LinkCell* boxes, struct AtomsSt* atoms);
46 
47 int maxOccupancy(LinkCell* boxes);
48 
49 
50 #endif