Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
2943d628
Commit
2943d628
authored
Oct 15, 2013
by
peastman
Browse files
Bug fix
parent
dd175b23
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
22 deletions
+21
-22
platforms/cpu/src/CpuNeighborList.cpp
platforms/cpu/src/CpuNeighborList.cpp
+2
-2
platforms/cpu/tests/TestCpuNeighborList.cpp
platforms/cpu/tests/TestCpuNeighborList.cpp
+7
-7
platforms/reference/src/SimTKReference/ReferenceNeighborList.cpp
...ms/reference/src/SimTKReference/ReferenceNeighborList.cpp
+2
-2
platforms/reference/tests/TestReferenceNeighborList.cpp
platforms/reference/tests/TestReferenceNeighborList.cpp
+10
-11
No files found.
platforms/cpu/src/CpuNeighborList.cpp
View file @
2943d628
...
@@ -42,8 +42,8 @@ public:
...
@@ -42,8 +42,8 @@ public:
ny
=
(
int
)
floorf
(
periodicBoxSize
[
1
]
/
voxelSizeY
+
0.5
f
);
ny
=
(
int
)
floorf
(
periodicBoxSize
[
1
]
/
voxelSizeY
+
0.5
f
);
nz
=
(
int
)
floorf
(
periodicBoxSize
[
2
]
/
voxelSizeZ
+
0.5
f
);
nz
=
(
int
)
floorf
(
periodicBoxSize
[
2
]
/
voxelSizeZ
+
0.5
f
);
voxelSizeX
=
periodicBoxSize
[
0
]
/
nx
;
voxelSizeX
=
periodicBoxSize
[
0
]
/
nx
;
voxelSizeY
=
periodicBoxSize
[
0
]
/
ny
;
voxelSizeY
=
periodicBoxSize
[
1
]
/
ny
;
voxelSizeZ
=
periodicBoxSize
[
0
]
/
nz
;
voxelSizeZ
=
periodicBoxSize
[
2
]
/
nz
;
}
}
}
}
...
...
platforms/cpu/tests/TestCpuNeighborList.cpp
View file @
2943d628
...
@@ -46,12 +46,13 @@ using namespace std;
...
@@ -46,12 +46,13 @@ using namespace std;
void
testNeighborList
(
bool
periodic
)
{
void
testNeighborList
(
bool
periodic
)
{
const
int
numParticles
=
500
;
const
int
numParticles
=
500
;
const
float
cutoff
=
2.0
f
;
const
float
cutoff
=
2.0
f
;
const
float
boxSize
=
20.0
f
;
const
float
boxSize
[
3
]
=
{
20.0
f
,
15.0
f
,
22.0
f
}
;
OpenMM_SFMT
::
SFMT
sfmt
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
float
>
positions
(
4
*
numParticles
);
vector
<
float
>
positions
(
4
*
numParticles
);
for
(
int
i
=
0
;
i
<
4
*
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
4
*
numParticles
;
i
++
)
positions
[
i
]
=
boxSize
*
genrand_real2
(
sfmt
);
if
(
i
%
4
<
3
)
positions
[
i
]
=
boxSize
[
i
%
4
]
*
genrand_real2
(
sfmt
);
vector
<
set
<
int
>
>
exclusions
(
numParticles
);
vector
<
set
<
int
>
>
exclusions
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
int
num
=
min
(
i
+
1
,
10
);
int
num
=
min
(
i
+
1
,
10
);
...
@@ -61,8 +62,7 @@ void testNeighborList(bool periodic) {
...
@@ -61,8 +62,7 @@ void testNeighborList(bool periodic) {
}
}
}
}
CpuNeighborList
neighborList
;
CpuNeighborList
neighborList
;
float
box
[
3
]
=
{
boxSize
,
boxSize
,
boxSize
};
neighborList
.
computeNeighborList
(
numParticles
,
positions
,
exclusions
,
boxSize
,
periodic
,
cutoff
);
neighborList
.
computeNeighborList
(
numParticles
,
positions
,
exclusions
,
box
,
periodic
,
cutoff
);
// Convert the neighbor list to a set for faster lookup.
// Convert the neighbor list to a set for faster lookup.
...
@@ -82,9 +82,9 @@ void testNeighborList(bool periodic) {
...
@@ -82,9 +82,9 @@ void testNeighborList(bool periodic) {
float
dy
=
positions
[
4
*
i
+
1
]
-
positions
[
4
*
j
+
1
];
float
dy
=
positions
[
4
*
i
+
1
]
-
positions
[
4
*
j
+
1
];
float
dz
=
positions
[
4
*
i
+
2
]
-
positions
[
4
*
j
+
2
];
float
dz
=
positions
[
4
*
i
+
2
]
-
positions
[
4
*
j
+
2
];
if
(
periodic
)
{
if
(
periodic
)
{
dx
-=
floor
(
dx
/
boxSize
+
0.5
f
)
*
boxSize
;
dx
-=
floor
(
dx
/
boxSize
[
0
]
+
0.5
f
)
*
boxSize
[
0
]
;
dy
-=
floor
(
dy
/
boxSize
+
0.5
f
)
*
boxSize
;
dy
-=
floor
(
dy
/
boxSize
[
1
]
+
0.5
f
)
*
boxSize
[
1
]
;
dz
-=
floor
(
dz
/
boxSize
+
0.5
f
)
*
boxSize
;
dz
-=
floor
(
dz
/
boxSize
[
2
]
+
0.5
f
)
*
boxSize
[
2
]
;
}
}
if
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
>
cutoff
*
cutoff
)
if
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
>
cutoff
*
cutoff
)
shouldInclude
=
false
;
shouldInclude
=
false
;
...
...
platforms/reference/src/SimTKReference/ReferenceNeighborList.cpp
View file @
2943d628
...
@@ -101,8 +101,8 @@ public:
...
@@ -101,8 +101,8 @@ public:
ny
=
(
int
)
floor
(
periodicBoxSize
[
1
]
/
voxelSizeY
+
0.5
);
ny
=
(
int
)
floor
(
periodicBoxSize
[
1
]
/
voxelSizeY
+
0.5
);
nz
=
(
int
)
floor
(
periodicBoxSize
[
2
]
/
voxelSizeZ
+
0.5
);
nz
=
(
int
)
floor
(
periodicBoxSize
[
2
]
/
voxelSizeZ
+
0.5
);
voxelSizeX
=
periodicBoxSize
[
0
]
/
nx
;
voxelSizeX
=
periodicBoxSize
[
0
]
/
nx
;
voxelSizeY
=
periodicBoxSize
[
0
]
/
ny
;
voxelSizeY
=
periodicBoxSize
[
1
]
/
ny
;
voxelSizeZ
=
periodicBoxSize
[
0
]
/
nz
;
voxelSizeZ
=
periodicBoxSize
[
2
]
/
nz
;
}
}
}
}
...
...
platforms/reference/tests/TestReferenceNeighborList.cpp
View file @
2943d628
...
@@ -86,7 +86,7 @@ void verifyNeighborList(NeighborList& list, int numParticles, vector<RealVec>& p
...
@@ -86,7 +86,7 @@ void verifyNeighborList(NeighborList& list, int numParticles, vector<RealVec>& p
for
(
int
j
=
i
+
1
;
j
<
numParticles
;
j
++
)
for
(
int
j
=
i
+
1
;
j
<
numParticles
;
j
++
)
if
(
distance2
(
positions
[
i
],
positions
[
j
],
periodicBoxSize
)
<=
cutoff
*
cutoff
)
if
(
distance2
(
positions
[
i
],
positions
[
j
],
periodicBoxSize
)
<=
cutoff
*
cutoff
)
count
++
;
count
++
;
ASSERT
(
count
==
list
.
size
());
ASSERT
_EQUAL
(
count
,
list
.
size
());
}
}
void
testPeriodic
()
{
void
testPeriodic
()
{
...
@@ -112,16 +112,15 @@ void testPeriodic() {
...
@@ -112,16 +112,15 @@ void testPeriodic() {
int
main
()
int
main
()
{
{
try
{
try
{
testNeighborList
();
testNeighborList
();
testPeriodic
();
testPeriodic
();
}
cout
<<
"Test Passed"
<<
endl
;
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
return
0
;
}
}
catch
(...)
{
cerr
<<
"*** ERROR: Test Failed ***"
<<
endl
;
return
1
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment