Example #1
0
 def test_exact_extended_spatial_hash_variable_radius(self):
     print ""
     for key in self.dataset_variable_radius:
         x, y, z, h = self.dataset_variable_radius[key]
         pa = get_particle_array(x=x, y=y, z=z, h=h)
         qid = randint(0,pa.get_number_of_particles()-1)
         nn_bf = brute_force_neighbours(pa, pa.x[qid], pa.y[qid],
                 pa.z[qid], pa.h[qid])
         exp = ExtendedSpatialHash(pa, 3, approximate = False)
         nn_sp = UIntArray()
         exp.nearest_neighbours(qid, nn_sp)
         print " - " + key
         assert equal(nn_bf, nn_sp)
Example #2
0
 def test_spatial_hash_variable_radius(self):
     print ""
     for key in self.dataset_variable_radius:
         x, y, z, h = self.dataset_variable_radius[key]
         pa = get_particle_array(x=x, y=y, z=z, h=h)
         qid = randint(0,pa.get_number_of_particles()-1)
         nn_bf = brute_force_neighbours(pa, pa.x[qid], pa.y[qid],
                 pa.z[qid], pa.h[qid])
         sp = SpatialHashNNPS([pa])
         nn_sp = UIntArray()
         sp.set_context(0,0)
         sp.get_nearest_neighbours(0,0,qid,nn_sp)
         print " - " + key
         assert equal(nn_bf, nn_sp)
Example #3
0
 def test_spatial_hash_large_num_cells(self):
     '''
     Tests SpatialHashNNPS for large number of cells.
     Fails with a segmentation fault.
     '''
     print ""
     for key in self.dataset_large_domain:
         x, y, z, h = self.dataset_large_domain[key]
         pa = get_particle_array(x=x, y=y, z=z, h=h)
         qid = randint(0,pa.get_number_of_particles()-1)
         nn_bf = brute_force_neighbours(pa, pa.x[qid], pa.y[qid],
                 pa.z[qid], pa.h[qid])
         sp = SpatialHashNNPS([pa])
         nn_sp = UIntArray()
         sp.set_context(0,0)
         sp.get_nearest_neighbours(0,0,qid,nn_sp)
         print " - " + key
         assert equal(nn_bf, nn_sp)
Example #4
0
 def test_linked_list_nnps_large_num_cells(self):
     '''
     Tests LinkedListNNPS for large number of cells.
     Fails with a malloc error
     '''
     print ""
     for key in self.dataset_large_domain:
         x, y, z, h = self.dataset_large_domain[key]
         pa = get_particle_array(x=x, y=y, z=z, h=h)
         qid = randint(0,pa.get_number_of_particles()-1)
         nn_bf = brute_force_neighbours(pa, pa.x[qid], pa.y[qid],
                 pa.z[qid], pa.h[qid])
         r = 1/1.101
         sp = LinkedListNNPS(dim=3, particles=[pa], radius_scale=r, cache=True)
         nn_sp = UIntArray()
         sp.set_context(0,0)
         sp.get_nearest_particles(0,0,qid,nn_sp)
         print " - " + key
         assert equal(nn_bf, nn_sp)