def test_xdmf_vector(self): mesh = UnitSquareMesh(3, 3) V = VectorFunctionSpace(mesh, 'CG', 1) f0 = interpolate(Expression(('x[0]', 'x[1]'), degree=1), V) f1 = interpolate(Expression(('2*x[0]', '-3*x[1]'), degree=1), V) with XDMFFile(mesh.mpi_comm(), 'xdmf_test.xdmf') as out: f0.rename('f', '0') out.write(f0, 0.) f1.rename('f', '0') out.write(f1, 1.) # PVDTempSeries('pod_test.pvd', V) series = XDMFTempSeries('xdmf_test.xdmf', V) self.assertTrue(error(f0, series.getitem(0)) < 1E-14) self.assertTrue(error(f1, series.getitem(1)) < 1E-14)
def test_xdmf_scalar(self): mesh = UnitSquareMesh(3, 3) V = FunctionSpace(mesh, 'CG', 1) f0 = interpolate(Expression('x[0]', degree=1), V) f1 = interpolate(Expression('x[1]', degree=1), V) with XDMFFile(mesh.mpi_comm(), 'xdmf_test.xdmf') as out: f0.rename('f', '0') out.write(f0, 0.) f1.rename('f', '0') out.write(f1, 1.) # PVDTempSeries('pod_test.pvd', V) series = XDMFTempSeries('xdmf_test.xdmf', V=V.ufl_element())