CN115983162B - Drainage basin modeling method based on digital twinning - Google Patents

Drainage basin modeling method based on digital twinning Download PDF

Info

Publication number
CN115983162B
CN115983162B CN202310269624.2A CN202310269624A CN115983162B CN 115983162 B CN115983162 B CN 115983162B CN 202310269624 A CN202310269624 A CN 202310269624A CN 115983162 B CN115983162 B CN 115983162B
Authority
CN
China
Prior art keywords
river
coordinate
point
basin
terrain
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310269624.2A
Other languages
Chinese (zh)
Other versions
CN115983162A (en
Inventor
熊佳
钱燕
韦露斯
何力劲
赵小娥
张晓琳
谢天云
陈畅
张义敏
何熙希
周舜轩
林芯伊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hydrology Bureau Of Zhujiang Water Resources Commission Ministry Of Water Resources
Original Assignee
Hydrology Bureau Of Zhujiang Water Resources Commission Ministry Of Water Resources
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hydrology Bureau Of Zhujiang Water Resources Commission Ministry Of Water Resources filed Critical Hydrology Bureau Of Zhujiang Water Resources Commission Ministry Of Water Resources
Priority to CN202310269624.2A priority Critical patent/CN115983162B/en
Publication of CN115983162A publication Critical patent/CN115983162A/en
Application granted granted Critical
Publication of CN115983162B publication Critical patent/CN115983162B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A10/00TECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE at coastal zones; at river basins
    • Y02A10/40Controlling or monitoring, e.g. of flood or hurricane; Forecasting, e.g. risk assessment or mapping

Abstract

The invention discloses a basin modeling method based on digital twinning, which comprises the following steps: step S1: obtaining geographic data of an area where a river basin is located, processing the geographic data in modeling software Unity, determining a surface fitting function of a terrain surface, and obtaining surface information of the terrain surface; step S2: drawing a target river grid on the curved surface of the terrain surface acquired in the step S1; step S3: and adding a shader to the target river grid to simulate a target river basin. According to the river basin simulation method, the terrain generated in the GIS plug-in unit can be well matched with the river in the current river basin simulation process through coordinate change, grid division, spline curve fitting, spline surface fitting, coloring device adding and the like, so that the river can be accurately displayed in the corresponding terrain area. The invention completes modeling of the river bed topography and generates good interaction with water. Lays a foundation for realizing flood inundation and rain forecast and early warning in the follow-up process.

Description

Drainage basin modeling method based on digital twinning
Technical Field
The invention belongs to the technical field of hydrologic modeling, and particularly relates to a drainage basin modeling method based on digital twinning.
Background
The hydrologic monitoring is an important component of hydrologic work, and has important significance for water conservancy planning, water engineering construction management, flood prevention, early-stage resistance, water resource management and protection in China. In recent years, with the development of new technologies such as communication technology, artificial intelligence technology and the like, and implementation of serious projects such as national small river hydrologic monitoring system engineering, national hydrologic infrastructure construction planning and the like, the hydrologic water resource monitoring capability of China is remarkably improved.
In the hydrologic research of the flow field, the simulation and analysis of the flow field are also particularly important. In the prior art, the generation of the digitized drainage basin is mainly divided into two parts, wherein one part is to directly add a GIS plug-in Unity, and the other part is to manually create the drainage basin through a brush by a designer. For the GIS plug-in, the displayed scene is formed by splicing a piece of dough, and the size of the scene can be changed along with the change of the distance of a cutting plane in the view port space, so that better interaction with water in a digital twin flow domain can not be generated; for example, during river basin simulation, the topography generated in the GIS plug-in cannot be matched with the river, so that the river cannot be displayed in the corresponding topography area, or the river flows out of the river channel. For the topography created by the artificial brush, the precision is not enough, the artificial brush has larger access with the actual river bed, and the effect is not ideal when the river is submerged and flood is predicted.
Disclosure of Invention
The invention provides a basin modeling method based on digital twinning, which solves the technical problems that in the basin simulation modeling process in the prior art, scenes displayed in a Unity GIS plug-in are spliced by a piece of dough, the size of the scene can be changed along with the change of the distance of a clipping plane in a view port space, and better interaction with other objects in the digital twinning basin cannot be generated.
In order to solve the technical problems, the invention adopts the following scheme:
a basin modeling method based on digital twinning comprises the following steps:
step S1: obtaining geographic data of an area where a river basin is located, processing the geographic data in modeling software Unity, determining a surface fitting function of a terrain surface, and obtaining surface information of the terrain surface;
step S2: drawing a target river grid on the curved surface of the terrain surface acquired in the step S1;
step S3: and adding a shader to the target river grid to simulate a target river basin.
Further preferably, in the step S1, the method specifically includes the following steps:
step S1.1: obtaining geographic data of an area where a river basin is located:
geographic data of the area where the drainage basin is located is obtained through the GIS, wherein the geographic data comprises a topographic map of the area where the drainage basin is located, longitude and latitude information and elevation information of different positions, and coordinate information of different position points in a world coordinate system.
Step S1.2: and (3) data processing:
establishing a three-dimensional rectangular coordinate system OXZY in the Unity, and marking the three-dimensional rectangular coordinate system OXZY as a simulation coordinate system; selecting an XOZ plane as a horizontal plane, expressing a Y-axis direction as a terrain height, observing from a direction vertical to the XOZ plane, wherein a terrain map of a region where a river basin is positioned is rectangular in the XOZ plane, setting an endpoint of a lower left corner of the terrain map as a coordinate origin O, converting coordinate values of points in a world coordinate system in the region where the river basin is positioned into coordinate values in an analog coordinate system, and integrating the coordinate-converted data into a table file in an XLSX format.
Step S1.3: determining a surface fitting function:
s1.3.1: according to the coordinate data integrated in the step S1.2, selecting a group of points with the same X-axis coordinate value to fit to obtain a B spline curve, selecting another group of points with the same X-axis coordinate value to fit to obtain another B spline curve, and sequentially fitting to obtain (m+1) B spline curves in the X-axis direction; fitting out (n+1) B spline curves in the Z-axis direction by adopting the same method; m and n are positive integers greater than 3.
S1.3.2: constructing the B spline curve obtained in the step S1.3.1 for multiple times in X, Z axes in two directions to synthesize the B spline curve, specifically: intersecting (m+1) B spline curves in the X-axis direction with (n+1) B spline curves in the Z-axis direction to obtain (m+1) X (n+1) control points, and forming a control grid by the (m+1) X (n+1) control points, wherein the parameter node vector of the ith curve in the X-axis direction is X= [ X ] 0 ,x 1 ,…,x i+k+1 ]The parameter node vector of the jth curve in the Z-axis direction is Z= [ Z ] 0 ,z 1 ,…,z j+l+1 ];
The equation for a B-spline surface is as follows:
Figure GDA0004208516330000021
f in the formula i,j I=0, 1 … m, j=0, 1 … n for controlling point sets, i.e. point sets in a three-dimensional point cloud; n (N) i,k (x) And N j,l (z) is a B spline surface basis function, wherein k and l represent powers of spline curves, and subscripts i and j represent serial numbers of the B spline curves;
i+k≤m,j+l≤n;
step S1.4: creating a terrain surface of the area where the river basin is located in the Unity digital twin river basin simulation platform:
in the simulated coordinate system, the topographic map has xSize points along the X-axis direction and zSize points along the Z-axis direction, and the xSize is multiplied by the zSize points, and the X coordinate and the Z coordinate corresponding to each point are given, wherein the coordinate value of the vertex of the lower left corner in the XOZ is (0, 0); substituting the XOZ coordinate value of each point into a B spline surface function to obtain a corresponding Y coordinate, namely obtaining coordinate information of a position corresponding to the terrain surface in a Unity digital twin-basin simulation platform, and storing the coordinate information; and then obtaining the surface curved surface of the terrain of the area where the river basin is by adopting a triangle definition method.
Further optimizing, converting coordinate values of points on the terrain in the area of the river basin in a world coordinate system into coordinate values of a simulation coordinate system, wherein the coordinate values comprise the following steps:
setting the position of the point A on the topographic map to coincide with the origin O in the simulated coordinate system, and setting the coordinate of the point A on the XOZ plane of the simulated coordinate system as (0, 0); the coordinate value of the X-axis of other points on the topographic map in the simulated coordinate system is the difference between the coordinate value of the X-axis of the point and the coordinate value of the X' -axis of the A point in the world coordinate system; likewise, the coordinate value of the Z-axis of other points on the map in the simulated coordinate system is the difference between the coordinate value of the Z-axis of the point and the coordinate value of the Z' -axis of the A-point in the world coordinate system.
For the Y-axis coordinate value, finding out the minimum value D of the Y '-axis coordinate values of all points on the topographic map in the world coordinate system, and subtracting D from the Y' -axis coordinate value of each point in the world coordinate system to obtain the Y-axis coordinate value in the simulated coordinate system; and thus obtaining the three-dimensional coordinate value of each point in the simulated coordinate system on the topographic map of the area where the river basin is located.
Further optimizing, obtaining the surface curved surface of the terrain of the area where the drainage basin is by adopting a triangle definition method, and specifically comprising the following steps:
the xSize xzSize mesh vertices are arranged as follows: the first row of grid points index 0 to xSize, the second row of grid points index xSize to 2× (xsize+1) -1, … …, and the last row of grid points index (zSize-1) × (xsize+1) -1 to zsize× (xsize+1) -1.
Triangles are defined by the array of vertex indices, arranged in a clockwise direction, then triangles are considered forward and visible, and counterclockwise triangles are discarded; each grid curved surface is generated by two triangles, and then 6 vertex indexes corresponding to the two triangles at the left lower corner vertex of the topographic map are as follows:
triangles[0]=0;
triangles[1]=xSize+1;
triangles[2]=1;
triangles[3]=1;
triangles[4]=xSize+1;
triangles[5]=xSize+2;
and according to the index mode, traversing all grids circularly to generate a large terrain grid.
Further preferably, in the step S2, the drawing of the target river grid specifically includes the following steps:
step S2.1: and selecting a plurality of control points to generate a Catmull-Rom curve L with the same shape as the target river, setting the target river as a grid band in a Unity digital twin-river basin simulation platform, and symmetrically distributing vertexes on the grid band on two sides of the curve L.
Step S2.2, newly creating a list in a Vector3 format, and storing coordinate information of a river control point; and creating a list of Int types, and storing the river width of the corresponding positions of different control points.
Step S2.3, calculating a vector P1P2 through two adjacent control points P1 and P2 on the curve; obtaining a river water plane vector V through cross multiplication, adding and subtracting half of the river width at the corresponding position in the direction of the vector V, and obtaining vertex coordinates at two sides of a control point P1; and sequentially solving the coordinate values of the vertexes of two sides of all river control points by using the same method.
And S2.4, drawing a river grid in the same way as the terrain drawing method.
Further optimizing, in the step S3, in the Unity digital twin-basin simulation platform, the following functions of simulating a river are realized by adding a shader:
1) Flowing water along the river direction:
firstly, calculating the displacement of vertexes, shifting the related vertexes in the corresponding direction according to vectors formed by adjacent river control points, adding position components of a model space to the shift, multiplying the shift by a coefficient to control the wavelength, multiplying a result value by the coefficient to control the fluctuation amplitude, and obtaining final displacement to simulate the flow of water in a flow domain;
2) Fitting terrain to a river:
raising all vertexes on the topographic map by the same height, then taking each vertex on the topographic map as a starting point, emitting rays downwards, and judging whether the vertexes collide with the river grid or not;
if collision occurs, downwards sinking the vertexes corresponding to the topographic map grids to a designated depth, and finely adjusting the degree of the vertex sinking according to texture coordinates of mapping of collision points in the coloring device and curves of cross sections of the river in the width direction, so that the river bed and the topography are more natural in transition;
3) Increasing the foam in the water stream:
a piece of foam texture map is newly added in the Unity scene, the river Mesh obtains color information of a corresponding position through a texture sampler, and the color information is added to a final output result of a fragment shader, so that the effect of generating foam is realized; in addition, the terrain gradient is judged by the projection of the current normal line of the river Mesh on the Y' axis of the world coordinate system, and the smaller the projection is, the steeper the projection is, and the more the corresponding foam is;
4) Adding a Perlin noise texture:
the process for realizing sea wave visualization by using the generated Perlin noise texture comprises the following steps:
4.1 A suitable random function is selected, named noise, and the seed is set to 1000;
4.2 For any point (x ', y'), by four vertex positions (x) 0 ,y 0 )、(x 0 ,y 1 )、(x 1 ,y 0 ) And (x) 1 ,y 1 ) Calculate each
Key value of random number at point-to-point (x ', y'):
Figure GDA0004208516330000041
wherein d (x 0 ,y 0 ) Is the point (x) 0 ,y 0 ) Gradient at;
4.3 Through interpolation function 3q 2 -2q 3 Processing the calculation results of the above formulas respectively:
Figure GDA0004208516330000051
processing a and b in the Y ' axis direction, and obtaining an interpolation result, namely a Perlin noise function value q at a point (x ', Y '):
Figure GDA0004208516330000052
the expression is calculated as a Perlin noise value under a single frequency, and a final random texture can be obtained by superposing a plurality of two-dimensional Perlin noises under different frequencies, wherein the expression is as follows:
Figure GDA0004208516330000053
wherein, the set duration is 1/2, and N is the total frequency number;
4.4 Finally, sampling the noise texture through a variable related to time to obtain corresponding normal line information, and then carrying out normal refraction and reflection calculation to obtain a final water surface fluctuation effect;
5) Adding fresnel reflection:
in the real-time rendering of Unity scenes, the Schlick fresnel approximation formula is adopted:
F schlick (v,r)=F 0 +(1-F 0 )(1-v·r) 5
wherein F is 0 For the reflection coefficient, v is the viewing angle direction and r is the surface normal for controlling the intensity of the fresnel reflection.
Compared with the prior art, the invention has the following beneficial effects:
1. according to the river basin simulation method, the terrain generated in the GIS plug-in unit can be well matched with the river in the current river basin simulation process through coordinate change, grid division, spline curve fitting, spline surface fitting, coloring device adding and the like, so that the river can be accurately displayed in the corresponding terrain area.
2. The invention completes modeling of the river bed topography and generates good interaction with water. Lays a foundation for realizing flood inundation and rain forecast and early warning in the follow-up process. The digital twinning-based simulation river basin facilitates water conservancy staff to observe the condition of the river basin more intuitively, analyzes and evaluates the condition of the river basin on the basis of the previewing result, adjusts countermeasures such as hydraulic engineering operation, emergency dispatch, personnel disaster prevention and the like more timely, and effectively improves the scientificity and operability of planning.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a basin modeling method based on digital twinning according to the present invention;
FIG. 2 is a topographical view of a village-dam-wearing basin according to the present invention;
FIG. 3 is a schematic diagram of a mesh vertex in accordance with the present invention;
FIG. 4 is a schematic diagram of a mesh vertex index;
FIG. 5 is a topography diagram generated by simulation in example 1;
FIG. 6 is an enlarged partial view of FIG. 5;
FIG. 7 is a graph showing the effect of the river in example 1 in combination with terrain modeling;
fig. 8 is a partial enlarged view of fig. 7.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Embodiment one:
in this embodiment, the village-wearing dam basin is located in the county of eastern prefecture of eastern province of Shandong, and is a branches of the large venturi river. As shown in fig. 1, a drainage basin modeling method based on digital twinning comprises the following steps:
step S1: obtaining geographic data of an area where a river basin is located, processing the geographic data in modeling software Unity, determining a surface fitting function of a terrain surface, and obtaining surface information of the terrain surface;
step S2: drawing a target river grid on the curved surface of the terrain surface acquired in the step S1;
step S3: and adding a shader to the target river grid to simulate a target river basin.
In this embodiment, the step S1 specifically includes the following steps:
step S1.1: obtaining geographic data of an area where a river basin is located:
geographic data of an area where a drainage basin is located is obtained through a GIS, wherein the geographic data comprises a topographic map of the area where the drainage basin is located, longitude and latitude information and elevation information of different positions, and coordinate information of different position points in a world coordinate system; wherein the topography is shown in fig. 2.
In this example, geographical data in world coordinates of the village-dam-wearing basin is given, and partial data is given due to space constraints, as shown in table 1.
Table 1 partial geographic data of a village-wearing dam basin in world coordinate system
Original coordinate number Coordinate value of X-axis Z-axis coordinate value Y-axis coordinate value
1 459501.4 3972667 51.96602
2 459569.3 3972731 52.16825
3 459576.5 3972745 52.55218
4 459599.7 3972840 52.23792
5 459609.6 3972906 51.79936
6 459635.6 3973033 52.3503
7 459632.1 3973098 52.31626
8 459620.9 3973127 51.60873
9 459653.4 3973227 52.11847
10 459695.3 3973313 51.50199
Step S1.2: and (3) data processing:
establishing a three-dimensional rectangular coordinate system OXZY in the Unity, and marking the three-dimensional rectangular coordinate system OXZY as a simulation coordinate system; selecting an XOZ plane as a horizontal plane, expressing a Y-axis direction as a terrain height, observing from a direction vertical to the XOZ plane, wherein a terrain map of a region where a river basin is positioned is rectangular in the XOZ plane, setting an endpoint of a lower left corner of the terrain map as a coordinate origin O, converting coordinate values of points in a world coordinate system in the region where the river basin is positioned into coordinate values in an analog coordinate system, and integrating the coordinate-converted data into a table file in an XLSX format. In this embodiment, the data of the field geographic data of the village-wearing dam after coordinate transformation is given, and due to space limitation, part of the data is given, as shown in table 2, the sequence numbers in table 2 correspond to those in table 1.
Table 2 data after coordinate transformation
Transformed coordinate number Coordinate value of X-axis Z-axis coordinate value Y-axis coordinate value
1 0 0 0
2 67.95481 63.81974 0.202223
3 75.10664 78.61626 0.586152
4 98.31744 173.0398 0.271898
5 108.1913 239.4591 -0.16666
6 134.2705 365.8869 0.38428
7 130.6974 430.8904 0.350239
8 119.5621 460.6561 -0.3573
9 152.0531 560.653 0.152448
10 193.9335 646.4402 -0.46403
In this embodiment, in the step S1.2, coordinate values of points on the terrain in the area where the river basin is located in a world coordinate system are converted into coordinate values of a simulated coordinate system, and specifically includes the following steps:
setting the position of the point A on the topographic map to coincide with the origin O in the simulated coordinate system, and setting the coordinate of the point A on the XOZ plane of the simulated coordinate system as (0, 0); the coordinate value of the X-axis of other points on the topographic map in the simulated coordinate system is the difference between the coordinate value of the X-axis of the point and the coordinate value of the X' -axis of the A point in the world coordinate system; likewise, the coordinate value of the Z-axis of other points on the map in the simulated coordinate system is the difference between the coordinate value of the Z-axis of the point and the coordinate value of the Z' -axis of the A-point in the world coordinate system.
For the Y-axis coordinate value, finding out the minimum value D of the Y '-axis coordinate values of all points on the topographic map in the world coordinate system, and subtracting D from the Y' -axis coordinate value of each point in the world coordinate system to obtain the Y-axis coordinate value in the simulated coordinate system; and thus obtaining the three-dimensional coordinate value of each point in the simulated coordinate system on the topographic map of the area where the river basin is located.
Step S1.3: determining a surface fitting function:
s1.3.1: according to the coordinate data integrated in the step S1.2, selecting a group of points with the same X-axis coordinate value to fit to obtain a B spline curve, selecting another group of points with the same X-axis coordinate value to fit to obtain another B spline curve, and sequentially fitting to obtain (m+1) B spline curves in the X-axis direction; fitting out (n+1) B spline curves in the Z-axis direction by adopting the same method; m and n are positive integers greater than 3.
In this embodiment, coordinates of a set of points with X-axis coordinate values of 0 are selected, and a B-spline curve is obtained by fitting as shown in table 3.
Table 3X coordinate values of a set of points each having an axis coordinate value of 0
Sequence number X Z Y
1 0 0 0
2 0 72.95317 0.168296
3 0 159.6556 0.229398
4 0 323.2218 0.123198
5 0 469.681 0.217907
6 0 591.4813 0.369316
7 0 720.8502 0.100035
8 0 883.6205 1.814597
9 0 978.7939 8.77098
10 0 1012.259 1.93005
11 0 1103.823 0.21056
12 0 1206.702 -0.12368
N 1,4 (z)=-6.386×10 -11 z 4 +1.322×10 -7 z 3 -7.876×10 -5 z 2 +0.01425z-0.2453;
And selecting the coordinates of a group of points with Z-axis coordinate values of 0, and fitting to obtain another B-spline curve as shown in table 4.
Table 4Z coordinate values of a set of points each having an axis coordinate value of 0
Sequence number X Z Y
1 0 0 0
2 186.7952 0 1.506994
3 582.6952 0 4.330679
4 974.9785 0 -0.99309
5 1271.671 0 -0.21696
6 1565.699 0 -0.41679
7 1893.568 0 -0.97224
8 2234.682 0 0.521484
9 2768.19 0 1.811969
10 3251.598 0 0.636894
11 3764.901 0 0.873042
12 4371.189 0 0.462905
13 4962.901 0 0.559569
14 5400.789 0 8.183614
15 5896.801 0 1.146506
N 1,4 (x)=-6.372×10 -14 x 4 +6.997×10 10 x 3 -2.085×10 -6 x 2 +0.01328x+1.001。
In the same way, a plurality of sample curves are obtained, and the description is omitted because of space limitation.
S1.3.2: constructing the B spline curve obtained in the step S1.3.1 for multiple times in X, Z two directions to synthesize the B spline curve, specifically: intersecting (m+1) B spline curves in the X-axis direction with (n+1) B spline curves in the Z-axis direction to obtain (m+1) X (n+1) control points, and forming a control grid by the (m+1) X (n+1) control points, wherein the X-axis is the X-axisThe parameter node vector of the i-th curve in the direction is X= [ X ] 0 ,x 1 ,...,x i+k+1 ]The parameter node vector of the jth curve in the Z-axis direction is Z= [ Z ] 0 ,z 1 ,...,z j+l+1 ]。
The equation for a B-spline surface is as follows:
Figure GDA0004208516330000091
f in the formula i,j I=0, 1..m, j=0, 1..n; n (N) i,k (x) And N j,l (z) is a B spline surface basis function, wherein k and l represent powers of spline curves, and subscripts i and j represent serial numbers of the B spline curves; i+k is less than or equal to m, and j+l is less than or equal to n.
In this embodiment, the equation of the curved surface obtained according to the spline curve is:
F(x,z)=-0.0917+0.2899×x-0.007464×z-6.839×10 -5 x 2
-4.007×10 -5 xz+1.265×10 -5 z 2 -2.707×10 -7 x 3 +1.914×10 -7 x 2 z
+2.972×10 -9 xz 2 -5.896×10 -9 z 3 +3.684×10 -10 x 4 +1.281×10 -10 x 3 z
-7.398×10 -11 x 2 z 2 +4.364×10 -12 x 1 z 3 +8.221×10 -13 z 4
step S1.4: target area topographic surface creation in a Unity digital twin-basin simulation platform:
in the simulated coordinate system, the topographic map has xSize points along the X direction and zSize points along the Z direction, and the xSize is multiplied by the zSize points in total, and as shown in fig. 3, the X coordinate and the Z coordinate corresponding to each point are given, wherein the coordinate value of the vertex of the lower left corner in the XOZ is (0, 0); substituting the XOZ coordinate value of each point into a B spline surface function to obtain a corresponding Y coordinate, namely obtaining coordinate information of a position corresponding to the terrain surface in a Unity digital twin-basin simulation platform, and storing the coordinate information; and then obtaining the surface curved surface of the topography of the target area by adopting a triangle definition method. The method specifically comprises the following steps: the xSize xzSize mesh vertices are arranged as follows: the first row of grid points index 0-xSize, the second row of grid points index xSize-2 x
(xsize+1) -1, … …, the last row grid point index is (zSize-1) × (xsize+1) -1 to zsize× (xsize+1) -1.
Triangles are defined by the array of vertex indices, as shown in FIG. 4, arranged in a clockwise direction, the triangle is considered forward and visible, and the counterclockwise triangle is discarded; each grid curved surface is generated by two triangles, and then 6 vertex indexes corresponding to the two triangles which are close to each other at the left lower corner vertex on the topographic map are as follows:
triangles[0]=0;
triangles[1]=xSize+1;
triangles[2]=1;
triangles[3]=1;
triangles[4]=xSize+1;
triangles[5]=xSize+2;
and according to the index mode, traversing all grids circularly to generate a large terrain grid.
In this embodiment, in the step S2, the drawing of the target river grid specifically includes the following steps:
step S2.1: and selecting a plurality of control points to generate a Catmull-Rom curve L with the same shape as that of the river in the target area, setting the target river as a grid band in a Unity digital twin-river basin simulation platform, and symmetrically distributing vertexes on the grid band on two sides of the curve L.
In this embodiment, the Catmull-Rom curve L for the village-wearing dam basin is:
y=2.57×10 -15 x 5 -4.56×10 -11 x 4 +2.9×10 -7 x 3 -7.6×10 -4 x 2 +0.7381x+142.2;
step S2.2, newly creating a Vector3 format list to store the coordinate information of the river control points, and newly creating an Int type list to store the river width of the corresponding positions of different control points;
s2.3, calculating a vector P1P2 through two adjacent control points P1 and P2 on the curve, and taking a Y axis as a Y' axis of a world coordinate system; obtaining a river water plane vector V through cross multiplication, adding and subtracting half of the corresponding river width in the direction of the vector V, and obtaining vertex coordinates of two sides of a control point P1; sequentially solving the vertex coordinate values of two sides of all river control points by using the same method;
and S2.4, drawing a river grid in the same way as the terrain drawing method.
In this embodiment, in the step S3, a new material is created in the Unity digital twin-basin simulation platform, and named as waters mat. A Unity loader is created and named loader-Water. And adding the newly built loader to the material. Opening the newly created shader, declaring the following properties: main Tex is the river texture, color is used to control the overall Color, magnitus is used to control the Magnitude of the water flow fluctuations, frequency is used to control the Frequency of the fluctuations, invWaveLength is used to control the reciprocal of the wavelength, and Speed is used to control the Speed of movement of the river texture the greater the InvWaveLength value, the lesser the wavelength.
The following functions of simulating a river are realized by adding a shader:
1) Flowing water along the river direction:
firstly, calculating the displacement of the vertexes, shifting the related vertexes in the corresponding direction according to vectors formed by adjacent river control points, adding the position components of a model space to the shift, multiplying the shift by a coefficient_InvWaveLength control wavelength, and finally multiplying the result value by a coefficient_Magnitus to control the fluctuation amplitude, so as to obtain the final displacement, and realizing the flow of water in a simulated flow domain.
2) Fitting terrain to a river:
raising all vertexes on the topographic map by a set height, taking each vertex on the topographic map as a starting point, emitting rays downwards, and judging whether the vertexes collide with the river grid or not;
if the river bed collides with the terrain, the vertexes corresponding to the terrain grids are downwards recessed by a designated depth, and the degree of vertex recession is finely adjusted according to UV of the collision points and designated animation Curve, so that the river bed and the terrain are more natural in transition.
3) Increasing the foam in the water stream:
and a piece of foam texture map is newly added in the Unity scene, the river Mesh acquires the color information of the corresponding position through the texture sampler, and the color information is added to the final output result of the fragment shader, so that the effect of generating foam is realized. In addition, the terrain gradient is judged by the projection of the current normal line of the river Mesh on the Y' axis of the world coordinate system, and the smaller the projection is, the steeper the projection is, and the more the corresponding foam is.
4) Adding a Perlin noise texture:
the process for realizing sea wave visualization by using the generated Perlin noise texture comprises the following steps:
4.1 A suitable random function is selected, named noise, and the seed is set to 1000;
4.2 For any point (x ', y'), by four vertex positions (x) 0 ,y 0 )、(x 0 ,y 1 )、(x 1 ,y 0 ) And (x) 1 ,y 1 ) Calculate each
Key value of random number at point-to-point (x ', y'):
Figure GDA0004208516330000121
wherein d (x 0 ,y 0 ) Is the point (x) 0 ,y 0 ) Gradient at;
4.3 Through interpolation function 3q 2 -2q 3 Processing the calculation results of the above formulas respectively:
Figure GDA0004208516330000122
processing a and b in the Y ' axis direction, and obtaining an interpolation result, namely a Perlin noise function value q at a point (x ', Y '):
Figure GDA0004208516330000123
the expression is calculated as a Perlin noise value under a single frequency, and a final random texture can be obtained by superposing a plurality of two-dimensional Perlin noises under different frequencies, wherein the expression is as follows:
Figure GDA0004208516330000124
wherein the duration is set to 1/2, and N is the total frequency number.
4.4 Finally, sampling the noise texture through a variable related to time to obtain corresponding normal line information, and then carrying out normal refraction and reflection calculation to obtain a final water surface fluctuation effect;
5) Adding fresnel reflection:
in the real-time rendering of Unity scenes, the Schlick fresnel approximation formula is adopted:
F schlick (v,r)=F 0 +(1-F 0 )(1-v·r) 5
wherein F is 0 For the reflection coefficient, v is the viewing angle direction and r is the surface normal for controlling the intensity of the fresnel reflection. By adding fresnel reflection, the water in the simulated river is almost transparent, and the small fish and the stones at the water bottom can be seen; however, when looking at the far water surface, the underwater scene is hardly seen, but only the environment reflected by the water surface is seen, so that the simulated river is more realistic. Therefore, the reflection is added, so that the integrally simulated river is more realistic, and a better visual effect is obtained.
In this embodiment, the topography generated is simulated, as shown in fig. 5, and fig. 6 is a partially enlarged view of fig. 5. Fig. 7 is an effect diagram of a river in cooperation with terrain modeling, and fig. 8 is a partially enlarged view of fig. 7.
With the above-described preferred embodiments according to the present invention as an illustration, the above-described descriptions can be used by persons skilled in the relevant art to make various changes and modifications without departing from the scope of the technical idea of the present invention. The scope of the invention is not limited by the description, but must be determined from the scope of the claims.

Claims (5)

1. The river basin modeling method based on digital twinning is characterized by comprising the following steps:
step S1: obtaining geographic data of an area where a river basin is located, processing the geographic data in modeling software Unity, determining a surface fitting function of a terrain surface, and obtaining surface information of the terrain surface;
the method specifically comprises the following steps:
step S1.1: obtaining geographic data of an area where a river basin is located:
geographic data of an area where a drainage basin is located is obtained through a GIS, wherein the geographic data comprises a topographic map of the area where the drainage basin is located, longitude and latitude information and elevation information of different positions, and coordinate information of different position points in a world coordinate system;
step S1.2: and (3) data processing:
establishing a three-dimensional rectangular coordinate system OXZY in the Unity, and marking the three-dimensional rectangular coordinate system OXZY as a simulation coordinate system; selecting an XOZ plane as a horizontal plane, expressing a Y-axis direction as a terrain height, observing from a direction vertical to the XOZ plane, wherein a terrain map of an area where a drainage basin is positioned is rectangular in the XOZ plane, setting an endpoint of a lower left corner of the terrain map as a coordinate origin O, converting coordinate values of each point in a world coordinate system in the area where the drainage basin is positioned into coordinate values in an analog coordinate system, and integrating the coordinate-converted data into a table file in an XLSX format;
step S1.3: determining a surface fitting function:
s1.3.1: according to the coordinate data integrated in the step S1.2, selecting a group of points with the same X-axis coordinate value to fit to obtain a B spline curve, selecting another group of points with the same X-axis coordinate value to fit to obtain another B spline curve, and sequentially fitting to obtain (m+1) B spline curves in the X-axis direction; fitting out (n+1) B spline curves in the Z-axis direction by adopting the same method; m and n are positive integers greater than 3;
s1.3.2: obtained in the step S1.3.1B spline curves of (2) are constructed to fit B spline curves for a plurality of times in two directions of X, Z axes, and the B spline curves are specifically: intersecting (m+1) B spline curves in the X-axis direction with (n+1) B spline curves in the Z-axis direction to obtain (m+1) X (n+1) control points, and forming a control grid by the (m+1) X (n+1) control points, wherein the parameter node vector of the ith curve in the X-axis direction is X= [ X ] 0 ,x 1 ,…,x i+k+1 ]The parameter node vector of the jth curve in the Z-axis direction is Z= [ Z ] 0 ,z 1 ,…,z j+l+1 ];
The equation for a B-spline surface is as follows:
Figure FDA0004208516320000011
f in the formula i,j I=0, 1 … m, j=0, 1 … n for controlling point sets, i.e. point sets in a three-dimensional point cloud; n (N) i,k (x) And N j,l (z) is a B spline surface basis function, wherein k and l represent powers of spline curves, and subscripts i and j represent serial numbers of the B spline curves; i+k is less than or equal to m, j+l is less than or equal to n;
step S1.4: creating a terrain surface of the area where the river basin is located in the Unity digital twin river basin simulation platform:
in the simulated coordinate system, the topographic map has xSize points along the X-axis direction and zSize points along the Z-axis direction, and the xSize is multiplied by the zSize points, and the X coordinate and the Z coordinate corresponding to each point are given, wherein the coordinate value of the vertex of the lower left corner in the XOZ is (0, 0); substituting the XOZ coordinate value of each point into a B spline surface function to obtain a corresponding Y coordinate, namely obtaining coordinate information of a position corresponding to the terrain surface in a Unity digital twin-basin simulation platform, and storing the coordinate information; then, a triangle definition method is adopted to obtain a terrain surface curved surface of the area where the river basin is located;
step S2: drawing a target river grid on the curved surface of the terrain surface acquired in the step S1;
step S3: and adding a shader to the target river grid to simulate a target river basin.
2. The method for modeling a river basin based on digital twinning according to claim 1, wherein in the step S1.2, coordinate values of points on the terrain in the region where the river basin is located in a world coordinate system are converted into coordinate values of an analog coordinate system, and specifically comprising the steps of:
setting the position of the point A on the topographic map to coincide with the origin O in the simulated coordinate system, and setting the coordinate of the point A on the XOZ plane of the simulated coordinate system as (0, 0); the coordinate value of the X-axis of other points on the topographic map in the simulated coordinate system is the difference between the coordinate value of the X-axis of the point and the coordinate value of the X' -axis of the A point in the world coordinate system; likewise, the coordinate value of the Z axis of other points on the topographic map in the simulated coordinate system is the difference between the coordinate value of the Z axis of the point and the coordinate value of the Z' axis of the A point in the world coordinate system;
for the Y-axis coordinate value, finding out the minimum value D of the Y '-axis coordinate values of all points on the topographic map in the world coordinate system, and subtracting D from the Y' -axis coordinate value of each point in the world coordinate system to obtain the Y-axis coordinate value in the simulated coordinate system; and thus obtaining the three-dimensional coordinate value of each point in the simulated coordinate system on the topographic map of the area where the river basin is located.
3. The digital twinning-based basin modeling method according to claim 2, wherein in the step S1.4, a triangle definition method is adopted to obtain a surface curved surface of a regional topography where the basin is located, and the method specifically comprises the following steps:
the xSize xzSize mesh vertices are arranged as follows: the first row of grid point indexes are 0 to xSize, the second row of grid point indexes are xSize to 2× (xSize+1) -1, … …, and the last row of grid point indexes are (zSize-1) × (xSize+1) -1 to zSize× (xSize+1) -1;
triangles are defined by the array of vertex indices, arranged in a clockwise direction, then triangles are considered forward and visible, and counterclockwise triangles are discarded; each grid curved surface is generated by two triangles, and then 6 vertex indexes corresponding to the two triangles at the left lower corner vertex of the topographic map are as follows:
triangles[0]=0;
triangles[1]=xSize+1;
triangles[2]=1;
triangles[3]=1;
triangles[4]=xSize+1;
triangles[5]=xSize+2;
and according to the index mode, traversing all grids circularly to generate a large terrain grid curved surface.
4. A method for modeling a river basin based on digital twinning according to claim 3, wherein in the step S2, the target river grid is drawn, specifically comprising the steps of:
step S2.1: selecting a plurality of control points to generate a Catmull-Rom curve L with the same shape as the target river, setting the target river as a grid band in a Unity digital twin-basin simulation platform, and symmetrically distributing vertexes on the grid band on two sides of the curve L;
step S2.2, newly creating a list in a Vector3 format, and storing coordinate information of a river control point; creating a list of Int types, and storing river width of corresponding positions of different control points;
step S2.3, calculating a vector P1P2 through two adjacent control points P1 and P2 on the curve; obtaining a river water plane vector V through cross multiplication, adding and subtracting half of the river width at the corresponding position in the direction of the vector V, and obtaining vertex coordinates at two sides of a control point P1; sequentially solving the vertex coordinate values of two sides of all river control points by using the same method;
and S2.4, drawing a river grid in the same way as the terrain drawing method.
5. The digital twin-based basin modeling method according to claim 4, wherein in the step S3, in the Unity digital twin basin simulation platform, the following functions of the target river are realized by adding a shader:
1) Flowing water along the river direction:
firstly, calculating the displacement of vertexes, shifting the related vertexes in the corresponding direction according to vectors formed by adjacent river control points, adding position components of a model space to the shift, multiplying the shift by a coefficient to control the wavelength, multiplying a result value by the coefficient to control the fluctuation amplitude, and obtaining final displacement to simulate the flow of water in a flow domain;
2) Fitting terrain to a river:
raising all vertexes on the topographic map by the same height, then taking each vertex on the topographic map as a starting point, emitting rays downwards, and judging whether the vertexes collide with the river grid or not;
if collision occurs, downwards sinking the vertexes corresponding to the topographic map grids to a designated depth, and finely adjusting the degree of the vertex sinking according to texture coordinates of mapping of collision points in the coloring device and curves of cross sections of the river in the width direction, so that the river bed and the topography are more natural in transition;
3) Increasing the foam in the water stream:
a piece of foam texture map is newly added in the Unity scene, the river Mesh obtains color information of a corresponding position through a texture sampler, and the color information is added to a final output result of a fragment shader, so that the effect of generating foam is realized; in addition, the terrain gradient is judged by the projection of the current normal line of the river Mesh on the Y' axis of the world coordinate system, and the smaller the projection is, the steeper the projection is, and the more the corresponding foam is;
4) Adding a Perlin noise texture:
the process for realizing sea wave visualization by using the generated Perlin noise texture comprises the following steps:
4.1 A suitable random function is selected, named noise, and the seed is set to 1000;
4.2 For any point (x ', y'), by four vertex positions (x) 0 ,y 0 )、(x 0 ,y 1 )、(x 1 ,y 0 ) And (x) 1 ,y 1 ) Calculating key values of random numbers at each point-to-point (x ', y'):
Figure FDA0004208516320000041
wherein d (x 0 ,y 0 ) Is the point (x) 0 ,y 0 ) Gradient at;
4.3 Through interpolation function 3q 2 -2q 3 Processing the calculation results of the above formulas respectively:
Figure FDA0004208516320000042
processing a and b in the Y ' axis direction, and obtaining an interpolation result, namely a Perlin noise function value q at a point (x ', Y '):
Figure FDA0004208516320000043
the expression is calculated as a Perlin noise value under a single frequency, and a final random texture can be obtained by superposing a plurality of two-dimensional Perlin noises under different frequencies, wherein the expression is as follows:
Figure FDA0004208516320000044
wherein, the set duration is 1/2, and N is the total frequency number;
4.4 Finally, sampling the noise texture through a variable related to time to obtain corresponding normal line information, and then carrying out normal refraction and reflection calculation to obtain a final water surface fluctuation effect;
5) Adding fresnel reflection:
in the real-time rendering of Unity scenes, the Schlick fresnel approximation formula is adopted:
F schlick (v,r)=F 0 +(1-F 0 )(1-v·r) 5
wherein F is 0 For the reflection coefficient, v is the viewing angle direction and r is the surface normal for controlling the intensity of the fresnel reflection.
CN202310269624.2A 2023-03-20 2023-03-20 Drainage basin modeling method based on digital twinning Active CN115983162B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310269624.2A CN115983162B (en) 2023-03-20 2023-03-20 Drainage basin modeling method based on digital twinning

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310269624.2A CN115983162B (en) 2023-03-20 2023-03-20 Drainage basin modeling method based on digital twinning

Publications (2)

Publication Number Publication Date
CN115983162A CN115983162A (en) 2023-04-18
CN115983162B true CN115983162B (en) 2023-06-20

Family

ID=85966885

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310269624.2A Active CN115983162B (en) 2023-03-20 2023-03-20 Drainage basin modeling method based on digital twinning

Country Status (1)

Country Link
CN (1) CN115983162B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116757004B (en) * 2023-08-21 2023-10-20 长江空间信息技术工程有限公司(武汉) EFDC three-dimensional water quality data multi-mode deduction method based on digital twin technology
CN117237567A (en) * 2023-08-22 2023-12-15 珠江水利委员会珠江水利科学研究院 Visual rendering method for digital twin flood flow field

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101912627B1 (en) * 2017-05-30 2018-10-30 에스지에이블록체인 주식회사 Method for Integration Visualizing GIS based Runoff-Hydraulic Model Analysis result

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7412362B2 (en) * 2005-05-18 2008-08-12 Microsoft Corporation River modeling
CN104318617B (en) * 2014-10-17 2017-03-08 福建师范大学 A kind of three-dimensional geography scene simulation method of Virtual emergency drilling
CN105631168B (en) * 2016-03-25 2018-12-28 中国水利水电科学研究院 A kind of river basin flood evolution visual simulating method of real-time high-efficiency
US20210286104A1 (en) * 2020-03-16 2021-09-16 River Software Inc Systems, apparatus, and methods of watershed modeling and assessment
CN113158451B (en) * 2021-04-08 2023-09-05 中国水利水电科学研究院 Large-area river three-dimensional simulation method based on one-dimensional flood evolution model
CN112860839A (en) * 2021-04-23 2021-05-28 成都四方伟业软件股份有限公司 Water environment quality real-time monitoring method and device based on Unity3D
CN113283095A (en) * 2021-05-31 2021-08-20 中国水利水电科学研究院 Evolutionary digital twin watershed construction method
CN113628337B (en) * 2021-08-20 2022-07-08 北京优锘科技有限公司 WebGL-based large-scale river flow field visual rendering method, device and equipment
CN115526999A (en) * 2022-10-17 2022-12-27 久瓴(上海)智能科技有限公司 Watershed model generation method and generation device, electronic device and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101912627B1 (en) * 2017-05-30 2018-10-30 에스지에이블록체인 주식회사 Method for Integration Visualizing GIS based Runoff-Hydraulic Model Analysis result

Also Published As

Publication number Publication date
CN115983162A (en) 2023-04-18

Similar Documents

Publication Publication Date Title
CN115983162B (en) Drainage basin modeling method based on digital twinning
Génevaux et al. Terrain generation using procedural models based on hydrology
CN109685914B (en) Automatic surface supplementing method for sectioning contour based on triangular mesh model
CN102663827B (en) Three-dimensional dynamic whole-process simulation method for storm surge and flood routing in complex flooding areas
CN105513133B (en) A kind of city wind environment numerical map makes and display methods
Génevaux et al. Terrain modelling from feature primitives
Brown et al. Dynamic simulation and visualisation of coastal erosion
CN102629391A (en) Three-dimensional space structure graph cutting and slicing method based on digital graph medium
CN114332395A (en) Method for realizing flood routing simulation based on hydraulic model and three-dimensional rendering technology
CN110375668A (en) Loess Surface mima type microrelief Surface Reconstruction based on point cloud data
CN115329691A (en) CFD and GIS-based super-large city wind environment simulation method
CN116401327A (en) Storm flood calculation auxiliary system for small and medium-sized watershed design in non-data area
CN114020943B (en) Basin water surface mixing drawing method and system, electronic equipment and storage medium
Pfeifer A subdivision algorithm for smooth 3D terrain models
CN101763659B (en) Method for automatically generating large-scale digitization altitude data model based on image set
Tymków et al. 3D GIS for flood modelling in river valleys
CN107767458B (en) Irregular triangulation network curved surface geometric topology consistency analysis method and system
Giannakidis et al. 3D photorealistic scientific visualization of tsunami waves and sea level rise
Cornel et al. Integrated Simulation and Visualization for Flood Management
Flanagin et al. Hydraulic splines: A hybrid approach to modeling river channel geometries
Yang et al. Predicting flood inundation and risk using geographic information system and hydrodynamic model
CN114627258B (en) Method and system for isomorphic modeling of gravity field catamaran spheres
Zhong et al. Application of three-dimensional visual simulation in tidal defense engineering
Croft Interpolating Beach Profile Data Using Linear and Non-linear Functions
Wan et al. A Digital Twin Watershed Three-dimensional Solid Topography Data Backplane Creation Method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant