ns = nx, ny, nz = 40, 50, 60 suite = unittest.TestSuite() suite.addTest( TestDirectIncident( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz - 1), False, ''))) suite.addTest( TestDirectIncident( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz - 1), True, ''))) suite.addTest( TestDirectIncident( (3, ny, nz, 'ex', (0, 33, 47), (2, 33, 47), True, 'x+'))) # random sets args_list = [(nx, ny, nz, str_f, pt0, pt1, is_array, '') \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, nx, ny, nz) \ for is_array in [False, True] ] suite.addTests(TestDirectIncident(args) for args in args_list) # random sets with mpi_type args_list = [(3, ny, nz, str_f, pt0, pt1, is_array, mpi_type) \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, 3, ny, nz) \ for is_array in [False, True] \ for mpi_type in ['x+', 'x-', 'y+', 'y-', 'z+', 'z-'] ] suite.addTests(TestDirectIncident(args) for args in args_list) unittest.TextTestRunner().run(suite)
# boundary exchange args_list1 = [(nx, ny, nz, str_f, pt0, pt1) \ for str_f, pt0, pt1 in [ [('ey', 'ez'), (0, 0, 0), (0, ny-2, nz-2)], [('ex', 'ez'), (0, 0, 0), (nx-2, 0, nz-2)], [('ex', 'ey'), (0, 0, 0), (nx-2, ny-2, 0)], [('hy', 'hz'), (nx-1, 1, 1), (nx-1, ny-1, nz-1)], [('hx', 'hz'), (1, ny-1, 1), (nx-1, ny-1, nz-1)], [('hx', 'hy'), (1, 1, nz-1), (nx-1, ny-1, nz-1)] ]] suite.addTests(TestGetFields(args) for args in args_list1) # random sets args_list2 = [(nx, ny, nz, str_f, pt0, pt1) \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, *ns) ] suite.addTests(TestGetFields(args) for args in args_list2) # Test SetFieds # single sets suite.addTest(TestSetFields( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz-1), False) )) suite.addTest(TestSetFields( (nx, ny, nz, ['ex', 'ey'], (0, 1, 0), (0, 1, nz-1), False) )) suite.addTest(TestSetFields( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz-1), True) )) suite.addTest(TestSetFields( (nx, ny, nz, ['ex', 'ey'], (0, 1, 0), (0, 1, nz-1), True) )) # boundary exchange args_list3 = [(nx, ny, nz, str_f, pt0, pt1, is_array) \ for str_f, pt0, pt1, is_array in [ [('ey', 'ez'), (0, 0, 0), (0, ny-2, nz-2), True], [('ex', 'ez'), (0, 0, 0), (nx-2, 0, nz-2), True],
original = eh[slices] copy = getf.get_fields(str_f) norm = np.linalg.norm(original - copy) self.assertEqual(norm, 0, '%s, %g' % (self.args, norm)) if __name__ == '__main__': nx, ny, nz = 40, 50, 60 gpu_devices = common_gpu.gpu_device_list(print_info=False) ngpu = len(gpu_devices) node_nx = (nx-1)*(ngpu+1) + 1 suite = unittest.TestSuite() suite.addTest(TestNodeDirectIncident( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz-1), False) )) suite.addTest(TestNodeDirectIncident( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz-1), True) )) suite.addTest(TestNodeDirectIncident( (nx, ny, nz, 'ex', (0, 5, 12), (node_nx-1, 5, 12), True) )) # random sets args_list = [(nx, ny, nz, str_f, pt0, pt1, is_array) \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, node_nx, ny, nz) \ for is_array in [False, True] ] test_size = int( len(args_list)*0.1 ) test_list = [args_list.pop( np.random.randint(len(args_list)) ) for i in xrange(test_size)] suite.addTests(TestNodeDirectIncident(args) for args in test_list) unittest.TextTestRunner().run(suite)
norm = np.linalg.norm(original - copy) self.assertEqual(norm, 0, '%s, %g' % (self.args, norm)) if __name__ == '__main__': ns = nx, ny, nz = 40, 50, 60 suite = unittest.TestSuite() suite.addTest(TestDirectIncident( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz-1), False, '') )) suite.addTest(TestDirectIncident( (nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz-1), True, '') )) suite.addTest(TestDirectIncident( (3, ny, nz, 'ex', (0, 33, 47), (2, 33, 47), True, 'x+') )) # random sets args_list = [(nx, ny, nz, str_f, pt0, pt1, is_array, '') \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, nx, ny, nz) \ for is_array in [False, True] ] suite.addTests(TestDirectIncident(args) for args in args_list) # random sets with mpi_type args_list = [(3, ny, nz, str_f, pt0, pt1, is_array, mpi_type) \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, 3, ny, nz) \ for is_array in [False, True] \ for mpi_type in ['x+', 'x-', 'y+', 'y-', 'z+', 'z-'] ] suite.addTests(TestDirectIncident(args) for args in args_list) unittest.TextTestRunner().run(suite)
# boundary exchange args_list1 = [(nx, ny, nz, str_f, pt0, pt1) \ for str_f, pt0, pt1 in [ [('ey', 'ez'), (0, 0, 0), (0, ny-2, nz-2)], [('ex', 'ez'), (0, 0, 0), (nx-2, 0, nz-2)], [('ex', 'ey'), (0, 0, 0), (nx-2, ny-2, 0)], [('hy', 'hz'), (nx-1, 1, 1), (nx-1, ny-1, nz-1)], [('hx', 'hz'), (1, ny-1, 1), (nx-1, ny-1, nz-1)], [('hx', 'hy'), (1, 1, nz-1), (nx-1, ny-1, nz-1)] ]] suite.addTests(TestGetFields(args) for args in args_list1) # random sets args_list2 = [(nx, ny, nz, str_f, pt0, pt1) \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, *ns) ] suite.addTests(TestGetFields(args) for args in args_list2) # Test SetFieds # single sets suite.addTest( TestSetFields((nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz - 1), False))) suite.addTest( TestSetFields((nx, ny, nz, ['ex', 'ey'], (0, 1, 0), (0, 1, nz - 1), False))) suite.addTest( TestSetFields((nx, ny, nz, 'ex', (0, 1, 0), (0, 1, nz - 1), True))) suite.addTest( TestSetFields((nx, ny, nz, ['ex', 'ey'], (0, 1, 0), (0, 1, nz - 1), True)))
if __name__ == '__main__': nx, ny, nz = 40, 50, 60 gpu_devices = common_gpu.gpu_device_list(print_info=False) ngpu = len(gpu_devices) node_nx = (nx - 1) * (ngpu + 1) + 1 suite = unittest.TestSuite() suite.addTest( TestNodeGetFields( (nx, ny, nz, 'ex', (0, 0, 10), (node_nx - 1, ny - 1, 10)))) suite.addTest( TestNodeGetFields((nx, ny, nz, ['ex', 'ey'], (0, 1, 0), (0, 1, nz - 1)))) suite.addTest( TestNodeGetFields((nx, ny, nz, ['ex'], (0, 1, 8), (0, 7, 16)))) args_list = [(nx, ny, nz, str_f, pt0, pt1) \ for str_f in ['ex', 'ey', 'ez', 'hx', 'hy', 'hz'] \ for shape in ['point', 'line', 'plane', 'volume'] \ for pt0, pt1 in random_set_two_points(shape, node_nx, ny, nz) ] test_size = int(len(args_list) * 0.1) test_list = [ args_list.pop(np.random.randint(len(args_list))) for i in xrange(test_size) ] suite.addTests(TestNodeGetFields(args) for args in test_list) unittest.TextTestRunner().run(suite)