Skip to main content

Meshes in Treble SDK

When a dg or hybrid simulation is added to a project, a tetrahedral mesh is automatically calculated.

A tetrahedral mesh is a collection of connected non-uniform triangular pyramid elements, also known as tetrahedrons. The Treble engine makes use of higher-order Discontinuous Galerkin (DG) method, for which the tetrahedral elements need to be resolved with more than 4 nodes. For the 4th order used in Treble there are 35 nodes per tetrahedron element, which are automatically created on and inside each element to allow for the higher order calculation.

The automatic generation of a tetrahedral mesh is based on the highest selected frequency for dg, or the crossover frequency for the hybrid method. Simulations that are ga only do not need the calculation of this mesh. This tetrahedral mesh is characterised by a series of boundary surface meshes corresponding to the material assignment and a volumetric mesh in the remaining internal space.

Example of the triangulation for the boundary meshes of a volumetric mesh

The triangular boundary surfaces meshes share vertices with the tetrahedrons of the volumetric mesh. For simplicity, we will call here "mesh" both the volumetric mesh and the boundary surface meshes.

Example of the 3D elements

The mesh used in Treble for finite elements calculation (DG) adopts a definition of quality based on the following conditions:

  • elements are as close as possible to regular tetrahedrons;
  • elements are as homogeneous as possible in size and volume;
  • elements do not have edges smaller than a certain length.

Creating a mesh

The creation of a mesh for user defined geometry is typically triggered by the command project.add_simulation(simulation_definition). Likewise this will happen when adding a simulation definition in the device import simulation workflow.

Plotting mesh info

After the DG mesh has been created, it is possible to plot a summary of its quality, based on the criteria previously addressed. Use the following command to plot in a table the general information about the mesh.

from treble_tsdk import display_data as dd

dd.display(simulation.get_mesh_info())

or

simulation.get_mesh_info().as_table()
Example of mesh info for a device mesh

The following command will plot the boundary surfaces of the volumetric mesh, to help inspecting potential problems.

simulation.get_mesh_info().plot()

The example below shows the surface meshing for a device with a 1m box size. The loss of mesh efficiency highlighted in the table above is due to the small elements that host the microphone placements.

Small elements in device import meshing

The plotting function can be used to evaluate how the input geometry is resolved in a boundary surface mesh. This is especially important when working with curved surfaces that are of high importance to the analysis, where it can happen that the meshing algorithm applies too broad a simplification to the curved geometry (especially when a low transition frequency has been chosen).

Mesh quality examples

The parameter defined in Treble as mesh quality, or more exactly mesh efficiency, is measured as a 2-digit percentage of how the minimum characteristic length differs from the optimal characteristic length for a given mesh size (controlled by the transition frequency).

Here the optimal mesh size depends on the crossover frequency and the optimal number of elements per wavelenght.

The characteristic length is the tetrahedron volume divided by its maximum area.

The optimal characteristic length is the mesh size as above divided by 3.76, corresponding to the characteristic length for an equilateral tetra with a side of mesh size.

Let us consider the following examples. We have an empty box of size 1 x 1 x 2 m. We create a mesh with a 360 Hz crossover frequency.

The mesh efficiency or quality for the room as per above will be 100% at 360 Hz and the number of elements will be 86. If we now increase the crossover frequency to 720 Hz, the mesh efficiency will still be 100%, but the number of elements will be much higher, growing with a factor of 8 (232^{3}).

Picture of a box 1x1x2m

If we add a box of 25 cm inside our model and set a simulation with the same crossover frequency, the resulting mesh quality will still be 100, but the number of elements will be higher.

Picture of a box 1x1x2m with a box inside
n1x1x2mBox edgeCrossover FrequencyElement CountElement min heightMesh efficiency percentage
1empty/360860.261983100
1empty/7206470.152038100
2w/ box25 cm7206240.145386100
3w/ box13 cm7207960.08769373.14
4w/ box15 cm7207650.10471187.33
5w/ box15 cm89111820.09474397.79
6w/ box15 cm89211430.098464100

The parameter element min height represents the minimum tetrahedron height that the mesh should have for a given crossover frequency. In example 4, the internal box has a side edge of 0.15m0.15 m. For a crossover frequency of 720 Hz, the element min height will be hmin=0.104711mh_{min} = 0.104711 m. We can reconstruct the min tetrahedron side length lminl_{min} with the following formula.

lmin=hmin36l_{min} = {h_{min} * 3\over \sqrt{6}}

The result will be lmin=0.1282ml_{min} = 0.1282 m.

We can then find the maximum wavelength λ\lambda that we can simulate for tetrehedra of this size by multiplying a factor of 3.

λmax=lmin3=0.3847m\lambda_{max} = l_{min} * 3 = 0.3847 m

In order to find the maximum crossover frequency we divide the speed of sound by the wavelength.

343m/s0.3847m=891.53Hz{343 m/s \over 0.3847 m } = 891.53 Hz

In example 5 we use 891Hz891 Hz as a crossover frequency for the element min height previously calculated. We obtain a mesh quality of 97.79%.

In Example 6 we use 892Hz892 Hz, and the mesh quality becomes 100 %.

This example demonstrates that in order to improve the mesh quality / efficiency percentage, we should try to create geometries with less details.

Increasing the transition frequency as a solution should not be done unless needed for valid sampling reasons, since it will automatically cause the creation of a larger number of smaller elements, therefore increasing the computing time.