Mesh refinement is especially important, being one of the major reasons for using an unstructured mesh. The mesh refinement method works especially well for right triangles.
The splitting operation is reversible and involves pairs of triangles. Pairs which are eligible for splitting must have their common side opposite their largest interior angles. This ensures, in the case of splitting, that the new triangles will not have excessively acute interior angles.
The mesh is refined by splitting pairs of triangles into four triangles. A new vertex is added at the midpoint of the common side. If the triangles are right triangles, only pairs with a common hypotenuse can be split. Isoceles right triangles will be divided into isoceles right triangles. They can be subdivided arbitrarily many times by this method. Non isoceles right triangles will generate geometrically similar descendants after two splittings, and can also be subdivided indefinitely. When a vertex is added, the variables are linearly interpolated onto the new vertex, consistent with the piecewise linear representation.
The mesh is unrefined by reversing the division process. Four triangles with a common vertex can be unsplit into two triangles by removing the vertex. A diagonal is drawn across the four remaining vertices.
We have an adaptive algorithm to refine the mesh as the computation proceeds. Because we want to resolve current sheets, we monitor the current. The vorticity is also large where current sheets form, so we monitor it too. If the product of triangle area times current density, and triangle area times vorticity, exceeds a threshold, we split the triangle in two. The local current density in a current sheet typically rises exponentially in time, so the refinement process has this same behavior. We have to stop the refinement at some preset triangle size and number of mesh points. Similarly, if the current and vorticity are too low, the triangles at that vertex are unrefined.