def l_shape_3d(h):
    tol = h / 10

    cube0 = SeismicMesh.Cube((-1.0, 1.0, -1.0, 1.0, -1.0, tol))
    cube1 = SeismicMesh.Cube((-1.0, 1.0, 0.0, 1.0, -tol, 1.0))
    cube2 = SeismicMesh.Cube((-tol, 1.0, -1.0, 1.0, -tol, 1.0))
    domain = SeismicMesh.Union([cube0, cube1, cube2])

    points, cells = SeismicMesh.generate_mesh(domain=domain, edge_length=h, verbose=0)
    points, cells = SeismicMesh.sliver_removal(
        domain=domain, points=points, edge_length=h, verbose=0
    )
    return points, cells
예제 #2
0
def test_smooth_diff():
    cube1 = sm.Cube((-0.5, 0.5, -0.5, 0.5, -0.5, 0.5))
    ball1 = sm.Ball((0.0, 0.0, 0.5), 0.85)

    domain = sm.Difference([ball1, cube1], smoothness=0.20)
    points, cells = sm.generate_mesh(
        domain=domain,
        edge_length=0.10,
    )
    points, cells = sm.sliver_removal(
        points=points,
        domain=domain,
        edge_length=0.10,
    )
    assert np.abs(cells.shape[0] - 9004) < 100
예제 #3
0
def test_pfix():
    hmin = 0.05
    bbox = (0.0, 1.0, 0.0, 1.0, 0.0, 1.0)

    pfix = np.linspace((0.0, 0.0, 0.0), (1.0, 0.0, 1.0),
                       int(np.sqrt(2) / hmin))

    pfix = np.vstack((pfix, SeismicMesh.geometry.corners(bbox)))

    cube = SeismicMesh.Cube(bbox)

    points, cells = SeismicMesh.generate_mesh(domain=cube,
                                              edge_length=hmin,
                                              pfix=pfix)

    def _closest_node(node, nodes):
        nodes = np.asarray(nodes)
        deltas = nodes - node
        dist_2 = np.einsum("ij,ij->i", deltas, deltas)
        return dist_2

    for p in pfix:
        d = _closest_node(p, points)
        assert np.isclose(np.min(d), 0.0)
예제 #4
0
def generate_mesh3D(model, G, comm):

    print('Entering mesh generation', flush=True)
    M = grid_point_to_mesh_point_converter_for_seismicmesh(model, G)
    method = model["opts"]["method"]

    Lz = model["mesh"]['Lz']
    lz = model['BCs']['lz']
    Lx = model["mesh"]['Lx']
    lx = model['BCs']['lx']
    Ly = model["mesh"]['Ly']
    ly = model['BCs']['ly']

    Real_Lz = Lz + lz
    Real_Lx = Lx + 2 * lx
    Real_Ly = Ly + 2 * ly

    minimum_mesh_velocity = model['testing_parameters'][
        'minimum_mesh_velocity']
    frequency = model["acquisition"]['frequency']
    lbda = minimum_mesh_velocity / frequency

    edge_length = lbda / M
    #print(Real_Lz)

    bbox = (-Real_Lz, 0.0, -lx, Real_Lx - lx, -ly, Real_Ly - ly)
    cube = SeismicMesh.Cube(bbox)

    if comm.comm.rank == 0:
        # Creating rectangular mesh
        points, cells = SeismicMesh.generate_mesh(domain=cube,
                                                  edge_length=edge_length,
                                                  mesh_improvement=False,
                                                  max_iter=75,
                                                  comm=comm.ensemble_comm,
                                                  verbose=0)

        points, cells = SeismicMesh.sliver_removal(points=points,
                                                   bbox=bbox,
                                                   domain=cube,
                                                   edge_length=edge_length,
                                                   preserve=True,
                                                   max_iter=200)

        print('entering spatial rank 0 after mesh generation')

        meshio.write_points_cells("meshes/3Dhomogeneous" + str(G) + ".msh",
                                  points, [("tetra", cells)],
                                  file_format="gmsh22",
                                  binary=False)
        meshio.write_points_cells("meshes/3Dhomogeneous" + str(G) + ".vtk",
                                  points, [("tetra", cells)],
                                  file_format="vtk")

    comm.comm.barrier()
    if method == "CG" or method == "KMV":
        mesh = fire.Mesh(
            "meshes/3Dhomogeneous" + str(G) + ".msh",
            distribution_parameters={
                "overlap_type": (fire.DistributedMeshOverlapType.NONE, 0)
            },
        )

    print('Finishing mesh generation', flush=True)
    return mesh
예제 #5
0
# when testing multiple cores.

print('Entering mesh generation', flush=True)
if model['opts']['degree'] == 2:
    M = 5.1
elif model['opts']['degree'] == 3:
    M = 3.1

edge_length = 0.286 / M
Real_Lz = model["mesh"]["Lz"] + model["BCs"]["lz"]
Lx = model["mesh"]["Lx"]
Ly = model["mesh"]["Ly"]
pad = model["BCs"]["lz"]

bbox = (-Real_Lz, 0.0, -pad, Lx + pad, -pad, Ly + pad)
cube = SeismicMesh.Cube(bbox)
points, cells = SeismicMesh.generate_mesh(domain=cube,
                                          edge_length=edge_length,
                                          max_iter=80,
                                          comm=comm.ensemble_comm,
                                          verbose=2)

points, cells = SeismicMesh.sliver_removal(points=points,
                                           bbox=bbox,
                                           max_iter=100,
                                           domain=cube,
                                           edge_length=edge_length,
                                           preserve=True)

meshio.write_points_cells("meshes/benchmark_3d.msh",
                          points, [("tetra", cells)],