## 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

- Certified Consultants 29
- Chemical 44
- COMSOL Now 130
- Conference 98
- Core Functionality 56
- Electrical 113
- AC/DC 42
- MEMS 13
- Plasma 4
- RF 29
- Semiconductor 2
- Wave Optics 6

- Fluid 85
- CFD 39
- Microfluidics 8
- Mixer 2
- Molecular Flow 8
- Pipe Flow 5
- Subsurface Flow 10

- Interfacing 34
- Mechanical 138
- Multipurpose 14
- Tips & Tricks 32
- Trending Topics 32
- User Perspectives 79
- Video 62

## 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.