A dynamic simulation method of flood inundation in digital twins of small and medium-sized watersheds based on UE5
By developing plug-ins in UE5, efficient drawing and rendering of flood models is achieved, combined with vertex shading materials and fluidized materials, the problem of difficult to realize dynamic simulation of digital twin flooding in small and medium-sized watersheds in the existing technology is solved, improving the authenticity and accuracy of the simulation, and supporting complex flood flow simulation.
Patent Information
- Application Number
- CN202411707323.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-11-27
AI Technical Summary
The existing technology is difficult to realize dynamic rendering of the ultra-large data flood model in three-dimensional scenarios in small and medium-sized watershed digital twins, and it is impossible to accurately simulate flood diffusion, local water level changes and complex flow states.
By developing plug-ins in UE5, using the C++ programming language and UE5's blueprint functions, a flood character class is built to realize efficient drawing and rendering of the triangle grid element of the flood model, combining vertex shading materials and flow materials, it displays the numerical simulation results of multi-dimensional flood submersion such as water level, water depth, flow velocity, flow direction, and complex flood flow states.
It has achieved the realization and accuracy of dynamic simulation of digital twin flooding in small and medium-sized river basins, supports millions of vertices and triangle grids, tens of millions of pixels, 1 billions of arithmetic logic units and texture operations, and enhanced the support capabilities for flood risk assessment and flood control plan decision-making.
Smart Images

Figure CN119203856B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital twins for small and medium-sized watersheds, and in particular to a method for dynamic simulation of flood inundation of digital twins for small and medium-sized watersheds based on UE5. Background Art
[0002] Small and medium-sized river basins usually refer to river basins with a catchment area of less than 3,000 square kilometers, which have the characteristics of fast convergence speed and complex flood characteristics. Digital twin technology for small and medium-sized river basins refers to the digital mapping of all elements and processes of small and medium-sized river basins, realizing dynamic, real-time information interaction and deep integration between physical river basins and digital river basins, and then realizing thorough perception, digital simulation and intelligent decision-making of river basins. Flood inundation simulation in digital twin three-dimensional scenes can improve the understanding and response capabilities of flood risks, enhance the predictability of flood prevention and disaster reduction, thereby protecting life and property and reducing economic losses;
[0003] At present, the three-dimensional flood inundation simulation based on WebGL graphics rendering engine technology such as CesiumJS is limited by browser performance and only supports the drawing and rendering of grids of 100,000 data levels at most. This requires that the hydrodynamic model cannot divide a particularly fine grid within the range of basin flood simulation, which limits the calculation accuracy of hydraulic elements and makes it difficult to further improve the accuracy of flood simulation. The real flood inundation is affected by the undulating terrain and the changes in the properties of the underlying surface such as houses, roads, and farmland. The water level change process will show regional localized characteristics. For example, the river channel often rises faster than the road on both sides, and the upstream water level is often higher than the downstream water level. However, the current Cesium-based Flood inundation simulations implemented by WebGL technologies such as JS usually use the flood model grid surface to fit the terrain and oblique photography model to display flood distribution, or use the maximum water level value of the flood model grid as the flood surface elevation for overall translation to express water level changes. Both cannot accurately simulate real processes such as flood diffusion and local water level changes. Furthermore, in existing three-dimensional flood inundation simulation methods, the visualization method of grid color changes can only express the numerical simulation results of flood inundation in two dimensions: water level and water depth. It cannot display information such as flow velocity and flow direction, nor can it simulate the complex flow patterns during flood inundation, such as backflow, converging flow, bifurcated flow, floodplain flow, turbulence, etc. These deficiencies will lead to the inability to achieve dynamic simulation of flood inundation, greatly reduce the authenticity and accuracy of flood inundation simulation, reduce the predictability of flood control and disaster reduction, and make it difficult to further improve the support capacity for flood control decisions, and fail to protect life and property safety and reduce economic losses to the greatest extent.
[0004] An existing Chinese patent (publication number: CN117237567A) discloses a digital twin flood flow field visualization rendering method, which includes the following steps: (1) obtaining a flood grid model and lightweight distributing the data in the flood grid model; (2) visually rendering a multi-mode flood flow field based on the data in the lightweight flood grid model; (3) designing an interactive method for the visually rendered multi-mode flood flow field. However, the above scheme requires lightweight processing of flood grid model data, resulting in the inability of some numerical model calculation results to participate in the simulation, reducing the accuracy of flood simulation; in addition, this invention displays data such as water depth, water flow velocity, and water flow direction on the surface of the two-dimensional flood grid model through color mapping, but not all data will be displayed at the same time. There is priority control in its display, resulting in the simulation process can only reflect the flood hydrological characteristics of one dimension, and it is impossible to achieve the simultaneous expression of multi-dimensional flood hydrological characteristics; in addition, in order to solve the problem of screen pixel flickering caused by the competition for screen pixels in the rendering of particle dynamic trajectories, the above invention removes particles that are too small, which will lead to the loss of detailed information of flood flow field characteristics, reduce the accuracy of flood flow field expression, and cannot accurately express the complex flow state of floods; finally, the above invention lacks simulation of optical characteristics such as reflection and refraction of flood water surface, lacks simulation of underwater visual effects, and insufficient expression of simulated visual characteristics of floods, making it difficult to achieve high-fidelity visualization of floods, reducing the authenticity of dynamic simulation of flood inundation;
[0005] Therefore, it is necessary to develop a method that can realize dynamic rendering of extremely large data volumes of flood models and high-fidelity visualization of flood hydrological characteristics in digital twin three-dimensional scenes, and can simultaneously express multi-dimensional flood inundation numerical simulation results such as water level, water depth, flow velocity, flow direction, as well as complex flood flow states such as backflow, converging flow, bifurcated flow, overbank flow, and turbulence, to improve the authenticity and accuracy of flood inundation simulation. Summary of the invention
[0006] The purpose of the present invention is to provide a dynamic simulation method of digital twin flood inundation in small and medium-sized watersheds based on UE5, and to carry out secondary development through UE5 plug-ins to realize dynamic rendering of extremely large-scale flood models (millions of grids) and high-fidelity visualization of flood hydrological characteristics, and to fully and completely express the multi-dimensional flood inundation numerical simulation results such as water level, water depth, flow velocity, flow direction, as well as complex flow states of floods such as backflow, converging flow, bifurcated flow, floodplain flow, and turbulence, so as to improve the authenticity and accuracy of flood inundation simulation, enhance the support capacity for flood risk assessment and flood control plan decision-making in small and medium-sized watersheds, improve the predictability of flood control and disaster reduction, and protect life and property safety and reduce economic losses to the greatest extent.
[0007] In order to achieve the above purpose, the technical solution of the present invention is: a dynamic simulation method of digital twin flood inundation in small and medium-sized watersheds based on UE5, characterized in that it includes the following steps:
[0008] Step 1: Collect and organize structured input data sets, build a two-dimensional hydrodynamic numerical model, and calculate the output grid node and triangle unit GeoJSON data;
[0009] Step 2: Create a flood inundation simulation UE5 plug-in project for parsing and visualizing the calculation results of the two-dimensional hydrodynamic numerical model, and configure the plug-in dependent modules;
[0010] Step 3: Create a flood character class in the flood simulation UE5 plug-in project;
[0011] Step 4: Construct a method for drawing flood model triangle mesh primitives in the flood role class;
[0012] Step 5: Construct the method of rendering flood hydrological characteristics and flood flow patterns in the flood role class;
[0013] Step 6: Parse the mesh node and triangular unit GeoJSON data, and pass the parsing results as parameters to the flood role class instantiation object's method of drawing the flood model triangular mesh primitives and rendering the flood hydrological characteristics and flood flow state, so as to realize the preloading and pre-rendering of the flood model, and realize the dynamic simulation of the digital twin flood inundation process in a frame-by-frame animation manner.
[0014] In the above technical solution, step one specifically includes the following steps:
[0015] Step 1.1: Determine the modeling scope of the two-dimensional hydrodynamic numerical model according to the small and medium-sized river basin flood research area, collect DEM (Digital Elevation Model) data and historical hydrological monitoring data of hydrological water level stations within the scope, and organize them into a structured input data set after data cleaning and formatting;
[0016] Step 1.2, based on the finite element mesh of the unstructured triangular element topology data, combined with the hydrodynamic control equations, calculate the river flood inundation changes under a given flood process scenario and construct a two-dimensional hydrodynamic numerical model;
[0017] Step 1.3: Using the structured data set compiled in step 1.1 as input, call the two-dimensional hydrodynamic numerical model for simulation calculations, and output the grid node and triangular unit data in GeoJSON format. The output data includes the simulation results of water level, water depth, flow velocity, flow direction, etc.
[0018] In the above technical solution, step 2 specifically includes the following steps:
[0019] Step 2.1. Create a flood simulation UE5 plug-in project of code plug-in type in the UE5 editor. The editor automatically creates the files and directory structure required for the plug-in project. The UE5 plug-in project is a flexible and powerful modular function expansion tool, which allows developers to expand the functions of UE5 by creating and configuring plug-ins to meet various complex development needs.
[0020] Step 2.2, according to the flood inundation simulation UE5 plug-in project created in step 2.1, configure the default startup module and public dependency module in the project configuration file; the default startup module includes JSON parsing and geographic coordinate conversion modules; the public dependency modules include procedural mesh components, instantiated static mesh components, and dynamic material instance modules;
[0021] The flood inundation simulation UE5 plug-in project created in steps 2.3 and 2.1 is mainly developed based on the C++ programming language, and combined with the UE5 blueprint function to realize the creation and editing of dynamic special effects water materials; therefore, the present invention uses VisualStudio2022 as a development tool, wherein the blueprint is a visual programming tool for UE5, which is used to create operating logic and functions without directly writing code.
[0022] In the above technical solution, the flood role class is based on the object-oriented design concept, and the flood system is designed as a class, which contains flood-related properties and behaviors. The object-oriented design concept emphasizes encapsulation, inheritance and polymorphism. The flood role class is a flood system with a well-designed structure implemented by using these principles. The drawing and rendering of flood models at different times can be realized through the instantiation of the flood role class;
[0023] In step three, the method of creating a flood character class in the flood inundation simulation UE5 plug-in project includes:
[0024] Step 3.1, create a new flood role class;
[0025] Create a new C++ class in the flood simulation UE5 plug-in project and set its parent class to the character class. This C++ class is the flood character class.
[0026] Step 3.2, set the flood attribute data structure in the flood role class;
[0027] The flood attribute data structure set includes an index identifier of a string type, an explicit and invisible identifier of a string type, a mesh node attribute array, a triangle unit attribute array, a triangle unit UV array, a water depth layer color array, a triangle mesh primitive material reference of a string type, and a three-dimensional arrow model material reference of a string type;
[0028] Step 3.3, set the component structure of the flood role class;
[0029] Create a procedural mesh component and an instanced static mesh component under the scene component of the flood character class, so that the flood character class can call the functional methods of the procedural mesh component and the instanced static mesh component;
[0030] Step 3.4, set the method of flood role class;
[0031] The methods of the flood character class refer to functions defined inside the flood character class, which are used to describe the behavior of the class or the state of the operation object. The methods of the class are called through the instance objects of the class, and can access the properties and other methods of the class; the methods of the flood character class specifically include methods for drawing flood model triangle mesh primitives, rendering flood hydrological features and flood flow patterns.
[0032] In the above technical solution, in step 4, a method for drawing flood model triangular mesh primitives is constructed in the flood role class, including:
[0033] Step 4.1, create a new method function for drawing flood model triangle mesh primitives in the flood role class;
[0034] Step 4.2, establish mesh vertices;
[0035] In the method function of drawing the flood model triangular mesh primitive, the spatial coordinate vectors of the three vertices of the triangular unit are stored in the mesh vertex array in sequence;
[0036] Step 4.3, create vertex index;
[0037] In the method function of drawing the flood model triangle mesh primitive, a clockwise vertex index order is used to write 3i, 3i+2, and 3i+1 into the vertex index array as vertex index numbers, where i is the loop counter of the triangle unit attribute array loop body, which is used to indicate the number of executions of the loop;
[0038] Step 4.4, establish vertex normals;
[0039] In the method function for drawing the flood model triangle mesh primitive, the positive direction of the Z axis is used as the normal direction of each vertex. In the loop body of the triangle unit attribute array, three unit vectors along the positive direction of the Z axis are sequentially written into the vertex normal array outside the loop body as the vertex normal.
[0040] Step 4.5, establish vertex texture coordinates;
[0041] In the method function of drawing the flood model triangular mesh primitive, the UV coordinate system of the triangular unit is mapped to the XY plane of the XYZ coordinate system, and then the flow direction of the flood texture on the surface of each triangular mesh primitive is controlled by the mapped UV vector;
[0042] Step 4.6, create vertex color;
[0043] In the method function for drawing the flood model triangle mesh primitive, the color of each vertex of the mesh is defined by setting the vertex color array;
[0044] Step 4.7, draw the triangular mesh primitives;
[0045] In the method function for drawing the triangular mesh primitives of the flood model, the mesh vertex array, vertex index array, vertex normal array, vertex texture coordinate array, and vertex color array are passed as parameters to the create mesh component method of the procedural mesh component of the flood character class, thereby realizing the drawing of massive triangular mesh primitives.
[0046] In the above technical solution, in step 4.5, the method for establishing vertex texture coordinates includes:
[0047] (1) Determine the mapping relationship; map the UV of the triangular unit to the XY plane;
[0048] (2) Normalize UV coordinates: Normalize the UV coordinate system of the triangle unit to the range of 0 to 1;
[0049] (3) Correct the direction of the UV vector; first, calculate the rotation angle of the UV vector on the XY plane, and then rotate the UV vector on the XY plane based on the origin of the XYZ coordinate system;
[0050] (4) Calculate vertex texture coordinates.
[0051] In the above technical solution, in step 5, a method for rendering flood hydrological characteristics and flood flow patterns is constructed in the flood character class, including:
[0052] Step 5.1, create a new method function for rendering flood hydrological characteristics and flood flow patterns in the flood role class;
[0053] Step 5.2. Create a vertex shading material using the UE5 editor; use the mesh vertex color information to affect the rendering effect;
[0054] Step 5.3, use the UE5 editor to create a flood flow material; use the UE5 flow map to simulate the effect of flood flow, and use the vertex texture coordinates to control the direction of flow, so that different triangular mesh units have their own flow states, and continuous adjacent triangular mesh units will present flow effects such as backflow, converging flow, bifurcated flow, floodplain flow, turbulence, etc. as a whole;
[0055] Step 5.4, apply the flood surface special effects material. In the method function of rendering flood hydrological characteristics and flood flow patterns, call the setting material function of the flood role class procedural mesh component to implement the application of the flood surface special effects material;
[0056] Step 5.5, create a three-dimensional arrow of flow velocity and direction;
[0057] In the flood hydrological characteristics and flood flow method functions, call the add instance method of the flood role class to instantiate the static mesh component, pass the three-dimensional space transformation matrix after setting the position, scale, and rotation status as a parameter to the method, and create three-dimensional arrows of flow velocity and direction on all mesh nodes;
[0058] Step 5.6: Create underwater visual effects;
[0059] Use the UE5 editor to create a post-processing volume between the flood surface and the underwater terrain, modify the post-processing volume's parameters such as bloom, depth of field, hue, and fluctuation to simulate underwater visual effects, thereby enhancing the realistic feeling of water depth.
[0060] In the above technical solution, in step 5.2, the specific method of creating a vertex shading material includes:
[0061] (1) Create a vertex shader material;
[0062] (2) Create vertex shading effects;
[0063] (3) Create water surface color, transparency, fluctuation, reflection, refraction and other effects;
[0064] (4) Create a material instance;
[0065] In step 5.3, the specific method of creating a flood flow material includes:
[0066] (1) Create a flood flow master material;
[0067] (2) Creating flood surface texture flow effects, including adding flow map textures, extracting flow direction, using vertex texture coordinates, setting flow direction, and applying flow effects;
[0068] (3) Create water surface color, transparency, fluctuation, reflection, refraction and other effects;
[0069] (4) Create a material instance;
[0070] In step 5.5, the specific method of creating a three-dimensional arrow of flow velocity and direction includes:
[0071] (1) Get the arrow model; use the 3D arrow model asset built into UE5;
[0072] (2) Instantiate the static mesh component to set the arrow model;
[0073] (3) Set the arrow model material;
[0074] (4) Set the arrow spatial position;
[0075] (5) Set the arrow scaling ratio;
[0076] (6) Set the arrow rotation angle;
[0077] (7) Add the arrow instance to the instanced Static Mesh component.
[0078] In the above technical solution, in step 6, a method for displaying a dynamic simulation process of digital twin flood inundation includes:
[0079] Step 6.1, analyzing the calculation results of the two-dimensional hydrodynamic numerical model;
[0080] Step 6.2, preloading and pre-rendering of sequence frame flood model;
[0081] Preload each frame of the flood inundation model into the digital twin scene, and draw triangular mesh primitives and render materials in advance;
[0082] In step 6.2, the sequence frame flood model preloading and pre-rendering method is adopted to preload each frame of the flood inundation model into the digital twin scene, and the triangular mesh primitive drawing and material rendering are performed in advance, that is, multiple flood instance objects are dynamically created according to the sequence frame order of the flood inundation animation, and each flood instance object draws and renders the flood inundation model at different times, and has the hydrological characteristics and flood flow state of the flood at different times; among them, there are two optional material rendering methods, one is the vertex shading rendering method, and the other is the flood flow state rendering method, and the two methods can be switched freely;
[0083] Step 6.3, play the sequence frame flooding simulation animation;
[0084] Create a timer to display the flood instance object at the current moment frame by frame, and hide the flood instance object of the previous frame to form a frame-by-frame animation.
[0085] The present invention has the following beneficial effects:
[0086] (1) The present invention realizes the dynamic rendering of extremely large-scale flood models and high-fidelity visualization of flood hydrological characteristics in the three-dimensional digital twin scenes of small and medium-sized watersheds, and fully and completely expresses the multi-dimensional flood inundation numerical simulation results such as water level, water depth, flow velocity, flow direction, as well as complex flood flow patterns such as backflow, converging flow, bifurcated flow, floodplain flow, and turbulent flow, thus improving the authenticity and accuracy of flood inundation simulation, which is conducive to enhancing the support capabilities for flood risk assessment and flood control plan decision-making in small and medium-sized watersheds;
[0087] (2) The present invention uses C++ as the programming language and calls the programmatic mesh component for secondary development by building a UE5 plug-in, thereby realizing efficient drawing and rendering of massive grids of flood models. It can support millions of vertices and triangular grids, tens of millions of pixels, and billions of arithmetic logic units and texture operations, providing an extremely high upper limit for improving the calculation accuracy of hydraulic elements and the accuracy of flood simulation. The present invention does not require lightweight processing of flood grid model data, and realizes a positive correlation between the higher the calculation accuracy of the numerical model and the higher the accuracy of the flood simulation, which is conducive to improving the predictability of flood prevention and disaster reduction and the accuracy of decision-making;
[0088] (3) The flood simulation results calculated by the two-dimensional hydrodynamic numerical model of the present invention include two parts: grid nodes and triangular units. The grid nodes record the longitude, latitude, water level elevation, water depth, U (average vertical velocity in the X direction), V (average vertical velocity in the Y direction) and other attribute information of each vertex of the triangular grid primitive, and the triangular unit records the topological relationship between the grid nodes. The grid nodes are unique and will not overlap in spatial position. The flood model triangular grid primitive is constructed by connecting related grid nodes according to the triangular unit topological relationship, which can achieve the continuity and smoothness of the connection between adjacent primitives and the spatial correspondence between the virtual flood surface and the real physical world. At the same time, when playing the flood inundation animation at a certain moment, the elevation value of each grid node is raised or lowered according to the calculation results of the numerical model, which can realize the dynamic display of the regional water level change of the flood.
[0089] (4) The present invention adds a three-dimensional arrow model at each grid node position, and the three-dimensional arrow corresponds to the grid node one by one. The three-dimensional arrow indicates the direction to express the local flood flow direction, and the size of the three-dimensional arrow model expresses the local flood flow rate; the triangular grid primitives of the flood model are given dynamic special effects water materials, the depth of the grid color is used to express the height of the flood depth, and the flow texture is used to express complex flood flow states such as backflow, converging flow, bifurcated flow, floodplain flow, turbulence, etc. At the same time, the flood surface has characteristics such as fluctuation, light reflection, and light refraction, so as to realize dynamic simulation of flood inundation; the present invention simulates underwater visual effects by changing the flood surface and underwater terrain through the post-processing volume (Post-Processing Volume) in the viewport, and enhances the realistic feeling of water depth; the present invention realizes the synchronous display of multi-dimensional numerical simulation results of the flood inundation process through a combination of multiple rendering methods, and can truly and accurately simulate the water flow state and its inundation process, with a high degree of flood simulation and good visual effects;
[0090] (5) The present invention does not need to process the GeoJSON data output by the two-dimensional hydrodynamic numerical model calculation into other formats such as 3DTiles and GZIP. Instead, the GeoJSON data can be directly parsed and the parsed result can be directly passed as an input parameter to each frame of the flood instance object. The flood role class is called by the instance to draw the flood model triangular mesh primitive method, render the flood hydrological characteristics and flood flow state method, thereby achieving high-performance drawing and high-fidelity visual rendering of massive flood model triangular mesh primitives, reducing the data processing links and improving the efficiency of the digital twin flood inundation simulation business application in small and medium-sized watersheds. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] Figure 1 The overall implementation flow chart of a UE5-based small and medium-sized river basin digital twin flood inundation dynamic simulation method provided by the present invention;
[0092] Figure 2 A structural diagram of the flood role class provided by the present invention;
[0093] Figure 3 A schematic diagram of the flow pattern expression effect during the flood inundation process provided by the present invention;
[0094] Figure 4 This is a virtual-real comparison diagram of the digital twin flood inundation dynamic simulation provided by the present invention. DETAILED DESCRIPTION
[0095] The following is a detailed description of the implementation of the present invention in conjunction with the accompanying drawings, but they do not constitute a limitation of the present invention and are only used as examples. At the same time, the advantages of the present invention are made clearer and easier to understand through the description.
[0096] The UE5 (Unreal Engine 5) in the present invention is a comprehensive development tool and graphics rendering engine. Its virtual micropolygon geometry technology and high-resolution virtual texture technology achieve highly scalable geometry compression and highly realistic texture rendering, which can significantly improve the authenticity and accuracy of digital twin flood inundation simulation of small and medium-sized watersheds. Using UE5 as a simulation engine can greatly enhance the user's visual experience, build a more interactive and realistic digital twin scene, and carry out simulation and deduction based on water conservancy professional model drive, which can improve the level of refined management.
[0097] Referring to the attached drawings, it can be seen that the present invention provides a method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5, such as Figure 1 As shown, the following steps are included:
[0098] Step 1: Collect and organize structured input data sets, build a two-dimensional hydrodynamic numerical model, and calculate the output grid node and triangle unit GeoJSON data;
[0099] The above implementation steps specifically include the following sub-steps:
[0100] Step 1.1: Determine the modeling scope of the two-dimensional hydrodynamic numerical model according to the small and medium-sized river basin flood research area, collect hydrological data such as DEM (Digital Elevation Model) data and historical monitoring data of hydrological water level stations within the scope, and organize them into a structured input data set after data cleaning and formatting. The specific implementation process is as follows:
[0101] (1) Determine the modeling scope. Based on the vector map and satellite remote sensing imagery of the small and medium-sized river basin flood research area, comprehensively judge the topographic features within the research scope, divide the modeling scope of the numerical model along the river direction and the regional distribution on both sides, and use the upstream and downstream boundary sections of the river and the hillsides or higher terrain areas on both sides as the boundaries of the modeling scope of the two-dimensional hydrodynamic numerical model;
[0102] (2) DEM projection conversion. Collect DEM data within the modeling range and convert it into UTM (Universal Transverse Mercator Grid System) projection coordinates in meters. This coordinate system is a plane rectangular coordinate system, which is convenient for the construction and calculation of numerical models;
[0103] (3) Organize the data set. Collect historical hydrological monitoring data and design flood data within the modeling scope, including cross-section elevation, historical monitoring water level, historical monitoring flow, design 10-year / 100-year flood process data, etc.; unify the data format, convert the data format into time series data and form a structured data set to facilitate subsequent model calibration and verification work;
[0104] Step 1.2: Based on the finite element mesh of the unstructured triangular unit topology data, the hydrodynamic control equations are combined to calculate the river flood inundation changes under a given flood process scenario and construct a two-dimensional hydrodynamic numerical model. The specific implementation process is as follows:
[0105] (1) Grid generation. Based on the numerical model modeling scope determined in step 1.1 and the collected DEM data, combined with satellite images, river bank and shoreline mapping results, sections or villages along the way, and actual project needs, determine the areas in the study area that need to be grid-encrypted (generally the river channel and its coastal areas), and gradually reduce the grid density from the river bank to the hillside or higher terrain;
[0106] (2) Grid elevation assignment. Based on an unstructured grid with irregular triangles, a two-dimensional finite element grid is constructed in the study area, and terrain elevation variable information is assigned at each grid node to carry out flood inundation calculations;
[0107] (3) Condition input. Based on the historical monitoring data or field measured data collected in step 1.1, select the flow process at the upstream boundary section and the water level process at the downstream boundary section during the typical period as the model boundary condition input data;
[0108] (4) Model algorithm coding. The two-dimensional shallow water equations in conservation form are used as the control equations for flood inundation calculation. The water depth and velocity data of each grid node are calculated to obtain the river flood inundation changes. To ensure calculation efficiency, the calculation results are written into a binary file in HDF5 format. The specific form of the equations is as follows:
[0109] ;
[0110] Where U represents the conservation vector; and denote the convective flux in the x and y directions respectively; and Respectively represent the diffusion flux in the x and y directions; S represents the source term, into which the additional energy or dissipation term brought by friction loss, wind and atmospheric pressure field can be introduced; the specific expressions of each conservation quantity are as follows:
[0111] ;
[0112] ;
[0113] ;
[0114] ;
[0115] ;
[0116] In the formula, the physical quantities are: h represents water depth; u represents the average vertical velocity component in the x direction; v represents the average vertical velocity component in the y direction; b represents the elevation of the riverbed bottom; g represents the gravitational acceleration; It represents the turbulent viscosity coefficient in the horizontal direction, which is related to the shear velocity of the bed surface;
[0117] In order to comprehensively consider the river hydraulic elements and meteorological driving elements, additional source terms and dissipation terms are introduced into the model equations, which can be expressed as:
[0118] ;
[0119] In the formula, as well as Represent the riverbed slopes in the x and y directions respectively, and their expressions are: as well as y and They represent the bottom friction loss in the x and y directions, respectively, which are determined by the roughness, water depth and flow velocity; f represents the Coriolis force coefficient, which is determined according to the latitude of each node; and represents the wind stress in the x and y directions, which is obtained by the wind speed and correlation coefficient of the atmospheric wind field at a height of ten meters; p represents the increase in static pressure on the river surface caused by the change in air pressure (negative numbers represent decreases);
[0120] Step 1.3: Using the structured data set organized in step 1.1 as input, call the two-dimensional hydrodynamic numerical model for simulation calculation, and output the grid node and triangular unit data in GeoJSON format, including the simulation results of water level, water depth, flow velocity, flow direction, etc. The specific implementation process is as follows:
[0121] (1) Output the grid node data in GeoJSON format. Read the binary result file in HDF5 format generated after the calculation is completed, record the physical quantity data such as the ID, longitude and latitude coordinates, water level elevation, water depth and flow velocity of each grid node, and write it in the GeoJSON file with the shape of a point in JSON format;
[0122] (2) Output the GeoJSON format data of the triangular unit. Read the binary result file in HDF5 format generated after the calculation is completed, record the topological structure data of the triangular mesh, index the mesh node corresponding to the triangular unit according to the topological data and obtain its data, use the average value calculation method to calculate the physical quantities such as the water depth of the triangular unit, and write it in the GeoJSON file with the shape of a polygon in JSON format;
[0123] Step 2. Create a flood inundation simulation UE5 plug-in project for parsing and visualizing the calculation results of the two-dimensional hydrodynamic numerical model, configure the plug-in dependent modules, and select Visual Studio 2022 as the development tool;
[0124] The above implementation steps include the following sub-steps:
[0125] Step 2.1, create a flood simulation UE5 plug-in project. In the UE5 editor, select the "Edit" menu, then select "Plugins". In the plug-in window, select the code plug-in type, click the "Create Plug-in" button, and the editor will automatically create the files and directory structure required for the plug-in project;
[0126] Step 2.2, configure the plugin dependency modules. In the ".uplugin" configuration file of the plugin project, configure JSON parsing, geographic coordinate conversion, etc. as default startup modules; in the ".Build.cs" configuration file, add programmatic mesh components, instantiated static mesh components, dynamic material instances, etc. as public dependency modules;
[0127] Step 2.3, select development tools. The flood inundation simulation UE5 plug-in project created in step 2.1 is mainly developed based on the C++ programming language, and combined with the UE5 blueprint function to realize the creation and editing of dynamic special effects water materials. Therefore, the present invention uses Visual Studio 2022 as a development tool;
[0128] Step 3. Create a flood character class in the flood simulation UE5 plug-in project;
[0129] In the above implementation steps, specifically Figure 2 As shown, the creation of the flood role class includes the following sub-steps:
[0130] Step 3.1, create a new flood character class. The character class of UE5 is the most basic blueprint class, which is used to represent any object in the digital twin scene and provide basic functions of the object, such as position, rotation, scaling, collision, etc.; when the character is used as a carrier of business logic, its main usage is to place the character class instance object in the scene so that it can express entities, behaviors or effects in the scene. The present invention sets the parent class of the flood character class to the character class. The flood character class inherits all the properties and methods of the parent class, but it itself has the characteristics and behaviors of the flood;
[0131] Step 3.2, set the flood attribute data structure in the flood character class. When processing two-dimensional hydrodynamic numerical models, data related to fluid flow, fluctuations and other hydrodynamic characteristics are usually generated. The calculation results of these models are often organized in a specific way, mainly used to describe spatial relationships and hydrodynamic characteristics. Their data structures do not fully conform to the data structure rules for efficient drawing and rendering of grids in the UE5 engine. Therefore, it is necessary to structure the flood inundation simulation input data. The flood attribute data structure is used to store the structured numerical model calculation results, and is used as an input parameter to drive the spatial changes and surface material changes of flood grid primitives. The flood attribute data structure set by the present invention includes the following contents:
[0132] (1) Index identifier. It is the unique index identifier of each frame flood character class instance object, which is used to retrieve the instance object of the flood character class. The index identifier is a string type data structure;
[0133] (2) Visibility flag. It is used to identify the display or hidden state of the current flood role class instance object in the digital twin scene. The visibility flag is a Boolean data structure;
[0134] (3) Grid node attribute array. It is used to store the attribute information of all grid nodes calculated by the numerical model. The attribute values of each grid node stored include longitude, latitude, water surface elevation, U, and V. The data structure of the grid node attribute array is TArray <TArray <float>> format, that is, the attribute value of each grid node is stored in a floating-point type array, namely, the attribute value array. One attribute value array will store 5 floating-point type data, and then all the attribute value arrays of the grid nodes are stored in a unified external array according to the grid node order, namely, the grid node attribute array;
[0135] (4) Triangle unit attribute array. It is used to store all triangle units calculated by the numerical model. Each triangle unit includes the attribute information of three vertices (i.e., mesh nodes). The attribute information of each vertex is longitude, latitude, water surface elevation, and water depth. The data structure of the triangle unit attribute array is TArray <TArray <float>> format, that is, the three vertex attributes of each triangle unit are stored in a floating-point type array, namely, the attribute value array, in the order of longitude, latitude, water surface elevation, and water depth. An attribute value array will store 12 floating-point type data, and then the attribute value arrays of all triangle units are stored in a unified external array in the order of triangle units, namely, the triangle unit attribute array;
[0136] (5) Triangle unit UV array. Triangle unit UV is used to represent the flow rate and direction of flood on a triangle mesh primitive. U and V are stored in a two-dimensional vector (FVector2D) data structure. The triangle unit UV array is used to store the UV vector of each triangle unit. Its data structure is TArray <fvector2d>In the form, the U of the triangular unit is obtained by summing the U of the three vertices of the triangular unit and dividing it by 3, and the V of the triangular unit is obtained by summing the V of the three vertices of the triangular unit and dividing it by 3;
[0137] (6) Water depth layered color array. Water depth layered color array refers to using different color layers to represent the changes in flood depth. The color layers are defined according to the flood depth classification standards. The data structure of the water depth layered color array is TArray <TArray <float>> In the form of, each layer is stored in a floating point type array in the order of the current minimum water depth, the current maximum water depth, the color R value, the color G value, the color B value, and the color A value, and then the array of each layer is stored in a unified external array, that is, the water depth layered color array;
[0138] (7) Triangle mesh primitive material reference. It is used to store the reference path of the flood surface special effect material and is a string type data structure;
[0139] (8) 3D arrow model material reference. Used to store the reference path of the 3D arrow model surface material, which is a string type data structure;
[0140] Step 3.3, set the component structure of the flood character class. A component is a special type of object. A character can attach a component to itself as a child object, so that the character has corresponding rendering, visual, or physical effects. Each character class has a scene component as a root node by default. The present invention creates a programmatic mesh component and an instantiated static mesh component under the scene component of the flood character class, respectively, so that the flood character class can call the functional methods of the programmatic mesh component and the instantiated static mesh component;
[0141] Step 3.4, a method for setting a flood character class. The method for setting a flood character class in the present invention mainly includes a method for drawing flood model triangle mesh primitives, a method for rendering flood hydrological characteristics and flood flow patterns;
[0142] Step 4: Construct a method for drawing flood model triangle mesh primitives in the flood role class;
[0143] In the above implementation steps, the construction of the method for drawing the flood model triangular mesh primitives includes the following sub-steps:
[0144] Step 4.1, create a new method function for drawing flood model triangle mesh primitives in the flood role class;
[0145] Step 4.2, establish mesh vertices. In the method function of drawing the flood model triangular mesh primitive, loop through the triangular unit attribute array; take out the attribute value array of each triangular unit, take out the longitude, latitude, and water surface elevation of the three vertices of the triangular unit from the attribute value array, establish a three-dimensional geographic space coordinate vector, and use the geographic reference function module of the Cesium plug-in to convert the three-dimensional geographic space coordinate vector into a three-dimensional space rectangular coordinate vector; store the converted three-dimensional space rectangular coordinate vectors of the three vertices of the triangular unit in the mesh vertex array outside the triangular unit attribute array loop body in turn;
[0146] Step 4.3, establish vertex index. Vertex index determines how to connect vertices into triangles. Different index orders will have a significant impact on the generation and rendering of triangle primitives. For example, if the vertex index order is incorrect, the generated mesh may be distorted, staggered or incomplete. At the same time, if the vertex order is inconsistent, it may cause the normal direction to be reversed, resulting in abnormal lighting effects. The present invention adopts a clockwise vertex index order. In the triangle unit attribute array loop body, the vertex index array outside the loop body (denoted as TArray <int32>triangles) write 3i, 3i+2, 3i+1 as vertex index numbers in sequence, where i is the loop counter of the triangle unit attribute array loop body, which is used to indicate the number of times the loop is executed;
[0147] Step 4.4, establish vertex normals. Vertex normals are used to calculate the angle between the light source and the flood surface, thereby determining the intensity and direction of the light. The illumination model uses normal information to simulate how light shines on the flood surface, thereby determining the brightness and shadow of the flood surface. The present invention uses the positive direction of the Z axis as the normal direction of each vertex. In the triangle unit attribute array loop body, three unit vectors FVector (0,0,1) along the positive direction of the Z axis are sequentially written into the vertex normal array outside the loop body as vertex normals;
[0148] Step 4.5, establish vertex texture coordinates. The UV coordinate system in UE5 is mainly used for texture mapping, while the XYZ coordinate system is used to describe the three-dimensional spatial position and direction of objects;
[0149] Establishing appropriate vertex texture coordinates is a key step in realizing the hydrological characteristics of the flood model surface and flood flow simulation. The present invention maps the UV coordinate system of the triangular unit to the XY plane of the XYZ coordinate system, and then controls the flow direction of the flood texture on the surface of each triangular mesh primitive through the mapped UV vector, so that the surface of the flood model can present regional localized flow characteristics with the correct flow direction in the digital twin scene. The specific implementation steps are as follows:
[0150] (1) Determine the mapping relationship. To map UV to the XY plane, it is necessary to ensure that the UV coordinates are directly related to the XY position of the grid, that is, the UV coordinates of each vertex should be proportional to its position on the XY plane. The grid range of the present invention on the UV coordinate system is (0,0) to (1,1), so the UV coordinates of each vertex can be directly set to its XY coordinates, but because the range of UV coordinates is usually 0 to 1, it is also necessary to map the XY coordinates into this range;
[0151] (2) Normalize UV coordinates. Normalizing the UV coordinate system to a range of 0 to 1 allows the texture to adapt to texture images of different sizes without being affected by the actual resolution, so that the texture can be correctly mapped to the 3D model;
[0152] The specific process is as follows: first, store the X and Y coordinates of the spatial position of the mesh vertex into a two-dimensional vector structure, and then store them in a two-dimensional vector array in sequence according to the order of the mesh vertices, recorded as the mesh vertex XY coordinate array; then, create a two-dimensional vector MinUV (FLT_MAX, FLT_MAX) and MaxUV (-FLT_MAX, -FLT_MAX), where FLT_MAX is a mathematical constant that represents the maximum value of a floating point number; then, loop through the mesh vertex XY coordinate array, calculate the minimum and maximum values of the UV coordinates, and assign them to MinUV and MaxUV respectively; finally, loop through the mesh vertex XY coordinate array again to calculate the normalized UV coordinates, and the calculation expression is:
[0153] UV.X=(UV.X-MinUV.X) / (MaxUV.X-MinUV.X);
[0154] UV.Y=(UV.Y-MinUV.Y) / (MaxUV.Y-MinUV.Y);
[0155] After this step, the mesh vertex XY coordinate array will be converted into a normalized UV coordinate array;
[0156] (3) Correct the direction of the UV vector. Since the grid vertices of the flood model are not regularly distributed in the spatial coordinate system, the shapes and sizes of the constructed triangular mesh primitives are uneven, which will cause the UV vectors of each triangular unit to be generally chaotic after being mapped to the XYZ coordinate system. However, after normalizing the UV coordinates, the UV vectors of all triangular units are mapped to the XYZ coordinate system and their directions will be consistent with the negative axis direction of the X-axis. On this basis, the rotation angle of the mapped UV vector on the XY plane is calculated, and the direction is corrected so that the UV vector calculated by the two-dimensional hydrodynamic numerical model has the correct direction in the XYZ coordinate system. The specific process is as follows:
[0157] 1) Calculate the rotation angle of the UV vector on the XY plane
[0158] First, create a three-dimensional vector, assign the U and V coordinates of the triangular unit to the X and Y of the three-dimensional vector respectively, and assign the Z of the three-dimensional vector to 0; then, use the three-dimensional vector dot product function of UE5 to calculate the angle between the three-dimensional vector and the Y axis; then, convert the angle into an angle value (denoted as angle); since the UV coordinate system and XYZ coordinates of UE5 are both left-handed coordinate systems, and the UV coordinate system of the two-dimensional hydrodynamic numerical model is a right-handed coordinate system, after mapping the UV vector of the triangular unit to the XYZ coordinate system, its direction is consistent with the negative axis direction of the X axis. Therefore, the rotation angle of the UV vector to the positive axis direction of the XY plane should be -(angle+90);
[0159] 2) Create a vector rotation function, and rotate the UV vector in the XY plane based on the origin of the XYZ coordinate system. Use the vector to be rotated and the rotation angle as the input parameters of the vector rotation function, calculate the rotation matrix and apply it to the vector to be rotated, obtain the UV vector after direction correction, and use it as the function return value;
[0160] (4) Calculate the vertex texture coordinates. Use the vector rotation function to correct the direction of the normalized UV coordinate two-dimensional vector, and then store the function return results in the binary dimension In the vector array, as the vertex texture coordinate array;
[0161] Step 4.6, establish vertex color. Define the color for each vertex of the mesh by setting the vertex color array; the implementation process is, first, obtain the water depth value of the current triangle mesh primitive in the triangle unit attribute array; then, compare the flood depth classification standard of each layer in the water depth layered color array in turn, when the water depth value meets the value range of the water depth classification standard of a certain layer, obtain the color R value, color G value, color B value, color A value of the layer; finally, use the UE5 data structure to represent the color to store the RGBA value of the color, for example, FLinearColor(R,G,B,A), and store the value in the vertex color array;
[0162] Step 4.7, draw triangular mesh primitives. Pass the mesh vertex array, vertex index array, vertex normal array, vertex texture coordinate array, and vertex color array as parameters to the create mesh component method of the flood character class procedural mesh component, thereby achieving the drawing of massive triangular mesh primitives (such as Figure 3 shown);
[0163] Step 5: Construct the implementation of the method for rendering flood hydrological characteristics and flood flow patterns in the flood role class;
[0164] In the above implementation steps, the construction of the method for rendering flood hydrological characteristics and flood flow patterns includes the following sub-steps:
[0165] Step 5.1, create a new method function for rendering flood hydrological characteristics and flood flow patterns in the flood role class;
[0166] Step 5.2, create vertex shading material. Vertex shading material is a technology that uses vertex color data in materials, and affects the rendering effect by using mesh vertex color information. The specific implementation process is:
[0167] (1) Create a vertex shader master material. Run the flood simulation UE5 plug-in project, in the content browser of the UE5 editor, right-click and select "Material" to create a new material, and then double-click to open the material editor;
[0168] (2) Create a vertex coloring effect. In the Material Editor, drag the Vertex Color node from the panel to the graph. This node will output the color information of the mesh vertices. Connect the output of the Vertex Color node to the Self-Illumination input of the material, connect the R channel output of the Vertex Color node to the Highlight input of the material, connect the G channel output of the Vertex Color node to the Roughness input of the material, and connect the B channel output of the Vertex Color node to the Global Position Offset input of the material;
[0169] (3) Create water surface color, transparency, fluctuation, reflection, refraction and other effects. In the material editor, add a vector parameter node to set it to the basic color of the water; change the material's blending mode property to translucent to support transparent effects, and add a scalar parameter node to control the transparency of the water; use a normal node and connect it to the material's normal input to affect the normal direction of the water surface, so that the water surface has a fluctuation effect; add a scene texture node and set its scene texture id to "reflection" to make the water surface have a light reflection effect; use a refraction node to add a light refraction effect on the water surface;
[0170] (4) Create a material instance. In the content browser of the UE5 editor, right-click the vertex shader material and select "Create Material Instance". Adjust the material attribute parameters in the instance to achieve the best visual effect;
[0171] Step 5.3, create flood flow material. Use UE5's flow map to simulate the effect of flood flow, and use vertex texture coordinates to control the direction of flow, so that different triangular mesh units have their own flow states, and continuous adjacent triangular mesh units will show flow effects such as backflow, converging flow, bifurcated flow, floodplain flow, turbulence, etc. The specific implementation process is:
[0172] (1) Create a flood flow master material. Run the flood simulation UE5 plug-in project, in the content browser of the UE5 editor, right-click and select "Material" to create a new material, and then double-click to open the material editor;
[0173] (2) Create flood surface texture flow effects;
[0174] 1) Add a flow map texture. Use a texture sampler node to load the flow map texture and connect the texture sampler node to the base color input of the material;
[0175] 2) Extract the flow direction. Extract the flow direction from the texture sampling node, use the component mask node to separate the R and G channels, which represent the flow information in the X and Y directions respectively, and synthesize the separated R and G channels into a two-dimensional vector node to represent the flow direction;
[0176] 3) Use vertex texture coordinates. Add a texture coordinate node to provide the UV coordinates of the mesh vertices, and connect the texture coordinate node to a product node to adjust the UV coordinates of the flow map;
[0177] 4) Set the flow direction. Connect the output of the product node to the UV input of the texture sampling node, and connect the R and G channel outputs of the texture sampling node to the product node to calculate the final flow direction;
[0178] 5) Apply flow effects. Connect the final flow direction result to the normal input to apply flow effects at the vertex level;
[0179] (3) Create water surface color, transparency, fluctuation, reflection, refraction and other effects. In the material editor, add a vector parameter node to set it to the basic color of the water; change the material's blending mode property to translucent to support transparent effects, and add a scalar parameter node to control the transparency of the water; use a normal node and connect it to the material's normal input to affect the normal direction of the water surface, so that the water surface has a fluctuation effect; add a scene texture node and set its scene texture id to "reflection" to make the water surface have a light reflection effect; use a refraction node to add a light refraction effect on the water surface;
[0180] (4) Create a material instance. In the content browser of the UE5 editor, right-click the flood flow parent material and select "Create Material Instance". Adjust the material property parameters in the instance to achieve the best visual effect;
[0181] Step 5.4, apply the flood surface special effects material. In the flood hydrological characteristics and flood flow method functions, pass the vertex shading material reference path or flood flow material reference path as a parameter to the triangle mesh primitive material reference variable; then, use the UE5 load object method to obtain the material instance; finally, call the set material method of the flood character class procedural mesh component to implement the application of the flood surface special effects material;
[0182] Step 5.5, create a three-dimensional arrow for flow velocity and direction. Add a three-dimensional arrow model to each grid node position of the flood model, use the three-dimensional arrow to indicate the direction to express the local flood flow direction, and use the size of the three-dimensional arrow model to express the local flood flow velocity; the specific implementation process is as follows:
[0183] (1) Get the arrow model. Find the built-in 3D arrow model asset from the UE5 engine, for example, the S_Arrow arrow in the default asset folder of the particle effect plug-in, and get the asset reference path of the arrow model; use the UE5 load object method to get the arrow model pointer;
[0184] (2) Set the arrow model for the instantiated static mesh component. In the flood hydrological characteristics and flood flow method functions, set the 3D arrow model for the instantiated static mesh component. Call the Set Static Mesh method of the instantiated static mesh component of the flood character class and pass the arrow model pointer as a parameter to the method;
[0185] (3) Set the arrow model material. In the flood hydrological characteristics and flood flow method functions, pass the 3D arrow model material reference as a parameter to the load object method to obtain the 3D arrow model material instance; then, pass the material instance to the set material method of the static mesh component instantiated by the flood character class to achieve the change of the 3D arrow model surface effect;
[0186] (4) Set the arrow spatial position. Loop through the grid node attribute array, and in the flood hydrological characteristics and flood flow method function, create a three-dimensional space transformation matrix in the loop body; then, obtain the longitude, latitude, and water surface elevation data of the grid node, establish a three-dimensional geographic space coordinate vector, and use the geographic reference function module of the Cesium plug-in to convert the three-dimensional geographic space coordinate vector into a three-dimensional space rectangular coordinate vector; finally, pass the three-dimensional space rectangular coordinate vector as a parameter to the three-dimensional space transformation matrix’s setting position method;
[0187] (5) Set the arrow scaling ratio. First, in the mesh node attribute array loop, create a three-dimensional vector, assign the mesh node U and V attribute values to the X and Y of the three-dimensional vector, and assign the Z of the three-dimensional vector to 0; then, calculate the scaling parameter and call the UE5 FMath::Clamp mathematical function to limit the length of the three-dimensional vector to the range of 0.5 to 1.5, thereby preventing the three-dimensional arrow model from becoming too small or too large after scaling; finally, pass the scaling parameter to the scaling method of the three-dimensional space transformation matrix;
[0188] (6) Set the arrow rotation angle. First, in the grid node attribute array loop, use the UE5 three-dimensional vector dot product function to calculate the angle between the three-dimensional vector in step (5) and the Y axis; then, convert the angle into an angle value, subtract 90 from the calculated angle value as the rotation angle, and then use the three-dimensional space transformation matrix to set the rotation transformation method to adjust the direction of the three-dimensional arrow so that it can indicate the correct flood flow direction in the XYZ coordinate system;
[0189] (7) Add arrow instances to the instantiated static mesh component. In the mesh node attribute array loop, call the add instance method of the instantiated static mesh component of the flood character class, and pass the three-dimensional space transformation matrix as a parameter to the method, so as to create three-dimensional arrows of flow velocity and direction on all mesh nodes;
[0190] Step 5.6, create underwater visual effects. Use the UE5 editor to create a post-processing volume between the flood surface and the underwater terrain, modify the post-processing volume's parameters such as floodlight, depth of field, hue, and fluctuation to simulate underwater visual effects, thereby enhancing the realistic feeling of water depth;
[0191] Step 6: Parse the mesh node and triangular unit GeoJSON data, and pass the parsing results as parameters to the flood role class instantiation object's method of drawing the flood model triangular mesh primitives and the method of rendering the flood hydrological characteristics and flood flow pattern, so as to realize the flood model preloading and pre-rendering, and display the digital twin flood inundation dynamic simulation process in a frame-by-frame animation manner;
[0192] In the above implementation steps, the display of the dynamic simulation process of flood inundation by digital twins includes the following sub-steps:
[0193] Step 6.1. Analyze the calculation results of the two-dimensional hydrodynamic numerical model. When conducting flood inundation analysis, water depth is an important indicator used to assess the degree and scope of the impact of flood disasters. However, not all water depths are of practical significance for assessing flood disasters. Some shallow water depths may disappear quickly due to various reasons (such as evaporation, infiltration, etc.). For assessing the impact of flood disasters, these shallow water depths can be regarded as invalid water depths. Therefore, when conducting flood inundation analysis, the invalid water depth standard of the study area should be obtained based on the actual situation and other data analysis. When parsing the grid node GeoJSON and triangle unit GeoJSON data output by the numerical model calculation, first eliminate the data below the invalid water depth standard, and then organize the data according to the data structure set in step 3.2 as the input parameter of the digital twin flood inundation simulation;
[0194] Step 6.2, preloading and pre-rendering of the sequence frame flood model. Since the amount of grid data in each frame of the flood model is very large, the method of dynamically updating the attribute information of all grid nodes and triangular units in real time and refreshing the triangular mesh primitives for redrawing and rendering will cause a few seconds of jamming, which cannot meet the requirements of continuous and smooth playback of the flood inundation sequence frame animation. Therefore, the present invention adopts the method of preloading and pre-rendering of the sequence frame flood model, pre-loads each frame of the flood inundation model into the digital twin scene, draws the triangular mesh primitives and renders the materials in advance, that is, dynamically creates multiple flood instance objects according to the sequence frame order of the flood inundation animation, and each flood instance object draws and renders the flood inundation model at different times, and has the hydrological characteristics and flood flow states of the flood at different times. The specific process is:
[0195] (1) Select rendering method
[0196] 1) Vertex shading rendering method
[0197] Pass the vertex shader material reference path as a parameter into the flood instance object's Set Flood Surface Effect Material method. According to the characteristics of flood level changes, the flood depth is divided into multiple levels. For example, the color transition from blue to red is used to finely express the flood depth in different areas, where blue represents shallow water level and red represents deep water level.
[0198] 2) Flood flow rendering method
[0199] The flood flow material reference path is passed as a parameter to the flood instance object's method of setting the flood surface special effect material. The flood surface will be rendered with texture flow according to the vertex texture coordinates to show the flood flow in different areas.
[0200] (2) Dynamically create flood instance objects
[0201] Through UE5's generate character method, the flood character class is instantiated into a flood instance object and dynamically added to the digital twin scene. The position vector of the flood instance object is set to zero vector, the rotation vector is set to zero vector, and the scale vector is set to FRotator(1,1,1). The method of drawing the flood model triangular mesh primitive of the flood instance object is called to realize the drawing of the triangular mesh primitive of the flood inundation model at a certain moment in the digital twin scene; the method of rendering the flood hydrological characteristics and flood flow state of the flood instance object is called to realize the setting of different visualization methods of vertex shading rendering or flood flow state rendering of the flood triangular mesh primitive. At the same time, the local flood flow direction is expressed by indicating the direction with a three-dimensional arrow, the local flood flow velocity is expressed by the size of the three-dimensional arrow model, and the underwater visual effect simulation is realized, so as to accurately express the hydrological characteristics and flood flow state of different flood areas at the current moment (such as Figure 3 As shown, Figure 3 Figure a in the figure is a simulation of underwater visual effects of the present invention; Figure 3 Figure b is a simulation of the reflux effect of the present invention; Figure 3 Figure c in the figure is a simulation of the turbulence effect of the present invention; Figure 3 Figure d in the figure is a simulation of the bifurcated flow effect of the present invention; Figure 3 Figure e in the figure is a simulation of the converging flow effect of the present invention; Figure 3 Figure f in the figure is a simulation of the floodplain flow effect of the present invention);
[0202] Step 6.3, play the sequence frame flooding simulation animation;
[0203] First, all preloaded flood instance objects are set to be hidden; then, a timer is created to display the flood instance objects at the current moment frame by frame, while hiding the flood instance objects of the previous frame, forming a frame-by-frame animation, thereby realizing the animation display of the flood inundation simulation process. Through functions such as start, pause, replay, and jump to keyframes, the flood inundation simulation process can be controlled (such as Figure 4 As shown, Figure 4 Figure a in the figure is a real flood inundation scene; Figure 4 Figure b in the figure is a flood simulation scene of the present invention; Figure 4 Figure a and Figure 4 It can be seen from Figure b that the flood inundation simulation scene of the present invention is basically consistent with the real flood inundation scene, realizing the dynamic rendering of the super-large data volume flood model and the high-fidelity visualization of the flood hydrological characteristics, and completely and fully expressing the multi-dimensional flood inundation numerical simulation results such as water level, water depth, flow velocity, flow direction, as well as the complex flow states of floods such as backflow, converging flow, bifurcated flow, floodplain flow, turbulence, etc., thereby improving the authenticity and accuracy of flood inundation simulation).
[0204] Other parts not described belong to the prior art. < / float> < / float> < / float>
Claims
1. A dynamic simulation method of digital twin flood inundation in small and medium-sized watersheds based on UE5, characterized by: The following steps are included: Step 1: Collect and organize structured input data sets, build a two-dimensional hydrodynamic numerical model, and calculate the output grid node and triangle unit GeoJSON data; Step 2: Create a flood inundation simulation UE5 plug-in project for parsing and visualizing the calculation results of the two-dimensional hydrodynamic numerical model, and configure the plug-in dependent modules; Step 3: Create a flood character class in the flood simulation UE5 plug-in project; Step 4: Construct a method for drawing flood model triangle mesh primitives in the flood role class; The specific steps include: Step 4.1, create a new method function for drawing flood model triangle mesh primitives in the flood role class; Step 4.2, establish mesh vertices; in the method function of drawing the flood model triangle mesh primitive, store the spatial coordinate vectors of the three vertices of the triangle unit into the mesh vertex array in sequence; Step 4.3, establish vertex index; in the method function of drawing the flood model triangle mesh primitive, use the clockwise vertex index order to write 3i, 3i+2, 3i+1 into the vertex index array as the vertex index sequence, where i is the loop counter of the triangle unit attribute array loop body, which is used to indicate the number of executions of the loop; Step 4.4, establish vertex normals; in the method function of drawing the flood model triangle mesh primitive, use the positive direction of the Z axis as the normal direction of each vertex, and in the loop body of the triangle unit attribute array, write three unit vectors along the positive direction of the Z axis into the vertex normal array outside the loop body in sequence as the vertex normal; Step 4.5, establish vertex texture coordinates; in the method function of drawing the flood model triangle mesh primitive, map the UV coordinate system of the triangle unit to the XY plane of the XYZ coordinate system, and then control the flow direction of the flood texture on the surface of each triangle mesh primitive through the mapped UV vector; Step 4.6, establish vertex colors; in the method function of drawing the flood model triangle mesh primitive, define the color for each vertex of the mesh by setting the vertex color array; Step 4.7, draw triangular mesh primitives; in the method function of drawing triangular mesh primitives of the flood model, the mesh vertex array, vertex index array, vertex normal array, vertex texture coordinate array, and vertex color array are passed as parameters to the create mesh component method of the procedural mesh component of the flood character class, thereby realizing the drawing of massive triangular mesh primitives; Step 5: Construct the method of rendering flood hydrological characteristics and flood flow patterns in the flood role class; The specific steps include: Step 5.1, create a new method function for rendering flood hydrological characteristics and flood flow patterns in the flood role class; Step 5.
2. Create a vertex shading material using the UE5 editor; use the mesh vertex color information to affect the rendering effect; Step 5.3, use the UE5 editor to create a flood flow material; use the UE5 flow map to simulate the effect of flood flow, and use the vertex texture coordinates to control the direction of flow, so that different triangular mesh units have their own flow states, and continuous adjacent triangular mesh units will present the flow effects of backflow, converging flow, bifurcated flow, floodplain flow, and turbulent flow as a whole; Step 5.4, apply the flood surface special effects material; in the method function of rendering flood hydrological characteristics and flood flow patterns, call the setting material function of the flood role class procedural mesh component to realize the application of the flood surface special effects material; Step 5.5, create a three-dimensional arrow of flow velocity and direction; in the method function of rendering flood hydrological characteristics and flood flow state, call the add instance method of the static mesh component instantiated by the flood role class, pass the three-dimensional space transformation matrix after setting the position, scale, and rotation status as a parameter to the method, and realize the creation of three-dimensional arrows of flow velocity and direction on all mesh nodes; Step 5.6, create underwater visual effects; use the UE5 editor to create a post-processing volume between the flood surface and the underwater terrain, modify the floodlight, depth of field, hue, and fluctuation parameters of the post-processing volume to simulate underwater visual effects, thereby enhancing the realistic feeling of water depth; Step 6: Parse the mesh node and triangular unit GeoJSON data, and pass the parsing results as parameters to the flood role class instantiation object's method of drawing the flood model triangular mesh primitives and rendering the flood hydrological characteristics and flood flow state, so as to realize the preloading and pre-rendering of the flood model, and realize the dynamic simulation of the digital twin flood inundation process in a frame-by-frame animation manner.
2. The method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5 according to claim 1 is characterized by: Step 1 specifically includes the following steps: Step 1.1: Determine the modeling scope of the two-dimensional hydrodynamic numerical model according to the small and medium-sized river basin flood research area, collect DEM data and historical hydrological monitoring data of hydrological and water level stations within the scope, and organize them into a structured input data set after data cleaning and formatting; Step 1.2, based on the finite element mesh of the unstructured triangular element topology data, combined with the hydrodynamic control equations, calculate the river flood inundation changes under a given flood process scenario and construct a two-dimensional hydrodynamic numerical model; Step 1.3: Using the structured data set compiled in step 1.1 as input, call the two-dimensional hydrodynamic numerical model for simulation calculations, and output the grid node and triangular unit data in GeoJSON format. The output data includes the simulation results of water level, water depth, flow velocity, and flow direction.
3. The method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5 according to claim 1 or 2 is characterized in that: Step 2 specifically includes the following steps: Step 2.
1. Create a flood simulation UE5 plug-in project in the UE5 editor. The editor automatically creates the files and directory structure required for the plug-in project. Step 2.
2. In the plugin project created in step 2.1, configure JSON parsing and geographic coordinate conversion as the default startup module; add procedural mesh components, instantiated static mesh components, and dynamic material instances as public dependency modules; Step 2.
3. Select Visual Studio 2022 as the development tool.
4. The method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5 according to claim 3 is characterized by: Step three specifically includes the following steps: Step 3.1, create a new flood character class; create a new C++ class in the flood inundation simulation UE5 plug-in project, set its parent class to the character class, and this C++ class is the flood character class; Step 3.2, set the flood attribute data structure in the flood role class; the set flood attribute data structure includes a string type index identifier, a string type visibility identifier, a mesh node attribute array, a triangle unit attribute array, a triangle unit UV array, a water depth layer color array, a string type triangle mesh primitive material reference, and a string type 3D arrow model material reference; Step 3.3, set the component structure of the flood character class; create a programmatic mesh component and an instantiated static mesh component under the scene component of the flood character class, so that the flood character class can call the functional methods of the programmatic mesh component and the instantiated static mesh component; Step 3.4, setting the methods of the flood role class; the methods of the flood role class specifically include methods for drawing flood model triangle mesh primitives, rendering flood hydrological characteristics and flood flow patterns.
5. The method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5 according to claim 1 is characterized in that: In step 4.5, the method of establishing vertex texture coordinates includes: (1) Determine the mapping relationship; map the UV of the triangle unit to the XY plane; (2) Normalize UV coordinates: Normalize the UV coordinate system of the triangular unit to the range of 0 to 1; (3) Correct the direction of the UV vector; first, calculate the rotation angle of the UV vector on the XY plane, and then rotate the UV vector on the XY plane based on the origin of the XYZ coordinate system; (4) Calculate vertex texture coordinates.
6. The method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5 according to claim 1 is characterized by: In step 5.2, the specific method of creating a vertex shading material includes: (1) Create a vertex shader material; (2) Create vertex shading effects; (3) Create water surface color, transparency, fluctuation, reflection, and refraction effects; (4) Create a material instance; In step 5.3, the specific method of creating a flood flow material includes: (1) Create flood flow master material; (2) Creating flood surface texture flow effects, including adding flow map textures, extracting flow direction, using vertex texture coordinates, setting flow direction, and applying flow effects; (3) Create water surface color, transparency, fluctuation, reflection, and refraction effects; (4) Create a material instance; In step 5.5, the specific method of creating a three-dimensional arrow of flow velocity and direction includes: (1) Get the arrow model; use the 3D arrow model asset built into UE5; (2) Instantiate the static mesh component to set the arrow model; (3) Set the arrow model material; (4) Setting the arrow spatial position; (5) Set the arrow scaling ratio; (6) Set the arrow rotation angle; (7) Add the arrow instance to the instanced Static Mesh component.
7. The method for dynamic simulation of flood inundation of small and medium-sized river basins based on UE5 according to claim 6 is characterized by: Step six specifically includes the following steps: Step 6.1, analyzing the calculation results of the two-dimensional hydrodynamic numerical model; Step 6.2: Preload and pre-render the flood model of the sequence frame; pre-load each frame of the flood model into the digital twin scene, and perform triangular mesh primitive drawing and material rendering in advance; Step 6.3, play the sequence frame flood inundation simulation animation; create a timer, display the current moment flood instance object frame by frame, and hide the previous frame flood instance object at the same time, forming a frame-by-frame animation.
Citation Information
Patent Citations
Visual rendering method for digital twinborn flood flow field
CN117237567A
Reservoir flood control system based on UE technology
CN117371233A
Cited By
Intelligent decision-making method and device for realizing flood simulation prevention in combination with Cesium
CN121095484A
A method and device for preventing intelligent decision-making by combining cesium to realize flood simulation
CN121095484B