1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
\input texinfo
@comment %**start of header
@settitle FullSWOF-utils Reference Manual
@syncodeindex pg cp
@comment %**end of header
@copying
This document describes FullSWOF-utils, a set of utility scripts to be
used with the FullSWOF shallow flow solver.
Copyright @copyright{} 2019 Paul Garlick.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the section entitled
``GNU Free Documentation License''.
@end quotation
@end copying
@dircategory Science
@direntry
* FullSWOF-utils: (FullSWOF-utils). Utility programs for the FullSWOF solver.
@end direntry
@titlepage
@title FullSWOF-utils Reference Manual
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@contents
@ifnottex
@node Top
@top FullSWOF-utils
Utility scripts for the FullSWOF shallow flow solver
@end ifnottex
@menu
* Installation:: Installing FullSWOF-utils.
* Usage::
* Demos::
* GNU Free Documentation License:: The license of this manual.
* Index:: Complete Index.
@end menu
@node Installation, Usage, Top, Top
@comment node-name, next, previous, up
@chapter Installation
@cindex chapter, installation
The @emph{fullSWOF-utils} package comprises a single top-level directory
and several sub-directories. The package may be installed in the same
location as @emph{FullSWOF} itself or any other convenient location.
@menu
* Requirements::
* Cloning::
* Uninstalling::
@end menu
@node Requirements, Cloning, Installation, Installation
@comment node-name, next, previous, up
@section Requirements
To install @emph{fullSWOF-utils} the following packages are required:
@itemize
@item
@url{https://git-scm.com/, Git}, the version control system.
@item
@url{https://www.gnu.org/software/texinfo/, Texinfo}, the GNU
documentation system.
@end itemize
@node Cloning, Uninstalling, Requirements, Installation
@comment node-name, next, previous, up
@section Cloning
FullSWOF-utils is maintained using git, the version control system. A
simple way to install the package is to clone the git repository. To do so,
first open a terminal window on a system that has git installed. Then,
from within a suitable working directory, execute the command:
@example
git clone http://cgit.tourbillion-technology.com/fullSWOF-utils
@end example
A directory named @emph{fullSWOF-utils} will be created. To complete
the installation first change directory to the new @emph{fullSWOF-utils}
directory. Then execute the command:
@example
make
@end example
This command will create the documentation for the package. The
documentation is available in two formats; GNU Info format and html.
The info file is located in the doc directory. The html files are
located in the manual directory. There are two versions.
@emph{fullswof-utils.html} contains the complete documentation set out
on one page. The subdirectory @emph{html_node} contains a top-level
@emph{index.html} file and a separate page for each node.
The info file may be read using the @command{info} program. The html
files may be read using any web browser.
@node Uninstalling, , Cloning, Installation
@comment node-name, next, previous, up
@section Uninstalling
All the files in the @emph{fullSWOF-utils} package are installed under a
single directory. To uninstall the package it is sufficient to remove
that directory. For example, to remove a clone of the repository, first
navigate to the directory on the system where the clone is located.
Then execute the command:
@example
rm -rf fullSWOF-utils
@end example
@node Usage, GNU Free Documentation License, Installation, Top
@comment node-name, next, previous, up
@chapter Usage
The programs provided in the @emph{fullSWOF-utils} package are written
in the @emph{python} programming language. Python version 3.0 or above
is recommended. @xref{Runtime Dependencies} for the python packages
that are required by each program.
To run an individual program it is convenient to create a symbolic link
to the corresponding file in the installation directory. For example,
from a suitable working directory, execute the following command to
create a link to the @emph{makeBoundary} program:
@example
ln -s /path/to/installation/directory/python/makeBoundary
@end example
@menu
* Runtime Dependencies::
* Invoking makeBoundary::
* Invoking slope.py::
@end menu
@node Runtime Dependencies, , Usage, Usage
@comment node-name, next, previous, up
@section Runtime Dependencies
The @emph{fullSWOF-utils} programs utilise functions provided by the
@emph{Python Standard Library}. @emph{FullSWOF-utils} will be able to
access these functions on systems that have the @emph{python} package
installed. In addition extra packages are required by the individual
programs as follows:
@table @command
@item makeBoundary:
@enumerate
@item
@url{https://matplotlib.org/, Matplotlib}, a library for
creating plots and visualisations in Python.
@item
@url{https://numpy.org/, NumPy}, a Python package for scientific
computation.
@end enumerate
@item slope.py:
@enumerate
@item
Matplotlib.
@item
NumPy.
@end enumerate
@end table
@node Invoking makeBoundary, , Runtime Dependencies, Usage
@comment node-name, next, previous, up
@section Invoking @command{makeBoundary}
The @command{makeBoundary} program creates boundary condition files for
the @emph{FullSWOF} solver. The command-line syntax is:
@example
./makeBoundary @option{boundary}
@end example
where @option{boundary} is one of @code{top}, @code{bottom}, @code{left}
and @code{right}.
There are five types of boundary condition that are recognised by the
solver:
@table @asis
@item case 1
imposed height condition
@item case 2
wall condition
@item case 3
Neumann condition
@item case 4
periodic condition
@item case 5
imposed discharge condition
@end table
Cases 1 and 5 are implemented in @emph{makeBoundary}. A height value
and a discharge value are calculated for each cell along the boundary.
At grid cells where the calculated values are zero the wall boundary
condition, case 2, is applied.
Each time @command{makeBoundary} runs it reads two input files and
produces one output file. The first input file, named
@file{topography.txt}, provides the height data. This file is also used
by @emph{FullSWOF} to define the domain topography. The file may be
saved in the current working directory or, alternatively, a symbolic
link to a file in an external directory may be created. To create such
a link use a command of the form:
@example
ln -s /path/to/topography/file topography.txt
@end example
The second input file is the @emph{boundary definition file}. This file
specifies the boundary type, the global discharge across the boundary
and the local gradient. Extra control parameters allow the global
discharge to be split across separate regions. Surface roughness may be
defined for the each region individually. @xref{Boundary Definition
File} for details of the input parameters and the file format.
@command{makeBoundary} generates an output file in the format required
by the @emph{FullSWOF} solver. Depending on the value of the
@option{boundary} command-line option, the filename of the output file
is one of @file{BCTop.txt}, @file{BCBottom.txt}, @file{BCLeft.txt} or
@file{BCRight.txt}.
@menu
* Boundary Definition File::
@end menu
@node Boundary Definition File, GNU Free Documentation License, Invoking makeBoundary, Invoking makeBoundary
@comment node-name, next, previous, up
@subsection Boundary Definition File
The @emph{boundary definition file} contains a list of parameters that
control the operation of the @emph{makeBoundary} program. The
parameters are defined in the file as a sequence of ``key-value'' pairs.
The key is the name of the variable. Each key has an associated value.
Each value is either a boolean (``True'' or ``False'') signifier, an
integer or floating point number, or a list of integers or floating
point numbers. Keys and values are defined on the same line, separated
by a colon.
The keys are defined as follows:
@table @asis
@item type
boundary type (1=imposed height, 2=wall, 3=Neumann, 4=periodic,
5=imposed discharge)
@item plotting
enable plotting (True or False)
@item printing
enable printing (True or False)
@item slope
local gradient
@item target_flow
imposed discharge (flow across boundary /@math{m@sup{3}/s})
@item markers
panel marker co-ordinates (comma-separated list of distances /m)
@item panel
fill order (comma-separated list of panel indices)
@item ztol
channel overtopping tolerance (/m)
@item n_co
Manning's n coefficients (comma-separated list, ordered by panel index)
@item numH
number of height intervals
@end table
Comment lines are allowed in the boundary definition file. Lines that
start with the @samp{#} character are treated as comments.
@node Invoking slope.py, Demos, Boundary Definition File, Usage
@comment node-name, next, previous, up
@section Invoking slope.py
@command{slope.py} is an interactive program that is able to derive
local gradient information from elevation data and user input. To start
the program the command is:
@example
./slope.py
@end example
The program responds with a request for user input:
@example
Locate markers (m), plot channel profile (p), save profile (s) or exit (q):
@end example
The derivation of the local gradient is a two-stage process. Firstly, a
series of markers are placed on opposite sides of the feature of
interest. For example, for a channel feature, markers are placed along
the channel on either side. Secondly, a best-fit curve is fitted to the
data. A plot is displayed and the gradient printed to standard output.
Optionally, the one-dimensional elevation data may be saved to an output
file.
A detailed description of the options follows:
@table @samp
@item m
Locate markers. @command{slope.py} opens a window that displays a
contour plot of the elevation data on the left hand side and a contour
plot of the derived slope on the right hand side. The axes are labeled
by cell index number. A legend to the side of each plot shows the range
of contour values.
The user is required to identify marker locations by positioning the
mouse pointer within the elevation plot and pressing the @key{SPACE}
key. The markers are entered in pairs, one on either side of the
feature of interest. To finish the sequence of marker pairs, the user
is required to move the mouse pointer to a position outside the
elevation plot and press the @kbd{q} key.
@item p
Plot channel profile. @command{slope.py} constructs a straight line
between each pair of markers and calculates the location of the minimum
elevation value along each line. These locations form a channel
``centre-line''. @command{slope.py} then uses a best-fit procedure to
plot a straight line through the centre-line elevation data. A new
window opens to show the centre-line data and the best-fit line. The
gradient and intercept of the best-fit line are printed to standard
output.
@item s
Save profile. The channel centre-line data is written to the file
@file{1D.txt}. The file is formatted in the @emph{FullSWOF} @emph{xyz}
format.
@item q
Quit @command{slope.py}.
@end table
@node Demos, GNU Free Documentation License, Boundary Definition File, Top
@comment node-name, next, previous, up
@chapter Demos
Examples of input files that demonstrate how to use
@emph{FullSWOF-utils} programs are included in the @file{demo}
directory. Sample height data, in the file @file{topography.txt}, is
also provided.
To run the demos directly, first change the current working directory to
the @file{demo} directory. Then execute the individual program
(@pxref{Usage} for the command line syntax).
The input files for @command{makeBoundary} may be viewed with a text
editor. To experiment with the control parameters, first back up the
distributed input files and then edit the parameter values as desired.
Note that the @command{makeBoundary} program will overwrite its output
file if it already exists.
Running @command{slope.py} provides an opportunity to test the effect of
marker positioning. Contour plots of elevation and slope are displayed
when the @kbd{m} key is pressed. The elevation contour plot allows the
feature of interest to be identified. Markers are placed in pairs on
either side of the channel feature. An example of a set of marker pairs
is shown in @ref{fig:markers}.
@float Figure,fig:markers
@center @image{./images/markers}
@caption{Contour plots of elevation (left) and slope (right). Feature markers are shown as red disks.}
@end float
@command{slope.py} draws a straight line between each pair of markers.
A search procedure reveals the position along each line at which the
elevation is a minimum. The set of minumum positions identifies the
centre-line of the channel. The profile of the channel is plotted and
displayed when the @kbd{p} key is pressed. The profile calculated from
the markers shown in @ref{fig:markers} is shown in @ref{fig:profile}.
@float Figure,fig:profile
@center @image{./images/profile}
@caption{Elevation plotted against distance from bottom boundary.}
@end float
The blue line in @ref{fig:profile} shows the height variation of the
channel centre-line. The best-fit line is shown by the dashed red line.
The gradient of the best-fit line and the intercept on the y-axis are
printed to standard output. The data points that define the blue line
are written to the file @file{1D.txt} when the @kbd{s} key is pressed.
The file is overwritten if it already exists.
@node GNU Free Documentation License, Index, Usage, Top
@appendix GNU Free Documentation License
@include fdl-1.3.texi
@node Index, , GNU Free Documentation License, Top
@unnumbered Index
@printindex cp
@bye
Local Variables:
mode: texinfo
eval: (outline-minor-mode)
TeX-master: t
End:
|