Meshing

Meshing is the process of dividing up the domain of interest into smaller elements (or cells) so that numerical methods can be used to solve the partial differential equations required to model fluids. Creating a high quality mesh is crucial for obtaining accurate results, plus it often helps the simulation converge faster. This guide will focus more on how to setup a mesh in SimScale but I’ll start with a brief discussion on mesh design to provide context for the various settings.

 

Mesh Design


Mesh design is mostly about finding just enough mesh elements to accurately represent the geometry of interest. Minimizing the number of mesh elements reduces the time and computing power required for the simulation, but not having enough increases the error of the results. A quick metric to use is the total number of elements. This number gives a rough idea of the mesh resolution and can help predict how long a simulation will take.

First, the region that will be simulated must be determined. This is known as the Background Mesh Box (Also commonly called the bounding box or domain). Typical guidelines are to use 2-8 times the car’s dimensions as the dimensions of the domain. Less space is needed on the sides, moderate space is needed in front of the car, and the majority of space should be behind the car. So for MSXIV (Approximately 5 m long, 2 m wide, 1 m tall), the domain should extend about 15 m (= 5 m * 3) in front of the car, 35 m (= 5 m * 7) behind the car, and 5 m above and on either side. Now, it is important to note that there is a plane of symmetry running down the center of the car. This means that we only need to simulate half of the car. The resulting drag (and other forces) can be doubled when post-processing, since each half of the car should have identical drags. This can drastically reduce the number of elements in your mesh, without sacrificing resolution. The end result is a domain that is still 50 m long, 5 m tall, and 5 m wide, offset to one side of the car.

Remember that a simulation might be asymmetric even if the geometry is symmetric. Crosswind simulations are one such example, which would require a full mesh.

Once the size of the domain is determined, the resolution on the surface of the car must be decided upon. This is partially determined by how the boundary layer will be modelled. There are 2 strategies for this: using full resolution or using wall functions. Whichever strategy is chosen will determine the height of the boundary layer elements in the direction perpendicular to the surface. The lateral dimensions of the elements should be similar in value to the height.

Then refinements are used to create appropriately sized elements between the car’s surface and the domain walls. Essentially, the area around the car should have the finest elements, then the edges of the domain should have the coarsest elements, and there should be a gradient of element sizes between them. There should also be moderately fine elements in the wake of the vehicle.

 

 

 

Mesh Settings


General Mesh Settings + Geometry Primitives

I think that gives enough context to start, so I’ll talk about how to actually set this up in SimScale now. To start editing the mesh settings, click Mesh in the left navigation panel. That should bring up global mesh settings, meaning that these settings apply everywhere in the domain (Other settings may only apply to specific regions). Change the algorithm from Standard to Hex-dominant parametric. This gives more control over the mesh and primarily uses hex-based elements rather than tet-based elements. Now expand the Geometry primitives section in the navigation panel and select the Background Mesh Box. A panel should open with the minimum x, y, and z coordinates, along with the maximum x, y, and z coordinates. I used minimum values of 0, 0, and -35, and maximum values of 5, 5, and 15. Next, select the Material Point section. This point determines which volume is divided into elements, so make sure the point is located within the background mesh box, but outside of the car geometry. While we’re here, add 2 Cartesian box geometry primitives. Select a region trailing from the car with one box inside the other one. For example use 0, 0, -20 to 2, 2, -4 for one, and 0, 0, -16 to 1.5, 1.5, -4 for the other. This is to enclose the wake behind the car, with 2 different mesh densities. Return to the general mesh settings. Beneath the algorithm setting, there should be a section for Bounding box resolution. I’ve been using values of 20, 20, and 200.

You’ll notice that there are a bunch of settings beneath these if you scroll down. I consider these to be advanced settings, and the defaults usually work for most cases. Not our case though, as there are some settings that need to be changed. For now, scroll down to the Layer adding controls and turn off Layer size and I’ll return to this section later for the rest of the changes. The reason I make this change now is that it changes the meaning of some other basic settings that we are going to set next and then I prefer to tweak the advanced settings at the end, since they might take a few tries to get right.

 

General Refinements

Using a mesh that is 20x20x200 is not fine enough to represent the flow patterns around a vehicle so refinements will be added around the car. Locate the Refinements section in the navigation panel, and begin by adding a bounding box refinement. Change the Face to Ymin, Min thickness to 0 m, and Final thickness to 12e-3 m. Save the refinement by clicking the blue check mark in the top right of that panel. Add a region refinement. Change the Refinement mode to Distance and use values similar to those from Table 2.1. These values can vary depending on how many elements you want in your mesh.

 

Table 2.1: Refinement levels used around MSXIV.

Distance [m]

Level [-]

Distance [m]

Level [-]

0.75

4

1.5

3

2.5

2

 

Assign this refinement to the car geometry by clicking the car in the geometry viewer (you may need to click inside the box that says Pick Volumes first so that the program knows you’re ready to select the geometry, ensure the box is blue). Add 2 more geometry refinements, this time leave the modes as Inside. Set the level of the first one to 2, and assign it to the larger Cartesian box geometry primitive that was created earlier by clicking the sliding switch to the left of the label at the bottom of the panel. Then set the level of the second one to 3 and assign it to the smaller Cartesian box geometry primitive that was created earlier. The next refinement is called a Surface refinement. Set the Min level and Max level to 5 and assign it to the car entity. We don’t need cell zones for this type of simulation.

 

Boundary Layer Refinement

The last refinement we need is a boundary layer refinement. This allows the simulation to properly model the effects of the boundary layer on the airflow around the vehicle. Add the Inflate boundary layer refinement and set the layers, expansion ratio, min thickness, and inner layer thickness to the desired values, based on whether you want to use wall functions or full resolution. I would start with wall functions, as they are computationally cheaper and I’ve had slightly better convergence with them. I’ve had success using 10 layers, at an expansion ratio of 1.2, a minimum thickness of 0 m, and an inner layer thickness of 6.6e-3 m. Select all the faces of the vehicle.

To select all faces on the vehicle quickly hold b, click, and drag a box that encompasses the geometry.

Those are all the refinements that I generally use, however the problem is that if this mesh is generated now the boundary layers will be missing. Maybe not all of them, but the vast majority in my experience. Proper boundary layer modelling is critical for predicting fluid behaviour around the vehicle so this must be corrected. My understanding of why this happens is that all of the layers are actually formed as requested during mesh generation but many of these layer elements do not meet quality standards and are removed. The solution is to either create higher quality layer elements or to relax the quality parameters, allowing lower quality elements to be used. Both of these require the advanced settings section I mentioned earlier (Return to Mesh in the navigation panel and scroll down to find the advanced settings).

Scroll down until the Snap controls, change the settings indicated in Table 2.2, then scroll to the Layer adding controls, and make the changes indicated in Table 2.3:

 

Table 2.2: Snap controls

Setting

Default Value

New Value

Setting

Default Value

New Value

Mesh to geometry conformation

5

3

Tolerance

2

1

Solver iterations

150

300

 

Table 2.3: Advanced layer addition settings.

Setting

Default Value

New Value

Setting

Default Value

New Value

Slip feature angle

75

60

Relax iterations

8

20

Surface normals max smoothing iterations

2

20

Internal mesh max smoothing iterations

5

50

Layer thickness max smoothing iterations

10

50

Layer addition max iterations

50

200

 

These changes are mostly to allow more iterations to generate the layer elements so that they are of higher quality. A few of these settings also speed up the mesh generation process. Then scroll down to Mesh quality controls and make the changes indicated in Table 2.4:

 

Table 2.4: Mesh quality settings.

Setting

Default Value

New Value

Setting

Default Value

New Value

Max non orthogonality

70

65

Min volume

1e-13

-1e+30

Relaxed max non orthogonality

75

70

 

You can now hit the Generate button in the bottom right of the settings panel.

These settings are likely not optimal. From the limited testing that I did, these gave the best mesh results, although there are still bad spots on the mesh. Some of the iterations I’ve added might also be unnecessary, and the mesh generation might be able to be sped up by reducing some of the maximum iterations for certain processes.

 

Reviewing the Mesh

After the mesh has been generated, navigate to mesh and click the yellow button that appears to select the mesh as your domain. The icon besides Mesh in the navigation panel should change from yellow to green. Before proceeding, we should check to make sure it looks right and that no mistakes have been made. SimScale has several tools for this, some of which have been recently added. The first and most basic is the mesh element count, found in the general mesh settings under Mesh selection. If your mesh is way smaller or way larger than expected, something may be wrong and any issues should be addressed before moving onto the simulation. A more detailed inspection can be done by looking at the mesh in the 3-D display. The symmetry plane provides a convenient cross-section to look at the boundary layers running along the middle of the car, and the mesh clip tool can be used to create any other cross-sections. Finally, you can navigate to the Mesh quality section to conduct more quantifiable analysis of your mesh quality, although it does take a while to load.

Figure 2.1: Symmetry plane of the mesh generated by the discussed settings.

Figure 2.2: Closer view of the boundary layer elements around the front of the vehicle.

Figure 2.3: Closer view of the boundary layer elements around the pontoon, created with a mesh clip.

You may also have noticed a section called Meshing log, this can be used to see what the mesh generation algorithm is doing while the mesh is being generated. This can be difficult to read at first, but it does provide a lot of information about the mesh.

If the mesh is an appropriate size, with an appropriate number of boundary layer cells, and no obvious defects you can continue to the actual simulation.