Exemple #1
0
 def testPointTest(self):
     N = 100 # test N quadrilaterals
     M = 1000 # M points
     # The 'wavefront' is [0,1] x [0,1], divided into vertical rectangles of width 1/N
     x0 = np.vstack((np.linspace(0,1,N+1), np.zeros(N+1))).transpose()
     x1 = x0 + [0,1.0]
     wpt = prw.WavefrontQuadsPointTest(x0, x1)
     p = np.random.rand(M,2)
     qs = put.print_timing(wpt.test)(p)
     np.testing.assert_array_equal(qs, np.int32(p[:,0]* N) == np.arange(N).reshape(N,1))
Exemple #2
0
    def testPointUnique(self):
        N = 100 # test N quadrilaterals
        M = 1000 # M points
        x0 = np.vstack((np.linspace(0,1,N+1), np.zeros(N+1))).transpose()
        x1 = x0 + [0,1.0]
        wpt = prw.WavefrontQuadsPointTest(x0, x1)
        p = np.random.rand(M,2)*2
#        p = x0 + [0.01,0.99]
        ptoqs = put.print_timing(wpt.unique)(p)
        pquad = np.int32(p[:,0] * N)
        pquad[(pquad >= N) | (p[:,1] > 1)] = -1
        np.testing.assert_array_equal(ptoqs, pquad)