Refer to the following YouTube video for instructions on how to generate the mesh:
You need to download the popular GMSH mesh generator from here:
Once you generated the mesh properly, in GMSH, you can proceed to the Toolbox. The mesh can ba also generated in other mesh generators that follow the basic data layout discused below. MATLAB PDE Toolbox can be used for mesh generation as well. Below you have the commands that let you manipulate the mesh in the Toolbox.
Remark on importing mesh from GMSH
At the current moment the QuickerSim cFD Toolbox for MATLAB® handles data only in pure-numbering format. Very often mesh files created in GMSH contain the named field of the following form: Import mesh generated by Gmsh.
Simply remove those fields before reading the mesh into our Toolbox.
Import mesh generated by Gmsh.
clc; clear; [p,e,t] = importMeshGmsh('cylinder.msh');
% You can now display mesh to check, if everything is alright. displayMesh2D(p,t); % In the finite element method formulation used in this Toolbox you use 2nd order mesh for flow simulations. % Therefore you need to generate additional nodes between the element vertices. In this way the mesh is % updated from the 1st order to the 2nd order. The pressure is still solved on the first order nodes only while % velocity on both 1st and 2nd order nodes. These 1st order and 2nd order nodes constitute the so-called % Taylor-Hood pair. Without extra these nodes the computations would be unstable. [p,e,t,nVnodes,nPnodes,indices] = convertMeshToSecondOrder(p,e,t);
The mesh used in the Tolbox follows the basic principle present in MATLAB® PDE Toolbox. The basic variables are: * p – array containig node coordinates * e – array with all edges in the mesh * t – array of all finite elements in the mesh
Type ‘help importMeshGmsh’ for more information or visit MATLAB website for more details:
Simple geometry manipulation example
The following code shrinks the mesh by 15% in x-direction and expands it in y-direction by 30%. The reference point for this transformation is the bottom left corner of the geometry located at (x0,y0) = (-2,-2).
x_scale=0.85; y_scale = 1.30; x0=-2; y0=-2; % We apply a linear transformation to each coordinate separately. p(1,:) = (p(1,:)-x0)*x_scale + x0; % p(1,:) are x coords. of mesh vertices p(2,:) = (p(2,:)-y0)*y_scale + y0; % p(2,:) are y coords. of mesh vertices % The cylinder in the middle is transformed into an elypsis. Note that the mesh topology does not change, % but modifications are applied to nodal coordinates stored in the variable p. figure(2) displayMesh2D(p,t);