Open krober10nd opened 3 years ago
This is just an example for the future. Labels all boundary edges with a y-coordinate > 0 with a tag 11.
import numpy as np
import meshio
import SeismicMesh
bbox = (0.0, 1.0, 0.0, 1.0)
square = SeismicMesh.Rectangle(bbox)
points, cells = SeismicMesh.generate_mesh(domain=square, edge_length=0.20)
# This gets the edges of the mesh in a winding order.
ordered_bnde = SeismicMesh.geometry.get_winded_boundary_edges(cells)
mdpt = points[ordered_bnde].sum(1) / 2
sel = ordered_bnde[mdpt[:, 1] > 0, :]
# Write to gmsh22 format with boundary conditions
meshio.write_points_cells(
"example.msh",
points,
cells=[
("triangle", cells),
("line", np.array(sel)),
],
field_data={
"Edges": np.array([11, 1]),
},
cell_data={
"gmsh:physical": [
np.repeat(3, len(cells)),
np.repeat(11, len(sel)),
],
"gmsh:geometrical": [
np.repeat(1, len(cells)),
np.repeat(1, len(sel)),
],
},
file_format="gmsh22",
binary=False,
)