MIKE ZERO: Creating 2D Bathymetries: Bathymetry Editor & Mesh Generator
MIKE ZERO: Creating 2D Bathymetries: Bathymetry Editor & Mesh Generator
mikebydhi@dhigroup.com
www.mikebydhi.com
PLEASE NOTE
COPYRIGHT This document refers to proprietary computer software,
which is protected by copyright. All rights are reserved.
Copying or other reproduction of this manual or the related
programs is prohibited without prior written consent of DHI.
For details please refer to your 'DHI Software Licence
Agreement'.
LIMITED LIABILITY The liability of DHI is limited as specified in Section III of
your 'DHI Software Licence Agreement':
'IN NO EVENT SHALL DHI OR ITS REPRESENTA-
TIVES (AGENTS AND SUPPLIERS) BE LIABLE FOR
ANY DAMAGES WHATSOEVER INCLUDING,
WITHOUT LIMITATION, SPECIAL, INDIRECT,
INCIDENTAL OR CONSEQUENTIAL DAMAGES OR
DAMAGES FOR LOSS OF BUSINESS PROFITS OR
SAVINGS, BUSINESS INTERRUPTION, LOSS OF
BUSINESS INFORMATION OR OTHER PECUNIARY
LOSS ARISING OUT OF THE USE OF OR THE
INABILITY TO USE THIS DHI SOFTWARE PRODUCT,
EVEN IF DHI HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. THIS
LIMITATION SHALL APPLY TO CLAIMS OF
PERSONAL INJURY TO THE EXTENT PERMITTED
BY LAW. SOME COUNTRIES OR STATES DO NOT
ALLOW THE EXCLUSION OR LIMITATION OF
LIABILITY FOR CONSEQUENTIAL, SPECIAL,
INDIRECT, INCIDENTAL DAMAGES AND,
ACCORDINGLY, SOME PORTIONS OF THESE
LIMITATIONS MAY NOT APPLY TO YOU. BY YOUR
OPENING OF THIS SEALED PACKAGE OR
INSTALLING OR USING THE SOFTWARE, YOU
HAVE ACCEPTED THAT THE ABOVE LIMITATIONS
OR THE MAXIMUM LEGALLY APPLICABLE SUBSET
OF THESE LIMITATIONS APPLY TO YOUR
PURCHASE OF THIS SOFTWARE.'
1 INTRODUCTION .............................................................................................. 1
7 REFERENCES ................................................................................................. 37
i
ii MIKE ZERO: Creating 2D Bathymetries
1 INTRODUCTION
The Bathymetry Editor and the Mesh Generator provides you an
environment for creating, editing and presenting detailed digital 2D
bathymetries. The Bathymetry Editor generates bathymetries in a
rectangular grid (dfs2) whereas the Mesh Generator generates
bathymetries in a flexible mesh format (mesh).
The program provides you the utilities for importing raw data from
various external source (i.e. xyz soundings, xyz contours, MIKE 21 /
MIKE 3 formatted data), or to manually create data by using the built-
in drawing tools. To aid the process of manually drawing data and for
presentation, graphical background images such as maps can be
imported and overlaid with the bathymetry data.
Figure 1.1 Example of import of raw data into a Bathymetry Editor workspace
The purpose of this document is to provide the user with the scientific
background for the 2D bathymetry generation.
1
The generation of a bathymetry is generally divided into two phases:
In the process of creating the grid the limiting bathymetry value for a
cell to be recognized as a land cell must be defined.
3
4 MIKE ZERO: Creating 2D Bathymetries
3 GRID INTERPOLATION
Before the interpolation starts an empty bathymetry is created. This
means that it contains only delete values. The interpolation of a
bathymetry is done in 3 steps:
• Finding the grid cells that have a centre inside the land polygons
identifies all the land points. This is known as Land Generation.
• The grid cells that aren’t land points needs to be assigned a depth.
The grid is used for sorting the data (loose points, contour points
and polygon vertices). All points used for the interpolation are
distributed into optional lookup-tables for each grid cell. This
enables a much more efficient search instead of something which
is proportional to number of horizontal grid cells times number of
vertical grid cells times number of raw data points. This is known
as Box Grouping
• Only grid cells defining land have been assigned an elevation (z-
value). Each of the remaining points needs to be assigned. The raw
data points are used for this interpolation. This is the Gap Filling
process.
The polygon fill algorithm defines a set of scan lines aligned with the
bottom of the bathymetry. There is a scan line defined for each k-grid
cell. For each scan line the list of polygons is searched and points
inside these polygons are marked as land points according to the
algorithm described on the two figures below. This is by far the most
efficient algorithm for identifying cells inside polygons.
5
Figure 3.1 Polygon Sweep-Line Algorithm
3.1.2 Extensive
The extensive method for computing land points loops over the total
number of grid points in a bathymetry and check versus inside/outside
boundaries of the polygon. This is significantly more time consuming
than the ‘Polygon fill’-algorithm.
All raw data points are attached to the grid cell that they are located in.
By doing this it is very easy to search through the raw data points and
identifying the points located close to the grid point.
This technique finds four points from the raw data set - one in each
quadrant. The search is done in the following way. A mask of relative
indices is created. The cells in this mask are sorted according to the
distance. For the quadrant Q1 the cells are sorted in the following way,
the grid point itself being excluded.
Note that the grid cells with a crosshatch pattern contain raw data
points. When the closest raw data point in each quadrant is found, we
have four points that form a quadrangle. This quadrangle contains the
centre point, where we want to calculate the z-value. This is illustrated
in Figure 3.4.
7
Figure 3.4 Illustration of the closest raw data points in each quadrant
Note that each grid cell might contain more raw data points. If this is
the case, the closest of these is chosen. We now have an irregular
quadrangle, where the elevation is defined in each vertex. We need to
compute the elevation in (xc, yc). If we transform our quadrangle into a
square, we can perform bilinear interpolation. This is illustrated in
Figure 3.5.
Mapping the coordinates (xc, yc) to the normalized square (dx, dy) is
done by solving Equation (3.2).
ax 2 bx c 0 (3.2)
a D1 B2 D2 B1
b D2 xc D1 y c D2 A1 D1 A2 C1 B2 C 2 B1 (3.3)
c C 2 xc C1 y c C1 A2 C 2 A1
b b 2 4ac
dx (3.4)
2a
xc A1 B1 dx
dy (3.5)
C1 D1 dx
or
xc A2 B2 dx
dy (3.6)
C 2 D2 dx
Choosing between Equations (3.5) and (3.6) is done in such a way that
division by zero is avoided. (xc, yc) has been mapped to (dx, dy). The
task was to compute the elevation in the point (xc, yc) and this is done
in the following way using regular bilinear interpolation:
9
z c 1 dx 1 dy z 2 dx1 dy z3 1 dx dy z1 dxdy z 0
(3.7)
If less than four points are found (if one or more quadrants are empty),
the double linear interpolation is replaced with inverse distance
weighted interpolation. This is done according to the following
scheme:
1
wi
xi xc 2 yi yc 2
(3.8)
N
ws wi (3.9)
i 1
N
1
zc
ws
w z
i 1
i i (3.10)
The method works fairly efficiently, but it has one drawback. The
quadrant search is heavily dependent on the orientation of the
bathymetry. If the bathymetry is rotated 45 degrees 4 completely
different points might be used for the interpolation. For this reason
there is also a Triangular interpolation method, which can be used, and
this method should be direction independent.
y1 y 0 z 2 z 0 y 2 y 0 z1 z 0
A
x1 x0 y 2 y0 x2 x0 y1 y0
B
x1 x0 z 2 z 0 x2 x0 z1 z 0 (3.11)
x1 x0 y 2 y0 x2 x0 y1 y0
C z 0 Ax 0 By 0
z c Ax c By c C (3.12)
11
1
wi
xi x c yi yc
2 2 (3.13)
N
ws wi (3.14)
i 1
N
1
zc
ws
w z
i 1
i i (3.15)
• Set properties for each (default values used if local properties are
not supplied)
• Use the triangular mesh approach for the area not contained within
any of the polygons.
Thus the overall idea is to generate the quadrangular mesh first and
then to use the triangular mesh to patch the mesh together.
The first of these is robust but may generate skewed grids. The second
is efficient but may not always be successful.
13
4.2.1 Algebraic Box Method
The aim is to generate a mesh for a polygon which aligns itself with
the polylines that make up the polygon. The main idea is to break any
closed polygon into quadrangles. Below is a polygon consisting of two
polylines l1 and l2 with a number of vertices. The number of vertices
on each polyline may be unequal in general. The polylines are joined
by two arcs. These end arcs consist each of only one line segment. The
polygon is considered as an abstraction of a stream tube i.e. the flow
direction is in the direction of the two polylines and the end arcs are
transversal to the flow direction. Ideally the end arcs should be chosen
so that these are perpendicular to the flow direction.
Vertex
Node
l1 End arc
l2
Figure 4.1 The polygon to be meshed. The vertices are displayed along with the
end arcs
Figure 4.2 The polygon with the interpolated complementary vertices displayed.
The polygon has now been divided into a number of quadrangles
Figure 4.3 A mesh is applied for each of the quadrangles in the polygon. Note that
the number of intervals in the t direction is fixed for all individual boxes
whereas the number in the s direction may vary significantly
vi
N t Ceiling max i 1,...M
(4.1)
t
15
Where v i is the length of the vertex pair i.
S2
(x0,Nt,y0,Nt) (xNs,Nt,yNs,Nt)
(xNs,0,yNs,0)
(x0,0,y0,0) S1
The notation for the quadrangles follows from the above figure. The
individual quadrangles should be meshed in the following way. First
the number of intervals in the s-direction is determined through
max( s1 , s 2 )
N s Ceiling (4.2)
s
Where
Once the number intervals is known the node locations may be found
through
i j i j
y i , j 1 1 y 0, 0 1 y N s , 0
N s N t Ns Nt
j i i j
1 y 0, N t y N ,N
Nt Ns N s Nt s t
Where
17
4.2.2 Transfinite Interpolation
‘East’
‘North’
‘West’
‘South’
Figure 4.6 The notation used for the transfinite interpolation grid generation
The grid points along the polylines must obey the location of the
original vertices. Thus the concept of vertex pairs for opposing
polylines should be used. Though note that the vertex pairs no-longer
by default are connected by a straight line due to the piecewise linear
nature of the end arcs.
‘East’
‘North’
‘West’
‘South’
Figure 4.7 The polygon with the original vertices along with the interpolated
vertices. Opposing polylines have identical number of total vertices.
Note that the end arcs also have additional interpolated vertices.
19
The number of grid points along the arcs is controlled by the
maximum grid element side length. More specifically a length is
applied for the and directions. This length is non-dimensionalised
by the maximum arc lengths in the respective direction. For example,
the maximum side length in the direction is denoted by s. This
value shall be used to define the location of the mesh nodes along the
‘south’ and ‘north’ polylines.
This value must be satisfied for all line segments along the ‘south’ and
‘north’ polylines. The approach is to determine the number of intervals
for the line segment i through
N ,i Ceiling i i 1 (4.9)
The procedure for the ‘west’ and ‘east’ arcs follows along the same
lines.
Figure 4.9 A triangulisation with the restriction that Steiner points are not allowed
It is especially important that the mesh routine does not insert Steiner
points along arcs which form part of a polygon designated for a
quadrangular mesh. To overcome this problem the idea is to run the
triangulisation twice. The first triangulisation is done to determine the
location of Steiner points along arcs without constraints (i.e. arcs not
part of a polygon for quadrangulisation).
Once the Steiner points have been identified along these ‘free’ arcs the
Steiner points are internally converted to vertices. The second
tringulisation is then done with the constraint that Steiner points are
not allowed. The procedure is outlined on the following pages.
21
Step 1:
Step 2:
Step 3:
Step 4:
Step 6:
Step 7:
23
4.4 Smoothing the Mesh
After the generation of the mesh it is prudent to smooth the mesh to
obtain a better applicability in a simulation. Smoothing a mesh is the
effort to position the nodes in a way such that the angles in each
element and the element area are as large as possible. The smoothing
only affects triangular mesh elements.
1 N elements
Q' N elements Q 2 Pi (4.10)
3N elements i 1
N elements
1
Q'
N elements
P
i 1
i (4.11)
The measure consists of the element area and the smallest angle in the
element. If one of these is smaller than the allowed values then the
calculated measure evaluates to false.
As can be seen from Figure 4.11, the operation will give rise to 4 new
elements per triangular element in the original mesh and 3 new
element faces.
25
Figure 4.12 Bisection of quadrangular element
As can be seen from Figure 4.12 also for the quadrangular elements
the process introduces 4 new elements per quadrangular element in the
original mesh and 4 element faces. Note that the quadrangular
elements also generate an additional mesh node on top of the ones
caused by the face bisection.
Triangular T 4T 16T
elements
Quadrangular Q 4Q 16Q
elements
∑ (∑ )
• Natural neighbour
• Linear interpolation
A B
C D
Figure 5.1 A meandering river with a point (O) at which the topography is to be
interpolated using the natural neighbour method. The crosses indicate
location at which data is located. The grey polygon illustrates the
weights of the values at A-E
As can be seen from the above figure the point B will have a
significant weight and thus impact on the interpolated value at O.
Point B is located on the opposite bank of the interpolation location O
and thus the bed level may be very different from the true value at O.
One would assume that the actual level at O is closer to the values at A
and C in the stream direction. Further the interpolation routine also
takes the values at D and E into account even though the points are
located outside the main river.
27
To create sound interpolated topographies in river beds an
interpolation routine that emphasises values in the stream direction and
does not interpolate across riverbanks has been developed for
quadrangular elements.
1
N 1 1
wi p p (5.1)
i 1 ri ri
A B
A B
E
E
C D
C D
Figure 5.2 The meandering river on the left without the mesh displayed. The right
figure illustrates the river overlaid with the mesh
Figure 5.3 The polygon displayed in the mesh coordinate system (j,k)
In the new coordinate system the points A, B and C will have the
following coordinates:
A: (jA,kA)
B: (jB,kB)
C: (jC,kC)
where q > p. The latter is to ensure that the effect of the j coordinate
decays more slowly than the effect of the k-coordinate. Both p and q
should be user defined (advanced option). Some experimentation is
needed to identify proper default values of p and q.
(x01,y01) (x11,y11)
(x,y)
(x10,y10)
(x00,y00)
Figure 5.4 A mesh element with four nodes with mesh coordinates (j,k),
(j+1,k),(j,k+1) and (j+1,k+1). The mesh coordinates of (x,y) are sought
29
The coordinates of (x,y) satisfy the following equation
Where s,t lies within the interval [0;1]. This equation may be re-
arranged as
d1 a1 b1 c
s t st 1 (5.5)
d 2 a2 b2 c2
of which the first is second order algebraic equation in s. Once the two
solutions are found t may be determined from equation number. The
true solution is the one that gives rise to a set of s and t lying within
the interval 0 to 1.
The mesh coordinates of the point (x,y) are thus given by (j+s,k+t).
∑ (5.7)
∑ (5.8)
The process is illustrated below using a set-up with three different data
sources.
31
Figure 5.5 Mesh point P in setup with three different data sources. Each scatter
data source has associated weight
After interpolation, the mesh point P will have a z value based on the
three interpolations from data source 1 to 3 weighted according to the
weights:
(5.9)
A
1
x2 x1 y3 y1 y 2 y1 x3 x1 (6.1)
2
x2 x1 x0 x1 y 2 y1 y0 y1
s 1 (6.2)
x2 x1 2 y 2 y1 2 x0 x1 2 y0 y1 2
33
The quantity S varies between 0 and 2 where 0 refers to the smallest
angle and 2 the largest.
min facelength
t CFL (6.3)
2 gh
35
36 MIKE ZERO: Creating 2D Bathymetries
References
7 REFERENCES
/1/ Jonathan Richard Shewchuk, Triangle: Engineering a 2D Quality Mesh Generator
and Delaunay Triangulator, in ``Applied Computational Geometry: Towards
Geometric Engineering'' (Ming C. Lin and Dinesh Manocha, editors), volume 1148
of Lecture Notes in Computer Science, pages 203-222, Springer-Verlag, Berlin, May
1996.
Scientific Documentation 37
Bathymetry Editor & Mesh Generator