TestNeighborList.cpp 938 Bytes
Newer Older
Christopher Bruns's avatar
Christopher Bruns committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "../src/SimTKReference/NeighborList.h"
#include <cassert>
#include <iostream>

using namespace std;
using namespace OpenMM;

void testNeighborList()
{
    AtomLocationList atomList;
    atomList.push_back(Vec3(13.6, 0, 0));
    atomList.push_back(Vec3(0, 0, 0));
    
    NeighborList neighborList;
    
    computeNeighborListNaive(neighborList, atomList, 13.7, 0.01);
    assert(neighborList.size() == 1);
    
    computeNeighborListNaive(neighborList, atomList, 13.5, 0.01);
    assert(neighborList.size() == 0);
    
    computeNeighborListVoxelHash(neighborList, atomList, 13.7, 0.01);
    assert(neighborList.size() == 1);
    
    computeNeighborListVoxelHash(neighborList, atomList, 13.5, 0.01);
    assert(neighborList.size() == 0);
}

int main() 
{
try {
    testNeighborList();
    
    cout << "Test Passed" << endl;
    return 0;
}
catch (...) {
    cerr << "*** ERROR: Test Failed ***" << endl;
    return 1;
}
}