def test_2dmesher(): fname = os.path.join(os.path.dirname(__file__), "testing.segy") bbox = (-10000.0, 0.0, 0.0, 10000.0) wl = 5 freq = 5.0 hmin = 100 hmax = 10e6 grade = 0.005 grad = 50.0 rectangle = Rectangle(bbox) ef = get_sizing_function_from_segy( fname, bbox=bbox, grade=grade, grad=grad, wl=wl, freq=freq, hmin=hmin, hmax=hmax, ) plot_sizing_function(ef) write_velocity_model(fname) points, cells = generate_mesh( rectangle, ef, h0=hmin, perform_checks=True, ) # should have: 7690 vertices and 15045 cells print(len(points), len(cells)) allclose([len(points), len(cells)], [7690, 15045], atol=100)
def _build_sizing(HMIN=150.0, FREQ=2): # This file is in a big Endian binary format, so we must tell the program the shape of the velocity model. path = "Salt_Model_3D/3-D_Salt_Model/VEL_GRIDS/" # Extract binary file Saltf@@ from SALTF.ZIP zipfile.ZipFile(path + "SALTF.ZIP", "r").extract("Saltf@@", path=path) fname = path + "Saltf@@" # Dimensions of model (number of grid points in z, x, and y) nx, ny, nz = 676, 676, 210 ef = get_sizing_function_from_segy( fname, bbox, hmin=HMIN, dt=0.001, freq=FREQ, wl=5, grade=0.15, hmax=5e3, nz=nz, nx=nx, ny=ny, byte_order="big", axes_order=[2, 0, 1], # default order z, x, y -> order for EAGE x, y, z axes_order_sort="F", # binary is packed in a FORTRAN-style ) return ef
def test_3dmesher_par_adapt(): fname = os.path.join(os.path.dirname(__file__), "test3D.bin") nz, nx, ny = 20, 10, 10 bbox = (-2000.0, 0.0, 0.0, 1000.0, 0.0, 1000.0) cube = Cube(bbox) hmin = 50 wl = 10 freq = 4 grade = 0.15 ef = get_sizing_function_from_segy( fname, bbox, hmin=hmin, wl=wl, freq=freq, grade=grade, nx=nx, ny=ny, nz=nz, byte_order="little", ) points, cells = generate_mesh( cube, ef, max_iter=10, ) points = comm.bcast(points, 0) points, cells = generate_mesh( points=points, domain=cube, edge_length=ef, axis=1, max_iter=10, ) points = comm.bcast(points, 0) points, cells = generate_mesh( points=points, edge_length=ef, domain=cube, axis=2, max_iter=10, ) 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
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
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)])
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)
def test_2dmesher_par_adapt(): fname = os.path.join(os.path.dirname(__file__), "testing.segy") bbox = (-10e3, 0.0, 0.0, 10e3) wl = 5 freq = 5 hmin = 100 grade = 0.005 ef = get_sizing_function_from_segy( fname, bbox, hmin=hmin, wl=wl, freq=freq, grade=grade, ) rectangle = Rectangle(bbox) points, cells = generate_mesh( edge_length=ef, domain=rectangle, h0=hmin, perform_checks=False, ) points = comm.bcast(points, 0) # pass the points and restart with a different axis points, cells = generate_mesh( points=points, edge_length=ef, h0=hmin, domain=rectangle, perform_checks=False, ) if comm.rank == 0: import meshio meshio.write_points_cells("test2d.vtk", points / 1000, [("triangle", cells)], file_format="vtk") area = geometry.simp_vol(points / 1000, cells) assert np.abs(100 - np.sum(area)) < 0.60 # km2
def _build_sizing(FREQ=2.0, HMIN=75.0): # Name of SEG-Y file containg velocity model. fname = "vel_z6.25m_x12.5m_exact.segy" # Bounding box describing domain extents (corner coordinates) bbox = (-12000.0, 0.0, 0.0, 67000.0) # Construct mesh sizing object from velocity model ef = get_sizing_function_from_segy( fname, bbox, hmin=HMIN, wl=10, freq=FREQ, dt=0.001, grade=0.15, ) return ef
def test_2dmesher_domain_extension(style_answer): style, answer = style_answer fname = os.path.join(os.path.dirname(__file__), "testing.segy") bbox = (-10e3, 0.0, 0.0, 10e3) wl = 5 freq = 5.0 hmin = 100 hmax = 10e6 grade = 0.005 grad = 50.0 rectangle = Rectangle(bbox) ef = get_sizing_function_from_segy( fname, bbox=bbox, grade=grade, grad=grad, stencil_size=100, wl=wl, freq=freq, hmin=hmin, hmax=hmax, pad_style=style, domain_pad=1e3, ) plot_sizing_function(ef) write_velocity_model(fname, bbox=bbox) points, cells = generate_mesh( rectangle, ef, h0=hmin, perform_checks=True, ) # import meshio # meshio.write_points_cells( # "TEST.vtk", points, [("triangle", cells)], file_format="vtk" # ) print(len(points), len(cells)) assert allclose([len(points), len(cells)], answer, atol=100)
def test_2dmesher_par(): fname = os.path.join(os.path.dirname(__file__), "testing.segy") bbox = (-10e3, 0.0, 0.0, 10e3) freq = 2 wl = 10 hmin = 75 grade = 0.005 rectangle = Rectangle(bbox) ef = get_sizing_function_from_segy(fname, bbox, hmin=hmin, wl=wl, freq=freq, grade=grade) points, cells = generate_mesh( rectangle, ef, h0=hmin, max_iter=100, perform_checks=False, ) if comm.rank == 0: import meshio meshio.write_points_cells( "test2d.vtk", points / 1000, [("triangle", cells)], file_format="vtk", ) area = geometry.simp_vol(points / 1000, cells) assert np.abs(100 - np.sum(area)) < 0.50 # km2