def test_bounded_single(self): # The will ideally require a 5x4 grid, but the limit on two cells in # the y-direction should redirect to a 10x2. nx = np.array([100, 2]) target = 20 coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(np.sort(coarse), np.array([2, 10]))
def test_two_bounds(self): # This will seemingly require 900^1/3 ~ 10 cells in each direction, but # the z-dimension has only 1, thus the two other have to do 30 each. y # can only do 15, so the loop has to be reset once more to get the # final 60. nx = np.array([2000, 15, 1]) target = 900 coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(np.sort(coarse), np.array([1, 15, 60]))
def test_round_up_and_down(self): nx = np.array([10, 10]) target = 19 coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(np.sort(coarse), np.array([4, 5]))
def test_round_down(self): nx = np.array([10, 10]) target = 17 coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(coarse, np.array([4, 4]))
def test_anisotropic_2d(self): nx = np.array([10, 4]) target = 4 coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(coarse, np.array([2, 2]))
def test_coarse_dimensions_single_coarse(self): nx = np.array([5, 5, 5]) target = 1 coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(coarse, np.ones_like(nx))
def test_coarse_dimensions_all_fine(self): nx = np.array([5, 5, 5]) target = nx.prod() coarse = partition.determine_coarse_dimensions(target, nx) assert np.array_equal(nx, coarse)