Editor: Grid Editor ()
The Grid Editor allows you to analyze the quality of a Tetra Grid according to different quality measures and to semi-automatically improve the grid quality.To activate the Grid Editor, press the Grid Editor button of a selected tetrahedral grid. A user interface composed of different button controls (Figure 1) will appear in 's Properties Area. If you select some other Selector or Modifier, other ports might be shown. The editor works in conjunction with the Tetra Grid View module. If such a module is not already active, an instance of it will be automatically created when the editor is invoked.
Figure 1: Grid editor for improving the quality of tetrahedral grids. Tetrahedra can be distorted in different ways (see Figure 2):
- Slivers contain four nearly coplanar vertices forming a quadrangle.
- Caps consist of a triangle and a fourth vertex 'just above' it.
- Needles consist of a triangle and a fourth vertex 'far away'.
- Wedges are characterized by one sharp edge.
Figure 2: Four examples of distorted tetrahedra. Using the tools of the Select menu
At the menu of port Selector you can choose one of several selection criteria. At the next port you can enter an expression which will be evaluated for each tetrahedron or edge. When you press the Select button, the number of selected tetrahedra or edges is shown in the Console Window, and the selected tetrahedra are shown by the Tetra Grid View module.
- Index Selector: This tool selects tetrahedra according to their index (i). This is mainly for debugging purposes.
- Tetra Quality Selector: This tool selects tetrahedra according to different quality measures.
'd' is the determinant of the matrix composed of the vectors pointing from vertex 0 to the vertices 1, 2, and 3. The tetrahedron volume is 1/6 of the absolute value of d. d approaches zero if the four vertices are nearly coplanar. d < 0 detects tetrahedra with an inverted orientation, which should normally not occur.
'R' is the ratio of the radii of an inscribed and a circumscribed sphere. R reaches its optimal (maximal) value 1/3 for an equilateral tetrahedron. All types of distorted tetrahedra are detected by a small value of R. Therefore, R is taken as the quality measure for all modifiers of the Grid Editor (see below). R shouldn't be smaller than approximately 1/10 of the optimal value.
'r1' is the ratio of the smallest to the largest edge length. r1 reaches its optimal (maximal) value 1 for an equilateral tetrahedron. Needles and wedges are detected by a small value of r1.
'r2' is the tetrahedron volume divided by the third power of the largest edge length, normalized to an optimal (maximal) value 1 for an equilateral tetrahedron. All types of distorted tetrahedra are detected by a small value of r2.
- Dihed/Solid Angle Selector: This tool selects tetrahedra according to their minimal and maximal dihedral angles (d,D) or solid angles (s,S). For each edge of a tetrahedron the dihedral angle is defined as the angle between its adjacent faces. The solid angles are related to the tetrahedron vertices; they measure the part of the unit sphere which is occupied by the tetrahedron. The solid angle at a tetrahedron vertex can be maximally , or 360 deg. For an equilateral tetrahedron all dihedral angles are approx. 70 deg, all solid angles are approx. 30 deg.
You can combine different selections, e.g., the selection (d<10) && (D>140) detects slivers, and the selection S>180 detects caps.
- Edge Quality Selector: This tool primarily selects edges, and then shows all tetrahedra adjacent to that edges. Edges are selected according to their length (e) or to the 'edge quality' q, which is computed as follows: for each tetrahedron adjacent to the edge the length l of the opposite edge and the dihedral angle d at the opposite edge are determined. The contribution of the tetrahedron is . q is the sum of those contributions over all adjacent tetrahedra. qi refers to the inner edges, qb to the boundary edges of the tetrahedral grid.
For an 'ideal' grid, all qi and qb should be positive. Such a grid would be well suited for a numerical simulation, because the Finite Element stiffness matrix (probably for the Laplacian operator) is an M-matrix if q is positive for all edges.
Using the tools of the Modify menu
At the menu of port Modifier you can choose one of several modifiers. When you press the Modify button, the grid modification will start. Some information will be displayed in the Console Window.
There is a certain inconsistency between the tetra quality selector and the modifiers of the Grid Editor, because the tetrahedron quality criterion for all modifiers is the inverse of the radius ratio R as defined above. In applying the modifiers, keep in mind that the optimal (minimal) value of 1/R is 3 and distorted tetrahedra are detected by large values of 1/R.
The modifiers Laplace Smoothing, Optimization Smoothing and Flip Edges and Faces are mainly for debugging purposes, because the Combined Smoothing modifier is a combination of them which should give the best results in most cases. The modifiers Repair Bad Tetras and Bisect Inner Edges are still in an experimental state. We recommend to apply the Remove Inner Vertices and the Combined Smoothing modifiers.
- Laplace Smoothing: This tool improves mesh quality by moving inner vertices. For each inner vertex the center of mass of the adjacent vertices is calculated. The vertex is moved to that location if this improves the quality 1/R of the adjacent tetrahedra. Otherwise, the midpoint between the old location and the center of mass is examined. Parameter nLoops defines the number of smoothing loops (maximally 10). Laplace smoothing will in general improve the mesh quality 1/R, but in most cases an Optimization Smoothing will be superior.
- Optimization Smoothing: This tool improves mesh quality by moving inner vertices. For each inner vertex a new location is determined that optimizes the quality 1/R of the adjacent tetrahedra. Parameter nLoops defines the number of smoothing loops (maximally 10), parameter Threshold defines a threshold for tetrahedron quality which is applied starting with the second loop. If all adjacent tetrahedra have a quality better than threshold, the vertex position is not changed. The default value 12 (quadruple of the optimal value) leaves tetrahedra unchanged which should be acceptable in most cases. Selecting a smaller value will induce opimization of more vertex locations.
- Flip Edges and Faces: This tool improves mesh quality by flipping edges and faces. For each inner (triangular) face the adjacent tetrahedra are determined. It is examined whether the face is a boundary face and whether the adjacent tetrahedra form a convex polyhedron. Depending on this classification a suitable type of edge or face flipping is selected. The flip operation is only performed if it improves the quality 1/R of the tetrahedra involved. Parameter Threshold defines a threshold for tetrahedron quality. If all adjacent tetrahedra have a quality better than Threshold, a face is not examined for flipping. If parameter save boundary triangles is set to 1, the edges and faces of the exterior grid boundary and the interior boundaries between different materials will not be flipped.
- Repair Bad Tetras: This tool tries to repair slivers and caps. For a sliver, two opposite edges with obtuse dihedral angles are bisected. If the distance between the new vertices is small compared to the sliver's mean edge length, the edge connecting them is collapsed. For a cap, the triangle opposite to the vertex with largest solid angle is determined. If that triangle is part of the outer boundary, the tetrahedron is removed. Otherwise, it is examined if the cap can be removed by a face flip. Parameter Threshold defines a threshold for tetrahedron quality 1/R. Only tetrahedra with a quality worse than the given threshold will be examined for repair.
- Remove Inner Vertices: This tool improves mesh quality by removing inner vertices. In a tetrahedral grid, the mean number of tetrahedra incident on an inner vertex is 24. If a vertex is incident on less than 10 tetrahedra, it is very likely that the mesh quality can be improved by removing that vertex and reconnecting the hole.
All inner vertices incident on a number of tetrahedra less or equal the value of parameter max num neighbors are inspected for removal. They will be removed, if this improves tetrahedral quality 1/R. If a value > 0 is set for parameter max edge length, this defines an upper bound for the edge length. An inner vertex will not be removed, if this would imply creation of a longer edge.
- Bisect Edges: This tool improves mesh quality by bisection of inner edges. An inner edge is bisected if for its vertices different boundary conditions are defined. After bisection, apply Optimization smoothing to improve the position of the new vertices.
- Combined Smoothing: This tool combines edge and face flipping and optimization smoothing. Parameter nLoops defines the number of 'large loops' (maximally 10), the other parameters define thresholds for tetrahedron quality 1/R which are applied in the first loop and the other loops, respectively. Setting the first threshold to 3 means that all edges and faces will be inspected for flipping and all vertices for optimization in the first loop. If parameter save boundary triangles is set to 1, the edges and faces of the exterior grid boundary and the interior boundaries between different materials will not be flipped.
- Flip/Bisect Long Edges: This tool tries to remove inner edges depending on their length or edge quality q as defined above. Parameter max edge length defines the maximal allowed edge length and parameter min edge quality the minimal allowed edge quality, which must be less or equal to zero. Setting a minimal quality of zero means that edge quality is ignored in edge selection. Parameter Threshold sets an upper limit for tetrahedron quality 1/R. The selected edges are removed, preferably by an edge flip, or by an edge bisection, if all newly generated tetrahedra will have a quality below that threshold.
This tool should be applied repeatedly, until the number of flips as reported in the Console Window goes down to 0, and applying an Optimization smoothing in between may improve the results.
- Automatic: This tool tries to improve the quality of the whole grid automatically with no further user-interaction. If save connectivity is set to 1 (true) then it only applies optimization smoothing repeatedly. If it is set to 0, then several of the reconnection methods described above are used and the elements are flipped and smoothed until the algorithm converges.
These improvements can take a really long time to converge but you can feel free to interrupt anytime by pressing the stop-button: This tool uses a floating threshold which you can observe in the console-window. That means that the tetrahedrons with worst quality are considered first and the others later when the threshold decreases. When the process is stopped while using a threshold of e.g., 6.0 then all tetra- hedrons with quality worse than 6 have been improved.
If you still detect bad quality elements after the Automatic tool has finished then the source-grid didn't allow improvements there because of vertices fixed on boundarys.