## Using Adaptive Meshing for Local Solution Improvement

##### Walter Frei December 27, 2013

One of the perennial questions in finite element modeling is how to choose a mesh. We want a fine enough mesh to give accurate answers, but not too fine, as that would lead to an impractical solution time. As we’ve discussed previously, adaptive mesh refinement lets the software improve the mesh, and by default it will minimize the overall error in the model. However, we often are only interested in accurate results over some subset of the entire model space. Today we will introduce a technique to refine the mesh based on a local metric.

### A Model with Global Mesh Refinement

Let’s take a look at a simple mechanical problem — a bracket that is fixed at the bottom and has a load applied at the top. Two different fillet radii are applied and, as a consequence, it is difficult to predict where the peak stresses will be. Let’s first solve the problem on an extremely coarse mesh, using the default second-order elements, and observe the results. We can see that the peak stresses are at the larger radius fillet, and that the mesh appears to quite poorly resolve the solution.

Stresses and deformations solved on a coarse mesh.

To get a more accurate solution, we can go to the Adaptation and Error Estimates settings available with the Stationary, Frequency Domain, and Eigenvalue study steps. An example of these settings is shown in the screenshot below. The error estimate is by default based upon minimizing the L2 norm of error squared, which is a global metric. That is, the remeshing will reduce the error everywhere in the model. The default refinement method is Mesh initialization, which will refine the mesh in areas where smaller elements are needed, but can also coarsen the mesh where a fine mesh is not needed. By default, this adaptive refinement will be done twice, but in the screenshot below, a total of four refinements are specified.

Adaptive mesh refinement settings to reduce the global error in the model. Relevant settings are highlighted.

The result of this adaptive mesh refinement is shown below. Note how the mesh is quite uniformly refined throughout the domain. The stress field is clearly smoother than on our original mesh.

The results of the adaptive mesh refinement using the L2 norm of error squared as the error estimate.

### Local Solution-Based Adaptive Mesh Refinement

Let’s now set up the same problem, but use a different metric for the adaptive mesh refinement. From the coarse mesh, we can probably already see that the highest stresses are at the larger radius fillet so we can tell the adaptive mesh refinement algorithm to address the stresses in this location. We will switch to a Functional Error Estimate, which requires that we enter a functional with respect to which the mesh will be improved. The functional can be any differentiable scalar output based upon the solution. The functional we will use is the integral, along the boundary, of the von Mises stress, the model variable `comp1.solid.mises`. An Integration component coupling named ` comp1.intop1()` is defined at the boundary defining the larger fillet, as shown in the screenshot below.

Adaptive mesh refinement settings to reduce the local error at one location in the model.

The Integration coupling operator is used to define the boundary where we will evaluate the stress.

When we look at the results of this approach, we should notice two features of the refined mesh. First, it has preferentially inserted smaller elements around the fillet boundary that we selected. This is as expected, since we are trying to get more accurate results in this region. However, we also observe that the mesh has been refined in other regions of the model, not just at the boundary of interest. The adaptive mesh refinement algorithm will globally adjust the mesh to better resolve the local stresses, and these stresses depend on the solution everywhere else in the model.

We can also see that using manual mesh refinement to predict the peak stress may be very difficult, because we usually cannot easily determine what other parts of the model may affect our solution.

The refined mesh, based upon a local functional error estimate.

We have seen that you can specify a local quantity over which to perform adaptive mesh refinement, and the software will refine the mesh to give better results locally, but also refine the mesh in other regions of the model that you may not immediately realize affect the local quantity you are interested in. The technique shown here is a powerful way to refine the mesh with confidence.

Editor’s note: This blog post was updated on 8/21/17.

#### Post Tags

Technical Content

The Linac-MR Project: Tumor Tracking and Treatment

#### Older Post

Learning to Solve Multiphysics Problems Effectively

1. Marvin Farrell August 25, 2014   6:29 am

Here I am wondering how to set the parameters to get the accurate results? Thanks

2. Walter Frei August 25, 2014   9:00 am

Thank you Marvin, When reading this article, keep it in the larger context of solving multiphysics problems:
http://www.comsol.com/blogs/learning-solve-multiphysics-problems-effectively/
In particular, meshing considerations are a topic we’ve addressed before:
http://www.comsol.com/blogs/how-to-implement-mesh-refinement-study/
http://www.comsol.com/blogs/meshing-considerations-linear-static-problems/

3. Roberto Gaddi December 21, 2015   10:50 am

I have a question about the functional: does it need to be a function that converges to zero as the mesh quality improves? Does the adaptive mesh algorithm try to minimize this quantity? Or is the error calculated as the delta of the functional in between steps, so the algorithm is looking for a stable value of the functional? In my case the functional is a quantity that would converge to a non-zero value. Is this going to work?

A second question is about the use of “Longest” vs. “Mesh Initialization” as refinement method: I cannot find an explanation on what the difference is an I cannot chose the best for my model.

Thanks,

Roberto

4. Walter Frei December 21, 2015   11:22 am

Hello Roberto,
The functional you choose does not need to converge to zero, no. In the case shown here, for example, it does not converge to zero. The algorithm is improving the accuracy of this functional by adjusting the mesh.
Regarding “Longest” vs. “Mesh Initialization”. The “longest” or “regular” methods will always work, but will only refine the mesh. The “mesh initialization” can both refine and coarsen the mesh but may, in rare circumstances, fail. There is no one method which will always be best for every case, you may want to try both.

5. Chinmoy Mallick March 1, 2016   2:02 am

Hi,
I’m doing simulations to find a contour or surface having 875 gauss field.I’ve two permanent ring magnets and i want to visualize the 2D field.while doing adaptive mesh confine following error coming during simulations……Pl can anyone tell me where is the error?..Thank you

“Failed to find a solution.
Attempt to evaluate negative power of zero.
Function: ^
Failed to evaluate temporary symbolic derivative variable.
Variable: comp1.mf.normBVDN\${realdot7}, Defined as: (((realdot(comp1.mf.Br,comp1.mf.Br)+realdot(comp1.mf.Bz,comp1.mf.Bz))^(-0.5))*0.5)
Failed to evaluate expression.
Expression: d((comp1.mf.normB-0.087499999999999994),{realdot7})
Returned solution is not converged.
– Feature: Stationary Solver 1 (sol3/s1)”

6. Bridget Cunningham March 1, 2016   8:33 am

Hello Chinmoy,

Online support center: https://www.comsol.com/support
Email: support@comsol.com

7. Soma Sai Sriram Kumar Bysani April 7, 2017   4:38 am

Hello,
My geometry is 3D I am designing a heat exchanger and similations are done in comsol 5.2a multiphysics. In my geometry one is heat domain and other one is fluid domain. The velocity profile in the fluid domain was not accurate, I want increase elements of fluid domain only can someone please help how to proceed it?
Now total elments in fluid domain are 280,000K
I need in that domain like 550,000K

8. Caty Fairclough May 3, 2017   8:39 am

Hi,

Online Support Center: https://www.comsol.com/support
Email: support@comsol.com

9. Joerg Ruediger August 3, 2017   7:15 am

Hi Walter,

I cannot find the Adaptive Mesh Refinement – node under stationary solver. How to enable it?

Joerg

10. Caty Fairclough August 4, 2017   2:59 pm

Hi Joerg,