This tutorial is intended for the full version of the toolbox.
In this tutorial we will show, how to cope with the function, which enables creation of boundary layer mesh for 2-D problems.
Case 1: Circular cylinder
In the first case we create boundary layer for a 2-D flow past a circular cylinder.
clc; clear; % Import and display mesh [p,e,t] = importMeshGmsh('cylinder.msh'); displayMesh2D(p,t); % Define global boundary layer parameters layers.h1 = 0.07; layers.q = 1.5; layers.n = 3; % Add boundary layer mesh wallIds = ; [p,e,t] = extrudeLayers2D(p,e,t,wallIds,layers); % Display mesh figure(2); displayMesh2D(p,t);
Case 2: Channel with obstacles
Geometry with ids of physical lines created in Gmsh is shown below.
The call to the function requires specification of ids of walls, from which the boundary layers should be extruded and definition of sizing parameters. Currently, there is only one option. One should define a MATLAB structure with fields (height of the first layer), (height ratio of the following layers) and (total number of layers in mesh). This structure shall be passed to the function as the fifth argument.
clc; clear; % Import and display mesh [p,e,t] = importMeshGmsh('urbanMesh.msh'); displayMesh2D(p,t); % Define global boundary layer parameters layers.h1 = 0.02; layers.q = 1.5; layers.n = 3; % Add boundary layer mesh wallIds = [18 19 20 21 22 23]; [p,e,t] = extrudeLayers2D(p,e,t,wallIds,layers); % Display mesh figure(3); displayMesh2D(p,t);
Laplace Smoothing in Boundary Layer
When layers are extruded and wall normal vectors are defined, the function performs automatically Laplace smoothing of directions and lengths of wall normal vectors. Default parameters are set to 10 smoothing iterations and smoothing coefficient equals 0.9 (should be between 0 and 1). Smoothing coefficient has a moderate impact on mesh quality, however, changing between a small and big number of smoothing steps can lead to significantly different results). Number of smoothing steps and smoothing coefficient are passed to the function optionally, as the two last parameters. We present a fragment of adequate script code and two different meshes illustrate the differences.
% Define global boundary layer parameters layers.h1 = 0.02; layers.q = 1.5; layers.n = 3; % Add boundary layer mesh wallIds = [18 19 20 21 23]; [p,e,t] = extrudeLayers2D(p,e,t,wallIds,layers); % The meshes were obtained with the following parameters: % % % # Mesh 1: nsteps = 3, coefficient = 0.8 % # Mesh 2: nsteps = 50, coefficient = 0.8 %
Mesh resulting from first parameters set:
Mesh resulting from second parameters set:
This QuickerSim CFD Toolbox function for boundary layer mesh generation is intended to be a quick and easy to use tool, but in no way to be replacement for advanced meshing environments. It works well in standard cases, but certain conditions must be met. Otherwise, this function may generate erroneous mesh and lead to wrong computation results. The function in most cases works well, if the boundary layer extends on the walls of geometry from inlet to outlet. If it should be broken in some places as depicted below, the mesh marked with red circles will be wrong, although it looks reasonably. If you run the simulation, extended edges of the boundary layer mesh will probably be treated as walls (coincident with top wall of the square). That is why it is adviced to build boundary layer on all geometry walls and pay attention that it is not broken at unexpected places.