CN115983162A - Basin modeling method based on digital twinning - Google Patents

Basin modeling method based on digital twinning Download PDF

Info

Publication number
CN115983162A
CN115983162A CN202310269624.2A CN202310269624A CN115983162A CN 115983162 A CN115983162 A CN 115983162A CN 202310269624 A CN202310269624 A CN 202310269624A CN 115983162 A CN115983162 A CN 115983162A
Authority
CN
China
Prior art keywords
coordinate
river
points
point
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.)
Granted
Application number
CN202310269624.2A
Other languages
Chinese (zh)
Other versions
CN115983162B (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

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

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

Description

Basin modeling method based on digital twins
Technical Field
The invention belongs to the technical field of hydrological modeling, and particularly relates to a basin modeling method based on digital twins.
Background
Hydrologic monitoring is an important component of hydrologic work and has important significance for water conservancy planning, water engineering construction management, flood prevention and early resistance, and 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 the implementation of important items such as hydrological monitoring system engineering of small and medium rivers in China, hydrological infrastructure construction planning in China and the like, the hydrological and water resource monitoring capability of China is remarkably improved.
In the watershed hydrological study, simulation and analysis of the watershed are also particularly important. In the prior art, the generation of the digital watershed is mainly divided into two parts, one part is to add a GIS plug-in directly in Unity, and the other part is to create the watershed manually by a designer through a brush. For GIS plug-ins, the displayed scenes are formed by splicing patches, the size of the GIS plug-ins can be changed along with the change of the distance of a cutting plane in a viewport space, and the GIS plug-ins cannot interact with water with good visual effect in a digital twin stream domain; for example, during the river basin simulation, the terrain generated in the GIS plug-in cannot be matched with the river, so that the river cannot be displayed in the corresponding terrain area, or the river appears in an area outside the river channel. For the terrain created by the manual brush pen, the accuracy is not enough, the terrain has a large entrance and exit with the actual river bed, and the effect is not ideal when river inundation and flood forecast are carried out.
Disclosure of Invention
The invention provides a digital twin-based watershed modeling method, which solves the technical problems that in the prior art, in the watershed simulation modeling process, scenes displayed in a Unity GIS plug-in are spliced by pieces of dough pieces, the size of the scenes can be changed along with the change of the distance of a cutting plane in a viewport space, and better interaction with other objects in a digital twin watershed cannot be generated.
In order to solve the technical problem, the invention adopts the following scheme:
a digital twin-based watershed modeling method comprises the following steps:
step S1: acquiring geographic data of a region where a drainage basin is located, processing the geographic data in modeling software Unity, determining a curved surface fitting function of a topographic surface, and obtaining curved surface information of the topographic surface;
step S2: drawing a target river grid on the curved surface of the terrain surface acquired in the step S1;
and step S3: and adding a shader to the target river grid to simulate a target river basin.
Further optimization, the step S1 specifically includes the following steps:
step S1.1: acquiring geographic data of a region where the drainage basin is located:
and acquiring geographic data of the area of the drainage basin through a GIS, wherein the geographic data comprises a topographic map of the area of the drainage basin, longitude and latitude information and elevation information of different positions, namely coordinate information of different position points in a world coordinate system.
Step S1.2: data processing:
establishing a three-dimensional rectangular coordinate system OXZY in Unity, and recording as a simulation coordinate system; selecting an XOZ plane as a horizontal plane, expressing the Y-axis direction as the terrain height, observing from the direction vertical to the XOZ plane, enabling a terrain map of an area where a drainage basin is located to be rectangular in the XOZ plane, setting an end point of the lower left corner of the terrain map as a coordinate origin O, converting coordinate values of all points in the area where the drainage basin is located in a world coordinate system into coordinate values in a simulation coordinate system, and integrating data subjected to coordinate conversion 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 the coordinate of a group of points with the same X-axis coordinate value to fit to obtain a B-spline curve, selecting the coordinate of another group of points with the same X-axis coordinate value to fit to obtain another B-spline curve, and sequentially fitting to obtain (A), (B) and (B)m+ 1) B-spline curves in the X-axis direction; by the same method, fit outn+ 1) B-spline curves in the Z-axis direction;m、nare all positive integers greater than 3.
S1.3.2: building a fitting B spline surface for multiple times in the X and Z directions of the B spline curve obtained in the step S1.3.1, specifically: (m+ 1B-spline curve in X-axis direction and: (A)nThe B spline curves of the (1) strips in the Z-axis direction are intersected to obtain (I)m+1)×(n+1 control points, wherebym+1)×(n+ 1) control points form a control grid, and the parameter node vectors in the X and Z directions are respectively X = [ (])x 0 ,x 1 ,…,x m k++1 ],Z=[z 0 ,z 1 ,…,z n l++1 ](ii) a The equation for a B-spline surface is as follows:
Figure SMS_1
in the formulaF i,j For a control point set, i.e. a set of points in a three-dimensional point cloud,i=0,1…m,j=0,1…n;N i,k (x) AndN j,l (z) is a B-spline surface basis function, whereinkAndldenotes the power, subscript, of the spline curveiAndjthe serial number of the B-spline curve is represented;
step S1.4: the method comprises the following steps of (1) performing terrain surface creation of a region where a watershed is located in a Unity digital twin watershed simulation platform:
in a simulation coordinate system, the topographic map is provided with xSize points in each row along the X direction and zSize points in each column along the Z direction, wherein the xSize points are shared, and the X coordinate and the Z coordinate corresponding to each point are assigned, wherein the coordinate value of the vertex at the lower left corner in 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 the coordinate information of the corresponding position of the surface of the ground in the Unity digital twin basin platform, and storing the coordinate information; and then obtaining the terrain surface curved surface of the region where the drainage basin is located by adopting a triangle definition method.
Further optimization, converting coordinate values of points on the terrain in the region of the drainage basin in a world coordinate system into coordinate values of a simulation coordinate system, and specifically comprising the following steps:
setting the position of the point A on the topographic map to coincide with an original point O in the simulation coordinate system, and setting the coordinate of the point A on an XOZ plane of the simulation coordinate system to be (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 point and the coordinate value of the X' axis of the point A in the world coordinate system; similarly, the coordinate value of the Z axis of other points on the topographic map in the simulated coordinate system is the difference between the point and the coordinate value of the Z' axis of the point A 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 then subtracting D from the Y' -axis coordinate value of each point in the world coordinate system to obtain the Y-axis coordinate of each point in the simulated coordinate system; thus, three-dimensional coordinate values of all points on the topographic map in the region of the watershed in the simulated coordinate system are obtained.
Further optimizing, and obtaining the terrain surface curved surface of the region where the drainage basin is located by adopting a triangle definition method, wherein the method specifically comprises the following steps:
the grid vertexes of xSize × zSize are arranged according to the following rule: the index of the grid points of the first line is 0-xSize, the index of the grid points of the second line is xSize-2 (xSize + 1) -1, ..., and the index of the grid points of the last line is (zSize-1) × (xSize + 1) -1-zSize: (xSize + 1) -1.
Triangles are defined by the vertex index array and arranged clockwise, and then the triangles are considered forward and visible, and the anti-clockwise triangles are discarded; each mesh surface is generated by two triangles, and the 6 vertex indexes corresponding to the two triangles close to the vertex at the lower left corner 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 circularly traversing all the grids according to the indexing mode to generate a large terrain grid.
Further optimization, in the step S2, drawing a target river grid, specifically including the following steps:
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 zone in a Unity digital twin basin simulation platform, and symmetrically distributing the vertexes on the grid zone on two sides of the curve L.
S2.2, building a Vector3 format list and storing the coordinate information of the river control point; and (5) establishing an Int type list, and storing 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; obtaining a river water plane vector V through cross multiplication, adding or subtracting half of the width of the river at the corresponding position in the direction of the vector V, and solving the vertex coordinates of two sides of the control point P1; and sequentially calculating the coordinate values of the vertexes of the two sides of all the river control points by the same method.
And S2.4, drawing river grids in the same way as the terrain drawing method.
Further optimization, 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) The water flow is made to flow along the river direction:
firstly, calculating the displacement of a vertex, shifting the relevant vertex in the corresponding direction according to a vector formed by adjacent river control points, adding a position component of a model space to the shift, multiplying the position component by a coefficient to control the wavelength, and finally multiplying a result value by the coefficient to control the fluctuation amplitude to obtain the final shift to simulate the water flow in a flow domain;
2) Fitting the terrain with rivers:
lifting all vertexes on the topographic map to the same height, then taking each vertex on the topographic map as a starting point, emitting rays downwards, and judging whether the rays collide into a river grid;
if the collision occurs, the vertex corresponding to the terrain map grid is sunken downwards for a designated depth, and the sunken degree of the vertex is finely adjusted according to texture coordinates of a collision point in a shader and a cross section curve in the width direction of the river, so that the transition between a river bed and the terrain is more natural;
3) Increase of foam in the water stream:
a foam texture map is newly added in the Unity scene, the river Mesh acquires color information of a corresponding position through a texture sampler, and the color information is added into 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 of the river Mesh on the Y axis of the world coordinate system, and the smaller the projection is, the steeper the projection is, the more the corresponding foams are;
4) Adding Perlin noise texture:
the process of realizing sea wave visualization by utilizing the generated Perlin noise texture comprises the following steps:
4.1 Select a suitable random function, name this function noise, set the seed to 1000;
4.2 For any point (a)x’,y') are provided, by the location of four vertices nearby (x 0 ,y 0 )、(x 0 ,y 1 )、(x 1 ,y 0 ) And (a)x 1 , y 1 ) Calculate each point pair: (x’,y') key value of random number:
Figure SMS_2
in the formula (I), the compound is shown in the specification,d(x 0 ,y 0 ) Is a point (x 0 ,y 0 ) The gradient of (d);
4.3 By an interpolation function 3p 2 -2p 3 And respectively processing the calculation results of the above formula:
Figure SMS_3
processing a and b in the y' direction, and obtaining an interpolation result which is a point (a)x’,y') Perlin noise function valueq:
Figure SMS_4
The above formula 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 SMS_5
in the formula, the set duration is 1/2, and N is the total frequency number;
4.4 Finally, sampling the noise texture through variables related to time to obtain corresponding normal information, and then performing normal refraction and reflection calculation to obtain the final water surface fluctuation effect;
5) Adding Fresnel reflection:
in the real-time rendering of the Unity scene, a Schlick fresnel approximation formula is adopted:
Figure SMS_6
wherein the content of the first and second substances,F 0 is a reflection coefficient, is used to control the intensity of the fresnel reflection,vis the direction of the angle of view,ris the surface normal.
Compared with the prior art, the invention has the following beneficial effects:
1. according to the method, the terrain generated in the GIS plug-in can be well matched with the river in the current watershed simulation process through coordinate change, grid division, spline curve fitting, spline surface adding, shader adding and the like, so that the river can be accurately displayed in the corresponding terrain area.
2. The invention completes the modeling of the riverbed terrain and generates good interaction with water. And a foundation is laid for the follow-up realization of flood submergence and rain condition forecast and early warning. The simulated watershed based on the digital twin facilitates water conservancy workers to observe the situation of the watershed more visually, analysis and evaluation are carried out on the basis of a preview result, the corresponding measures such as water conservancy project operation, emergency scheduling and personnel disaster prevention are adjusted more timely, and the scientificity and operability of a plan are improved effectively.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of a digital twin-based watershed modeling method of the invention;
FIG. 2 is a topographic view of the village-wearing dam basin of the present invention;
FIG. 3 is a schematic diagram of a mesh vertex in the invention;
FIG. 4 is a diagram illustrating a mesh vertex index;
FIG. 5 is a topographic map generated by simulation in example 1;
FIG. 6 is an enlarged partial view of FIG. 5;
FIG. 7 is an effect diagram of river and terrain modeling in accordance with example 1;
fig. 8 is a partially enlarged view of fig. 7.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this embodiment, the village dam watershed is used as a target watershed, and the village dam watershed is located in the east prefecture of Shandong province and is a tributary in the Wen river. As shown in fig. 1, a digital twin-based watershed modeling method includes the following steps:
step S1: acquiring geographic data of an area where a drainage basin is located, processing the geographic data in modeling software Unity, determining a curved surface fitting function of a terrain surface, and obtaining curved 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;
and 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: acquiring geographic data of a region where the drainage basin is located:
acquiring geographic data of an area where a drainage basin is located through a GIS (geographic information system), wherein the geographic data comprise a topographic map of the area where the drainage basin is located, longitude and latitude information and elevation information of different positions, namely coordinate information of different position points in a world coordinate system; wherein the topographical view is shown in figure 2.
In the present embodiment, the geographical data of the village-wearing dam basin in the world coordinate system is given, and due to space limitation, part of the data is given as shown in table 1.
TABLE 1 partial geographic data of the village-wearing dam basin in the world coordinate system
Figure SMS_7
Step S1.2: data processing:
establishing a three-dimensional rectangular coordinate system OXZY in Unity, and recording as a simulation coordinate system; selecting an XOZ plane as a horizontal plane, expressing the Y-axis direction as the terrain height, observing from the direction vertical to the XOZ plane, enabling a terrain map of an area where a drainage basin is located to be rectangular in the XOZ plane, setting an end point of the lower left corner of the terrain map as a coordinate origin O, converting coordinate values of all points in the area where the drainage basin is located in a world coordinate system into coordinate values in a simulation coordinate system, and integrating data subjected to coordinate conversion into a table file in an XLSX format. In the embodiment, the coordinate-transformed data of the real-world geographic data of the village-wearing dam basin is given, and due to space limitation, part of the data is given, as shown in table 2, and the sequence numbers in table 2 correspond to those in table 1.
TABLE 2 data after coordinate transformation
Figure SMS_8
In this embodiment, in step S1.2, the converting coordinate values of the points on the terrain in the region of the drainage basin in the world coordinate system into coordinate values of the simulation coordinate system specifically includes the following steps:
setting the position of the point A on the topographic map to coincide with the origin O in the simulation coordinate system, and setting the coordinate of the point A on the XOZ plane of the simulation coordinate system to be (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 A and the coordinate value of the point A in the world coordinate system; similarly, the coordinate value of the Z axis of other points on the topographic map in the simulated coordinate system is the difference between the point and the coordinate value of the Z' axis of the point A 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 then subtracting D from the Y' -axis coordinate value of each point in the world coordinate system to obtain the Y-axis coordinate of each point in the simulated coordinate system; thus, three-dimensional coordinate values of each point on the topographic map in the watershed area in the simulated coordinate system are obtained.
Step S1.3: determining a surface fitting function:
s1.3.1: according to the coordinate data integrated in the step S1.2, selecting the coordinates of a group of points with the same X-axis coordinate value to fit to obtain a B-spline curve, selecting the coordinates of another group of points with the same X-axis coordinate value to fit to obtain another B-spline curve, and sequentially fitting to obtain (A), (B) and (C)m+ 1) B-spline curves in the X-axis direction; by the same method, fit outn+ 1) B-spline curves in the Z-axis direction;m、nare all positive integers greater than 3.
In this embodiment, coordinates of a group of points with X-axis coordinate values all being 0 are selected, and a B-spline curve is obtained by fitting, as shown in table 3.
TABLE 3 coordinate values of a set of points for which the X-axis coordinate values are all 0
Figure SMS_9
Figure SMS_10
And selecting 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 4 coordinate values of a set of points whose Z-axis coordinate values are all 0
Figure SMS_11
Figure SMS_12
Similarly, a plurality of spline curves are obtained, and are not repeated one by one due to space limitation.
S1.3.2: building a fitting B spline for multiple times in the X and Z directions by the B spline curve obtained in the step S1.3.1The curved surface specifically is: (m+ 1B-spline curve in X-axis direction and: (A)nThe B spline curves of the (1) strips in the Z-axis direction are intersected to obtain (I)m+1)×(n+1 control points, wherebym+1)×(n+1 control points form a control grid, and the parameter node vectors in the X and Z directions are X = [, ], respectivelyx 0 ,x 1 ,…,x m k++1 ],Z=[z 0 ,z 1 ,…,z n l++1 ](ii) a The equation for a B-spline surface is as follows:
Figure SMS_13
in the formulaF i,j For a control point set, i.e. a set of points in a three-dimensional point cloud,i=0,1…m,j=0,1…n;N i,k (x) AndN j,l (z) is a B-spline surface basis function, whereinkAndlpower of the spline curve, subscriptiAndjthe serial number of the B spline curve is represented;
in this embodiment, the equation of the curved surface obtained from the spline curve is:
Figure SMS_14
step S1.4: performing target area terrain surface creation in a Unity digital twin basin simulation platform:
in the simulation coordinate system, the topographic map has xSize points in each row along the X direction and zSize points in each column along the Z direction, and the xSize points and the zSize points are shared, 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 at the lower left corner in 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 the coordinate information of the corresponding position of the surface of the ground in the Unity digital twin basin platform, and storing the coordinate information; and then obtaining the terrain surface curved surface of the target area by adopting a triangle definition method. The method specifically comprises the following steps: the grid vertexes of xSize × zSize are arranged according to the following rule: the index of the grid points in the first row is 0-xSize, the index of the grid points in the second row is xSize-2: (xSize + 1) -1, ..., and the index of the grid points in the last row is (zSize-1) (xSize + 1) -1-zSize: (xSize + 1) -1.
Triangles are defined by the vertex index array, as shown in FIG. 4, arranged in a clockwise direction, then triangles are considered forward and visible, and anti-clockwise triangles are discarded; each mesh surface is generated by two triangles, and the indexes of 6 vertexes corresponding to two triangles close to the vertex at the lower left corner 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, circularly traversing all the grids 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: selecting a plurality of control points to generate a Catmull-Rom curve L with the same shape as the river in the target area, setting the target river as a grid zone in the Unity digital twin basin simulation platform, and symmetrically distributing the vertexes on the grid zone on two sides of the curve L.
In this embodiment, the Catmull-Rom curve L of the village dam drainage basin is:
Figure SMS_15
s2.2, a Vector3 format list is newly built to store the coordinate information of the river control points, and an Int type list is newly built 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 then taking a Y axis as a Y' axis of a world coordinate system; obtaining a river water plane vector V through cross multiplication, and adding or subtracting a half of the corresponding river width in the direction of the vector V to obtain vertex coordinates of two sides of the control point P1; sequentially solving the coordinate values of the vertexes of the two sides of all the river control points by using the same method;
and S2.4, drawing river grids in the same way as the terrain drawing method.
In this embodiment, in step S3, a new material is created in the Unity digital twin basin simulation platform, and the new material is named WaterMat. And newly building a Unity Shader named Shader-Water. Adding the newly-built Shader to the material. The newly created shader is turned on, declaring the following attributes: mainTex is the river texture, color is used to control the overall Color, magnetic is used to control the amplitude of the water flow fluctuation, frequency is used to control the fluctuation Frequency, invWaveLength is used to control the inverse of the wavelength, the larger the InvWaveLength value, the smaller the wavelength, speed is used to control the Speed of movement of the river texture.
The following functions of simulating rivers are realized by adding shaders:
1) The water flow is made to flow along the river direction:
the method comprises the steps of firstly calculating vertex displacement, shifting relevant vertexes in corresponding directions according to vectors formed by adjacent river control points, adding position components of a model space to the shifts, multiplying the position components by a coefficient _ InvWaveLength control wavelength, and multiplying a result value by a coefficient _ Magnitude to control fluctuation amplitude to obtain final shift, so that water flow in a simulated flow domain is realized.
2) Fitting the terrain with a river:
lifting 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 rays collide into river meshes;
and if the vertex is collided, the vertex corresponding to the terrain map grid is sunken downwards by a specified depth, and the vertex sunken degree is finely adjusted according to the UV of the collision point and the specified animationCurve, so that the river bed and the terrain transition is more natural.
3) Increase of foam in the water stream:
and newly adding a foam texture map in the Unity scene, acquiring color information of a corresponding position by the river Mesh through a texture sampler, and adding the color information into a final output result of the fragment shader to realize the effect of generating foam. In addition, the terrain gradient is judged by projecting the current normal of the river Mesh on the Y axis of the world coordinate system, and the smaller the projection is, the steeper the projection is, the more the corresponding foams are.
4) Adding Perlin noise texture:
the process of realizing sea wave visualization by utilizing the generated Perlin noise texture comprises the following steps:
4.1 Select a suitable random function, name this function noise, set the seed to 1000;
4.2 For any point (a)x’,y') are provided, by the location of four vertices nearby (x 0 ,y 0 )、(x 0 ,y 1 )、(x 1 ,y 0 ) And (a)x 1 , y 1 ) Calculating each point pair (x’,y') key value of random number:
Figure SMS_16
in the formula (I), the compound is shown in the specification,d(x 0 ,y 0 ) Is a point (x 0 ,y 0 ) The gradient of (d);
4.3 By an interpolation function 3p 2 -2p 3 And respectively processing the calculation results of the above formulas:
Figure SMS_17
processing a and b in the y' direction, and obtaining an interpolation result which is a point (a)x’,y') Perlin noise function valueq:
Figure SMS_18
The above formula 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 SMS_19
in the formula, the set duration is 1/2, and N is the total frequency number;
4.4 Finally, sampling the noise texture through variables related to time to obtain corresponding normal information, and then performing normal refraction and reflection calculation to obtain the final water surface fluctuation effect;
5) Adding Fresnel reflection:
in the real-time rendering of the Unity scene, a Schlick fresnel approximation formula is adopted:
Figure SMS_20
wherein the content of the first and second substances,F 0 is a reflection coefficient, is used for controlling the intensity of Fresnel reflection,vis the direction of the viewing angle and,ris the surface normal. By adding Fresnel reflection, the simulated river water is almost transparent, and small fish and stones at the bottom of the river can be seen; however, when looking at a distant water surface, the underwater scene can hardly be seen, and only the environment reflected by the water surface can be seen, so that the simulated river is more vivid. Therefore, the reflection is added to ensure that the integrally simulated river is more vivid and a better visual effect is obtained.
In the present embodiment, the generated topographic map is simulated, as shown in fig. 5, and fig. 6 is a partially enlarged view of fig. 5. Fig. 7 is a diagram showing effects of a river in cooperation with terrain modeling, and fig. 8 is a partially enlarged view of fig. 7.
In light of the foregoing description of the preferred embodiment of the present invention, many modifications and variations will be apparent to those skilled in the art without departing from the spirit and scope of the invention. The scope of the invention is not limited to the description, but should be determined with reference to the appended claims.

Claims (6)

1. A digital twin-based watershed modeling method is characterized by comprising the following steps:
step S1: acquiring geographic data of a region where a drainage basin is located, processing the geographic data in modeling software Unity, determining a curved surface fitting function of a topographic surface, and obtaining curved surface information of the topographic surface;
step S2: drawing a target river grid on the curved surface of the terrain surface acquired in the step S1;
and step S3: and adding a shader to the target river grid to simulate a target river basin.
2. The digital twin-based watershed modeling method according to claim 1, wherein the step S1 specifically comprises the following steps:
step S1.1: acquiring geographic data of a region where a drainage basin is located:
acquiring geographic data of a region of a drainage basin through a GIS (geographic information system), wherein the geographic data comprises a topographic map of the region of the drainage basin, and longitude and latitude information and elevation information of different positions, namely coordinate information of different position points in a world coordinate system;
step S1.2: data processing:
establishing a three-dimensional rectangular coordinate system OXZY in Unity, and recording as a simulation coordinate system; selecting an XOZ plane as a horizontal plane, expressing the Y-axis direction as the terrain height, observing from the direction vertical to the XOZ plane, converting coordinate values of all points in the area of the drainage basin in a world coordinate system into coordinate values in a simulation coordinate system by setting the endpoint of the lower left corner of the terrain map as a coordinate origin O, and integrating the data subjected to coordinate conversion 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 the coordinate of a group of points with the same X-axis coordinate value to fit to obtain a B-spline curve, selecting the coordinate of another group of points with the same X-axis coordinate value to fit to obtain another B-spline curve, and sequentially fitting to obtain (A), (B) and (B)m+ 1) B-spline curves in the X-axis direction(ii) a By the same method, fit outn+ 1) B-spline curves in the Z-axis direction;m、nare all positive integers greater than 3;
s1.3.2: building a fitting B spline surface for multiple times in the X and Z directions of the B spline curve obtained in the step S1.3.1, specifically: (m+ 1B-spline curve in X-axis direction and: (A)nThe B spline curves of the (1) strips in the Z-axis direction are intersected to obtain (I)m+1)×(n+1 control points, wherebym+1)×(n+1 control points form a control grid, and the parameter node vectors in the X and Z directions are X = [, ], respectivelyx 0 ,x 1 ,…,x m k++1 ],Z=[z 0 ,z 1 ,…,z n l++1 ](ii) a The equation for a B-spline surface is as follows:
Figure QLYQS_1
in the formulaF i,j For a control point set, i.e. a set of points in a three-dimensional point cloud,i=0,1…m,j=0,1…n;N i,k (x) AndN j,l (z) is a B-spline surface basis function, whereinkAndldenotes the power, subscript, of the spline curveiAndjthe serial number of the B spline curve is represented;
step S1.4: the method comprises the following steps of (1) performing terrain surface creation of a region where a watershed is located in a Unity digital twin watershed simulation platform:
in a simulation coordinate system, the topographic map is provided with xSize points in each row along the X direction and zSize points in each column along the Z direction, wherein the xSize points are shared, and the X coordinate and the Z coordinate corresponding to each point are assigned, wherein the coordinate value of the vertex at the lower left corner in 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 the coordinate information of the corresponding position of the surface of the ground in the Unity digital twin basin platform, and storing the coordinate information; and then obtaining the terrain surface curved surface of the region where the drainage basin is located by adopting a triangle definition method.
3. The digital twin-based watershed modeling method according to claim 2, wherein in step S1.2, the coordinate values of the points on the terrain in the region of the watershed in the world coordinate system are converted into coordinate values of the analog coordinate system, and the method specifically comprises the following steps:
setting the position of the point A on the topographic map to coincide with the origin O in the simulation coordinate system, and setting the coordinate of the point A on the XOZ plane of the simulation coordinate system to be (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 point and the coordinate value of the X' axis of the point A in the world coordinate system; similarly, the coordinate value of the Z axis of other points on the topographic map in the simulation coordinate system is the difference between the point and the coordinate value of the Z' axis of the point A 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 then subtracting D from the Y' -axis coordinate value of each point in the world coordinate system to obtain the Y-axis coordinate of each point in the simulated coordinate system; thus, three-dimensional coordinate values of each point on the topographic map in the watershed area in the simulated coordinate system are obtained.
4. The digital twin-based watershed modeling method according to claim 3, wherein in the step S1.4, the terrain surface curved surface of the region where the watershed is located is obtained by a triangle definition method, and the method specifically comprises the following steps:
the grid vertices of xSize × zSize are arranged according to the following rule: the index of the grid points in the first row is 0-xSize, the index of the grid points in the second row is xSize-2: (xSize + 1) -1, ..., the index of the grid points in the last row is (zSize-1) (xSize + 1) -1-zSize: (xSize + 1) -1;
triangles are defined by the vertex index array and arranged clockwise, and then the triangles are considered forward and visible, and the anti-clockwise triangles are discarded; each mesh surface is generated by two triangles, and the 6 vertex indexes corresponding to the two triangles close to the vertex at the lower left corner 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 circularly traversing all the meshes according to the index mode to generate a large terrain mesh curved surface.
5. The digital twin-based watershed modeling method according to claim 4, wherein in the step S2, a target river grid is drawn, and the method specifically comprises the following steps:
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 zone in a Unity digital twin basin simulation platform, wherein the vertexes on the grid zone are symmetrically distributed on two sides of the curve L;
s2.2, building a Vector3 format list and storing the coordinate information of the river control point; newly building an Int type list, and storing 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; obtaining a river water plane vector V through cross multiplication, adding or subtracting half of the width of the river at the corresponding position in the direction of the vector V, and solving the vertex coordinates of two sides of the control point P1; sequentially solving the coordinate values of the vertexes of the two sides of all the river control points by using the same method;
and S2.4, drawing river grids in the same way as the terrain drawing method.
6. The digital twin-based watershed modeling method according to claim 5, wherein in the step S3, in the Unity digital twin watershed simulation platform, the following functions of the target river are realized by adding a shader:
1) The water flow is made to flow along the river direction:
firstly, calculating the displacement of a vertex, shifting the relevant vertex in the corresponding direction according to a vector formed by adjacent river control points, adding a position component of a model space to the shift, multiplying the position component by a coefficient to control the wavelength, and finally multiplying a result value by the coefficient to control the fluctuation amplitude to obtain the final shift to simulate the water flow in a flow domain;
2) Fitting the terrain with rivers:
lifting all vertexes on the topographic map to the same height, then taking each vertex on the topographic map as a starting point, emitting rays downwards, and judging whether the rays collide into a river mesh;
if the collision occurs, the vertex corresponding to the terrain map grid is sunken downwards for a designated depth, and the sunken degree of the vertex is finely adjusted according to texture coordinates of a collision point in a shader and a cross section curve in the width direction of the river, so that the transition between a river bed and the terrain is more natural;
3) Increase of foam in water flow:
a foam texture map is newly added in the Unity scene, the river Mesh acquires color information of a corresponding position through a texture sampler, and the color information is added into 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 of the river Mesh on the Y axis of the world coordinate system, and the smaller the projection is, the steeper the projection is, the more the corresponding foams are;
4) Adding Perlin noise texture:
the process of realizing sea wave visualization by utilizing the generated Perlin noise texture comprises the following steps:
4.1 Select a suitable random function, name this function noise, set the seed to 1000;
4.2 For any point: (x’,y') through four vertex positions in the vicinity (x 0 ,y 0 )、(x 0 ,y 1 )、(x 1 ,y 0 ) And (a)x 1 ,y 1 ) Calculating each point pair (x’,y') key value of random number:
Figure QLYQS_2
in the formula (I), the compound is shown in the specification,d(x 0 ,y 0 ) Is a point (x 0 ,y 0 ) The gradient of (d);
4.3 By an interpolation function 3p 2 -2p 3 And respectively processing the calculation results of the above formulas:
Figure QLYQS_3
processing a and b in the y' direction, and obtaining an interpolation result which is a point (a)x’,y') Perlin noise function valueq:
Figure QLYQS_4
The above formula 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 QLYQS_5
;/>
in the formula, the set duration is 1/2, and N is the total frequency number;
4.4 Finally, sampling the noise texture through variables related to time to obtain corresponding normal information, and then performing normal refraction and reflection calculation to obtain the final water surface fluctuation effect;
5) Adding Fresnel reflection:
in the real-time rendering of the Unity scene, a Schlick fresnel approximation formula is adopted:
Figure QLYQS_6
wherein the content of the first and second substances,F 0 is a reflection coefficient, is used to control the intensity of the fresnel reflection,vis the direction of the angle of view,ris the surface normal.
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 true CN115983162A (en) 2023-04-18
CN115983162B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116757004A (en) * 2023-08-21 2023-09-15 长江空间信息技术工程有限公司(武汉) 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 (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070038421A1 (en) * 2005-05-18 2007-02-15 Microsoft Corporation River Modeling
CN104318617A (en) * 2014-10-17 2015-01-28 福建师范大学 Three-dimensional geographical scene simulation method for virtual emergency exercises
CN105631168A (en) * 2016-03-25 2016-06-01 中国水利水电科学研究院 Real-time and efficient drainage basin flood routing visual simulation method
KR101912627B1 (en) * 2017-05-30 2018-10-30 에스지에이블록체인 주식회사 Method for Integration Visualizing GIS based Runoff-Hydraulic Model Analysis result
CN112860839A (en) * 2021-04-23 2021-05-28 成都四方伟业软件股份有限公司 Water environment quality real-time monitoring method and device based on Unity3D
CN113158451A (en) * 2021-04-08 2021-07-23 中国水利水电科学研究院 Large-area river three-dimensional simulation method based on one-dimensional flood routing model
CN113283095A (en) * 2021-05-31 2021-08-20 中国水利水电科学研究院 Evolutionary digital twin watershed construction method
US20210286104A1 (en) * 2020-03-16 2021-09-16 River Software Inc Systems, apparatus, and methods of watershed modeling and assessment
CN113628337A (en) * 2021-08-20 2021-11-09 北京优锘科技有限公司 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 (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070038421A1 (en) * 2005-05-18 2007-02-15 Microsoft Corporation River Modeling
CN104318617A (en) * 2014-10-17 2015-01-28 福建师范大学 Three-dimensional geographical scene simulation method for virtual emergency exercises
CN105631168A (en) * 2016-03-25 2016-06-01 中国水利水电科学研究院 Real-time and efficient drainage basin flood routing visual simulation method
KR101912627B1 (en) * 2017-05-30 2018-10-30 에스지에이블록체인 주식회사 Method for Integration Visualizing GIS based Runoff-Hydraulic Model Analysis result
US20210286104A1 (en) * 2020-03-16 2021-09-16 River Software Inc Systems, apparatus, and methods of watershed modeling and assessment
CN113158451A (en) * 2021-04-08 2021-07-23 中国水利水电科学研究院 Large-area river three-dimensional simulation method based on one-dimensional flood routing 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
CN113628337A (en) * 2021-08-20 2021-11-09 北京优锘科技有限公司 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

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘志成 等: "数字孪生流域方案研究", 《2022中国水利学术大会(中国水利学会2022学术年会)》, pages 195 - 199 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116757004A (en) * 2023-08-21 2023-09-15 长江空间信息技术工程有限公司(武汉) EFDC three-dimensional water quality data multi-mode deduction method based on digital twin technology
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
CN117237567B (en) * 2023-08-22 2024-05-07 珠江水利委员会珠江水利科学研究院 Visual rendering method for digital twin flood flow field

Also Published As

Publication number Publication date
CN115983162B (en) 2023-06-20

Similar Documents

Publication Publication Date Title
Génevaux et al. Terrain generation using procedural models based on hydrology
CN104766366B (en) A kind of method for building up of three-dimension virtual reality demonstration
CN115983162A (en) Basin modeling method based on digital twinning
CN108052776B (en) Flood model construction and dynamic display method based on BIM and three-dimensional live-action model
CN102663827B (en) Three-dimensional dynamic whole-process simulation method for storm surge and flood routing in complex flooding areas
Génevaux et al. Terrain modelling from feature primitives
CN105760581B (en) A kind of valley Renovation and planning emulation mode and system based on OSG
CN104835202A (en) Quick three-dimensional virtual scene constructing method
Roudier et al. Landscapes synthesis achieved through erosion and deposition process simulation
JP2005128838A (en) Simplified system for analyzing flood
CN112017285B (en) Method for accurately fitting terrain to strip-shaped model in three-dimensional GIS (geographic information System) in real time
CN114332395A (en) Method for realizing flood routing simulation based on hydraulic model and three-dimensional rendering technology
Khayyal et al. Creation and spatial analysis of 3D city modeling based on GIS data
JP5241296B2 (en) Numerical map data processing program and numerical map data processing apparatus
Borisov et al. An automated process of creating 3D city model for monitoring urban infrastructures
CN115690286B (en) Three-dimensional terrain generation method, terminal device and computer readable storage medium
CN101763659B (en) Method for automatically generating large-scale digitization altitude data model based on image set
Giannakidis et al. 3D photorealistic scientific visualization of tsunami waves and sea level rise
Cornel et al. Integrated Simulation and Visualization for Flood Management
CN117456074B (en) Three-dimensional rendering method and equipment for offshore wind power scouring pit based on digital twin simulation
CN109147041A (en) A kind of water bodies management analogue system based on virtual reality technology
CN114627258B (en) Method and system for isomorphic modeling of gravity field catamaran spheres
CN114103127B (en) Drainage basin terrain 3D printing method and device, electronic equipment and storage medium
CN112233237B (en) Water area leveling processing method and computer equipment for manufacturing digital elevation model
Yang et al. Predicting flood inundation and risk using geographic information system and hydrodynamic model

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