コード例 #1
0
def test_submesh_cell_assembly(d, n, k, space, ghost_mode):
    """Check that assembling a form over a unit square gives the same
    result as assembling over half of a 2x1 rectangle with the same
    triangulation."""
    if d == 2:
        mesh_0 = create_unit_square(
            MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode)
        mesh_1 = create_rectangle(
            MPI.COMM_WORLD, ((0.0, 0.0), (2.0, 1.0)), (2 * n, n),
            ghost_mode=ghost_mode)
    else:
        mesh_0 = create_unit_cube(
            MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode)
        mesh_1 = create_box(
            MPI.COMM_WORLD, ((0.0, 0.0, 0.0), (2.0, 1.0, 1.0)),
            (2 * n, n, n), ghost_mode=ghost_mode)

    A_mesh_0 = assemble(mesh_0, space, k)

    edim = mesh_1.topology.dim
    entities = locate_entities(mesh_1, edim, lambda x: x[0] <= 1.0)
    submesh = create_submesh(mesh_1, edim, entities)[0]
    A_submesh = assemble(submesh, space, k)

    # FIXME Would probably be better to compare entries rather than just
    # norms
    assert(np.isclose(A_mesh_0.norm(), A_submesh.norm()))
コード例 #2
0
def xtest_submesh(tempdir, d, n, codim, ghost_mode, encoding):
    mesh = mesh_factory(d, n, ghost_mode)
    edim = d - codim
    entities = locate_entities(mesh, edim, lambda x: x[0] >= 0.5)
    submesh = create_submesh(mesh, edim, entities)[0]

    filename = os.path.join(tempdir, "submesh.xdmf")
    # Check writing the mesh doesn't cause a segmentation fault
    with XDMFFile(mesh.comm, filename, "w", encoding=encoding) as xdmf:
        xdmf.write_mesh(submesh)
コード例 #3
0
def test_submesh_boundary(d, n, boundary, ghost_mode):
    if d == 2:
        mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode)
    else:
        mesh = create_unit_cube(MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode)
    edim = mesh.topology.dim - 1
    entities = locate_entities_boundary(mesh, edim, boundary)
    submesh, vertex_map, geom_map = create_submesh(mesh, edim, entities)
    submesh_topology_test(mesh, submesh, vertex_map, edim, entities)
    submesh_geometry_test(mesh, submesh, geom_map, edim, entities)
コード例 #4
0
def test_submesh(d, n, codim, marker, ghost_mode):
    if d == 2:
        mesh = create_unit_square(MPI.COMM_WORLD, n, n, ghost_mode=ghost_mode)
    else:
        mesh = create_unit_cube(MPI.COMM_WORLD, n, n, n, ghost_mode=ghost_mode)

    edim = mesh.topology.dim - codim
    entities = locate_entities(mesh, edim, marker)
    submesh, vertex_map, geom_map = create_submesh(mesh, edim, entities)
    submesh_topology_test(mesh, submesh, vertex_map, edim, entities)
    submesh_geometry_test(mesh, submesh, geom_map, edim, entities)