コード例 #1
0
def run_SeismicMesh(ef, HMIN=75.0):

    cube = Cube(bbox)

    t1 = time.time()
    points, cells = generate_mesh(
        domain=cube,
        edge_length=ef,
        max_iter=25,
    )

    points, cells = sliver_removal(
        points=points,
        domain=cube,
        edge_length=ef,
    )
    elapsed = time.time() - t1

    # meshio.write_points_cells(
    #    "sm_EAGE.vtk",
    #    points,
    #    [("tetra", cells)],
    #    file_format="vtk",
    # )

    plex = meshplex.MeshTetra(points, cells)
    angles = plex.q_min_sin_dihedral_angles
    quality = plex.q_radius_ratio

    num_cells = len(cells)
    num_vertices = len(points)

    return angles, quality, elapsed, num_vertices, num_cells
コード例 #2
0
def test_3dmesher_par():

    fname = os.path.join(os.path.dirname(__file__), "test3D.bin")
    nz, nx, ny = 20, 10, 10
    bbox = (-2e3, 0.0, 0.0, 1e3, 0.0, 1e3)

    hmin = 50
    wl = 10
    freq = 4
    grade = 0.15
    grad = 50.0
    cube = Cube(bbox)
    ef = get_sizing_function_from_segy(
        fname,
        bbox,
        hmin=hmin,
        grade=grade,
        grad=grad,
        wl=wl,
        freq=freq,
        nz=nz,
        nx=nx,
        ny=ny,
        byte_order="little",
        axes_order=(2, 0,
                    1),  # order for EAGE (x, y, z) to default order (z,x,y)
    )

    points, cells = generate_mesh(
        h0=hmin,
        edge_length=ef,
        domain=cube,
        perform_checks=False,
    )

    points, cells = sliver_removal(
        points=points,
        domain=cube,
        edge_length=ef,
        h0=hmin,
        perform_checks=False,
    )

    if comm.rank == 0:
        import meshio

        meshio.write_points_cells(
            "foo3D_V3.vtk",
            points,
            [("tetra", cells)],
        )

        vol = geometry.simp_vol(points / 1000, cells)
        assert np.abs(2 - np.sum(vol)) < 0.10  # km2
        print(len(points), len(cells))
        assert np.abs(9220 - len(points)) < 5000
        assert np.abs(49156 - len(cells)) < 5000
コード例 #3
0
def test_3dmesher_domain_extension(style_answer):
    style, answer = style_answer
    fname = os.path.join(os.path.dirname(__file__), "test3D.bin")
    wl = 5
    freq = 2
    hmin = 150
    grade = 0.005
    bbox = (-2e3, 0.0, 0.0, 1e3, 0.0, 1e3)
    cube = Cube(bbox)
    ef = get_sizing_function_from_segy(
        fname,
        bbox,
        grade=grade,
        grad=hmin,
        freq=freq,
        wl=wl,
        hmin=hmin,
        nz=20,
        nx=10,
        ny=10,
        byte_order="little",
        domain_pad=200,
        pad_style=style,
        axes_order=(2, 0, 1),
    )

    write_velocity_model(fname,
                         nz=20,
                         nx=10,
                         ny=10,
                         byte_order="little",
                         ofname="testing",
                         bbox=bbox)

    points, cells = generate_mesh(
        domain=cube,
        edge_length=ef,
        h0=hmin,
        perform_checks=False,
    )

    points, cells = sliver_removal(points=points,
                                   domain=cube,
                                   edge_length=ef,
                                   h0=hmin)
    print(len(points), len(cells))
    allclose([len(points), len(cells)], answer, atol=100)

    import meshio

    meshio.write_points_cells("foo3D" + style + ".vtk", points,
                              [("tetra", cells)])
コード例 #4
0
def test_3dmesher_SDF():
    """Unit cylinder"""

    hmin = 0.10
    bbox = (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)

    def cylinder(p):
        r, z = sqrt(p[:, 0] ** 2 + p[:, 1] ** 2), p[:, 2]
        d1, d2, d3 = r - 1.0, z - 1.0, -z - 1.0
        d4, d5 = sqrt(d1 ** 2 + d2 ** 2), sqrt(d1 ** 2 + d3 ** 2)
        d = maximum.reduce([d1, d2, d3])
        ix = (d1 > 0) * (d2 > 0)
        d[ix] = d4[ix]
        ix = (d1 > 0) * (d3 > 0)
        d[ix] = d5[ix]
        return d

    def EF(p):
        return array(
            [
                hmin,
            ]
            * len(p)
        )

    points, cells = generate_mesh(
        bbox=bbox,
        domain=cylinder,
        h0=hmin,
        edge_length=EF,
        max_iter=100,
    )

    points, cells = sliver_removal(
        points=points, domain=cylinder, edge_length=EF, h0=hmin, bbox=bbox
    )

    assert allclose(sum(geometry.simp_vol(points, cells)), 6.28, atol=hmin)

    print(len(points), len(cells))
    allclose([len(points), len(cells)], [6825, 36206], atol=100)

    import meshio

    meshio.write_points_cells(
        "blah.vtk",
        points / 1000,
        [("tetra", cells)],
        file_format="vtk",
    )
コード例 #5
0
def test_3dmesher():

    fname = os.path.join(os.path.dirname(__file__), "test3D.bin")

    wl = 10
    freq = 2
    hmin = 50
    grade = 0.005
    bbox = (-2e3, 0.0, 0.0, 1e3, 0.0, 1e3)
    cube = Cube(bbox)
    ef = get_sizing_function_from_segy(
        fname,
        bbox,
        grade=grade,
        grad=hmin,
        freq=freq,
        wl=wl,
        hmin=hmin,
        nz=20,
        nx=10,
        ny=10,
        byte_order="little",
        domain_pad=0.0,
        axes_order=(2, 0, 1),
    )

    write_velocity_model(fname,
                         nz=20,
                         nx=10,
                         ny=10,
                         byte_order="little",
                         ofname="testing")

    points, cells = generate_mesh(
        domain=cube,
        edge_length=ef,
        h0=hmin,
        max_iter=25,
        perform_checks=False,
    )

    points, cells = sliver_removal(points=points,
                                   edge_length=ef,
                                   domain=cube,
                                   h0=hmin)
    print(len(points), len(cells))
    allclose([len(points), len(cells)], [16459, 89240], atol=100)