def save_output(basepath, max_iters): merged = merge_subdomains(os.path.join(tmpdir, 'result'), io.filename_iter_digits(max_iters), max_iters, save=False) rho = merged['rho'] lat_nz, lat_ny, lat_nx = rho.shape vx = merged['v'][0] vy = merged['v'][1] vz = merged['v'][2] nxh = lat_nx / 2 nyh = lat_ny / 2 nzh = lat_nz / 2 res_vx = (vx[:, nyh, nxh] + vx[:, nyh - 1, nxh - 1]) / 2 / LDCBlock.max_v res_vz = (vz[nzh, nyh, :] + vz[nzh - 1, nyh - 1, :]) / 2 / LDCBlock.max_v np.savetxt(os.path.join(basepath, 're400_vx.dat'), res_vx) np.savetxt(os.path.join(basepath, 're400_vz.dat'), res_vz) plt.plot(res_vx, np.linspace(-1.0, 1.0, lat_nz), label='Sailfish') plt.plot(np.linspace(-1.0, 1.0, lat_nx), res_vz, label='Sailfish')
def test_vert_2blocks(self): global blocks, vertical, output output = os.path.join(tmpdir, 'vert_2block') blocks = 2 vertical = True LBSimulationController(SimulationTest, EqualSubdomainsGeometry2D).run(ignore_cmdline=True) merged = merge_subdomains(output, self.digits, MAX_ITERS, save=False) rho = merged['rho'] vx = merged['v'][0] vy = merged['v'][1] np.testing.assert_array_almost_equal(rho, self.vrho) np.testing.assert_array_almost_equal(vx, self.vvx) np.testing.assert_array_almost_equal(vy, self.vvy)
def test_horiz_3blocks(self): global blocks, vertical, output output = os.path.join(tmpdir, 'horiz_3block') blocks = 3 vertical = False LBSimulationController( SimulationTest, EqualSubdomainsGeometry2D).run(ignore_cmdline=True) merged = merge_subdomains(output, self.digits, MAX_ITERS, save=False) rho = merged['rho'] vx = merged['v'][0] vy = merged['v'][1] np.testing.assert_array_almost_equal(rho, self.hrho) np.testing.assert_array_almost_equal(vx, self.hvx) np.testing.assert_array_almost_equal(vy, self.hvy)
def save_output(basepath, max_iters): merged = merge_subdomains(os.path.join(tmpdir, "result"), io.filename_iter_digits(max_iters), max_iters, save=False) rho = merged["rho"] lat_ny, lat_nx = rho.shape vx = merged["v"][0] vy = merged["v"][1] nxh = lat_nx / 2 nyh = lat_ny / 2 res_vx = (vx[:, nxh] + vx[:, nxh - 1]) / 2 / LDCBlock.max_v res_vy = (vy[nyh, :] + vy[nyh - 1, :]) / 2 / LDCBlock.max_v plt.plot(res_vx, np.linspace(-1.0, 1.0, lat_ny), label="Sailfish") plt.plot(np.linspace(-1.0, 1.0, lat_nx), res_vy, label="Sailfish") np.savetxt(os.path.join(basepath, "vx.dat"), res_vx) np.savetxt(os.path.join(basepath, "vy.dat"), res_vy)
def save_output(basepath): merged = merge_subdomains(os.path.join(tmpdir, 'result'), io.filename_iter_digits(MAX_ITERS), MAX_ITERS, save=False) rho = merged['rho'] lat_ny, lat_nx = rho.shape vx = merged['v'][0] vy = merged['v'][1] nxh = lat_nx / 2 nyh = lat_ny / 2 res_vx = (vx[:, nxh] + vx[:, nxh-1]) / 2 / LDCBlock.max_v res_vy = (vy[nyh, :] + vy[nyh-1, :]) / 2 / LDCBlock.max_v plt.plot(res_vx, np.linspace(-1.0, 1.0, lat_ny), label='Sailfish') plt.plot(np.linspace(-1.0, 1.0, lat_nx), res_vy, label='Sailfish') np.savetxt(os.path.join(basepath, 'vx.dat'), res_vx) np.savetxt(os.path.join(basepath, 'vy.dat'), res_vy)
def save_output(basepath): merged = merge_subdomains(os.path.join(tmpdir, "result"), io.filename_iter_digits(MAX_ITERS), MAX_ITERS, save=False) rho = merged["rho"] lat_nz, lat_ny, lat_nx = rho.shape vx = merged["v"][0] vy = merged["v"][1] vz = merged["v"][2] nxh = lat_nx / 2 nyh = lat_ny / 2 nzh = lat_nz / 2 res_vx = (vx[:, nyh, nxh] + vx[:, nyh - 1, nxh - 1]) / 2 / LDCBlock.max_v res_vz = (vz[nzh, nyh, :] + vz[nzh - 1, nyh - 1, :]) / 2 / LDCBlock.max_v np.savetxt(os.path.join(basepath, "re400_vx.dat"), res_vx) np.savetxt(os.path.join(basepath, "re400_vz.dat"), res_vz) plt.plot(res_vx, np.linspace(-1.0, 1.0, lat_nz), label="Sailfish") plt.plot(np.linspace(-1.0, 1.0, lat_nx), res_vz, label="Sailfish")
def save_output(basepath, max_iters): merged = merge_subdomains(os.path.join(tmpdir, 'result'), io.filename_iter_digits(max_iters), max_iters, save=False) rho = merged['rho'] lat_nz, lat_ny, lat_nx = rho.shape vx = merged['v'][0] vy = merged['v'][1] vz = merged['v'][2] nxh = lat_nx / 2 nyh = lat_ny / 2 nzh = lat_nz / 2 res_vx = (vx[:, nyh, nxh] + vx[:, nyh-1, nxh-1]) / 2 / LDCBlock.max_v res_vz = (vz[nzh, nyh, :] + vz[nzh-1, nyh-1, :]) / 2 / LDCBlock.max_v np.savetxt(os.path.join(basepath, 're400_vx.dat'), res_vx) np.savetxt(os.path.join(basepath, 're400_vz.dat'), res_vz) plt.plot(res_vx, np.linspace(-1.0, 1.0, lat_nz), label='Sailfish') plt.plot(np.linspace(-1.0, 1.0, lat_nx), res_vz, label='Sailfish')
def verify_fields(ref, output, digits, max_iters): merged = merge_subdomains(output, digits, max_iters, save=False) for f in ref.files: np.testing.assert_array_almost_equal(merged[f], ref[f])