Exemplo n.º 1
0
def test_triangle_mesh():
    mesh = Mesh(
        MPI.comm_world, CellType.triangle,
        numpy.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]], dtype=numpy.float64),
        numpy.array([[0, 1, 2]], dtype=numpy.int32), [],
        cpp.mesh.GhostMode.none)
    assert mesh.num_entities_global(0) == 3
    assert mesh.num_entities_global(2) == 1
Exemplo n.º 2
0
def test_read_mesh_data(tempdir, tdim, n):
    filename = os.path.join(tempdir, "mesh.xdmf")
    mesh = mesh_factory(tdim, n)

    encoding = XDMFFile.Encoding.HDF5
    ghost_mode = cpp.mesh.GhostMode.none

    with XDMFFile(mesh.mpi_comm(), filename, encoding) as file:
        file.write(mesh)

    with XDMFFile(MPI.comm_world, filename) as file:
        cell_type, points, cells, indices = file.read_mesh_data(MPI.comm_world)

    mesh2 = Mesh(MPI.comm_world, cell_type, points, cells, indices, ghost_mode)

    assert (mesh.topology.cell_type == mesh2.topology.cell_type)
    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)