## How to Implement and Perform a Mesh Refinement Study

Mesh Refinement in COMSOL Multiphysics

Mesh refinement is a very important stage of process of a numerical simulation. When a computational problem is investigated, the mesh refinement is a vital to achieve a reliable result which does not depend on mesh size and location of cells. In this article we will try to be familiar with this process and implement of that.

### Best Mesh Size and Fineness for a Mesh Refinement Study

COMSOL primarily uses the finite element method (FEM) to compute single- and multiphysics simulations. Whenever you use the finite element method, it is important to remember that the accuracy of your solution is linked to the mesh size. As mesh size decreases towards zero (leading to a model of infinite size), you move toward the exact solution for the equations you are solving. However, since we are limited by finite computational resources and time, you will have to rely on an approximation of the real solution. The goal of simulation, therefore, is to minimize the difference (“error”) between the exact and the approximated solution, and to ensure that the error is below some accepted tolerance level that will vary from project to project based on your design and analysis goals.

You will need to track a characteristic output parameter from your simulation as you vary the mesh size and determine at which mesh size the parameter has “converged” on the correct value. Note that “converged” is used in quotation marks because the convergence criteria will depend on your design and analysis goals.

### Implementing a Mesh Refinement Study

In order to implement a mesh refinement study in COMSOL Multiphysics, you must first decide what output parameter you will use for your convergence criteria. This must be a numerical value evaluated over some, or all, of the nodes in your mesh. You can track a variable or mathematical expression of variables at a single point of interest, or you can use some operation (integral, average, minimum, maximum, etc.) performed over one or more domains, boundaries, or edges. If you choose the latter option, you can define the integral, average, minimum, or maximum operator by right-clicking Component 1 > Definitions and choosing the appropriate option in the Component Couplings menu, then selecting which geometric entity or entities to apply the operation to. Note that this should be added to your model before running your simulation. This should take care of setting up your output parameter.

Now you need to set up your mesh size by applying a user-defined parameter. Define a parameter under Global Definitions > Parameters and then use that parameter in the relevant Size feature in the Mesh node of your model to define a maximum element size.

Next, right-click your Study node and add a Parametric Sweep. In the Settings window, add your dummy mesh size parameter to the Parameter names list and enter the range of values to sweep your parameter over. Be sure you sweep through a wide enough range of maximum mesh sizes so you can fully capture the convergence effect in your analysis. This range will depend on your geometry and the nature of the physics equations you are solving. For example, for wave radiation problems, we recommend you use at least 5 elements per wavelength for a 3D problem and at least 8 elements per wavelength for a 2D problem, but you may still need to verify the best mesh size for your model using a mesh refinement study.

After computing the simulation, you will need to first set up a Join data set that compares the tracking parameter at each mesh size with the value of the tracking parameter that is considered to be the reliable solution; the solution at our finest mesh size will be chosen as that reliable solution here. Right-click Results > Data Sets and choose Join. Then in the Settings window, choose the solution containing your parametric sweep results (usually Solution 2) and select All solutions for Data 1, and click on the solution you want to compare your Parametric Sweep results to for Data 2 (Data: Solution 2, Solutions: One, etc.). Since we want to subtract these values, keep the Combination method as the default Difference option.

Once you’ve completed all of these steps, you are ready to create your plot. Add a 1D Plot Group with a Global or Point plot (depending on which parameter you are tracking for your convergence criteria, as described above), and make sure you specify the Data set as Join 1. Then type in the expression for the tracking parameter you are monitoring the convergence of and from the x-Axis Data > Axis source data drop-down menu, choose Outer solutions if you are running a Frequency Domain simulation (because your frequency range is considered your inner solution). Finally, click the Plot icon above the Settings window and you will see your convergence plot.

Below are a couple of key things that you’ll notice in the final model (megaphone model):

• The parameter elements_per_wavelength is used in the Parametric sweep to sweep from 1 element per wavelength through 8 elements per wavelength (remember, the recommended value is 5 for this wave radiation problem), but the maximum mesh size is defined by the parameter max_element_size, which is the wavelength divided by the elements_per_wavelength parameter.
• We are tracking the convergence of the maximum sound pressure level (SPL) in this model, so we first define the maximum operator on the domain of interest under Component 1 > Definitions > Maximum 1 and then after running the simulation we plot the expression maxop1(acpr.Lp) in a 1D Global plot. Note that operators act as functions, and you can find their “function” name listed in italics next to the operator in the Model Builder window. Here we are finding the maximum of the variable acpr.Lp, which is the sound pressure level (SPL), so acpr.Lp is the argument in parentheses.

### Performing a Mesh Refinement Study

How do I gain confidence in the accuracy of the solution to my problem? How do I perform a mesh refinement study?

All of the numerical methods used within COMSOL Multiphysics® discretize the modeling space via a Mesh that serves two purposes. First, this mesh is used to approximate the CAD geometry. Second, the approximate solution to the problem is solved at discrete points in space defined by this mesh. As this mesh is refined, the solution will tend to more accurately approximate the true to solution to the boundary value problem being posed. (Not all physics problems within COMSOL are boundary value problems, in particular the governing equations solved by the Ray Optics and Particle Tracing interfaces are ordinary differential equations. Even these, however, still require a discretization of the CAD geometry.)

To gain confidence in the accuracy of your model, you must re-solve the model on progressively finer meshes and compare results. In the limit of mesh refinement, well-posed problems will be convergent. In practice, there is a limit to how much mesh refinement can be done before you exceed the computational resources that you have available.

There are several different strategies that you can take to performing a mesh refinement study:

When using adaptive mesh refinement, as shown in the screenshot below, the software will compute the solution on an initial mesh and estimate where the error is high. The geometry will then be re-meshed with finer elements in these regions and the model re-solved on this new mesh. This feature allows you to control how many levels of adaptive mesh refinement are performed, how many elements will be created on the finer mesh, what metric to use to estimate the error, as well as the method used to adapt the mesh. This functionality is not available in combination with all physics interfaces, Ray Optics and Particle Tracing for example.

The results of adaptive mesh refinement will be a set of different Meshes, viewable within the Mesh branch, and a single Data Set that combines the results from all the levels of mesh refinement. The initial mesh that you start with can be either manually set up, or using the software default mesh. The settings and interface for adaptive mesh refinement of a time dependent study look a little bit different, as shown in the screenshot below. Rather than just a single mesh, several meshes will be created during the simulation time-span.

#### – Manually Defining Mesh Refinement

When using this approach, you will need to manually edit the meshing sequence and use a combination of different settings to define different mesh sizes in different parts of the model. The advantage of this approach is that you can more directly control how fine of a mesh is created, and you can also control the aspect ratio of the elements created. This is particularly advantageous if you know that the solution will vary strongly, or gradually, in one or two directions. This approach does require a greater level of interactivity, effort, and understanding as compared to adaptive mesh refinement, but it can lead to a strategy that uses less computational resources. Introduce a parameter that controls the mesh size and use a Parametric Sweep to sweep over a range of values that control the mesh. The results will be available within a single Data Set that contains all the parametric solutions.

#### – Using Physics-Controlled Mesh settings

It is also possible to use the default Physics-controlled mesh settings. Depending upon the physics involved in the model, the software will adjust the mesh based upon the geometry, and possibly also the applied domain and boundary conditions within the physics as well as the materials properties.

When using this approach, you have no direct control over the mesh, but it is very easy to use. Create several different meshes, each with their own Element Size: setting and introduce several different studies. Select the mesh as shown in the screenshot above. The results will be contained in different data sets, one for each study.

#### – Increasing Element Order

In additional to the above techniques it is also possible, albeit less common, to study the effect of increasing element order. Each physics interface defines an element order for approximating the fields within each element. This can be increased or decreased via the Discretization settings as shown in the screenshot below. Increasing discretization significantly increases memory usage. Use caution when altering this setting for multiphysics models, especially when mixing element orders in different physics.

#### – General Remarks

These approaches all presume that the software will converge to a solution for every different mesh. This is not necessarily the case for nonlinear problems, which may not converge if the mesh is too coarse.

#### – Comparing and Evaluating Results

Once you have used any one of, or any combination of, the above approaches you will want to compare the results between different cases. To view the differences between any two cases, create and use a Join data set within Results > Data Sets. Adjust the settings for the two sets of data that you wish to compare and select the Combination method to be Difference to create a set of data the is the difference between two different levels of mesh refinement, as shown in the screenshot below.

Be careful in evaluating the results of a mesh refinement study. Depending upon what metric you are evaluating, some quantities will converge faster, or slower, than others. Generally speaking integrals over the entire model will converge the most quickly, and local values the most slowly with mesh refinement. Also be careful in evaluating the derivatives of the fields at sharp corners, these will be locally non-convergent although they will not affect much the overall accuracy of the model far away from the singularity.

Source: COMSOl Multiphysics I , II

R&D Website
R & D is the research and development center of Acamech that develops Mechanical Engineering Problems; including Renewable Energy Technology, Strctural Mechanics, Acoustics, Micro and Nano Scale especially MEMS, Fluid Flow and Thermal Systems, Computational Fluid Dynamics, Finite Element Analysis, Computer-Aided Design, Concepts and Relevant Technology.