Skip to content

Commit

Permalink
Suggested fix to the issue GOMC-WSU#143 and GOMC-WSU#123
Browse files Browse the repository at this point in the history
  • Loading branch information
msoroush committed Oct 6, 2019
1 parent f9f6cc1 commit 0c40b76
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/CellList.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ inline int CellList::PositionToCell(const XYZ& posRef, int box) const
int x = (int)(pos.x / cellSize[box].x);
int y = (int)(pos.y / cellSize[box].y);
int z = (int)(pos.z / cellSize[box].z);
//Check the cell number to avoid segfult for coordinates close to axis
//x, y, and z should never be equal or greater than number of cells in x, y,
// and z axis, respectively.
x -= (x == edgeCells[box][0] ? 1 : 0);
y -= (y == edgeCells[box][1] ? 1 : 0);
z -= (z == edgeCells[box][2] ? 1 : 0);
return x * edgeCells[box][1] * edgeCells[box][2] + y * edgeCells[box][2] + z;
}

Expand Down

0 comments on commit 0c40b76

Please sign in to comment.