I used the GMSH module and import it into dolfinx using model_to_mesh
:
Eg:
import gmsh
import sys
gmsh.initialize()
lc = 1e-2
point1 = gmsh.model.geo.add_point(0, 0, 0, lc)
point2 = gmsh.model.geo.add_point(1, 0, 0, lc)
point3 = gmsh.model.geo.add_point(1, 1, 0, lc)
point4 = gmsh.model.geo.add_point(0, 1, 0, lc)
line1 = gmsh.model.geo.add_line(point1, point2)
line2 = gmsh.model.geo.add_line(point2, point3)
line3 = gmsh.model.geo.add_line(point3, point4)
line4 = gmsh.model.geo.add_line(point4, point1)
curve_loop = gmsh.model.geo.add_curve_loop([line1,line2,line3,line4])
plane_surface=gmsh.model.geo.add_plane_surface([curve_loop])
gmsh.model.geo.synchronize()
gmsh.model.addPhysicalGroup(1, [line1,line2,line3,line4], 7)
gmsh.model.addPhysicalGroup(2, [plane_surface], name = "My surface")
gmsh.model.mesh.generate()
domain, cell_tags, facet_tags = model_to_mesh(gmsh.model, MPI.COMM_WORLD, 0,gdim=2)
gmsh.finalize()
Then it generates the following output in the Jupyter notebook:
Info : Meshing 1D...
Info : [ 0%] Meshing curve 1 (Line)
Info : [ 30%] Meshing curve 2 (Line)
Info : [ 50%] Meshing curve 3 (Line)
Info : [ 80%] Meshing curve 4 (Line)
Info : Done meshing 1D (Wall 0.00456533s, CPU 0.006704s)
Info : Meshing 2D...
Info : Meshing surface 1 (Plane, Frontal-Delaunay)
Info : Done meshing 2D (Wall 0.320374s, CPU 0.321686s)
Info : Meshing 3D...
Info : Done meshing 3D (Wall 0.000103284s, CPU 0.000103s)
Info : 11833 nodes 23668 elements
May I please know whether there is a way to hide this information prints because it becomes tedious if you have lot of lines