How to Refine and Adapt Imported Meshes

August 15, 2019

If you have ever imported a mesh into the COMSOL Multiphysics® software, you might have found yourself wondering if there is any way to modify the mesh without going back to the source of the mesh. The Refine and Adapt operations are two useful tools for doing just that. As of COMSOL Multiphysics® version 5.4, these operations are also available for imported meshes. In this blog post, we demonstrate how these operations work and how you can use them to get the most out of your imported meshes.

The Refine Operation

The Refine operation provides a convenient and quick way of reducing the element size in an imported mesh. As the name suggests, the operation essentially partitions the elements that are already present in the mesh. Having a look at the settings available, shown in the figure below, we can select the Number of refinements to perform and a bounding box for the operation. It is also possible to perform the operation on the entire mesh or a selection of domains, boundaries, or edges. However, the option that we will be discussing in this article is the Refinement method, for which there are two settings to choose from:

  1. Split longest side
  2. Regular refinement

A screenshot showing the settings for the Refine operation in COMSOL Multiphysics®.
The Settings window for the Refine operation. It is possible to specify the Refinement method and the Number of refinements, as well as a bounding box for the operation and a Geometric Entity Selection.

To demonstrate how these methods work and what the differences are, let’s have a look at the case of a single tetrahedral mesh element. The second figure in the image below shows the element after one refinement step using the Split longest side method. The operation partitions the longest edge of the element into two equal pieces. The element is then divided in two using the new edges. Note, however, that when you have several connected elements, this will lead to some elements being split into more than two new ones to preserve a conforming mesh.

3 side-by-side images of a tetrahedral mesh element before and after using the Refine operation.
Three mesh plots of a single tetrahedral mesh element before and after building the Refine operation. Left: Unpartitioned element. Center: Element partitioned using the Split longest side setting. Right: Element partitioned using the Regular refinement setting. The element colors in the center and right figures indicate mesh element quality.

Using Regular refinement, the third plot shows the result on the same tetrahedral element. This time, every edge has been divided into two and then used to split the element into several smaller elements of the same type. For a tetrahedron, this results in eight new elements where there was previously only one. The Regular refinement option also has the feature of preserving the structure in structured meshes, so if you are importing a structured mesh, this might be something to take into consideration.

The Adapt Operation

Now, let’s have a look at the Adapt operation. While it includes a lot of functionality, in this blog post, we will be focusing on how you can use the Absolute size expression to modify the element size of your imported meshes.

For more information on using the Adapt operation in conjunction with error estimates and solution data, check out a previous blog post on using adaptive meshing for local solution improvement and the tutorials listed at the end of the article. Additionally, the blog post “2 Mesh Adaptation Methods: Enabling More Efficient Computations” shows how to use Adapt when dealing with anisotropic elements.

We’ll start by looking at how you can apply the Adapt operation to work with the size of your elements. The mesh we will be using has been saved to the NASTRAN® file format and can be found in the Eigenvalue Analysis of a Crankshaft tutorial model. Like with the Refine operation, Adapt requires all mesh elements to be linear, so to start, we will make sure to select Import as linear elements in the Import operation. We then add an Adapt feature node, where we select Absolute size as the Type of expression.

A screenshot of the Model Builder with an imported mesh for a crankshaft model.
The crankshaft mesh is imported from the NASTRAN® format using the option Import as linear elements. An Adapt node has been added to the sequence of Mesh operations with the settings Solution: None, Type of expression: Absolute size.

Whereas the Refine operation simply partitions all elements to create a finer mesh, by selecting Absolute size, the Adapt operation will try to modify the mesh to make the size of the elements conform to the expression we provide. There are three different ways by which the operation can try to achieve this:

  1. Longest edge refinement
  2. Regular refinement
  3. General modification

Which method is used can be selected in the Adaptation method menu.

Longest Edge Refinement and Regular Refinement

You might recognize Longest edge refinement and Regular refinement from the discussion on the Refine operation above, and you would be correct in doing so: They function based on essentially the same principles. However, while Refine partitions all elements in the mesh, the Adapt operation will strive to make the mesh conform to the size expression. Thus, if you have elements in your mesh that already closely match the expression, or are smaller, these will generally be kept unaltered.

In this way, the Adapt operation prevents unnecessary memory usage by not refining parts of the mesh where the resolution is already satisfactory. As an example, say we want to make the larger elements of the crankshaft mesh finer. Using the Refine operation set to Split longest edge and Number of refinements set to 1, we increase the number of elements in the mesh by a factor of about 3.5. However, using Adapt with Longest edge refinement and a Size expression of 8 [mm], we can achieve the same size reduction in the desired elements with an increase of less than a factor of 2 in the total number of elements.

A graphic showing a meshed section of the crankshaft model.
An image of the crankshaft mesh after the Adapt operation.

A section of the crankshaft mesh before (left) and after (right) running Adapt with the Longest edge refinement setting and the Size expression 8 [mm]. Note that not all elements have been partitioned, only those larger than the size specified in the expression (colored in green in both images).

General Modification

Using the General modification setting, in addition to creating new elements by partitioning elements, the operation is able to move mesh vertices and collapse elements that are too small to coarsen the mesh. As such, while attempting to make the mesh fit the size expression, it tends to make the elements more isotropic, thereby eliminating some poor-quality elements. This makes for a very versatile and powerful tool, as we shall see.

A section of mesh before applying the Adapt operation with general refinement.
A mesh section after using the General refinement setting.

A section of mesh before (left) and after (right) applying Adapt with the General refinement setting. The color indicates element quality, which can be seen to clearly increase as small elements are collapsed and vertices are moved.

The figure below displays how Adapt might typically modify the mesh when the General modification method is selected. In it, a section of the crankshaft mesh is shown before and after building Adapt using General modification and a Size expression of 8 [mm]. The figure also shows the results of using Longest edge refinement with the same expression, for the purpose of comparison. Notice that, for General modification, the operation has moved the vertices. This results in more isotropic and higher-quality elements. Additionally, say that you would like to run a quick simulation to get an estimate of the results. Then, General modification can, with an appropriate Size expression, be used to coarsen the mesh, reducing the number of elements and thereby the computation time.

An image of the unmodified crankshaft mesh.
An image of the crankshaft mesh with the Longest edge refinement option.
An image of the crankshaft mesh with the General modification setting.

A section of the crankshaft mesh with the unmodified version to the left. The Adapt operation has been applied with the Size expression 8 [mm] to the one in the middle and to the right, using Longest edge refinement and General modification, respectively. Notice how General modification has coarsened parts of the mesh and moved vertices to better fit the expression and improve quality.

Modifying the Boundary Mesh

When using the Refine or the Adapt operation on an imported 2D or 3D mesh, the operation will create a spline curve for each edge of the input mesh. The operation will use these splines to determine the positions of the edge mesh vertices of the refined or adapted mesh. The figure below indicates that the new mesh vertices that appear on the boundary reside on a spline rather than just residing on the input boundary mesh.

A graphic showing the mesh vertices on the refined mesh boundaries.
A graphic showing the mesh vertices of the input mesh boundary.

The positions of the new mesh vertices on the boundary of the refined mesh (to the right) are determined using a spline curve that is based on the mesh vertices of the boundary of the input mesh (to the left).

For mesh vertices on 3D faces, the Refine and Adapt operations do not create any spline surface. This means that for the refined or adapted mesh, the face mesh vertices will be projected to the input surface mesh. The figure below indicates that the new vertices that appear on the faces reside on the input surface mesh.

A graphic showing where the mesh vertices are on the refined mesh faces.
An image of the surface mesh of the input mesh.

The positions of the new mesh vertices on the faces of the refined mesh (to the right) are determined by projection onto the surface mesh of the input mesh (to the left), while the positions of the mesh vertices on the edges are determined using splines curves.

Concluding Thoughts

We have shown how the Refine and Adapt operations can be used to modify and improve your imported meshes. Refine offers a quick way to easily decrease the size of your mesh elements, while Adapt allows for more granularity by specifying a Size expression. Especially powerful is the setting General modification, which is able to refine and coarsen the mesh, as well as move vertices, thereby creating more isotropic elements and increasing the quality of the mesh.

Next Steps

The Adapt operation has a lot of useful features. If you would like to learn more about using Adapt and the all of the powerful functionality it brings, try out these tutorial models:

NASTRAN is a registered trademark of NASA.

Categories


Comments (0)

Leave a Comment
Log In | Registration
Loading...
EXPLORE COMSOL BLOG