Exemple #1
0
def test_corner_case_parallel_octree_1d_few_cells():
    x, y, z = [0.131, 0.359], [1.544, 1.809], [-3.6489999, -2.8559999]
    pa = get_particle_array(name='fluid', x=x, y=y, z=z, h=1.0)
    nbrs = UIntArray()
    bf_nbrs = UIntArray()
    nps = nnps.OctreeNNPS(dim=3, particles=[pa], radius_scale=0.7,
                          test_parallel=True)
    for i in range(2):
        nps.get_nearest_particles(0, 0, i, nbrs)
        nps.brute_force_neighbors(0, 0, i, bf_nbrs)
        assert sorted(nbrs) == sorted(bf_nbrs), 'Failed for particle: %d' % i
Exemple #2
0
def test_large_number_of_neighbors_octree():
    x = numpy.random.random(1 << 14) * 0.1
    y = x.copy()
    z = x.copy()
    h = numpy.ones_like(x)
    pa = get_particle_array(name='fluid', x=x, y=y, z=z, h=h)

    nps = nnps.OctreeNNPS(dim=3, particles=[pa], cache=False)
    nbrs = UIntArray()
    nps.get_nearest_particles(0, 0, 0, nbrs)
    # print(nbrs.length)
    assert nbrs.length == len(x)
Exemple #3
0
 def test_octree_works_for_large_domain(self):
     # Given
     pa = self._make_particles(20)
     # We turn on cache so it computes all the neighbors quickly for us.
     nps = nnps.OctreeNNPS(dim=3, particles=[pa], cache=True)
     nbrs = UIntArray()
     direct = UIntArray()
     nps.set_context(0, 0)
     for i in range(pa.get_number_of_particles()):
         nps.get_nearest_particles(0, 0, i, nbrs)
         nps.brute_force_neighbors(0, 0, i, direct)
         x = nbrs.get_npy_array()
         y = direct.get_npy_array()
         x.sort(); y.sort()
         assert numpy.all(x == y)
Exemple #4
0
 def setUp(self):
     NNPSTestCase.setUp(self)
     self.nps = nnps.OctreeNNPS(
         dim=3, particles=self.particles, radius_scale=2.0
     )