This knowledge base article will guide you on how to check mesh quality and how to improve it.
A high-quality mesh is one of the most critical factors that must be considered to ensure simulation accuracy, and this is why it is very important to check and improve your mesh quality. In this article, we will use the Standard mesher as an example.
The following topics are discussed:
- Checking the Meshing Log to have a quantitative idea about the overall mesh quality.
- Using the Mesh Quality feature to locate bad elements.
- Using manual mesh refinement to improve mesh quality.
The picture above is the initial mesh that will be used as an example.
1. Meshing Log
First, generate the mesh and once the mesh has been generated, you can see the mesh quality in the Meshing Log. You will find the Meshing Log under the Mesh settings in the simulation tree.
In the meshing log, you will find the statistical results of your generated mesh. These results will be mentioned as mesh metrics and these metrics will differ depending on the mesh type. It is worth keeping in mind that we need to monitor these values because it will affect the result of the simulation. Below are values that can be used as a best practice reference on when to check and improve your mesh quality:
- tetAspectRatio: \(\ll \) 100
- Non-orthogonality: \(\ll \) 75
- tetEdgeRatio: \(\ll \) 100
- VolumeRatio: \(\ll \) 100
The picture above shows that our mesh has bad quality because the maximum volume ratio is 93. Now, we have learned how to identify a bad quality mesh, but what is the cause and where are these bad quality elements located? Let’s find out.
2. Mesh Quality Feature
The Mesh quality is a SimScale feature, which visualizes the element quality. You will find this feature below the Meshing Log. In this example, we are only going to focus on reducing the maximum value for our volume ratio.
To visualize the volume ratio, do the following:
- Click ‘Results’.
- Choose the ‘Volume ratio’.
Everything in blue shows that the volume ratio is small in the overall domain. However, the current view can only show the surface elements. The best way to locate the bad quality elements is to isolate them and to do this we can use Isovolumes.
Isovolumes serves as a filter to isolate elements, whose volume ratio falls under a defined range. In this example, we will find mesh cells that have a volume ratio between 20 and 93. The steps below will explain how you can isolate these elements:
- Click the ‘+’ icon next to Isovolumes.
- Type the range of the Volume ratio you are interested in. In this example, we want to identify the elements in between 20 and 93 volumetric ratio. Keeping the volume ratio below 100 is good enough for incompressible flow simulation. Here, we reduced the minimum limit to be able to locate the bad elements faster. The assumption is that the element quality will most likely change gradually.
- Locate the highlighted elements on the screen.
In the picture above, bad elements can be seen, but it is difficult to determine their location. You can focus on the bad elements by changing the view to Transparent Surface Outline Mesh, and then zooming in.
Now, we know where the bad elements are located. Such issues often occur due to the CAD model issues, ill-defined surfaces, small gaps, or sharp corners. The most cost-effective way to deal with these issues is through CAD cleaning.
However, if you don’t have a chance to do CAD cleaning, you can try to refine the mesh for the whole domain or only refine the mesh where the bad elements exist.
3. Improve Mesh Quality
The meshing log might report a bad mesh quality. This is usually bad news but does not necessarily mean that the mesh is inconvenient to use. If there are only a few elements that have bad quality, and if those elements are not at the inlet or outlet boundaries, probably the simulation will still work all right.
There are two ways to improve the mesh quality:
- CAD cleaning: Modify the CAD model to prevent the generation of bad quality elements. As an example, remove the tiny gaps, remove the sharp angles, defeature, remove the small features.
- Mesh settings: Perform manual adjustments to prevent the generation of bad quality elements. For instance, adjust the global mesh settings and add manual refinements to control the cell size.
Mesh quality metrics are highly correlated to each other. In other words, if the Aspect ratio is bad, most probably the other quality metrics will be bad too. Therefore, it is important to aim for reducing the maximum AspectRatio quality metric.
Some useful tips to reduce the maximum Aspect ratio are listed below. Keep in mind that these measures won’t always work. The best workflow is to understand why the quality is bad and apply a corresponding measure accordingly:
- Reduce the ‘Number of layers’: Use at least 1 layer. If you are aiming for the correct y+ range, ignore this measure.
- Increase the ‘Overall relative thickness’: Keep the range between 10-60%. If you are aiming for the correct y+ range, ignore this measure.
- Reduce the ‘Growth rate’: Keep the range between 1.1-1.5. If you are aiming for the correct y+ range, ignore this measure.
- Increase the ‘Small feature suppression’: This value will determine the smallest edge length in the mesh, as well as the smallest cell size. Keep in mind that if this value is too high, the mesher will fail.
- Increase the ‘Gap refinement factor’: Usually, 0.5 will improve the mesh quality significantly. Ideally, keep this value above 1. Keep in mind that increasing this value will increase the overall mesh size significantly if there is a considerable volume of gap region/s in your model.
6. Use ‘Local refinement’ and ‘Region refinement’ to locally control the maximum cell size. For example, if there is an edge with a size of 1 \(mm\) in the CAD model, assign 1 \(mm\) maximum edge length at this region.
7. If you are using manual mesh refinements, be conscious about the cell size assignment. Above all, sudden cell size changes to keep the VolumeRatio small.
Example: Refine the Elements Locally
Previously, we found some regions with bad element qualities (Figure 5 and Figure 6). You can always use SimScale’s automatic sizing feature to adjust the mesh size. Increasing the Fineness level will gradually increase the mesh size in the overall domain.
Another possibility is to refine the mesh in the problematic region with region refinement. Below is an example of how to refine the mesh in a specific region of your model:
The picture above shows the problematic region where there is a face in the geometry that becomes smaller and smaller. This is a problem because when the thickness of this face becomes too small, sharp edge cells are generated in this region. We will need a region refinement to mesh this region properly. For that:
- Add a region refinement.
- Create a geometry primitive (Cartesian box).
- Assign the Cartesian box you’ve just created.
- Assign a suitable cell size to the region.
We can also see that the mesh generated at the inlet of the pump is too coarse, and we can refine this by refining the whole model by increasing the fineness level.
After regenerating the mesh, we will get new mesh with new mesh quality statistics.
The initial mesh was updated with a region refinement as well as an increase in the general mesh fineness. We can see that the maximum volume ratio has decreased to 60.240.
We can also observe visually that the element sizes are relatively smaller in the region where the refinement was applied.