def test_pvd_read(self): pvdfile = VTUinterface.PVDIO("examples/square_1e2_pcs_0.pvd", dim=2) time = pvdfile.timesteps selected_points = {'pt0': (0.25, 0.5, 0.0), 'pt1': (0.75, 0.5, 0.0)} pressure_interpolation = pvdfile.read_time_series( 'pressure', selected_points) self.assertAlmostEqual(pressure_interpolation['pt0'][-1], 0.5) self.assertAlmostEqual(pressure_interpolation['pt1'][-1], -0.5)
def test_read_time_step(self): t1 = 0.5 t2 = 1 pvdfile = VTUinterface.PVDIO("examples/square_1e2_pcs_0.pvd", dim=2) field_last_step = pvdfile.read_time_step(t2, "pressure") field_t1 = pvdfile.read_time_step(t1, "pressure") for i, entry in enumerate(field_t1): self.assertAlmostEqual(0.5 * field_last_step[i], entry)
def test_point_set_read(self): t = 0.5 pvdfile = VTUinterface.PVDIO("examples/square_1e2_pcs_0.pvd", dim=2) xaxis = [(i, 0, 0) for i in np.linspace(start=0.0, stop=1.0, num=100)] y_pred = np.linspace(start=0.5, stop=-0.5, num=100) pressure_xaxis_t1 = pvdfile.read_point_set_data(t, 'pressure', pointsetarray=xaxis) for i, p in enumerate(pressure_xaxis_t1): self.assertAlmostEqual(y_pred[i], p)
def test_time_series_cell(self): pvdfile = VTUinterface.PVDIO("examples/square_1e2_pcs_0.pvd", dim=2) ts = pvdfile.read_time_series("MaterialIDs", pts={"pt0": [0.345, 0.5231, 0]}, data_type="cell") self.assertEqual(ts["pt0"].all(), np.array([0.0, 0.0]).all())