How to Inspect Your Mesh in COMSOL Multiphysics®
Creating a suitable mesh for your FEA simulations is crucial for getting accurate results. In this blog post, we discuss how to check entities reported in mesh warnings and errors, how to view the statistics of a mesh or parts of a mesh, as well as how to plot the mesh and mesh-specific quantities and delimit these plots to selected regions.
Inspecting Entities Reported in Warning and Error Nodes
We sometimes get warnings and errors while meshing models. When this happens, we should inspect the entities listed in the Warning and Error nodes. Most warnings are caused by using mesh settings that are too coarse, preventing thin regions and short edges from being resolved properly.
To find these geometric entities, we can use the Zoom to Selection button in the Warning node. Toggling off the Mesh Rendering button and toggling on the Wireframe button for 3D meshes lets us easily see the entities reported inside the geometry. We can gain further insight into the issue by using the Measure button from the Geometry or Mesh toolbars for selected entities, for example, to get the length of edges or distance between points.
With our measurements and information from the Warning node, we can then set up Virtual Operations, or CAD Defeaturing, to eliminate the small geometric entities or reduce the mesh size if the features are important for the simulation.
A mesh of an airplane (left), where some interior boundaries are indicated as being too narrow to be properly resolved by the current mesh settings. The same boundaries, highlighted in blue, after clicking the Mesh Rendering and Wireframe buttons (right).
An Error node referring to a coordinate will have a button that enables us to zoom in on the coordinate. A small red sphere will appear around the coordinate so that the particular region can be studied in detail. When a warning indicates that one or more low-quality elements have been generated, it requires some special attention. We can check the Minimum element quality in the Statistics window and plot the mesh elements of the worst quality (explained in further detail later in this post).
If we have negative mesh quality or values very close to zero, it indicates that the reported mesh elements are inverted or nearly inverted. Note that inverted linear mesh elements, which we discuss here, are not the same phenomenon as inverted higher-order elements that you may run into when solving. The inverted linear mesh elements must be avoided to achieve convergence and accurate results.
Viewing the Statistics of the Mesh
One way to quickly get an overview of the created mesh is to have a look at the statistics in the Mesh Statistics window, which we open by right-clicking the Mesh head node.
It is possible to change the selection of domains, boundaries, or edges for which we display the numbers. For this, we use the Geometric Entity Level drop-down menu at the top of the window. The Quality Measure menu lets us choose from a list of quality measures, including:
- Maximum angle
- Volume versus circumradius
- Volume versus length
- Condition number
- Growth rate
About the Quality Measure Options
The Skewness measure is a suitable measure for most types of meshes; hence, it is the default measure. This quality measure is based on the equiangular skew that penalizes elements with large or small angles as compared to the angles in an ideal element. This quality measure is also used when reporting bad element quality during mesh generation. With the Maximum angle measure, only elements with large angles are penalized, making this option particularly well suited for meshes where anisotropic elements are desired, such as boundary layer meshes.
Volume versus circumradius is based on a quotient of the element volume and the radius of the circumscribed sphere (or circle) of the element. This quality measure is sensitive to large angles, small angles, and anisotropy. For triangular meshes in 2D and tetrahedral meshes in 3D where isotropic elements are desired, Volume versus circumradius is a suitable measure. On the other hand, Volume versus length is based on a quotient of element edge lengths and element volume. This quality measure is primarily sensitive to anisotropy.
The Condition number quality measure is based on properties of the matrix transforming the actual element to an ideal element. Lastly, Growth rate is based on a comparison of the local element size to the sizes of neighboring elements in all directions.
Notes on Mesh Quality
For all quality measures, a quality of 1 is the best possible and it indicates an optimal element in the chosen quality measure. At the other end of the interval, 0 represents a degenerated element. Although the meshing algorithms in COMSOL Multiphysics try to avoid low-quality elements, it is not always possible to do so for all geometries. High geometric aspect ratios, small edges and faces, thin regions, and highly curved surfaces may all lead to poor-quality meshes. When the geometry does lead to a poor-quality mesh, the mesher returns the poor-quality mesh for examination, rather than no mesh at all.
Depending on the quality measure used, the Minimum element quality, Average element quality, and the Element Quality Histogram sections will change accordingly. To get accurate results, it is important to know which Minimum element quality and Average element quality are sufficient for your particular application.
There are no absolute numbers to present for what the quality should be, as the physics and solvers used will have different requirements on the quality needed. In general, elements with a quality below 0.1 are considered as poor quality for many applications. The mesher will automatically present a warning for elements with a quality below 0.01, as these are considered to be very low quality and should be avoided in most cases. In some cases, a couple of low-quality elements may be okay if they are located in a part of the model with less importance, while in other cases, one low-quality element may lead to convergence problems.
The histogram in the Mesh Statistics window will give us a visual of the quality of the mesh, which can be a quick way to see if we need to change the overall mesh sizes in some way.
Creating a Mesh Plot
To understand where low-quality elements are positioned and which mesh size parameters to change, it can be a good idea to perform a plot of the mesh. We do this either by clicking the Plot button in the Mesh ribbon or by right-clicking the Mesh head node of the mesh we would like to plot and selecting Plot. This gives us a Mesh data set, available under Results > Data Sets, under which we can add Selections to narrow down the amount of entities shown in the plot. The Mesh plot feature can also be combined with other plot features.
We can gain a general understanding of how a specific mesh is set up by the different types of mesh elements. To do so, we set Level to Volume, choose an Element Type from the list, and set a uniform Element Color for this element type. To duplicate the Mesh plot feature node, we select another Element Type and Element Color. Then, we repeat the process until we have colored all of the available element types in the mesh. In the image below, the elements shrink by setting the Element Scale Factor to 0.8.
A colorful representation of the different element types in a mesh. The tetrahedrals are shown in cyan, the pyramids in magenta, and the prisms in gray. To understand more about how the elements are connected, they shrink with a factor of 0.8.
As we already mentioned, it can be important to understand where the elements of poor quality are located. This will help us understand if the geometry needs to be changed in any way or if the mesh-size parameters need to be modified to better handle the problematic area.
We can start by setting Level to Volume and in the Element Filter section selecting the Enable Filter check box. Then, we enter a Boolean expression, which reflects the elements we want to check. In the image below, the elements with a Skewness that is below 0.05 are shown. We can use the Replace Expression feature to easily access the names of the different quality measures. These measures can be used to spot different weaknesses in the generated mesh, so we should make sure we check all of them to see which is best used for our particular meshes.
The volume elements with a Skewness below 0.05 are displayed for the Shell-and-Tube Heat Exchanger model. In front of the Graphics window, the Replace Expression window gives easy access to the different quality measures.
Among the new quality measures, the Growth Rate is a bit different, as it shows a relation between two mesh elements, whereas the other quality measures display the quality of the shape of each single mesh element. The growth rate evaluates toward a maximum of 1 in regions of the mesh where the elements are constant in size. It is lower in regions where the element growth rate increases from one element to the next. The most important things to plot are often happening inside the mesh of a domain, while it can be good to add a filter expression including the space dimensions. Here is one such example:
The growth rate displayed for the mesh of the Biconical Antenna model. The plot shows that the boundary layer mesh in the PML domains are of similar size, while the growth rate shifts more in the tetrahedral mesh in the middle domains. In this example, the mesh elements for where y > 0.1 mm are shown by using the Element filter option. The slice plot shows the Electric field norm (dB).
Concluding Thoughts on How to Inspect Your Mesh in COMSOL Multiphysics®
We have discussed three different ways of inspecting a mesh, which can be used to spot regions with low-quality mesh elements. Now that we know how to find out where the low-quality mesh elements are, we can either manually adjust the mesh in these regions or address the issues with the underlying CAD geometry itself. To learn about modifying CAD geometries for meshing purposes, see the following blog posts and webinar video:
- Working with Imported CAD Designs
- Using Virtual Operations to Simplify Your Geometry
- Improving Your Meshing with Partitioning
- Analyzing Meshes in COMSOL Multiphysics®
If you want to evaluate the meshing capabilities of COMSOL Multiphysics for your own modeling needs, please contact us.
- COMSOL Now
- Today in Science