Suppose that I have the following function I wrote to generate a rectangle mesh using GMSH:
def generate_mesh_quadrilateral(A,B,C,D,mesh_size):
gmsh.initialize()
gmsh.option.setNumber("General.Terminal",0) #To hide the mesh output values
gmesh_point_A = gmsh.model.geo.add_point(A[0], A[1], 0, mesh_size)
gmesh_point_B = gmsh.model.geo.add_point(B[0], B[1], 0, mesh_size)
gmesh_point_C = gmsh.model.geo.add_point(C[0], C[1], 0, mesh_size)
gmesh_point_D = gmsh.model.geo.add_point(D[0], D[1], 0, mesh_size)
gmesh_line_AB = [gmsh.model.geo.add_line(gmesh_point_A, gmesh_point_B)]
gmesh_line_BC = [gmsh.model.geo.add_line(gmesh_point_B, gmesh_point_C)]
gmesh_line_CD = [gmsh.model.geo.add_line(gmesh_point_C, gmesh_point_D)]
gmesh_line_DA = [gmsh.model.geo.add_line(gmesh_point_D, gmesh_point_A)]
line_list = gmesh_line_AB+gmesh_line_BC+gmesh_line_CD+gmesh_line_DA
curve_loop = gmsh.model.geo.add_curve_loop(line_list)
plane_surface = gmsh.model.geo.add_plane_surface([curve_loop])
gmsh.model.geo.synchronize()
wall_marker = int(1e8)
in_flow_marker = int(2e8)
out_flow_marker = int(3e8)
print("gmesh_point_A: ",gmesh_point_A)
print("wall_marker: ",wall_marker)
print("plane_surface: ",plane_surface)
print("gmesh_line_BC: ",gmesh_line_BC)
gmsh.model.addPhysicalGroup(2, [plane_surface], name = "My surface")
gmsh.model.addPhysicalGroup(1, gmesh_line_AB+gmesh_line_CD, wall_marker)
gmsh.model.addPhysicalGroup(1, gmesh_line_BC, out_flow_marker)
gmsh.model.addPhysicalGroup(1, gmesh_line_DA, in_flow_marker)
gmsh.model.mesh.generate()
domain, cell_tags, facet_tags = model_to_mesh(gmsh.model, MPI.COMM_WORLD, 0,gdim=2)
gmsh.finalize()
mesh = domain
grid = pyvista.UnstructuredGrid(*create_vtk_mesh(mesh, mesh.topology.dim))
pyvista.start_xvfb()
plotter = pyvista.Plotter()
plotter.add_mesh(grid, show_edges=True)
plotter.view_xy()
if not pyvista.OFF_SCREEN:
plotter.show()
else:
pyvista.start_xvfb()
output = {"domain":domain, "cell_tags":cell_tags, "facet_tags":facet_tags,
"wall_marker":wall_marker,"in_flow_marker":in_flow_marker,"out_flow_marker":out_flow_marker }
return output
Let
A = np.array([0,0])
B = np.array([5,0])
C = np.array([5,2])
D = np.array([0,2])
Then
mesh_size = 0.3
mesh_generator_output_without_dimensions= generate_mesh_quadrilateral(A,B,C,D,mesh_size)
will generate the following mesh:
My question is, in the code to generate this mesh, I used
wall_marker = int(1e8)
in_flow_marker = int(2e8)
out_flow_marker = int(3e8)
Reason for using such a large integer is because, numbers like 1
and 2
will be already allocated for GMSH points. My question is, does it really matter if I mark them as
wall_marker = int(1)
in_flow_marker = int(2)
out_flow_marker = int(3)
or should I have to avoid repeating the numbers at all cost? In this case, please note that number 1
is associated with the first GMSH point as well.
And later on, I will be utilizing these markers to implement the Navier stokes sover on FENICSx
Thank you