Function File: [mesh] = msh2m_gmsh(geometry,option,value,...)
Function File: [mesh, gmsh_out] = msh2m_gmsh(...)
Construct an unstructured triangular 2D mesh making use of the free software gmsh.
The compulsory argument geometry is the basename of the
*.geo
file to be meshed.The optional arguments option and value identify respectively a gmsh option and its value. For more information regarding the possible option to pass, refer to gmsh manual or gmsh site http://www.geuz.org/gmsh/.
The returned value mesh is a PDE-tool like mesh structure. If the function is called with two outputs gmsh_out is the verbose output of the gmsh subprocess.
See also: msh2m_structured_mesh, msh3m_gmsh, msh2m_mesh_along_spline.
The following code
name = [tmpnam ".geo"]; fid = fopen (name, "w"); fputs (fid, "Point(1) = {0, 0, 0, .1};\n"); fputs (fid, "Point(2) = {1, 0, 0, .1};\n"); fputs (fid, "Point(3) = {1, 0.5, 0, .1};\n"); fputs (fid, "Point(4) = {1, 1, 0, .1};\n"); fputs (fid, "Point(5) = {0, 1, 0, .1};\n"); fputs (fid, "Point(6) = {0, 0.5, 0, .1};\n"); fputs (fid, "Line(1) = {1, 2};\n"); fputs (fid, "Line(2) = {2, 3};\n"); fputs (fid, "Line(3) = {3, 4};\n"); fputs (fid, "Line(4) = {4, 5};\n"); fputs (fid, "Line(5) = {5, 6};\n"); fputs (fid, "Line(6) = {6, 1};\n"); fputs (fid, "Point(7) = {0.2, 0.6, 0};\n"); fputs (fid, "Point(8) = {0.5, 0.4, 0};\n"); fputs (fid, "Point(9) = {0.7, 0.6, 0};\n"); fputs (fid, "BSpline(7) = {6, 7, 8, 9, 3};\n"); fputs (fid, "Line Loop(8) = {6, 1, 2, -7};\n"); fputs (fid, "Plane Surface(9) = {8};\n"); fputs (fid, "Line Loop(10) = {7, 3, 4, 5};\n"); fputs (fid, "Plane Surface(11) = {10};\n"); fclose (fid); mesh = msh2m_gmsh (canonicalize_file_name (name)(1:end-4), "clscale", ".5"); trimesh (mesh.t(1:3,:)', mesh.p(1,:)', mesh.p(2,:)'); unlink (canonicalize_file_name (name));
Produces the following output
Generating mesh... Processing gmsh data... Creating PDE-tool like mesh... Check for hanging nodes... Setting region number in edge structure... Deleting temporary files...
and the following figure
Figure 1 |
---|
Package: msh