demo02 of writeMesh
Triangular mesh with multiple phases
Initialize
Set default image size.
x = 250; y = 250; width = 250; height = 250;
set(groot, 'DefaultFigurePosition', [x,y,width,height])
% set(groot, 'DefaultFigurePosition', 'factory')
Load mesh
Let's load the mesh data from "mesh_data_2.mat"
We will see 3 variables: vert, ele, tnum
vert
5 5
5 35
35 5
35 35
45 15
45 25
55 15
55 25
65 5
65 35
ele
28 14 53
59 51 22
56 35 11
46 37 6
44 25 35
41 44 35
18 25 44
45 34 41
41 35 43
34 55 44
Check the number of phase in the mesh
Plot mesh
Use function plotMeshes to plot mesh.
plotMeshes(vert,ele,tnum);
We saw 2 phases in the mesh.
Export as inp file (Abaqus)
We use function printInp2d to write 2d mesh to inp file.
By default, the exported inp file would have a model with one part, which contains multiple sections. Each section corresponds to one phase in the mesh.
Please refer to demo06 to learn about format setting of inp file.
When using function printInp2d, we can specify element type, precision and file name.
printInp2d( vert, ele, tnum, ele_type, precision, file_name );
printInp2d Done! Check the inp file!
Export as bdf file (Nastran bulk data)
We use function printBdf2d to write 2d mesh to bdf file.
printBdf2d( vert, ele, tnum, [], precision, file_name );
printBdf2d Done! Check the bdf file!
Export as msh file (Gmsh mesh file)
We use function printMsh to write 2d mesh to msh file.
printMsh( vert, ele, tnum, [], precision, file_name );
printMsh Done! Check the msh file!
When we open 'test.msh' in Gmsh, we can see 2 physical surfaces, which corresponds to 2 phases in our mesh.
BTW, we will see 3 surfaces in Gmsh. Note that, in Gmsh, surface and physical surface are different concepts. Gmsh use surfaces to define physical surface. Check Gmsh manual.
set(groot, 'DefaultFigurePosition', 'factory')