## Meshing your Geometry: When to Use the Various Element Types

##### Walter Frei | November 4, 2013

In a previous blog entry, we introduced meshing considerations for linear static problems. One of the key concepts there was the idea of *mesh convergence* — as you refine the mesh, the solution will become more accurate. In this post, we will delve deeper into how to choose an appropriate mesh to start your mesh convergence studies for linear static finite element problems.

### What Are the Different Element Types

As we saw earlier, there are four different 3D element types — tets, bricks, prisms, and pyramids:

These four elements can be used, in various combinations, to mesh any 3D model. (For 2D models, you have triangular and quadrilateral elements available. We won’t discuss 2D very much here, since it is a logical subset of 3D that doesn’t require much extra explanation.) What we haven’t spoken in-depth about yet is *why* you would want to use these various elements.

### Why and When to Use the Elements

Tetrahedral elements are the default element type for most physics within COMSOL. Tetrahedra are also known as a *simplex*, which simply means that *any* 3D volume, regardless of shape or topology, can be meshed with tets. They are also the only kind of elements that can be used with adaptive mesh refinement. For these reasons, tets can usually be your first choice.

The other three element types (bricks, prisms, and pyramids) should be used only when it is motivated to do so. It is first worth noting that these elements will not always be able to mesh a particular geometry. The meshing algorithm usually requires some more user input to create such a mesh, so before going through this effort, you need to ask yourself if it is motivated. Here we will talk about the motivations behind using brick and prism elements. The pyramids are only used when creating a transition in the mesh between bricks and tets.

*It is worth giving a bit of historical context. The mathematics behind the finite element method was developed well before the first electronic computers. The first computers to run finite element programs were full of vacuum tubes and hand-wired circuitry, and although the invention of transistors led to huge improvements, even the supercomputers from 25 years ago had about the same clock speed as today’s fashion accessories. Some of the first finite element problems solved were in the area of structural mechanics, and the early programs were written for computers with very little memory. Thus, first-order elements (often with special integration schemes) were used to save memory and clock cycles. However, first-order tetrahedral elements have significant issues for structural mechanics problems, whereas first-order bricks can give accurate results. As a legacy of these older codes, many structural engineers will still prefer bricks over tets. In fact, the second order tetrahedral element used for structural mechanics problems in COMSOL will give accurate results, albeit with different memory requirements and solution times from brick elements.*

The primary motivation in COMSOL for using brick and prism elements is that they can significantly reduce the number of elements in the mesh. These elements can have very high aspect ratios (the ratio of longest to shortest edge) whereas the algorithm used to create a tet mesh will try to keep the aspect ratio close to unity. It is reasonable to use high aspect ratio brick and prism elements when you know that the solution varies gradually in certain directions, or if you are not very interested in accurate results in those regions because you already know the interesting results are elsewhere in the model.

### Meshing Example 1: Wheel Rim

Consider the example of a wheel rim, shown below.

The mesh on the left is composed only of tets, while the mesh on the right has tets (green), bricks (blue), and prisms (pink) as well as pyramids to transition between these. The mixed mesh uses smaller tets around the holes and corners, where we expect higher stresses. Bricks and prisms are used in the spokes and around the rim. Neither the rim nor the spokes will carry peak stresses (at least under a static load) and we can safely assume a relatively slow variation of the stresses in these regions. The tet mesh has about 145,000 elements and around 730,000 degrees of freedom. The mixed mesh has close to 78,000 elements and roughly 414,000 degrees of freedom, and takes about half as much time and memory to solve. The mixed mesh does take significant user interaction to set up, while the tet mesh requires essentially no user effort.

*Note that there is not a direct relationship between degrees of freedom and memory used to solve the problem. This is because the different element types have different computational requirements. A second-order tet has 10 nodes per element, while a second-order brick has 27. This means that the individual element matrices are larger, and the corresponding system matrices will be denser, when using a brick mesh. The memory (and time) needed to compute a solution depends upon the number of degrees of freedom solved for, as well as the average connectivity of the nodes, and other factors.*

### Meshing Example 2: Loaded Spring

Another example is shown below, this time it’s a structural analysis of a loaded spring. Since the deformation is quite uniform along the length of the helix of the spring, it makes sense to have a mesh that describes the overall shape and cross section, but relatively stretched elements along the length of the wire. The prism mesh has 504 elements with 9,526 degrees of freedom, and the tet mesh has 3,652 elements with 23,434 degrees of freedom. So although the number of elements is quite different, the number of degrees of freedom is less so.

### Meshing Example 3: Material on a Wafer

The other significant motivation for using brick and prism elements is when the geometry contains very thin structures in one direction, such as an epitaxial layer of material on a wafer, a stamped sheet metal part, or a sandwiched composite.

For example, let’s look at the figure below, of a thin trace of material patterned onto a substrate. The tet mesh has very small elements in the trace, whereas the prism mesh is composed of thin elements in this region. Whenever your geometry has layers that are about 10^{-3} or so times thinner than the largest dimension of the part, the usage of bricks and prisms becomes very highly motivated.

### Additional Examples

It is also worth pointing out that COMSOL offers many boundary conditions that can be used in lieu of explicitly modeling thin layers of materials. For example, in electromagnetics, the following four examples consider thin layers of material with relatively high and low conductivity, and relatively high and low permeability:

- Electric Shielding Comparison
- Contact Impedance Comparison
- Dielectric Shielding Comparison
- Thin Low Permittivity Gap Comparison

Similar types of boundary conditions exist in most of the physics interfaces. Usage of these types of boundary conditions will avoid the need to mesh such thin layers entirely.

Lastly, the above comments apply only to linear static finite element problems. Different meshing techniques are needed for nonlinear static problems, or if we are modeling time-domain or frequency-domain phenomena.

### Concluding Thoughts

To summarize, here is what you should keep in mind when starting your meshing of linear static problems:

- Use tets if you can; they require the least user interaction and support adaptive mesh refinement
- If you know the solution varies slowly in one or more directions, use bricks or prisms with high aspect ratios in those regions
- If the geometry contains thin layers of material, use bricks or prisms or consider using a boundary condition instead
- Always perform a mesh refinement study and monitor the memory requirements and convergence of the solution as you refine the mesh

- Applications 13
- Certified Consultants 32
- Chemical 60
- COMSOL Now 148
- Conference 107
- Core Functionality 87
- Electrical 153
- AC/DC 47
- MEMS 20
- Plasma 7
- Ray Optics 7
- RF 40
- Semiconductor 5
- Wave Optics 8

- Fluid 100
- CFD 49
- Microfluidics 12
- Mixer 3
- Molecular Flow 9
- Pipe Flow 9
- Subsurface Flow 10

- Interfacing 41
- Mechanical 175
- Multipurpose 17
- Tips & Tricks 16
- Trending Topics 56
- User Perspectives 84
- Video 68

## Comments

Hi Walter

Thanks for nice clear examples

Thanks for the guidance. I wonder if you could expand your essay to comment on the utility, in various cases, of employing large numbers of small, but low-order elements vs. using small numbers of larger, but higher-order elements?

Dear Robert,

It depends very much on how you define utility. Second-order elements represent the best compromise between growth in memory requirements and accuracy, and are the default in most physics interfaces. The most common exceptions are problems involving chemical species transport and when solving for a fluid flow field, which use 1st order elements by default because of the convection-dominated nature of the problem.

Dear Walter,

Thanks for your interesting blog entrance, has been of a great help. Right now I’m struggling a lot with a simple stationary 3D electrostatics model that I have to run within an iterative loop commanded from Matlab. The problem that always kills my simulation after a few hours is the mesh creating point while the program has advancede a few steps.

After trying several different techniques, I came to realize that the detail I am using for certain edges is affecting drastically the way the free-tets are created next to this ‘detail’ edges or boundaries.

Could you tell us your experience while using free-tets meshing in combination with certain edge or free-triangular elements in a 3D meshing?

Dear Oscar,

You will find virtual operations helpful in such circumstances. Please see, for example, this model:

http://www.comsol.com/model/virtual-operation-on-a-wheel-rim-geometry-14317