Efficient Visualization Method and Implementation of Reservoir Model Based on WPF

In view of the slow speed and poor effect of real-time rendering of large-scale reservoir geological grid model, a new grid model hidden algorithm is proposed by analyzing the Eclipse reservoir grid model storage format, grid model representation, and cell sorting rule, which optimizes the original grid data and improves the rendering speed of reservoir grid model. /e algorithm in this paper eliminates hidden points and faces according to the topological relationship of the grid, and finally, only the visible point and face data are extracted as the final visual input data. /rough the realization of 3D visualization software of reservoir geological model and well trajectory, the correctness and efficiency of the hidden algorithm are verified. In the software, firstly, the number of display grids is effectively reduced by preprocessing, and the 3D graphics technology of WPF and helix is adopted to realize the high-efficiency display of reservoir grids./e comparison test of different scale reservoir models shows that the method can reduce the point and surface data by more than 85% and shows that the speed optimization effect is significant./e 3D display function realizes the interactive functions such as roaming, zooming, and viewpoint switching of the reservoir model, truly reveals again the geological environment and borehole information of underground drilling, which is helpful for drilling interpretation and decision-making, provides a reasonable drilling tracking geological target drilling scheme for the drilling process, and realizes the seamless connection of geological engineering integration.


Introduction
Geological engineering integration, as an effective workflow for exploration and development of unconventional oil and gas reservoirs, has become a broad consensus in the industry [1][2][3][4][5][6] which covers professional fields such as geology, reservoir, geophysical exploration, drilling, mud logging, well testing, production testing, oil and gas production, and downhole operation. e "geology" here does not specifically refer to the geological discipline in the sense of discipline but generally refers to the multidisciplinary comprehensive research work centered on reservoir, including reservoir characterization, geological modeling, and so on [7][8][9][10][11][12]. "Engineering" refers to a series of engineering technology application and solution optimization from drilling to production in the process of exploration and development. During the drilling process, threedimensional engineering geological data are loaded into a unified three-dimensional model, and the three-dimensional scene of the underground space is vividly displayed through software display, which can establish a good communication channel for engineering and geological experts and better realize multidiscipline cooperation.
is is one of the important manifestation forms of geological engineering integration. At present, the theoretical research and technical methods of 3D reservoir visualization in China are still in the exploratory stage.
Reservoir geological model is the foundation and core of geological engineering integration of oil and gas exploration and development. Its visualization technology based on 3D geological model of reservoir makes use of the characteristics of virtual reality to truly reproduce the distribution law of reservoir in underground space, and developers can intuitively study complex geological structure and analyze exploration results. Mature large-scale commercial application software mostly contains 3D visualization modeling module.
In order to study and utilize geological research results in mainstream commercial software, it is necessary to analyze grid description methods of different software and write corresponding processing programs to realize efficient visualization of 3D geological model. e organization, loading, and visualization of large-scale reservoir model data require high storage capacity, processing speed, and drawing speed of computer. When rotating and scaling interactive operations are carried out, the amount of calculation data is huge, and the display speed is slow and discontinuous [13][14][15][16].
In this paper, the reservoir model is optimized according to the needs of geological engineering integration. By analyzing the commonly used file format of reservoir model data in Eclipse, extracting the required data, and blanking the reservoir grid, the amount of file data is greatly reduced. At the same time, combined with the latest 3D graphical interface, the efficiency of transmission and display of reservoir model is comprehensively improved, which meets the needs of model drawing and visualization platform construction under large-scale reservoir geological data.
To realize the modular development of grid blanking, first read the file, and then extract the read file data. After the data is extracted, it is processed to judge whether the face is completely repeated by judging the coordinate values of 12 points. If the 12 values are exactly the same, the face is repeated; otherwise, it is not repeated. After all the faces of the mesh are judged, the display and hide relations of all the faces are obtained. At this time, as long as the points on the display surface are all the points that need to be displayed, after all the points on the display surface are displayed, all the points that need to be displayed will be displayed, and the relationship between the display and hiding of the points will be clear. At this time, the displayed points will be repeated, because one point may be used by multiple displayed faces. ese points that need to be used repeatedly do not need to be displayed repeatedly; they only need to be displayed once. erefore, it is necessary to arrange the displayed points in the order of natural numbers, and all the displayed points are only arranged once. After sorting, the point set is obtained. At the beginning, the coordinates of points are stored in double type, and the displayed surface is composed of 4 points with 3 values for each point, that is, 12 double type storage values. After the surface set is represented by the point set, a point is composed of four integers, that is, four int type values. It is self-evident that this processing improves the computational efficiency by 5 times and greatly improves the display effect.

Reservoir Model Data Format
Eclipse is the most commonly used reservoir numerical simulation software, so reservoir departments can generally provide reservoir model data files in Eclipse format. Firstly, this paper interprets the file format of Eclipse model and extracts data content and grid data by keywords according to the attributes to be displayed in visualization, which provides input data for the next step of blanking optimization.
Eclipse reservoir model adopts hexahedron grid, and its basic unit is convex hexahedron. e model file contains multiple data files to describe different contents. e data file types are shown in Table 1.
Model data is stored in sections according to keywords. When the software loads data, it can determine the content of subsequent data according to keywords when corresponding keywords are encountered. Common keywords of Eclipse are shown in Table 2.
e data files are stored in text format and binary format, among which the data files in text format can be viewed directly by text editor, which is easy to read, but it is not conducive to computer processing, with large amount of data and low processing efficiency. Binary files cannot be viewed directly by text, but they can be loaded into computers quickly, with small amount of data and high processing efficiency. e following are introduced separately.

Text Formatting.
Take the FGRID grid file in Eclipse as an example, as shown in Figure 1.
Its basic format is segmented according to keywords; for example, dimensions keyword is used to describe dimensions, COORDS keyword is used to describe coordinates of cells, and CORNERS keyword is used to describe coordinates of corners. Because the text format can be read directly, it can be read programmatically according to the meaning of keywords.

Binary Format.
ere are five data types in Eclipse binary files, as shown in Table 3.
e main point is that the binary type byte coding order of Eclipse file is Big Endian, which is different from the commonly used x86 CPU byte coding order Little Endian. If x86 CPU is adopted, the byte order needs to be reversed when loading data. A perfect computer program can determine the coding order of CPU by dynamically judging byte order at runtime, so as to dynamically determine whether the coding order needs to be processed, which is particularly important for cross-platform development.

Reservoir Model Pretreatment
e grid data of reservoir model is very huge. In the visualization process, if all grids are displayed directly, it will bring great pressure to the display card, and the general display card can hardly meet the display requirements. On the basis of analyzing the rules of reservoir geological grid data, this paper puts forward a new grid blanking algorithm, optimizes the original grid data, compiles three-dimensional visualization software, and realizes interactive functions such as roaming, zooming, and viewpoint switching of reservoir model in three-dimensional environment. After analysis, there are a large number of occlusion relations among the cells of the grid. On the premise of not affecting the display effect of the reservoir model, the repeated vertices and faces in a large number of 3D cells are hidden and simplified, and finally only the points and faces on the surface can be displayed to achieve the same visualization purpose, and at the same time, the data needed for display can be greatly reduced, the display efficiency can be improved, and the demand for hardware can be reduced.
At the same time, most of the numerical simulation parameters in the model file need not be used in the visualization process, and it is also invalid to transmit this part of data in the network. By preprocessing with software, extracting the data needed for visualization, and storing and transmitting it in an efficient way, the amount of data stored and transmitted can be effectively reduced and the efficiency can be improved.
e pretreatment of reservoir model mainly includes two aspects, one is the blanking calculation of grid model [17], and the other is the efficient storage of blanking results.
According to the characteristics of reservoir geological model grid, this paper puts forward a hidden algorithm based on topological relation of cells, which realizes fast hidden calculation through a set of predefined data of point and plane association relations.
is method is fast and stable and has achieved satisfactory results in practical application. e following is the main implementation process of the algorithm.

Cell Hexahedron Definition.
e reservoir model is described by hexahedron corner grid. A reservoir grid is composed of NX × NY × NZ hexahedron (cells). ese cells are not disordered but arranged in an orderly manner along the X, Y, and Z directions. erefore, knowing the number of a cell can determine the position of the cell in the whole grid and its adjacent cells.
First, define a cell, as shown in Figure 2. As shown in the figure, the numbers of the six faces of each cell are 0, front; 1, back; 2, left; 3, right; 4, up; and 5-down, with eight vertices: the upper four vertices are numbered from 0 to 3 in counterclockwise order, and the lower four vertices are numbered from 4 to 7.

Hidden Data of Reservoir Grid.
In this paper, the hidden algorithm eliminates hidden points and faces according to the topological relations of meshes, in which hidden faces refer to faces where four vertices of two hexahedrons coincide completely. e strategy of the algorithm is to solve the visible point set and face set of the effective grid. Firstly, the algorithm judges the validity of the grid, scans and calculates according to the X, Y, and Z directions of the cells, judges the coincidence of six faces and adjacent faces of the effective grid, and eliminates the overlapping faces and vertices according to the visibility of the faces. Finally, only the visible point and face data are extracted as the input data of the final visualization, in which the point set also considers the processing problem of coincidence points, thus obtaining an efficient and concise blanking method.
As shown in Figure 3, observing the grid, if the coordinates of four vertices of adjacent faces of adjacent grids coincide completely, then these two faces can be hidden, and if all three faces adjacent to each vertex are hidden faces, the points are changed to hidden points, so the coordinate values of this point do not need to be used when displaying the grid, and only one coincident visible point needs to be kept.

Hidden Data of Reservoir Grid.
e basic steps of grid model blanking algorithm are shown in Figure 4.
Determine whether the current cell is valid. If it is valid, continue the blanking calculation; otherwise, go to step (2). (iv) Find adjacent right, back, and lower cells, respectively, that is, and Cell(i, j, k + 1), to determine the visibility of faces 3, 1, and 5. If the adjacent cells are invalid, the faces are visible. Otherwise, if the adjacent faces, i.e., 2, 0, and 4, do not coincide with this face, then both faces are visible; otherwise, they are invisible. Note that, in this step, the visibility of 2, 0, and 4 sides of adjacent cells has been confirmed, so the current cell only needs to judge the visibility of 3, 1, and 5 sides. (v) According to the visibility of six faces of the current cell, determine the visibility of eight vertices, that is, if all three faces adjacent to each vertex are invisible, the point is hidden; otherwise, the point is visible. (vi) According to the visibility of vertices, determine which vertices need to be output to the final point

Efficient Blanking Calculation.
In order to make the program more concise and efficient, the software designed a set of calculation tables according to the topological relations of cells for fast calculation. e data in Table 4 is used for face blanking, from which it can be seen that only a three-step cycle is needed, and the adjacent cells in the corresponding direction can be found according to the increment of data i, j, k J, and K in each row. According to the blanking face index and the adjacent face index, the faces to be compared can be determined, and the visibility can be determined only by comparing the vertices in the blanking face vertex index and the adjacent face vertex index.
Whether any vertex in a cell is visible or not can be judged by the visibility of the face where the point is located. It can be seen from the graph observation that each vertex is on three faces, and if any face is visible, the point is visible. e data in Table 5 is used for vertex blanking calculation. For any p point in the cell, 0 ≤ p ≤ 7, and its visibility can be determined only by looking at the visibility of three adjacent faces in the corresponding row in the table.

Optimization of Blanking
Results. Based on the above calculation, the visible and visible points of each cell can be obtained, but the vertices of these faces may overlap. In the process of visualization, the data of coincidence points will occupy a large amount of memory of the graphics card, so it is necessary to further optimize it. e optimization goal is to get a point set and a face set, in which there are no coincident points in the point set, and all visible faces can be represented by these points.
First, process the cells one by one. When the visible points are found, check whether there are overlapping points on the adjacent upper, front, and left sides according to the data shown in Table 6. If there are no overlapping points, output the point to the point set, and record the index value of the point in point set, that is, the order attribute of the cell; otherwise, use the index value of the previously appearing points.   After the above processing, the optimized point set data with eliminated coincidence points can be obtained, and only the indexes of the four vertex coordinates in the point set need to be given when the visible faces are expressed.

Storage of Blanking
Results. Saving the result of blanking calculation as a data file is beneficial to reduce the amount of data transmitted by the network, is easy to encode and parse, and has good self-description and scalability.
By investigating various text and binary data formats, such as XML, JSON, BSON, MsgPack, etc., the MsgPack format is determined as the basic format, which is a binary format similar to JSON format and has good self-description and extensibility. Generally, the data amount is 1/20 of XML and 1/10 of JSON. Almost all systems and development languages provide support for MsgPack format.

Visual Mapping of Reservoir Data.
Obtaining a grid data set in a unified format for visualization is the data preprocessing in the prestage of scientific computing visualization process, which is called data manipulation. e next step is to display the data grid, including visual mapping and drawing. Study and analyze the visual mapping scheme, and find the appropriate image display effect and man-machine interaction mode.

Visual Rendering of Reservoir Data.
e drawing process of reservoir grid includes ① drawing geometric shape based on data, including grid and well trajectory, ② determining the relationship between cell parameters and colors, that is, cell coloring, and ③ control of 3D objects, such as rotation, translation, and scaling [18].

Grid Drawing.
e key to the display of reservoir model is the grid processing and display [19][20][21][22][23]. ere is a huge amount of data in reservoir model, which must be preprocessed before displaying. e grid is composed of a series of hexahedrons, in which a large number of cells are continuous and have a mutual shielding relationship; that is, the surfaces of many cells are invisible because of overlapping. In the process of visualization, it is meaningless to display these overlapping surfaces, which will only increase the display burden and affect the performance. In the preprocessing process, all hidden points and faces need to be eliminated according to the topological relations of cells, so as to reduce the amount of displayed data.
Taking a medium-sized model as an example, the size of the model is 132 × 92 × 45 � 564,300 cells, including 182,104    Table 7. e reservoir model inherits the MeshGeome-tryModel3D, allowing developers to specify location, common, and texture coordinate information. e key point is to construct the Geometry object through the MeshBuilder class, in which the key attributes are vertex Positions, Tri-angleIndices, triangle Normals, and TextureCoordinates. e reservoir grid is composed of a series of quadrangles, as shown in Figure 5 for a single quadrangle. e basic element of 3D graphics is triangle, so a quadrilateral is divided into two triangles (p 0 , p 1 , p 2 ) and (p 2 , p 3 , p 0 ). e normal vector n is e material is Color Stripe Material, and the material coordinate (u, v) is where V is cell attribute value, V min is minimum attribute value, and V max is maximum value of attribute value.

Grid Coloring.
Color code module is the foundation of the whole 3D visualization module, and the design of color code module directly determines the visualization effect. In the process of visualization, the corresponding attributes of reservoir model can be expressed in different colors, because using colors can better show the trend of the whole formation and the distribution of attributes, and it is easier to judge the current state of the region, so it is very important to design a good color coding system. In this paper, the grid is colored by color code. By choosing different color codes, the grid can be colored with different effects. e basic concept of color code is to use a set of color values to represent numerical values, such as the commonly used rainbow color code. At the same time, this paper also establishes other color codes to meet different needs. e effects are shown in Table 8.

Well Trajectory Drawing.
ree-dimensional display of well trajectory model plays an important part in the reservoir three-dimensional model [24]. It reflects well trajectory model through three-dimensional visualization technology and combines with reservoir grid model, which not only facilitates reservoir and geological personnel to observe and analyze the well location and well trajectory direction of exploited wells more intuitively, but also understands the drilling depth and the stratum situation of trajectory crossing and also brings convenience for subsequent well trajectory design and control, development scheme formulation, and oilfield development management and decision-making. Trajectory data mainly include measured depth (MD), angle of inclination (Dev), and Azimuth (Azi). As shown in Table 9, the spatial coordinates of the trajectory need to be obtained through calculation: north coordinate x, east coordinate y, and vertical depth z, which, respectively, represent the displacement of a certain point on the trajectory in the north-south direction, east-west direction, and vertical direction relative to the wellhead.
Taking the wellhead as the origin of coordinates, two adjacent measuring points are recursively calculated from the wellhead in turn. By assuming the three-dimensional curve shape of the well section between the two measuring points, the vertical increment ΔZ, the north-south increment ΔX, and the east-west increment ΔY of the measuring well section are calculated, and then they are accumulated to obtain x, y, and z, and the well trajectory is formed by connecting these data. In some cases, if the well trajectory data is sparse, there will be broken lines in the direct connection line, so the smooth well trajectory can be obtained by spatial arc interpolation or cubic spline interpolation [25]. For a single well, its X, Y, and Z are relative to its wellhead coordinates. For different wells, the wellhead's north coordinates and east coordinates and wellhead altitude on the map are different. If the multiwell data are placed in the same coordinate system, all well data must be corrected to a unified coordinate system.(X u , Y u , Z u ): where W b is bushing elevation, W X is north coordinate of wellhead map, and W Y is east coordinates of wellhead map. In order to reduce the calculation in actual development, relative coordinates can be used to move the well trajectory to the wellhead position through translation transformation, so that GPU calculation can be fully utilized.

4.2.4.
ree-Dimensional Transformation. Translation, rotation, and scaling are basic three-dimensional transformations, and formulas can be used to represent each transformation. However, when representing a variety of continuous transformations, the formulas will become very complicated, and it is more convenient to realize various basic transformations and combined transformations by using coordinate transformation matrix.
Perspective transformation is similar to photographic imaging principle, which is to project the three-dimensional geometry of space to the two-dimensional plane, and the perspective view is very close to human vision. e visualization of reservoir model often uses perspective transformation, which can get more realistic display effect.
By setting the parameters of "camera," including position, upward direction, orientation, viewing angle, near plane, and far plane, the user can view the 3D scene from different angles and distances and realize the rotation, scaling, and translation of the whole scene, as shown in Figure 6.

Efficient Visualization Method and Implementation of the Reservoir Model Based on WPF
In the study of geological engineering integration, engineering and geological data are combined and three-dimensional scenes of underground oil reservoirs are vividly displayed through the visualization technology, which can effectively strengthen multidisciplinary communication, improve the efficiency of technical decision-making, and provide an intuitive technical means for drilling process. In order to realize the visualization of geological reservoir data, the first step is to load the model file, which mainly includes grid and attribute data. e 3D visualization software is developed to display a large amount of data with high performance, which requires the use of efficient graphic interface and organization data. e developed software loads the grid produced by the previous hidden algorithm. Reading Egrid file is a cycle process. A data segment according to the keywords of the data segment is read each time, and the content of the data segment records s determined and carried out by different processing until all data segments are read.
Most of the previous researches on reservoir data visualization are based on C++ language and OpenGL graphics technology. Commercial software is based on Open Inventor, an advanced commercial software package of OpenGL, and some of them are developed with OSG or OpenGL directly. Windows, as the current mainstream desktop platform, can provide very powerful graphics functions and provides a powerful direct 3D graphics interface and a powerful direct 3D graphics interface for WPF development, which is in the leading position in the field of game development. However, due to historical reasons, there are few researches on reservoir data visualization based on direct 3D, which has not been reported.  Mathematical Problems in Engineering is paper presents a high-performance 3D visualization solution based on Windows Presentation Foundation (WPF) technology and ModelView-ViewModel (MVVM) design mode and using helix, DirectX graphic interface using C# language. It can not only meet the requirements in display efficiency and effect but also greatly improve the usability of 3D control by applying MVVM mode, which can be easily embedded in WPF applications. is model is of great significance for the realization of software with higher quality and easier maintenance and migration.
is paper adopts the interface design engine WPF under. Net framework which inherits the framework element of WPF in the derived class to realize the specific drawing operation and makes a reasonable design. Helix toolkit is an advanced 3D development technology in .Net. It has a good balance between graphics performance and development efficiency and can meet the needs of most applications. Helix toolkit has two versions of WPF and sharpdx, both of which can perfectly integrate with WPF.
e WPF architecture is shown in Figure 7. MVVM mode divides the user interface into three parts: model, view, and view model according to different responsibilities, which makes the code hierarchical and easy to maintain and transplant. e main function of view layer is to display data, which is designed by XAML. e model layer is mainly used to process data and business logic. View model can process data in model and business logic in view at the same time. e workflow of MVVM logical structure is as follows: user operates view interface; view receives user's operation instructions; the operation instruction is sent to the view model at the same time, as shown in Figure 8. e view model updates the data of the model according to the operation instruction. After the model is updated, the notification is sent to the view model. e view model sends the interface update instruction to the view, and the view adjusts the view interface. MVVM logic structure has the characteristics of low coupling, reusability, and testability.
is software develops in strict accordance with MVVM mode so that the visualization function is completely decoupled from user interface and data model, and the ease of use and maintainability reach a new height.
Based on WPF technology and MVVM design pattern, the visualization function of hidden grid is realized by using the high-performance 3D visualization solution of Helix and DirectX graphical interface, which can not only meet the requirements in display efficiency and effect, but also greatly improve the usability of 3D controls.

Application of Reservoir Model in Geological
Engineering Integration e software interface is shown in Figure 9, (a) is model parameter selection interface, (b) is importing file interface, and (c) is color bar selection interface. e software can display more than 20 attributes of reservoir model, such as tops, depth, porosity, permeability, and net to gross ratio. 3D display of well trajectory and reservoir of model 2 in Table 7 is shown in Figure 10. Figure 10 shows the visual effect comparison between the developed software and commercial software CMG. It can be seen that the software developed in this paper is accurate and efficient in showing reservoir model. In order to reduce the number of invalid grids and accelerate the display speed, the hidden algorithm proposed in the previous paper is used to display the reservoir model. e three-dimensional graphics displayed by the two software pieces are basically the same, but the time of data import and drawing is far different. When the data is not processed, it takes a long time to import the data and draw the graph. According to the example, it takes about half a minute to import the data into the computer and get the image as shown in Figure 10; however, after data simplification, the amount of imported data is greatly reduced, and the import time is also greatly reduced. It takes about 10 seconds to import the same model into the same computer, and the image shown in Figure 10 is obtained. As can be seen from Figure 10(d), due to the great reduction of data to be processed in drawing, the drawing time of the whole process is greatly reduced, almost the data can be quickly imported, and the graphics can be calculated immediately, which greatly facilitates the graphic display, improves the display time, and improves the display efficiency.
It should also be mentioned here that the above calculation is the amount of data to be processed. In fact, there are many calculations inside these data when the actual comparison calculation is made, so the amount of data required for the calculation is much higher than the data obtained above. After processing and simplification, each data is not repeated, only once, so there is no need for internal calculation between data, so the actual amount of calculation and simplification effect will be better. In addition, as the number of grids increases, for example, next time, it will be 100 × 100 × 100 mesh, the number of simplification will be larger, and the effect of improvement will be more obvious. Figure 11 shows the 3D reservoir attributes of model 1 and model 3 with different grid color and background color including static-gross ratio (NTG), porosity (PORO), vertical enlargement plus grid display, and grid rotation enlargement display.

Conclusions
(1) Aiming at the defects of efficient visualization of reservoir models at present, based on the analysis of data format and sorting rules of reservoir geological model grids, this paper puts forward blanking algorithms for reservoir geological model grids. ese blanking algorithms based on topological relations greatly reduce the number of cells involved in the final calculation and improve the blanking efficiency. e sorting of unit face numbers directly eliminates the completely invisible grid inside, avoiding a large number of line and face search calculations. By sorting the depth of the cell plane, a large number of intersection and comparison calculations in the blanking algorithm are avoided, and the calculation amount is greatly reduced, thus achieving the goal of fast blanking. Reduce the demand of computer hardware for 3D visualization and improve the display efficiency.
(2) On the basis of reservoir model, a 3D visualization software of reservoir based on WPF is developed, which realizes interactive operations such as roaming, zooming, moving, and viewpoint switching of reservoir model, and achieves good results. Practical application proves that the algorithm is simple, fast, and stable, and it is a more practical algorithm for hiding geological data grid, which lays a solid foundation for in-depth research and application of geological engineering integration technology. (3) Sharpdx and MVVM mode are used to develop 3D components; WPF encapsulates 3D development related technologies, which makes the development of the system more convenient and can effectively shorten the development cycle. Compared with the traditional development methods, the performance, function, ease of use, and maintainability are greatly improved. e application shows that the system can accurately and in real time visualize the reservoir model data and well trajectory and runs smoothly, with high practical value. At the same time, all the technologies used are open-source technology, without any additional cost, which provides a new economic and efficient solution for the application of data visualization in petroleum industry.

Data Availability
e data used to support the findings of the study is available from the first author upon request.