def test_save_and_load_1d_mesh(tempdir, encoding): filename = os.path.join(tempdir, "mesh.xdmf") mesh = UnitIntervalMesh(MPI.comm_world, 32) with XDMFFile(mesh.mpi_comm(), filename, encoding=encoding) as file: file.write(mesh) with XDMFFile(MPI.comm_world, filename) as file: mesh2 = file.read_mesh(cpp.mesh.GhostMode.none) assert mesh.num_entities_global(0) == mesh2.num_entities_global(0) dim = mesh.topology.dim assert mesh.num_entities_global(dim) == mesh2.num_entities_global(dim)
def test_save_and_load_1d_mesh(tempdir, encoding): if invalid_config(encoding): pytest.skip("XDMF unsupported in current configuration") filename = os.path.join(tempdir, "mesh.xdmf") mesh = UnitIntervalMesh(MPI.comm_world, 32) with XDMFFile(mesh.mpi_comm(), filename, encoding=encoding) as file: file.write(mesh) with XDMFFile(MPI.comm_world, filename) as file: mesh2 = file.read_mesh(MPI.comm_world, cpp.mesh.GhostMode.none) assert mesh.num_entities_global(0) == mesh2.num_entities_global(0) dim = mesh.topology.dim assert mesh.num_entities_global(dim) == mesh2.num_entities_global(dim)
def test_small_mesh(): mesh3d = UnitCubeMesh(MPI.comm_world, 1, 1, 1) gdim = mesh3d.geometry.dim assert mesh3d.num_entities_global(gdim) == 6 mesh2d = UnitSquareMesh(MPI.comm_world, 1, 1) gdim = mesh2d.geometry.dim assert mesh2d.num_entities_global(gdim) == 2 mesh1d = UnitIntervalMesh(MPI.comm_world, 2) gdim = mesh1d.geometry.dim assert mesh1d.num_entities_global(gdim) == 2
def test_ghost_facet_1d(): mesh = UnitIntervalMesh(MPI.comm_world, 20, ghost_mode=cpp.mesh.GhostMode.shared_facet) assert mesh.num_entities_global(0) == 21 assert mesh.num_entities_global(1) == 20