Enhanced algorithm of streamline color mapping based on double-layer grid control

. 2D Flow field streamline visualization, as a classic visualization method, expresses the structure and characteristics of the flow field with continuous streamlines. In this paper, a streamline color mapping enhancement algorithm based on double-layer grid control is proposed, which can better display the flow field and its field intensity distribution. The distance of the streamline is controlled by the double-layer grid, the seed point is scattered in the largest blank seeding area, and the visual streamline diagram of different effects can be obtained by setting the density control parameters, vector illustration with more even color distribution. The results show that the algorithm in this paper can obtain more continuous streamline distribution, and the streamline distribution obtained by regional equalization color mapping can reflect more field intensity distribution characteristics of the flow field.


Introduction
Flow field visualization is an important branch of scientific computing visualization, and has made certain contributions in aviation, geography, environment and many other aspects. streamline placement, as a classical visualization method, has been widely studied by many scholars because of its continuity of expression of the flow field. Jobard et al. [1] proposed a seed point strategy with uniform distribution of streamlines. This method tries to ensure local uniformity, but the details of the flow field are not obvious. Abdelkrim Mebraki et al. [2] proposed the farthest seed point placement algorithm, avoiding large blank areas. Xujia Qin [3] proposed to use the Sobel sequence to determine the position of the streamline seed point, but the streamline spacing still lacks uniformity. Color mapping is a common method to express vector information, but when the data distribution is not uniform, especially when the data aggregation is serious, there will be a large number of color aggregation phenomena. For this, Fangfang Zhan [4] proposed a nonlinear color Mapping, color uniformity is improved by using a non-linear function to calculate the data values. In this paper, a streamline color mapping enhancement algorithm based on double-layer grid control is proposed. The algorithm can obtain the visualization effect of uniform distribution or mostly long streamlines, and enhance the color mapping of streamlines, showing more detailed information of field intensity.
2 Enhanced algorithm of streamline color mapping based on double-layer grid control

Grid control
First, the flow field area is divided into grids, and uses the seeding grid and the tracking grid to control the distance of the streamlines. Streamline spacing is controlled by properly setting the control parameters max A seeding grid therefore contains multiple tracking grids with the following relationship: any tracking grid gets a corresponding seeding grid and vice versa; After a tracking grid is marked as visited, its associated seed grid must be marked as saturated, and seed grids marked as saturated cannot place seed points anymore; a seeded grid marked as saturated has at least one of its tracking grids marked as visited; There must not be a tracked grid marked as visited with respect to an unmarked seeding grid. Trace meshes that can only have seeded mesh boundaries are marked as forbidden. After a streamline is generated, mark the tracking grid that the streamline passes through as visited, and mark the corresponding seeding grid as saturated, and then mark the four-connected area of the streamline tracking grid as forbidden access, which stipulates that no streamline can be traced. For the tracking grid that has been marked, the selection of seed points and grid marking are performed after the marking is completed. When all the seeding grids are marked, stop placing streamlines. The purpose of marking the streamlines passing through the four-connected area of the tracking grid is to ensure that the minimum distance of the streamlines is min s d . Figure 1 shows the influence of different marking situations on the tracking of other streamlines. The large grid is the seeding grid, and the small grid is the tracking grid. To illustrate the control of the minimum distance, only markers for the tracking grid are shown here. After the right streamline marks the fourconnected area, the end points of the left streamlines are different. Because the marking of the four-connected region affects the tracking of the streamlines, thereby affecting the minimum distance between the streamlines. Therefore, the marking of the four-connected region effectively controls the minimum distance of the streamlines. Since it is forbidden to flow through the streamlines after the seeding grid is marked, the maximum distance of streamlines can be directly controlled by the seeding grid size, so the maximum distance between adjacent seeding grid streamlines is not more than

Streamline generation
In order to obtain longer streamlines as much as possible, the seed point should be selected as far as possible in the blank sowing area with the largest area to ensure more long streamlines in the flow field. Therefore, when calculating the seed point, first find the largest blank seeding area, and calculate the centroid of the area. If the centroid is inside the area, it will be used as a valid seed point; if the centroid is not inside the area, in order to ensure that the seed point is selected in the center of the largest blank sowing area, draw straight lines from the horizontal and vertical directions of the centroid, and calculate the length of the line segment intersecting with the largest blank area, and take the midpoint of the line segment with the longest intersecting length as the valid seed point. After the seed point is selected, the streamline tracking is carried out by numerical integration method, and the tracking of the streamline ends when it reaches the critical points, the field borders or the marked tracking grids. This paper adopts the fourth-order Runge-Kutta method with a fixed step size, starting from the seed point, and integrating forward and backward to generate streamlines.

Colormap enhancement
The rational layout of the streamlines can display the structural information of the flow field, but cannot display the field intensity distribution of the flow field, so color mapping is used here to reflect the field intensity distribution of the flow field. Creating a suitable color map plays an important role in the visualization of the mapping. The color map used in this paper is shown in figure 2, where blue represents the lowest value, dark red represents the  In this paper, a new mapping method, area equalization color mapping, is used to represent the same proportion of data with the same proportion of color, which can make full use of the color space and obtain a more uniform color distribution in the case of uneven data. First, reorder the original data set according to size and divide it into n intervals 0 1 1 { , ,... } n d d d − , let the amount of data be M , assuming / < 1 k M n k ≤ + , when / k M n = , the quantity obtained in each interval is k , otherwise, the method of taking k data amount for some intervals and 1 k + data amount for the rest interval is adopted to obtain the final relatively average data interval. Create a color map, the color range c c n − , then the color value corresponding to the data interval i d is [ ] c i .

Full algorithm
The algorithm flow proposed in this paper is shown in table 1:

Distribution mass of streamlines
The data in this paper is the data generation method mentioned in the reference [5], and the  increase at the same time, and the maximum distance between the streamlines increases, the uniformity between the streamlines decreases, but the length of the streamlines does not change. It can be concluded that the uniformity of the streamlines is mainly reflected in the parameter c . The increase of c will inevitably lead to a decrease in the uniformity of the streamline spacing, but the decrease in the uniformity will not necessarily lead to a decrease in the visualization effect, because the long streamlines Increase. It is discovered that when c is 4 or 5, a better balance can be achieved in terms of streamline length and uniformity. Table 1. Streamline color mapping enhancement algorithm based on double-layer grid control.

Input: Raw flow field data
Step 1: Initialize the tracking grid and seeding grid; Step 2: According to the seeding strategy, calculate the maximum blank seeding area and valid seed point i seed of the seeding grid, and the initial value is 1 i = ; Step 3: Streamlines are generated starting from Step 4: Correspondingly mark the tracking grid, seeding grid and four-connected area that the streamline i line passes through; Step5: If there is still a blank seeding area, i + + , and execute Step2; if all seeding grids are marked, stop generating streamlines; Step 6: Calculate the field strength information of the streamline set all line , and perform regional equalization color mapping for all streamlines; Step 7: Streamline generation and color mapping are complete, save the results. In order to compare the quality of the streamline distribution, the placement effect of the streamlines between the algorithm in this paper and the Jobard [2] algorithm is compared.

Colormap quality
The color distribution obtained by linear color mapping can only show good uniformity when the data distribution is uniform. The improvement of color mapping in this paper can use as many color spaces as possible for color mapping even when the data is unevenly distributed. Figure 6 (a) is the result obtained by the linear color mapping of the field strength. It can be seen that the data aggregation is serious, and the same color appears in a large area. Figure 6 (b) shows the color mapping enhancement effect in this paper. The color space is fully utilized. Compared with the linear color mapping results, the obtained color is more uniform, and the difference between the flow field intensity distributions The gap can be more reflected.

Conclusion
In this paper, a streamline color mapping enhancement algorithm based on double-layer grid control is proposed. By using regional equalization color mapping and setting reasonable grid parameters, a streamline diagram with uniform distribution or mostly long streamlines can be obtained, the distribution of streamline flow field information can be obtained more intuitively. At present, the algorithm in this paper is only applicable to twodimensional flow fields, and the parameters with the best visualization effect still need to be further explored. These shortcomings can be further developed as follow-up work.