Пример #1
0
def test_cylinder():
    radius = 1.0
    z0 = 0.0
    z1 = 1.0
    edge_length = 0.1
    s0 = pygalmesh.Cylinder(z0, z1, radius, edge_length)
    pygalmesh.generate_mesh(s0,
                            "out.mesh",
                            cell_size=0.1,
                            edge_size=edge_length,
                            verbose=False)

    mesh = meshio.read("out.mesh")

    tol = 1.0e-1
    assert abs(max(mesh.points[:, 0]) - radius) < tol
    assert abs(min(mesh.points[:, 0]) + radius) < tol
    assert abs(max(mesh.points[:, 1]) - radius) < tol
    assert abs(min(mesh.points[:, 1]) + radius) < tol
    assert abs(max(mesh.points[:, 2]) - z1) < tol
    assert abs(min(mesh.points[:, 2]) + z0) < tol

    vol = sum(compute_volumes(mesh.points, mesh.cells["tetra"]))
    ref_vol = numpy.pi * radius * radius * (z1 - z0)
    assert abs(vol - ref_vol) < tol
    return
Пример #2
0
def test_cylinder():
    radius = 1.0
    z0 = 0.0
    z1 = 1.0
    edge_length = 0.1
    s0 = pygalmesh.Cylinder(z0, z1, radius, edge_length)
    pygalmesh.generate_mesh(s0,
                            'out.mesh',
                            cell_size=0.1,
                            edge_size=edge_length,
                            verbose=False)

    vertices, cells, _, _, _ = meshio.read('out.mesh')

    tol = 1.0e-1
    assert abs(max(vertices[:, 0]) - radius) < tol
    assert abs(min(vertices[:, 0]) + radius) < tol
    assert abs(max(vertices[:, 1]) - radius) < tol
    assert abs(min(vertices[:, 1]) + radius) < tol
    assert abs(max(vertices[:, 2]) - z1) < tol
    assert abs(min(vertices[:, 2]) + z0) < tol

    vol = sum(compute_volumes(vertices, cells['tetra']))
    ref_vol = numpy.pi * radius * radius * (z1 - z0)
    assert abs(vol - ref_vol) < tol

    return
Пример #3
0
def cylinder(h):
    s = pygalmesh.Cylinder(0.0, 1.0, 0.5, h)
    # The circumradius of a regular tetrahedron with the given edge_size is sqrt(3 / 8)
    # * edge_size ~= 0.61 * edge_size. Relax it a bit and just use h.
    mesh = pygalmesh.generate_mesh(
        s, max_cell_circumradius=h, max_edge_size_at_feature_edges=h, verbose=False
    )
    return mesh.points, mesh.get_cells_type("tetra")
Пример #4
0
def test_cylinder():
    radius = 1.0
    z0 = 0.0
    z1 = 1.0
    edge_length = 0.1
    s0 = pygalmesh.Cylinder(z0, z1, radius, edge_length)
    mesh = pygalmesh.generate_mesh(s0,
                                   cell_size=0.1,
                                   edge_size=edge_length,
                                   verbose=False)

    tol = 1.0e-1
    assert abs(max(mesh.points[:, 0]) - radius) < tol
    assert abs(min(mesh.points[:, 0]) + radius) < tol
    assert abs(max(mesh.points[:, 1]) - radius) < tol
    assert abs(min(mesh.points[:, 1]) + radius) < tol
    assert abs(max(mesh.points[:, 2]) - z1) < tol
    assert abs(min(mesh.points[:, 2]) + z0) < tol

    vol = sum(
        helpers.compute_volumes(mesh.points, mesh.get_cells_type("tetra")))
    ref_vol = numpy.pi * radius * radius * (z1 - z0)
    assert abs(vol - ref_vol) < tol