Skip to content

Commit

Permalink
[test] Fix issues in "bls_particle_grid" tests caused by float-point …
Browse files Browse the repository at this point in the history
…errors (#1590)
  • Loading branch information
yuanming-hu authored Jul 25, 2020
1 parent a0eb4fe commit 915dd56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/python/bls_test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ def bls_particle_grid(N,
def insert():
ti.block_dim(256)
for i in x:
# Note that since we manually subtract grid offset from base, its values are always positive.
# So no ti.floor is needed here and int() suffices.
# It is important to ensure insert and p2g uses the exact same way to compute the base
# coordinates. Otherwise there might be coordinate mismatch due to float-point errors.
base = ti.Vector([
int(x[i][0] * N - grid_offset[0]),
int(x[i][1] * N - grid_offset[1])
int(ti.floor(x[i][0] * N) - grid_offset[0]),
int(ti.floor(x[i][1] * N) - grid_offset[1])
])
ti.append(pid.parent(), base, i)

Expand Down

0 comments on commit 915dd56

Please sign in to comment.