# Automatic Meshing for Electromagnetic Simulations

December 9, 2014

Here’s a question for all you electromagnetics-focused simulation engineers out there: Have you ever looked in envy at your structural, fluid, and chemical counterparts as they mesh their models with the click of a button, while you struggle to mesh your infinite elements or perfectly matched layers? Well, now you too can enjoy automatic meshing with a click (or two). Let me show you how.

### Electromagnetic Simulations with Open Boundaries

Measuring the electromagnetic phenomena around an object is common practice that necessitates the creation of a boundary to enclose an air domain around your geometry. In theory, we should include large domains (technically infinite) in our model, but we do not, for obvious reasons.

In COMSOL Multiphysics, this problem is resolved by adding infinite element and perfectly matched layer (PML) domains, which take the place of these large open boundaries. Infinite element domains allow for the modeling of unbounded domains. Perfectly matched layers absorb all of the waves that enter the domain, preventing waves from reflecting off the boundaries.

For a more detailed description of these features, see page 300 of the COMSOL Reference Manual found in the documentation.

Meshing these virtual domains to provide correct results is a time-consuming process when done manually. However, with version 5.0, COMSOL Multiphysics will mesh the domains for you with a Physics-Controlled Mesh option.

Image and model created by my colleague Jiyoun Munn. With all the time he saved by auto meshing his PMLs, he created this awesome image.

### Automatically Mesh Infinite Elements

Meshing infinite element domains is now simply a two-click process. In fact, I can sum up the process of using this feature in one image:

Enable automatic meshing from the settings window of the physics interface node (e.g., Magnetic Fields, Electric Currents, etc.).

After enabling the Physics-Controlled Mesh feature and clicking the mesh button, COMSOL Multiphysics will mesh the infinite element domains with a Swept mesh (and the rest of the domains accordingly). That is all.

Of course, there are always those of you who like to have a hand in everything — you know who you are. As is the case with most all COMSOL Multiphysics features, you are still free to inspect the mesh sequence and make edits to your liking.

The video below shows the short process of implementing and using the Physics-Controlled Mesh for infinite elements, as well as how to inspect and edit it.

### Automatically Mesh Perfectly Matched Layers

If Electromagnetic Waves, Frequency Domain Simulations are more your speed, we’ve got you covered too. This process is ever so slightly more complicated. It involves a click of the check box and a specification of the maximum element size. When meshing Electromagnetic Waves, Frequency Domain, the maximum element size must be at most 20% of the wavelength. Dividing your wavelength parameter by 5 is a good practice. Alternatively, you can enter the numerical value instead.

Enable automatic meshing and specify the maximum element size (based on the wavelength) through dividing it by 5.

The rest of the process is the same as for infinite elements. Check out the video below to see the full process for the automatic meshing of perfectly matched layers and how to inspect and edit the mesh sequence.

### Next Step

For any COMSOL simulation software users who have models with infinite elements or perfectly matched layers, this simple feature will literally transform your modeling experience by eliminating the arduous task of manually meshing these domains.