def grid_setup(rp, ng=1): nx = rp.get_param("mesh.nx") ny = rp.get_param("mesh.ny") try: xmin = rp.get_param("mesh.xmin") except KeyError: xmin = 0.0 msg.warning("mesh.xmin not set, defaulting to 0.0") try: xmax = rp.get_param("mesh.xmax") except KeyError: xmax = 1.0 msg.warning("mesh.xmax not set, defaulting to 1.0") try: ymin = rp.get_param("mesh.ymin") except KeyError: ymin = 0.0 msg.warning("mesh.ymin not set, defaulting to 0.0") try: ymax = rp.get_param("mesh.ymax") except KeyError: ymax = 1.0 msg.warning("mesh.ynax not set, defaulting to 1.0") my_grid = patch.Grid2d(nx, ny, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, ng=ng) return my_grid
def test_is_symmetric(): g = patch.Grid2d(4, 3, ng=0) a = g.scratch_array() a[:, 0] = [1, 2, 2, 1] a[:, 1] = [2, 4, 4, 2] a[:, 2] = [1, 2, 2, 1] assert_equal(a.is_symmetric(), True)
def grid_setup(rp, ng=1): nx = rp.get_param("mesh.nx") ny = rp.get_param("mesh.ny") xmin = rp.get_param("mesh.xmin") xmax = rp.get_param("mesh.xmax") ymin = rp.get_param("mesh.ymin") ymax = rp.get_param("mesh.ymax") my_grid = patch.Grid2d(nx, ny, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, ng=ng) return my_grid
def test_indexer(): g = patch.Grid2d(2, 3, ng=2) a = g.scratch_array() a[:, :] = np.arange(g.qx*g.qy).reshape(g.qx, g.qy) assert_array_equal(a.v(), np.array([[16., 17., 18.], [23., 24., 25.]])) assert_array_equal(a.ip(1), np.array([[23., 24., 25.], [30., 31., 32.]])) assert_array_equal(a.ip(-1), np.array([[9., 10., 11.], [16., 17., 18.]])) assert_array_equal(a.jp(1), np.array([[17., 18., 19.], [24., 25., 26.]])) assert_array_equal(a.jp(-1), np.array([[15., 16., 17.], [22., 23., 24.]])) assert_array_equal(a.ip_jp(1, 1), np.array([[24., 25., 26.], [31., 32., 33.]]))