Often, the most tedious step of finite element modeling is subdividing your CAD geometry into a finite element mesh. This step, usually just called meshing, can sometimes be fully automated. More often, however, the careful finite element analyst will want to semi-manually create their meshes. Although this does require more work, sometimes there are significant advantages in doing so. In this blog entry, we will look at one of the key manual meshing techniques: the concept of geometric partitioning.

### How Does the Meshing Algorithm Work?

Let’s start by giving a very conceptual introduction to how a 3D CAD geometry is meshed when you use the default mesh settings in COMSOL Multiphysics. The default mesh settings will always use a Free Tetrahedral mesh to discretize an arbitrary volume into smaller elements. Tetrahedral elements (tets) are the default element type because any geometry, no matter how topologically complex, can be subdivided and approximated as tets. Within this article, we will only discuss free tetrahedral meshing, although there are situations when other types of meshes can be more appropriate, as discussed here.

*A cylinder (left) is meshed with triangular elements (grey) on the surface and the tetrahedral meshing algorithm subdivides the volume with tets (cyan). The ends are omitted for clarity.*

At a conceptual level, the tetrahedral meshing algorithm begins by applying a triangular mesh to all of the faces of the volume that you want to mesh. The volume is then subdivided into tetrahedra, such that each triangle on the boundary is respected and the size and shape of the tetrahedra inside the volume meets the specified size and growth criteria. If you get the error message “Failed to respect boundary element edge on geometry face” or similar, it is because the shape of the tetrahedra became too distorted during this process.

Of course, the true algorithm can only be stated mathematically, not in words. There are, however, cases that can cause this algorithm some difficulties, and these cases can be understood without resorting to any equations. The free tetrahedral meshing algorithm can have difficulties if:

- The part is extremely complex with very detailed regions mixed with coarse mesh.
- The aspect ratios of the edges and boundaries defining the domain are very large.

Let’s take a look at some examples of each case and how partitioning can help us.

### Simplifying Complex Geometries

To get us started, let us consider a modestly complex geometry: the *Helix* geometry primitive. You can certainly think of more complex geometries than this, but we can illustrate many concepts starting with this case.

Go ahead and open a new COMSOL Model file and create a helix with ten turns, and then mesh it with the default settings, as shown below.

*A ten-turn helix primitive with the corresponding default tetrahedral mesh.*

When you were meshing this relatively simple part, you may have noticed that the meshing step took a relatively long time. So let’s look at how partitioning can simplify this geometry. Add a *Work plane* to your geometry sequence that bisects the length of the helix and then add a *Partition* feature, using the Work plane as the partitioning object.

*A Work plane is used to partition the helix.*

As you can see from the image above, the resultant ten-turn helix object is now composed of twenty different domains, each representing a half-turn of the helix. When you re-mesh this model, you will find that the meshing time is reduced, which is good. Each domain represents a much easier meshing problem than the original problem, and, furthermore, the domains can be meshed in parallel on a multi-core computer.

However, you’re probably also thinking to yourself that we now have twenty different domains, and that we’ve subdivided the six surfaces of this helix into one hundred two surfaces, including the internal boundaries, which are dividing up the domain. Although this geometry now meshes a lot faster, we have added many more domains and boundaries that can be a distraction as we apply material properties and boundary conditions. What we actually want is to use the partitioned geometry for the mesh, but ignore the partitioning during the set-up of the physics.

What you’ll want to do next is to add a *Virtual Operation, the Mesh Control Domains* operation. This feature will take, as input, all twenty domains defining the helix. The output will appear to be our original helix, and when we apply material properties and physics settings, there will be only one domain and six boundaries.

*The Mesh Control Domains will specify that these are different domains only for the purposes of meshing.*

When you now mesh this geometry, you’ll observe that you have the best of both. The meshing takes relatively little time, and the physics settings will be easy to apply. If you haven’t already, try this out on your own!

We have only looked at one example geometry here, but there are many other cases where you’ll want to use this type of partitioning. Domains that look like combs or serpentines or objects that have many holes, cutouts, or domains embedded within them all present situations in which you should consider partitioning. Also, keep in mind that you don’t need to partition with planes; you can create and use other objects for partitioning. We’ll take a look at such an example next.

### Geometries with High Aspect Ratios

The CAD geometries you are working with can often contain some edges or surfaces that have vastly different sizes relative to the other edges and surfaces defining a domain. We often want to avoid such situations, since small features on a large domain may not be that important for our analysis objectives.

We’ve already looked at how we can ignore these small features using Virtual Operations to Simplify the Geometry, but what if these small features are important? Let’s examine how partitioning can help us in terms of the example geometry shown below.

*A flow domain to be meshed. Three small inlets, with even smaller fillets, protrude from the main pipe.*

The geometry that you see above has a large pipe with three smaller pipes protruding from it. The small fillets that round the transition between the two have dimensions that are over one hundred times smaller than the pipe volume. If we mesh this domain with the default mesh settings, the same settings will be used throughout. However, we will almost certainly want to have smaller mesh sizes around the inlets.

The default mesh will use one setting for all elements within the model. That will not be very useful here. We could just add additional *Size* features to the mesh, and apply these features to all of the faces around the small pipes to adjust the element sizes at these boundaries, but this is not quite optimal. It’s a lot of work and might not give us exactly what we want.

We can also use partitioning to define a small volume within which we will want to have different mesh settings. In the figure below, additional cylinders have been included that surround each of the smaller pipes and extend some distance into the pipe.

*Additional domains (wireframe) which will be used for partitioning of the blue domain.*

*Results of the partitioning operation.*

These additional cylinder objects can be used to partition the original modeling domain, as shown above. Using the Mesh Control Domains, it will again be possible to simplify this geometry down to a single domain for the purposes of physics and materials settings. Once you get to the meshing step, however, it is possible to add a Size feature to the Mesh sequence that will set the element size settings of these newly partitioned domains. This gives us control over the element sizes in these domains and makes things a little bit easier for the mesher.

*Different size features can be applied to each partitioned geometry.*

### What About When Automatic Meshing Fails?

The geometries that we have looked at here can be meshed with minimal effort or modification to the default meshing settings, but this is not always the case. It is relatively easy to come up with a geometry that no meshing algorithm will ever be able to mesh in a reasonable amount of time. What can we do in that situation?

The answer (as I’m sure you’ve already guessed) is partitioning along with one other concept: divide and conquer. When confronted with a domain that does not mesh, use partitioning to divide it into two domains. Try to individually mesh each one. If one of the domains does not mesh, keep partitioning each half. Using this approach, you’ll very quickly zoom in on the problematic region of the original domain. You can then decide if you want to simplify the problematic parts of the geometry via the usage of Virtual Operations, or you can use the techniques we’ve outlined here and mesh sub-domain by sub-domain, or you can even use some combination of the two.

Another technique that you can use is to apply a Free Triangular mesh on all of the boundaries of the imported geometry. Surface meshing is much faster than volume meshing and will almost always succeed. Visually inspect the resultant surface mesh. It will then often be immediately apparent where in the model the small features and problematic areas are. Once you know where the issues are, delete the Free Triangular mesh, since the free tetrahedral meshing algorithm will typically want to adjust the mesh on the boundaries, but will not do so if there is already a surface mesh defined.

Along with the Virtual Operations which we have already mentioned for simplifying the geometry for meshing, you can also use the Repair and Defeaturing functionality to clean up CAD data originating from another source. The Virtual Operations will simply create an abstraction of the CAD geometry which can only be used inside of the COMSOL software, as compared to the Repair and Defeaturing operations which will modify the CAD directly, and will create a modified CAD representation that can be written out from COMSOL Multiphysics to other software packages.

### Summary of Meshing with Partitioning

We have now looked at two different representative cases where the default mesh settings are not optimal — a domain that is very complex as well as a domain with extreme aspect ratios. In both cases, we can use partitioning along with the Mesh Control Domains Virtual Operations feature to simplify the meshing operations.

We have also presented some strategies for handling cases in which your geometry will not mesh with the default settings. It is also worth saying that such situations arise most often when working with imported CAD geometry that was meant for manufacturing, rather than analysis purposes. If you are given a CAD file with many features that are cosmetic rather than functional or that you are reasonably certain will not affect the physics of the problem, consider removing these features in the originating CAD package, before they even get to COMSOL Multiphysics.

In future blog posts, we will also look at combining partitioning with swept meshing, which is another powerful technique in your toolkit as you use COMSOL Multiphysics. Stay tuned!

## Comments (8)

## Saleha Quadssia

May 5, 2015Hei,

Its a great post and I have been trying to implement the partitioning using work-plane in my 3D imported geometry but I just end up with a line in the geometry but it still is not divided. So I decided to try the simple helix model you proposed here and its the same issue. I end up with the geometry with one line at the place of work plane but no separate domains. I think there is something very basic I am missing. Can you please help?

Thanks

Regards,

Saleha

## Walter Frei

May 5, 2015Hello Saleha,

Such questions would be more appropriate to pose to your COMSOL Support Team: http://www.comsol.com/support/

## Aditya Date

July 16, 2015Waka Waka

## Mohammad Almajhadi

October 5, 2015Saleha,

Once you create the partition, change the “PARTITION WITH” option into Workplan, and press “Build All” icon.

malmajhadi

## Nicola Young

February 17, 2016Hello,

This meshing technique looks very useful. I am trying to implement the latter part where you partition the mesh around the inlets.

It is not quite clear how you do this. I have revolved a cylindrical work plane, partitioned it and set it as a mesh control domain. However any objects within this disappear at the last build stage in geometry.

Could you please explain how you implement the mesh partitioning while keeping domains that already exist (in your case, the inlet), from disappearing?

Many thanks,

Nicky

## Ravinder Banyal

March 30, 2016Hi

I have a 3D geometry with two objects. Two objects are in tangential contact. One object is a cylinder which is supported by another object having V-shape. In 2D (x-y) plane you can think of it as letter ‘o’ dropped inside the two inclined lines of letter ‘V’. Letter ‘o’ makes point contact with each inclined lines of letter ‘V’. I get my 3D geometry (cylinder+V-block) by extruding the 2D geometry along z-direction. Now the point contacts in 2D become line contact in 3D. When I do the meshing, I get the error at the error message: “Failed to generate mesh for domain. Failed to respect boundary element edge on geometry face.” The mesh size along the contact lines between cylinder and V-block becomes diminishingly small. I do not really need small mesh along the contact lines. How can I overcome such mesh related issues where two objects/domains are in only in tangential contact?

## Bridget Cunningham

April 1, 2016Hello Ravinder,

Thank you for your comment.

For questions specific to your modeling work, please contact our support team.

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

Email: support@comsol.com

## Mahendar Kumbham

March 9, 2017Very useful post. Thank you so much for your time.