# Adaptive refinement for 2D triangular meshes (Electrical Machine) Part 2

By

## Additional refinement rules

Marking the edges to be refined is performed in four steps to improve the quality of the generated mesh, even in regions where no elements have to be refined.

• To improve the initial average aspect ratio of the new elements, the edges of elements with an aspect ratioare marked in a special way (Fig. 5.62).

• All edges of an element to be refined are marked.

• All non-outline edges that touch two outlines are marked for refinement during the first adaptation step (Fig. 5.63).

• All edges that touch an outline edge to be refined are marked (Fig. 5.64).

Fig. 5.62. Refinement of elements with an aspect ratio

Fig. 5.63. Refinement of non-outline edges touching two outlines.

Fig. 5.64. Refinement of edges touching an outline edge i.

## A posteriori error estimation

An a posteriori error estimator evaluates the local errorper element, based on a previously computed solution. This error estimation can be performed in two different ways:

• model based and

• region, label based.

Fig. 5.64. Refinement of edges touching an outline edge i.

To obtain a local error betweenfor the model based strategy,it is normalised, i.e. divided by the maximum error over all elements in the model.

This type of estimation is called model error estimation. A maximum accepted local errorcan be specified and all elements with a larger error bound are considered for refinement.

The elements are arranged according to their local error and the elements with the highest error are refined first. The number of refined elements is determined by the maximum percentage of new elements p specified (e.g. 100 %). The maximum number of elementsmarked for refinement is given by:

withthe number of elements, c a constant depending on the refinement method. The constant c indicates the ratio of the number of refined elements to the number of new elements:for an edge-based refinement andfor an element-based refinement.

Fig. 5.65. Determining the elements to be refined.

A label-based error estimator calculates the local error within each region label separately and the error is normalised by division with the maximum error within the label. The maximum number of elementsto be refined is determined by the number of elementsinside the label.

Elements are refined all over the model, but also in regions (labels) where it is probably not necessary. This, if not desired explicitly, represents a disadvantage of a label-based refinement.

The local error can be evaluated in various ways. The error indicator has influence on the generated mesh and its proper choice is dependent on the problem definition as such, time-harmonic or static magnet field solution and on the strategy of refinement, minimum or quality meshing. Therefore, no indication regarding use of a particular estimator or estimation scheme will be given.

Energy in an element The energyin an element is an indication for the local error

Flux density at a node The magnetic flux densityat a nodeis the weighted average of the values of the magnetic flux density of the surrounding elements k belonging to the same label (Fig. 5.66). The weighting factor is the areaof the elements.

The local errorof an element is calculated as the difference between the magnetic flux density of the element and the average of the nodal values.

Fig. 5.66. Calculation of the magnetic flux density at a node.

Magnetic flux density in a node weighted with the energy The local errorbased on the magnetic flux density in a node is weighted with the energyin an element.

## Numerical implementation

Error estimation and mesh enhancements require computation time. Searching in very large data structures absorbs most of this time. To optimise such efforts with respect to the computational costs towards a better approximation of a field solution, ‘intelligent’ data structures are recommended to accelerate the search routines.

Starting from the element matrix ‘eletti’ indicating how the elements are built out of the nodes, the node-to-element matrix ‘nodeeleni is built in a straightforward way (Fig. 5.67). This matrix gives for each node the surrounding elements. The number of surrounding elements is stored in the vector ‘surrelem’. Fig. 5.68 gives the element matrix for the initial triangulation of Fig. 5.56 and Fig. 5.69 the node-to-element matrix and the number-of-surrounding-elements vector.

Fig. 5.67. Building the node-to-element matrix.

Fig. 5.68. Element matrix.

Fig. 5.69. Node-to-element matrix and number-of-surrounding-elements vector.

The neighbouring-element matrix is now built. For each edge of an element the neighbouring element is determined. The two rows of the node-to-element matrix are searched for the common element numbers. The element itself is found and if another element number is found, it is that of the neighbouring element. As shown in Fig. 5.69, the rows of the node-to-element matrix are sorted and the number of surrounding elements is almost a constant. This means that very effective and fast search algorithms can be used. Fig. 5.70 shows the neighbouring-element matrix for the initial triangulation. Binary constraints are dealt with during the building of the neighbouring-element matrix. Elements connected through binary constraints are neighbouring elements.

Fig. 5.70. Neighbouring-element matrix.

Edge-based refinement An edge-based refinement is implemented using a neighbouring-element matrix. The refinement of an element influences the neighbouring elements. An error estimator marks the elements to be refined. All the edges of the marked elements are marked for refinement. Putting the number of the new node according to the edge to be refined in the to-be-refined-edges matrix ‘re/edge" does this. At the same time, the appropriate edge of the neighbouring element is marked with the same node number. When two elements are connected through binary constraints, the next node number is used. Fig. 5.71 shows the to-be-reflned-edges matrix according to the refinement of Fig. 5.56. Again only element 6 is to be refined ("Red’ element). Elements 5, 7 and 9 are ‘Green I elements.

Fig. 5.71. To-be-refined-edges matrix.

Fig. 5.72. Edge-based refinement.

After all edges are marked for refinement, each element is refined according Fig. 5.72. Testing as to whether the intermediate triangulation is a Delaunay triangulation is not done. A Delaunay triangulation is unique and therefore it is sufficient to use a global Delaunay algorithm to obtain a Delaunay triangulation with the new nodes. A possible algorithm is a loop over all nodes and testing all pairs of two adjacent surrounding elements. The number of swapped diagonals is counted and the loop is repeated until there are no swaps performed. The resulting triangulation is a Delaunay triangulation (Fig. 5.72c). In practice, the loop is repeated until the number of swaps is less than 10 % of the number of swaps in the first loop. Because the number of swaps is rather low for an edge-based refinement, the quality of the generated mesh is high, but the mesh is strictly speaking not a Delaunay triangulation.