CoMD
A Mini-app for Co-Design of Classical Molecular Dynamics.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
linkCells.h File Reference

Functions to maintain link cell structures for fast pair finding. More...

#include "mytype.h"
Include dependency graph for linkCells.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LinkCellSt
 Link cell data. More...
 

Macros

#define MAXATOMS   64
 The maximum number of atoms that can be stored in a link cell. More...
 

Typedefs

typedef struct LinkCellSt LinkCell
 Link cell data. More...
 

Functions

LinkCellinitLinkCells (const struct DomainSt *domain, real_t cutoff)
 
void destroyLinkCells (LinkCell **boxes)
 
int getNeighborBoxes (LinkCell *boxes, int iBox, int *nbrBoxes)
 
void putAtomInBox (LinkCell *boxes, struct AtomsSt *atoms, const int gid, const int iType, const real_t x, const real_t y, const real_t z, const real_t px, const real_t py, const real_t pz)
 
int getBoxFromTuple (LinkCell *boxes, int x, int y, int z)
 Calculates the link cell index from the grid coords. More...
 
void moveAtom (LinkCell *boxes, struct AtomsSt *atoms, int iId, int iBox, int jBox)
 Move an atom from one link cell to another. More...
 
void updateLinkCells (LinkCell *boxes, struct AtomsSt *atoms)
 Update link cell data structures when the atoms have moved. More...
 
int maxOccupancy (LinkCell *boxes)
 

Detailed Description

Functions to maintain link cell structures for fast pair finding.

Definition in file linkCells.h.

Macro Definition Documentation

#define MAXATOMS   64

The maximum number of atoms that can be stored in a link cell.

Definition at line 10 of file linkCells.h.

Typedef Documentation

typedef struct LinkCellSt LinkCell

Link cell data.

For convenience, we keep a copy of the localMin and localMax coordinates that are also found in the DomainsSt.

Function Documentation

void destroyLinkCells ( LinkCell **  boxes)

Definition at line 112 of file linkCells.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int getBoxFromTuple ( LinkCell boxes,
int  ix,
int  iy,
int  iz 
)

Calculates the link cell index from the grid coords.

The valid coordinate range in direction ii is [-1, gridSize[ii]]. Any coordinate that involves a -1 or gridSize[ii] is a halo link cell. Because of the order in which the local and halo link cells are stored the indices of the halo cells are special cases.

See Also
initLinkCells for an explanation of storage order.

Definition at line 189 of file linkCells.c.

Here is the caller graph for this function:

int getNeighborBoxes ( LinkCell boxes,
int  iBox,
int *  nbrBoxes 
)

Populates the nbrBoxes array with the 27 boxes that are adjacent to iBox. The count is 27 instead of 26 because iBox is included in the list (as neighbor 13). Caller is responsible to alloc and free nbrBoxes.

Returns
The number of nbr boxes (always 27 in this implementation).

Definition at line 130 of file linkCells.c.

Here is the call graph for this function:

Here is the caller graph for this function:

LinkCell* initLinkCells ( const struct DomainSt domain,
real_t  cutoff 
)
int maxOccupancy ( LinkCell boxes)
Returns
The largest number of atoms in any link cell.

Definition at line 293 of file linkCells.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void moveAtom ( LinkCell boxes,
Atoms atoms,
int  iId,
int  iBox,
int  jBox 
)

Move an atom from one link cell to another.

Parameters
iId[in] The index with box iBox of the atom to be moved.
iBox[in] The index of the link cell the particle is moving from.
jBox[in] The index of the link cell the particle is moving to.

Definition at line 242 of file linkCells.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void putAtomInBox ( LinkCell boxes,
Atoms atoms,
const int  gid,
const int  iType,
const real_t  x,
const real_t  y,
const real_t  z,
const real_t  px,
const real_t  py,
const real_t  pz 
)

Finds the appropriate link cell for an atom based on the spatial coordinates and stores data in that link cell.

Parameters
[in]gidThe global of the atom.
[in]iTypeThe species index of the atom.
[in]xThe x-coordinate of the atom.
[in]yThe y-coordinate of the atom.
[in]zThe z-coordinate of the atom.
[in]pxThe x-component of the atom's momentum.
[in]pyThe y-component of the atom's momentum.
[in]pzThe z-component of the atom's momentum.

Definition at line 155 of file linkCells.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void updateLinkCells ( LinkCell boxes,
Atoms atoms 
)

Update link cell data structures when the atoms have moved.

This is the first step in returning data structures to a consistent state after the atoms move each time step. First we discard all atoms in the halo link cells. These are all atoms that are currently stored on other ranks and so any information we have about them is stale. Next, we move any atoms that have crossed link cell boundaries into their new link cells. It is likely that some atoms will be moved into halo link cells. Since we have deleted halo atoms from other tasks, it is clear that any atoms that are in halo cells at the end of this routine have just transitioned from local to halo atoms. Such atom must be sent to other tasks by a halo exchange to avoid being lost.

See Also
redistributeAtoms

Definition at line 273 of file linkCells.c.

Here is the call graph for this function:

Here is the caller graph for this function: