source: documentation/user_manual/anuga_user_manual.tex @ 2866

Last change on this file since 2866 was 2866, checked in by ole, 19 years ago

Implemented Domain(meshfile) variant widely, updated documentation and added more statistics

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 80.6 KB
Line 
1% Complete documentation on the extended LaTeX markup used for Python
2% documentation is available in ``Documenting Python'', which is part
3% of the standard documentation for Python.  It may be found online
4% at:
5%
6%     http://www.python.org/doc/current/doc/doc.html
7
8
9%labels
10%Sections and subsections \label{sec: }
11%Chapters \label{ch: }
12%Equations \label{eq: }
13%Figures \label{fig: }
14
15
16
17\documentclass{manual}
18
19\usepackage{graphicx}
20\usepackage{datetime}
21
22\input{definitions}
23
24\title{\anuga User Manual}
25\author{Geoscience Australia and the Australian National University}
26
27% Please at least include a long-lived email address;
28% the rest is at your discretion.
29\authoraddress{Geoscience Australia \\
30  Email: \email{ole.nielsen@ga.gov.au}
31}
32
33%Draft date
34
35% update before release!
36% Use an explicit date so that reformatting
37% doesn't cause a new date to be used.  Setting
38% the date to \today can be used during draft
39% stages to make it easier to handle versions.
40
41
42\longdate       % Make date format long using datetime.sty
43%\settimeformat{xxivtime} % 24 hour Format
44\settimeformat{oclock} % Verbose
45\date{\today, \ \currenttime}
46
47\ifhtml
48\date{\today} % latex2html does not know about datetime
49\fi
50
51
52
53
54
55\release{1.0}   % release version; this is used to define the
56                % \version macro
57
58\makeindex          % tell \index to actually write the .idx file
59\makemodindex       % If this contains a lot of module sections.
60
61\setcounter{tocdepth}{3}
62\setcounter{secnumdepth}{3}
63
64
65\begin{document}
66\maketitle
67
68
69% This makes the contents more accessible from the front page of the HTML.
70\ifhtml
71\chapter*{Front Matter\label{front}}
72\fi
73
74%Subversion keywords:
75%
76%$LastChangedDate: 2006-05-15 04:26:21 +0000 (Mon, 15 May 2006) $
77%$LastChangedRevision: 2866 $
78%$LastChangedBy: ole $
79
80\input{copyright}
81
82
83\begin{abstract}
84
85\noindent \anuga\index{\anuga} is a hydrodynamic modelling tool that
86allows users to model realistic flow problems in complex geometries.
87Examples include dam breaks or the effects of natural hazards such
88as riverine flooding, storm surges and tsunami.
89
90The user must specify a study area represented by a mesh of triangular
91cells, the topography and bathymetry, frictional resistance, initial
92values for water level (called \emph{stage}\index{stage} within \anuga),
93boundary
94conditions and forces such as windstress or pressure gradients if
95applicable.
96
97\anuga tracks the evolution of water depth and horizontal momentum
98within each cell over time by solving the shallow water wave equation
99governing equation using a finite-volume method.
100
101\anuga cannot model details of breaking waves, flow under ceilings such
102as pipes, turbulence and vortices, vertical convection or viscous
103flows.
104
105\anuga also incorporates a mesh generator, called \code{pmesh}, that
106allows the user to set up the geometry of the problem interactively as
107well as tools for interpolation and surface fitting, and a number of
108auxiliary tools for visualising and interrogating the model output.
109
110Most \anuga components are written in the object-oriented programming
111language Python and most users will interact with \anuga by writing
112small Python programs based on the \anuga library
113functions. Computationally intensive components are written for
114efficiency in C routines working directly with the Numerical Python
115structures.
116
117
118\end{abstract}
119
120\tableofcontents
121
122
123\chapter{Introduction}
124
125
126\section{Purpose}
127
128The purpose of this user manual is to introduce the new user to
129the software, describe what it can do and give step-by-step
130instructions for setting up and running hydrodynamic simulations.
131
132\section{Scope}
133
134This manual covers only what is needed to operate the software
135after installation and configuration. It does not includes instructions for
136installing the software or detailed API documentation, both of
137which will be covered in separate publications.
138
139\section{Audience}
140
141Readers are assumed to be familiar with the operating environment
142and have a general understanding of the problem background, as
143well as enough programming experience to adapt the code to
144different requirements, as described in this manual,  and to
145understand the basic terminology of object-oriented programming.
146
147\section{Structure of This Manual}
148
149This manual is structured as follows:
150
151\begin{itemize}
152  \item Background (What \anuga does)
153  \item A \emph{Getting Started} section
154  \item A detailed description of the public interface
155  \item \anuga 's overall architecture, components and file formats
156  \item Assumptions
157\end{itemize}
158
159
160\pagebreak
161\chapter{Background}
162
163\chapter{Getting Started}
164\label{ch:getstarted}
165
166This section is designed to assist the reader to get started with
167\anuga by working through simple examples. Two examples are discussed;
168the first is a simple but artificial example that is useful to illustrate
169many of the ideas, and the second is a more realistic example.
170
171\section{A Simple Example}
172
173\subsection{Overview}
174
175What follows is a discussion of the structure and operation of the
176file \file{bedslopephysical.py}, with just enough detail to allow
177the reader to appreciate what's involved in setting up a scenario
178like the one it depicts.
179
180This example carries out the solution of the shallow-water wave
181equation in the simple case of a configuration comprising a flat
182bed, sloping at a fixed angle in one direction and having a
183constant depth across each line in the perpendicular direction.
184
185The example demonstrates many of the basic ideas involved in
186setting up a more complex scenario. In the general case the user
187specifies the geometry (bathymetry and topography), the initial
188water level, boundary conditions such as tide, and any forcing
189terms that may drive the system such as wind stress or atmospheric
190pressure gradients. Frictional resistance from the different
191terrains in the model is represented by predefined forcing
192terms. The boundary is reflective on three sides and a time dependent wave on one side.
193
194The present example represents a simple scenario and does not
195include any forcing terms, nor is the data taken from a file as it
196would be in many typical cases.
197
198The conserved quantities involved in the
199problem are water depth, $x$-momentum and $y$-momentum. Other quantities
200involved in the computation are the friction, stage (absolute height of water surface)
201and elevation, the last two being related to
202the depth through the equation
203
204\begin{tabular}{rcrcl}
205  \code{stage} &=& \code{elevation} &+& \code{depth}
206\end{tabular}
207
208
209%\emph{[More details of the problem background]}
210
211\subsection{Outline of the Program}
212
213In outline, \file{bedslopephysical.py} performs the following steps:
214
215\begin{enumerate}
216
217   \item Sets up a triangular mesh.
218
219   \item Sets certain parameters governing the mode of
220operation of the model-specifying, for instance, where to store the model output.
221
222   \item Inputs various quantities describing physical measurements, such
223as the elevation, to be specified at each mesh point (vertex).
224
225   \item Sets up the boundary conditions.
226
227   \item Carries out the evolution of the model through a series of time
228steps and outputs the results, providing a results file that can
229be visualised.
230
231\end{enumerate}
232
233\subsection{The Code}
234
235%FIXME: we are using the \code function here.
236%This should be used wherever possible
237For reference we include below the complete code listing for
238\file{bedslopephysical.py}. Subsequent paragraphs provide a
239`commentary' that describes each step of the program and explains it
240significance.
241
242\verbatiminput{examples/bedslopephysical.py}
243%\verbatiminput{examples/bedslope.py}
244
245\subsection{Establishing the Mesh}
246
247The first task is to set up the triangular mesh to be used for the
248scenario. This is carried out through the statement:
249
250{\small \begin{verbatim}
251    points, vertices, boundary = rectangular(10, 10)
252\end{verbatim}}
253
254The function \function{rectangular} is imported from a module
255\module{mesh\_factory} defined elsewhere. (\anuga also contains
256several other schemes that can be used for setting up meshes, but we
257shall not discuss these now.) The above assignment sets up a $10
258\times 10$ rectangular mesh, triangulated in a specific way. In
259general, the assignment
260
261{\small \begin{verbatim}
262    points, vertices, boundary = rectangular(m, n)
263\end{verbatim}}
264
265returns:
266
267\begin{itemize}
268
269   \item a list \code{points} of length $N$, where $N = (m + 1)(n + 1)$,
270comprising the coordinates \code{(x, y)} of each of the $N$ mesh
271points,
272
273   \item a list \code{vertices} of length $2mn$ (each entry specifies the three
274vertices of one of the triangles used in the triangulation) , and
275
276   \item a dictionary \code{boundary}, used to tag the triangle edges on
277the boundaries. Each key corresponds to a triangle edge on one of
278the four boundaries and its value is one of \code{`left'},
279\code{`right'}, \code{`top'} and \code{`bottom'}, indicating
280which boundary the edge in question belongs to.
281
282\end{itemize}
283
284Since these three variables encapsulate the information needed to
285specify the grid, it may be helpful to consider how they look in a
286very simple case, not directly related to the example at hand.
287Figure \ref{fig:simplemesh} represents a very simple mesh comprising
288just 11 points and three triangles. (To avoid confusion, we should
289emphasise that this particular mesh is \emph{not} generated by
290\code{rectangular}---and is not even rectangular in nature. )
291
292\begin{center}
293\begin{figure}[h]
294
295  \includegraphics[width=95mm, height=95mm]{triangularmesh.eps}
296
297  \caption{A simple mesh}
298  \label{fig:simplemesh}
299\end{figure}
300\end{center}
301
302The variables \code{points}, \code{vertices} and \code{boundary}
303represent the data displayed in Figure \ref{fig:simplemesh} as
304follows. The list \code{points} stores the coordinates of the
305points, and may be displayed schematically like this:
306
307%\medskip \code{points}
308
309\begin{center}
310\begin{tabular}[t]{|c|cc|} \hline
311$index$ & $x$ & $y$\\  \hline
3120 & 1 & 1\\
3131 & 4 & 2\\
3142 & 8 & 1\\
3153 & 1 & 3\\
3164 & 5 & 5\\
3175 & 8 & 6\\
3186 & 11 & 5\\
3197 & 3 & 6\\
3208 & 1 & 8\\
3219 & 4 & 9\\
32210 & 10 & 7\\  \hline
323\end{tabular}
324\end{center}
325
326The list \code{vertices} specifies the triangles that make up the
327mesh. It does this by specifying, for each triangle, the indices
328(the numbers shown in the first column above) that correspond to the
329three points at its vertices, taken in an anti-clockwise order
330around the triangle. Thus, in the example shown in Figure
331\ref{fig:simplemesh}, the variable \code{vertices} contains the
332following entries:
333
334%\code{vertices} \nopagebreak
335
336\begin{center}
337\begin{tabular}{|c|ccc|} \hline
338$index$ & \multicolumn{3}{c|}{\code{vertices}}\\ \hline
3390 & 0 & 1 & 3\\
3401 & 1 & 2 & 4\\
3412 & 2 & 5 & 4\\
3423 & 2 & 6 & 5\\
3434 & 4 & 5 & 9\\
3445 & 4 & 9 & 7\\
3456 & 3 & 4 & 7\\
3467 & 7 & 9 & 8\\
3478 & 1 & 4 & 3\\
3489 & 5 & 10 & 9\\  \hline
349\end{tabular}
350\end{center}
351
352Finally, the variable \code{boundary} identifies the boundary
353triangles and associates a tag with each.
354
355
356
357
358\subsection{Initialising the Domain}
359
360These variables are then used to set up a data structure
361\code{domain}, through the assignment:
362
363{\small \begin{verbatim}
364    domain = Domain(points, vertices, boundary)
365\end{verbatim}}
366
367This uses a Python class \class{Domain}, imported from
368\module{shallow\_water}, which is an extension of a more generic
369class of the same name in the module \refmodule{pyvolution.domain}
370(page \pageref{mod:pyvolution.domain}),
371and inherits
372some methods from the generic class but has others specific to the
373shallow-water scenarios in which it is used. Specific options for
374domain are set at this point. One of them is to set the basename for
375the output file:
376
377{\small \begin{verbatim}
378    domain.set_name('bedslope')
379\end{verbatim}}
380
381
382\subsection{Initial Conditions}
383
384The next task is to specify a number of quantities that we wish to
385set for each mesh point. The class \class{Domain} has a method
386\method{set\_quantity}, used to specify these quantities. It is a
387particularly flexible method that allows the user to set quantities
388in a variety of ways---using constants, functions, numeric arrays or
389expressions involving other quantities, arbitrary data points with
390associated values, all of which can be passed as arguments. All
391quantities can be initialised using \method{set\_quantity}. For
392conserved quantities (\code{stage, xmomentum, ymomentum}) this is
393called the \emph{initial condition}, for other quantities that
394aren't updated by the equation, the same interface is used to assign
395their values. The code in the present example demonstrates a number
396of forms in which we can invoke \method{set\_quantity}.
397
398
399\subsubsection{Elevation}
400
401The elevation, or height of the bed, is set using a function,
402defined through the statements below, which is specific to this
403example and specifies a particularly simple initial configuration
404for demonstration purposes:
405
406{\small \begin{verbatim}
407    def f(x,y):
408        return -x/2
409\end{verbatim}}
410
411This simply associates an elevation with each point \code{(x, y)} of
412the plane.  It specifies that the bed slopes linearly in the
413\code{x} direction, with slope $-\frac{1}{2}$,  and is constant in
414the \code{y} direction.  %[screen shot?]
415
416Once the function \function{f} is specified, the quantity
417\code{elevation} is assigned through the simple statement:
418
419{\small \begin{verbatim}
420    domain.set_quantity('elevation', f)
421\end{verbatim}}
422
423
424\subsubsection{Friction}
425
426The assignment of the friction quantity demonstrates another way we
427can use \method{set\_quantity} to set quantities---namely, assign
428them to a constant numerical value:
429
430{\small \begin{verbatim}
431    domain.set_quantity('friction', 0.1)
432\end{verbatim}}
433
434This just specifies that the Manning friction coefficient is set
435to 0.1 at every mesh point.
436
437\subsubsection{Stage}
438
439The stage (the height of the water surface) is related to the
440elevation and the depth at any time by the equation
441
442
443{\small \begin{verbatim}
444    stage = elevation + depth
445\end{verbatim}}
446
447
448For this example, we simply assign a constant value to \code{stage},
449using the statement
450
451{\small \begin{verbatim}
452    domain.set_quantity('stage', -.4)
453\end{verbatim}}
454
455which specifies that the surface level is set to a height of $-0.4$, i.e. 0.4 units
456below the zero level.
457
458(Although it is not necessary for this example, it may be useful to
459digress here and mention a variant to this requirement, which allows
460us to illustrate another way to use \method{set\_quantity}---namely,
461incorporating an expression involving other quantities. Suppose,
462instead of setting a constant value for the stage, we wished to
463specify a constant value for the \emph{depth}. For such a case we
464need to specify that \code{stage} is everywhere obtained by adding
465that value to the value already specified for \code{elevation}. We
466would do this by means of the statements:
467
468{\small \begin{verbatim}
469    h = 0.05 # Constant depth
470    domain.set_quantity('stage', expression = 'elevation + %f' %h)
471\end{verbatim}}
472
473That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus
474the value of \code{elevation} already defined.
475
476The reader will probably appreciate that this capability to
477incorporate expressions into statements using \method{set\_quantity}
478greatly expands its power.)
479
480\subsection{Boundary Conditions}
481
482The boundary conditions are specified as follows:
483
484{\small \begin{verbatim}
485    Br = Reflective_boundary(domain)
486
487    Bt = Transmissive_boundary(domain)
488
489    Bd = Dirichlet_boundary([0.2,0.,0.])
490
491    Bw = Time_boundary(domain=domain,
492                f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0])
493\end{verbatim}}
494
495The effect of these statements is to set up four alternative
496boundary conditions and store them in variables that can be
497assigned as needed. Each boundary condition specifies the
498behaviour at a boundary in terms of the behaviour in neighbouring
499elements. The boundary conditions introduced here may be briefly described as
500follows:
501
502\begin{description}
503    \item[Reflective boundary] Returns same \code{stage} as
504    as present in its neighbour volume but momentum vector reversed 180 degrees (reflected).
505    Specific to the shallow water equation as it works with the
506    momentum quantities assumed to be the second and third conserved
507    quantities.
508
509    \item[Transmissive boundary]Returns same conserved quantities as
510    those present in its neighbour volume.
511
512    \item[Dirichlet boundary]Specifies a fixed value at the
513boundary and assigns initial values to the $x$-momentum and $y$-momentum.
514
515    \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time.
516\end{description}
517
518Once the four boundary types have been specified through the
519statements above, they can be applied through a statement of the
520form
521
522{\small \begin{verbatim}
523    domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br})
524\end{verbatim}}
525
526This statement stipulates that, in the current example, the right
527boundary varies with time, as defined by the equation, while the other
528boundaries are all reflective.
529
530The reader may wish to experiment by varying the choice of boundary
531types for one or more of the boundaries. In the case of \code{Bd}
532and \code{Bw}, the three arguments in each case represent the
533elevation, $x$-momentum and $y$-momentum, respectively.
534
535{\small \begin{verbatim}
536    Bw = Time_boundary(domain=domain,
537                f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0])
538\end{verbatim}}
539
540
541
542\subsection{Evolution}
543
544The final statement \nopagebreak[3]
545{\small \begin{verbatim}
546    for t in domain.evolve(yieldstep = 0.1, duration = 4.0):
547        print domain.timestepping_statistics()
548\end{verbatim}}
549
550is the key step that causes the configuration of the domain to
551`evolve' in accordance with the model embodied in the code, over a
552series of steps indicated by the values of \code{yieldstep} and
553\code{duration}, which can be altered as required.
554The value of \code{yieldstep} controls the time interval between successive model outputs.
555Behind the scenes more time steps are generally taken.
556
557
558\subsection{Output}
559
560%Give details here of the form of the output and explain how it can
561%be used with swollen. Include screen shots.//
562
563The output is a NetCDF file with the extension \code{.sww}. It
564contains stage and momentum information and can be used with the
565\code{swollen} visualisation package to generate a visual display.
566See Section \ref{sec:file formats} (page \pageref{sec:file formats})
567for more on NetCDF and other file formats.
568
569
570\section{How to Run the Code}
571
572The code can be run in various ways:
573
574\begin{itemize}
575  \item{from a Windows command line} as in \code{python bedslopephysical.py}
576  \item{within the Python IDLE environment}
577  \item{within emacs}
578  \item{from a Linux command line} as in \code{python bedslopephysical.py}
579\end{itemize}
580
581
582\section{Exploring the model output}
583
584Figure \ref{fig:bedslopestart} shows the \\
585Figure \ref{fig:bedslope2} shows later snapshots...
586
587
588
589\begin{figure}[hbt]
590
591  \centerline{ \includegraphics[width=75mm, height=75mm]{examples/bedslopestart.eps}}
592
593  \caption{Bedslope example viewed with Swollen}
594  \label{fig:bedslopestart}
595\end{figure}
596
597
598\begin{figure}[hbt]
599
600  \centerline{
601    \includegraphics[width=75mm, height=75mm]{examples/bedslopeduring.eps}
602    \includegraphics[width=75mm, height=75mm]{examples/bedslopeend.eps}
603   }
604
605  \caption{Bedslope example viewed with Swollen}
606  \label{fig:bedslope2}
607\end{figure}
608
609
610
611
612\clearpage
613
614%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615
616\section{An Example with Real Data}
617
618The following discussion builds on the concepts introduced through
619the \file{bedslopephysical.py} example and introduces a second
620example, \file{run\_sydney\_smf.py}, that follows the same basic
621outline, but incorporates more complex features and refers to a
622real-life scenario, rather than the artificial illustrative one used
623in \file{bedslopephysical.py}. The domain of interest surrounds the
624Sydney region, and predominantly covers Sydney Harbour. A
625hypothetical tsunami wave is generated by a submarine mass failure
626situated on the edge of the continental shelf.
627
628\subsection{Overview}
629As in the case of \file{bedslopephysical.py}, the actions carried
630out by the program can be organised according to this outline:
631
632\begin{enumerate}
633
634   \item Set up a triangular mesh.
635
636   \item Set certain parameters governing the mode of
637operation of the model---specifying, for instance, where to store the
638model output.
639
640   \item Input various quantities describing physical measurements, such
641as the elevation, to be specified at each mesh point (vertex).
642
643   \item Set up the boundary conditions.
644
645   \item Carry out the evolution of the model through a series of time
646steps and outputs the results, providing a results file that can be
647visualised.
648
649\end{enumerate}
650
651
652
653\subsection{The Code}
654
655Here is the code for \file{run\_sydney\_smf.py}:
656
657%\verbatiminput{"runsydneysmf.py"}
658\verbatiminput{examples/runsydney.py}
659
660In discussing the details of this example, we follow the outline
661given above, discussing each major step of the code in turn.
662
663\subsection{Establishing the Mesh}
664
665One obvious way that the present example differs from
666\file{bedslopephysical.py} is in the use of a more complex method to
667create the mesh. Instead of imposing a mesh structure on a
668rectangular grid, the technique used for this example involves
669building mesh structures inside polygons specified by the user,
670using a mesh-generator referred to as \code{pmesh}.
671
672The following remarks may help the reader understand how
673\code{pmesh} is used.
674
675In its simplest form, \code{pmesh} creates the mesh within a single
676polygon whose vertices are at geographical locations specified by the
677user. The user specifies the \emph{resolution}---that is, the maximal
678area of a triangle used for triangulation---and mesh points are
679created inside the polygon through a random process. Figure
680\ref{fig:pentagon} shows a simple example of this, in which
681the triangulation is carried out within a pentagon.
682
683
684\begin{figure}[hbt]
685
686
687
688  \caption{Mesh points are created inside the polygon}
689  \label{fig:pentagon}
690\end{figure}
691
692Boundary tags are not restricted to \code{`left'}, \code{`right'},
693\code{`bottom'} and \code{`top'}, as in the case of
694\file{bedslopephysical.py}. Instead the user specifies a list of
695tags appropriate to the configuration being modelled.
696
697While a mesh created inside a polygon offers more flexibility than
698one based on a rectangular grid, using \code{pmesh} in the limited
699form we have described so far still doesn't provide a way to adapt
700to geographic or other features in the landscape, whose presence may
701require us to vary the resolution in the neighbourhood of the
702features. To cope with this requirement, \code{pmesh} also allows
703the user to specify a number of \emph{interior polygons}, which are
704triangulated separately, each according to a separately specified
705resolution. See Figure \ref{fig:interior meshes}.
706
707\begin{figure}[hbt]
708
709
710
711  \caption{Interior meshes with individual resolution}
712  \label{fig:interior meshes}
713\end{figure}
714
715In its general form, \code{pmesh} takes for its input a bounding
716polygon and (optionally) a list of interior polygons. The user
717specifies resolutions, both for the bounding polygon and for each of
718the interior polygons. Given this data, \code{pmesh} first creates a
719triangular mesh inside the bounding polygon, using the specified
720resolution, and then creates a separate triangulation inside each of
721the interior polygons, using the resolution specified for that
722polygon.
723
724The function used to implement this process is
725\function{create\_mesh\_from\_regions}. Its arguments include the
726bounding polygon and its resolution, a list of boundary tags, and a
727list of pairs \code{[polygon, resolution]}, specifying the interior
728polygons and their resolutions.
729
730In practice, the details of the polygons used are read from a
731separate file \file{project.py}. The resulting mesh is output to a
732\emph{meshfile}\index{meshfile}. This term is used to describe a
733file of a specific format used to store the data specifying a mesh.
734(There are in fact two possible formats for such a file: it can
735either be a binary file, with extension \code{.msh}, or an ASCII
736file, with extension \code{.tsh}. In the present case, the binary
737file format \code{.msh} is used. See Section \ref{sec:file formats}
738(page \pageref{sec:file formats}) for more on file formats.)
739\code{pmesh} assigns a name to the file by appending the extension
740\code{.msh} to the name specified in the input file
741\file{project.py}. This name is stored in the variable
742\code{meshname}.
743
744The statements
745
746{\small \begin{verbatim}
747    interior_res = 5000%
748    interior_regions = [[project.harbour_polygon_2, interior_res],
749                    [project.botanybay_polygon_2, interior_res]]
750\end{verbatim}}
751
752are used to read in the specific polygons \code{project.harbour\_polygon\_2} and
753\code{botanybay\_polygon\_2} from \file{project.py} and assign a
754common resolution of 5000 to each. The statement
755
756{\small \begin{verbatim}
757    create_mesh_from_regions(project.diffpolygonall,%
758                         boundary_tags= {'bottom': [0],%
759                                         'right1': [1],%
760                                         'right0': [2],%
761                                         'right2': [3],%
762                                         'top': [4],%
763                                         'left1': [5],%
764                                         'left2': [6],%
765                                         'left3': [7]},%
766                         maximum_triangle_area=100000,%
767                         filename=meshname,%
768                         interior_regions=interior_regions)
769\end{verbatim}}
770
771is then used to create the mesh, taking the bounding polygon to be the polygon
772\code{diffpolygonall} specified in \file{project.py}. The
773argument \code{boundary\_tags} assigns a dictionary, whose keys are the
774names of the boundary tags used for the bounding polygon---\code{`bottom'},
775`right0', `right1', `right2', `top', `left1', `left2' and `left3'---
776and whose values identify the indices of the segments associated with each of these
777tags. (The value associated with each boundary tag is a one-element list.)
778
779
780\subsection{Initialising the Domain}
781
782As with \file{bedslopephysical.py}, once we have created the mesh, the next
783step is to create the data structure \code{domain}. We did this for
784\file{bedslopephysical.py} by inputting lists of points and triangles and
785specifying the boundary tags directly. However, in the present case,
786we use a method that works directly with the meshfile
787\code{meshname}, as follows:
788
789
790{\small \begin{verbatim}
791    domain = Domain(meshname, use_cache=True, verbose=True)
792\end{verbatim}}
793
794Providing a filename instead of the lists used in bedslopephysical
795above causes Domain to convert a meshfile
796\code{meshname} into an instance of the data structure
797\code{domain}, allowing us to use methods like \method{set\_quantity}
798to set quantities and to apply other operations.
799
800%(In principle, the
801%second argument of \function{pmesh\_to\_domain\_instance} can be any
802%subclass of \class{Domain}, but for applications involving the
803%shallow-water wave equation, the second argument of
804%\function{pmesh\_to\_domain\_instance} can always be set simply to
805%\class{Domain}.)
806
807The following statements specify a basename and data directory, and
808identify quantities to be stored. For the first two, values are
809taken from \file{project.py}.
810
811{\small \begin{verbatim}
812    domain.set_name(project.basename)%
813    domain.set_datadir(project.outputdir)%
814    domain.set_quantities_to_be_stored(['stage', 'xmomentum',
815        'ymomentum'])
816\end{verbatim}}
817
818
819\subsection{Initial Conditions}
820Quantities for \file{runsydney.py} are set
821using similar methods to those in \file{bedslopephysical.py}. However,
822in this case, many of the values are read from the auxiliary file
823\file{project.py} or, in the case of \code{elevation}, from an
824ancillary points file.
825
826
827
828\subsubsection{Stage}
829
830For the scenario we are modelling in this case, we use a callable
831object \code{tsunami\_source}, assigned by means of a function
832\function{slump\_tsunami}. This is similar to how we set elevation in
833\file{bedslopephysical.py} using a function---however, in this case the
834function is both more complex and more interesting.
835
836The function returns the water displacement for all \code{x} and
837\code{y} in the domain. The water displacement is a double Gaussian
838function that depends on the characteristics of the slump (length,
839thickness, slope, etc), its location (origin) and the depth at that
840location.
841
842
843\subsubsection{Friction}
844
845We assign the friction exactly as we did for \file{bedslopephysical.py}:
846
847{\small \begin{verbatim}
848    domain.set_quantity('friction', 0.03)
849\end{verbatim}}
850
851
852\subsubsection{Elevation}
853
854The elevation is specified by reading data from a file:
855
856{\small \begin{verbatim}
857    domain.set_quantity('elevation',
858                        filename = project.combineddemname + '.pts',
859                        use_cache = True,
860                        verbose = True)
861\end{verbatim}}
862
863However, before this step can be executed, some preliminary steps
864are needed to prepare the file from which the data is taken. Two
865source files are used for this data---their names are specified in
866the file \file{project.py}, in the variables \code{coarsedemname}
867and \code{finedemname}. They contain `coarse' and `fine' data,
868respectively---that is, data sampled at widely spaced points over a
869large region and data sampled at closely spaced points over a
870smaller subregion. The data in these files is combined through the
871statement
872
873{\small \begin{verbatim}
874combine_rectangular_points_files(project.finedemname + '.pts',
875                                 project.coarsedemname + '.pts',
876                                 project.combineddemname + '.pts')
877\end{verbatim}}
878
879The effect of this is simply to combine the datasets by eliminating
880any coarse data associated with points inside the smaller region
881common to both datasets. The name to be assigned to the resulting
882dataset is also derived from the name stored in the variable
883\code{combinedname} in the file \file{project.py}.
884
885\subsection{Boundary Conditions}
886
887Setting boundaries follows a similar pattern to the one used for
888\file{bedslopephysical.py}, except that in this case we need to associate a
889boundary type with each of the
890boundary tag names introduced when we established the mesh. In place of the four
891boundary types introduced for \file{bedslopephysical.py}, we use the reflective
892boundary for each of the
893eight tagged segments:
894
895{\small \begin{verbatim}
896    Br = Reflective_boundary(domain)
897    domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
898                          'right2': Br, 'top': Br, 'left1': Br,
899                          'left2': Br, 'left3': Br} )
900\end{verbatim}}
901
902\subsection{Evolution}
903
904With the basics established, the running of the `evolve' step is
905very similar to the corresponding step in \file{bedslopephysical.py}:
906
907{\small \begin{verbatim}
908    import time t0 = time.time()
909
910    for t in domain.evolve(yieldstep = 120, duration = 18000):
911        print domain.timestepping_statistics()
912        print domain.boundary_statistics(tags = 'bottom')
913
914    print 'That took %.2f seconds' %(time.time()
915\end{verbatim}}
916
917%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
918%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
919
920\chapter{\anuga Public Interface}
921\label{ch:interface}
922
923This chapter gives an overview of the features of \anuga available
924to the user at the public interface. These are grouped under the
925following headings:
926
927\begin{itemize}
928    \item Establishing the Mesh
929    \item Initialising the Domain
930    \item Specifying the Quantities
931    \item Initial Conditions
932    \item Boundary Conditions
933    \item Forcing Functions
934    \item Evolution
935\end{itemize}
936
937The listings are intended merely to give the reader an idea of what
938each feature is, where to find it and how it can be used---they do
939not give full specifications. For these the reader
940may consult the code. The code for every function or class contains
941a documentation string, or `docstring', that specifies the precise
942syntax for its use. This appears immediately after the line
943introducing the code, between two sets of triple quotes.
944
945Each listing also describes the location of the module in which
946the code for the feature being described can be found. All modules
947are in the folder \file{inundation} or one of its subfolders, and the
948location of each module is described relative to \file{inundation}. Rather
949than using pathnames, whose syntax depends on the operating system,
950we use the format adopted for importing the function or class for
951use in Python code. For example, suppose we wish to specify that the
952function \function{create\_mesh\_from\_regions} is in a module called
953\module{mesh\_interface} in a subfolder of \module{inundation} called
954\code{pmesh}. In Linux or Unix syntax, the pathname of the file
955containing the function, relative to \file{inundation}, would be
956
957\begin{center}
958%    \code{pmesh/mesh\_interface.py}
959    \code{pmesh}$\slash$\code{mesh\_interface.py}
960\end{center}
961
962while in Windows syntax it would be
963
964\begin{center}
965    \code{pmesh}$\backslash$\code{mesh\_interface.py}
966\end{center}
967
968Rather than using either of these forms, in this chapter we specify
969the location simply as \code{pmesh.mesh_interface}, in keeping with
970the usage in the Python statement for importing the function,
971namely:
972\begin{center}
973    \code{from pmesh.mesh\_interface import create\_mesh\_from\_regions}
974\end{center}
975
976Each listing details the full set of parameters for the class or
977function; however, the description is generally limited to the most
978important parameters and the reader is again referred to the code
979for more details.
980
981The following parameters are common to many functions and classes
982and are omitted from the descriptions given below:
983
984%\begin{center}
985\begin{tabular}{ll}  %\hline
986%\textbf{Name } & \textbf{Description}\\
987%\hline
988\emph{usecache} & Specifies whether caching is to be used\\
989\emph{verbose} & If \code{True}, provides detailed terminal output
990to the user\\  % \hline
991\end{tabular}
992%\end{center}
993
994\section{Mesh Generation}
995\refmodindex[pmesh.meshinterface]{pmesh.mesh\_interface}
996\begin{funcdesc}  {create\_mesh\_from\_regions}{bounding_polygon,
997                             boundary_tags,
998                             maximum_triangle_area,
999                             filename=None,
1000                             interior_regions=None,
1001                             poly_geo_reference=None,
1002                             mesh_geo_reference=None,
1003                             minimum_triangle_angle=28.0}
1004Module: \module{pmesh.mesh\_interface}
1005
1006This function allows a user to initiate the automatic creation of a
1007mesh inside a specified polygon. Among the parameters that can be
1008set are the \emph{resolution} (maximal area for any triangle in the
1009mesh) and the minimal angle allowable in any triangle. The user can
1010specify a number of internal polygons within each of which a
1011separate mesh is to be created, generally with a smaller resolution.
1012Additionally, the user specifies a list of boundary tags, one for
1013each edge of the bounding polygon.
1014\end{funcdesc}
1015
1016
1017\begin{funcdesc}  {Mesh}{userSegments=None,
1018                 userVertices=None,
1019                 holes=None,
1020                 regions=None,
1021                 geo_reference=None}
1022Module: \module{pmesh.mesh}
1023
1024% Translate following into layman's language
1025An instance of the class \class{Mesh} is used to store .  This can
1026then be used to build the outline of the mesh and then generate the
1027mesh.
1028\end{funcdesc}
1029
1030
1031\begin{funcdesc}  {add_region_from_polygon}{self, polygon, tags=None,
1032                                max_triangle_area=None, geo_reference=None}
1033Module: \module{pmesh.mesh.Mesh}
1034
1035% Translate following into layman's language
1036This method is used to add a region to a \class{Mesh} instance.  The
1037region is described by the polygon passed in.  Additionally, the
1038user specifies a list of boundary tags, one for each edge of the
1039bounding polygon.
1040
1041
1042\end{funcdesc}
1043
1044\begin{funcdesc}  {add_hole_from_polygon}{self, polygon, tags=None,
1045    geo_reference=None}
1046Module: \module{pmesh.mesh.Mesh}
1047
1048% Translate following into layman's language
1049This method is used to add a `hole'---that is, a region where the
1050triangular mesh will not be generated---to a \class{Mesh} instance.
1051The region is described by the polygon passed in.  Additionally, the
1052user specifies a list of boundary tags, one for each edge of the
1053bounding polygon.
1054\end{funcdesc}
1055
1056\begin{funcdesc}  {generate_mesh}{self,
1057                      maximum_triangle_area=None,
1058                      minimum_triangle_angle=28.0,
1059                      verbose=False}
1060Module: \module{pmesh.mesh.Mesh}
1061
1062% Translate following into layman's language
1063This method is used to generate the triangular mesh.  The  maximal area
1064of any triangle in the mesh can be specified, along with the minimum
1065angle of all triangles.
1066\end{funcdesc}
1067
1068
1069\begin{funcdesc}  {export_mesh_file}{self,ofile}
1070Module: \module{pmesh.mesh.Mesh}
1071
1072% Translate following into layman's language
1073This method is used to save the mesh to a file. \code{ofile} is the name of the mesh file to be writen,
1074including the extension.  Use the extension \code{.msh} for the file to
1075be in NetCDF format and \code{.tsh} for the file to be ASCII format.
1076\end{funcdesc}
1077
1078%%%%%%
1079\section{Initialising Domain}
1080
1081\begin{funcdesc}  {pmesh\_to\_domain\_instance}{file_name, DomainClass, use_cache = False, verbose = False}
1082Module: \module{pyvolution.pmesh2domain}
1083
1084Once the initial mesh file has been created, this function is
1085applied to convert it to a domain object---that is, to a member of
1086the special Python class \class{Domain} (or a subclass of
1087\class{Domain}), which provides access to properties and methods
1088that allow quantities to be set and other operations to be carried
1089out.
1090
1091\code{file\_name} is the name of the mesh file to be converted,
1092including the extension. \code{DomainClass} is the class to be
1093returned, which must be a subclass of \class{Domain} having the same
1094interface as \class{Domain}---in practice, it can usually be set
1095simply to \class{Domain}.
1096
1097This is now superseded by Domain(mesh_filename).
1098\end{funcdesc}
1099
1100
1101\subsection{Key Methods of Domain}
1102
1103\begin{funcdesc} {set\_name}{name}
1104    Module: \refmodule{pyvolution.domain}, page \pageref{mod:pyvolution.domain}  %\code{pyvolution.domain}
1105
1106    Assigns the name \code{name} to the domain.
1107\end{funcdesc}
1108
1109\begin{funcdesc} {get\_name}{}
1110    Module: \module{pyvolution.domain}
1111
1112    Returns the name assigned to the domain by \code{set_name}. If no name has been
1113    assigned, returns \code{`domain'}.
1114\end{funcdesc}
1115
1116\begin{funcdesc} {set\_datadir}{name}
1117    Module: \module{pyvolution.domain}
1118
1119    Specifies the directory used for data, assigning it to the pathname \code{name}. The default value, before
1120    \code{set\_datadir} has been run, is the value \code{default_datadir}
1121    specified in \code{config.py}.
1122
1123    Since different operating systems use different formats for specifying pathnames,
1124    it is necessary to specify path separators using the Python code \code{os.sep}, rather than
1125    the operating-specific ones such as `$\slash$' or `$\backslash$'.
1126    For this to work you will need to include the statement \code{import os}
1127    in your code, before the first appearance of \code{set\_datadir}.
1128
1129    For example, to set the data directory to a subdirectory
1130    \code{data} of the directory \code{project}, you could use
1131    the statements:
1132
1133    {\small \begin{verbatim}
1134        import os
1135        domain.set_datadir{'project' + os.sep + 'data'}
1136    \end{verbatim}}
1137\end{funcdesc}
1138
1139\begin{funcdesc} {get_datadir}{}
1140    Module: \module{pyvolution.domain}
1141
1142    Returns the data directory set by \code{set\_datadir} or, if \code{set\_datadir} has not
1143    been run, returns the value \code{default_datadir} specified in
1144    \code{config.py}.
1145\end{funcdesc}
1146
1147\begin{funcdesc} {set_time}{time=0.0}
1148    Module: \module{pyvolution.domain}
1149
1150    Sets the initial time, in seconds, for the simulation. The
1151    default is 0.0.
1152\end{funcdesc}
1153
1154\begin{funcdesc} {set_default_order}{??}
1155\end{funcdesc}
1156
1157
1158%%%%%%
1159\section{Initial Conditions}
1160
1161\begin{funcdesc}{set\_quantity}{name,
1162    numeric = None,
1163    quantity = None,
1164    function = None,
1165    geospatial_data = None,
1166    filename = None,
1167    attribute_name = None,
1168    alpha = None,
1169    location = 'vertices',
1170    indices = None,
1171    verbose = False,
1172    use_cache = False}
1173  Module: \module{pyvolution.domain}
1174  (see also \module{pyvolution.quantity.set_values})
1175
1176This function is used to assign values to individual quantities for a
1177domain. It is very flexible and can be used with many data types: a
1178statement of the form \code{domain.set\_quantity(name, x)} can be used
1179to define a quantity having the name \code{name}, where the other
1180argument \code{x} can be any of the following:
1181
1182\begin{itemize}
1183\item a number, in which case all vertices in the mesh gets that for
1184the quantity in question.
1185\item a list of numbers or a Numeric array ordered the same way as the mesh vertices.
1186\item a function (e.g.\ see the samples introduced in Chapter 2)
1187\item an expression composed of other quantities and numbers, arrays, lists (for
1188example, a linear combination of quantities)
1189\item the name of a file from which the data can be read. In this case, the optional argument attribute_name will select which attribute to use from the file. If left out, set_quantity will pick one. This is useful in cases where there is only one attribute.
1190\item a geospatial dataset (See ?????). Optional argument attribute_name applies here as with files.
1191\end{itemize}
1192
1193
1194Exactly one of the arguments
1195  numeric, quantity, function, points, filename
1196must be present.
1197
1198
1199Set quantity will look at the type of the second argument (\code{numeric}) and
1200determine what action to take.
1201
1202Values can also be set using the appropriate keyword arguments.
1203If x is a function, for example, \code{domain.set\_quantity(name, x)}, \code{domain.set\_quantity(name, numeric=x)}, and \code{domain.set\_quantity(name, function=x)}
1204are all equivalent.
1205
1206
1207Other optional arguments are
1208\begin{itemize}
1209\item \code{indices} which is a list of ids of triangles to which set_quantity should apply its assignment of values.
1210\item \code{location} determines which part of the triangles to assign to. Options are 'vertices' (default), 'edges', and 'centroids'.
1211\end{itemize}
1212
1213
1214a number, in which case all vertices in the mesh gets that for
1215the quantity in question.
1216\item a list of numbers or a Numeric array ordered the same way as the mesh vertices.
1217
1218
1219\end{funcdesc}
1220
1221
1222
1223
1224
1225
1226
1227%%%
1228\anuga provides a number of predefined initial conditions to be used
1229with \code{set_quantity}.
1230
1231\begin{funcdesc}{tsunami_slump}{length, depth, slope, width=None, thickness=None,
1232                x0=0.0, y0=0.0, alpha=0.0,
1233                gravity=9.8, gamma=1.85,
1234                massco=1, dragco=1, frictionco=0, psi=0,
1235                dx=None, kappa=3.0, kappad=0.8, zsmall=0.01,
1236                domain=None,
1237                verbose=False}
1238This function returns a callable object representing an initial water
1239displacement generated by a submarine sediment failure. These failures can take the form of
1240a submarine slump or slide.
1241
1242The arguments include as a minimum, the slump or slide length, the water depth to the centre of sediment
1243mass, and the bathymetric slope. Other slump or slide parameters can be included if they are known.
1244\end{funcdesc}
1245
1246
1247%%%
1248\begin{funcdesc}{file_function}{filename,
1249                  domain = None,
1250                  quantities = None,
1251                  interpolation_points = None,
1252                  verbose = False,
1253                  use_cache = False}
1254Module: \module{pyvolution.util}
1255
1256Reads the time history of spatial data from NetCDF file and returns
1257a callable object. Returns interpolated values based on the input
1258file using the underlying \code{interpolation\_function}.
1259
1260\code{quantities} is either the name of a single quantity to be
1261interpolated or a list of such quantity names. In the second case, the resulting
1262function will return a tuple of values---one for each quantity.
1263
1264\code{interpolation\_points} is a list of absolute UTM coordinates
1265for points at which values are sought.
1266\end{funcdesc}
1267
1268%%%
1269\begin{classdesc}{Interpolation\_function}{self,
1270                 time,
1271                 quantities,
1272                 quantity_names = None,
1273                 vertex_coordinates = None,
1274                 triangles = None,
1275                 interpolation_points = None,
1276                 verbose = False}
1277Module: \module{pyvolution.least\_squares}
1278
1279Given a time series, either as a sequence of numbers or
1280defined at the vertices of a triangular mesh (such
1281as those stored in \code{sww} files), \code{Interpolation\_function}
1282is used to create a callable object that interpolates a value for
1283an arbitrary time \code{t} within the model limits and possibly a
1284point \code{(x, y)} within a mesh region.
1285
1286The actual time series at which data is available is specified by
1287means of an array \code{time} of monotonically increasing times. The
1288quantities containing the values to be interpolated are specified in
1289an array---or dictionary of arrays (used in conjunction with the
1290optional argument \code{quantity\_names}) --- called
1291\code{quantities}. The optional arguments \code{vertex_coordinates}
1292and \code{triangles} represent the spatial mesh associated with the
1293quantity arrays. If omitted the function created by
1294\code{Interpolation\_function} will be a function of \code{t} only.
1295
1296Since, in practice, values need to be computed at specified points,
1297the syntax allows the user to specify, once and for all, a list
1298\code{interpolation\_points} of points at which values are required.
1299In this case, the function may be called using the form \code{f(t,
1300id)}, where \code{id} is an index for the list
1301\code{interpolation\_points}.
1302
1303\end{classdesc}
1304
1305%%%
1306\begin{funcdesc}{set\_region}{functions}
1307[Low priority. Will be merged into set\_quantity]
1308
1309Module:\module{pyvolution.domain}
1310\end{funcdesc}
1311
1312
1313
1314%%%%%%
1315\section{Boundary Conditions}
1316
1317\anuga provides a large number of predefined boundary conditions,
1318represented by objects such as \code{Reflective\_boundary(domain)} and
1319\code{Dirichlet\_boundary([0.2, 0.0, 0.0])}, described in the examples
1320in Chapter 2. Alternatively, you may prefer to ``roll your own'',
1321following the method explained in Section \ref{sec:roll your own}.
1322
1323These boundary objects may be used with the function \code{set\_boundary} described below
1324to assign boundary conditions according to the tags used to label boundary segments.
1325
1326\begin{funcdesc}{set\_boundary}{boundary_map}
1327Module: \module{pyvolution.domain}
1328
1329This function allows you to assign a boundary object (corresponding to a
1330pre-defined or user-specified boundary condition) to every boundary segment that
1331has been assigned a particular tag.
1332
1333This is done by specifying a dictionary \code{boundary\_map}, whose values are the boundary objects
1334and whose keys are the symbolic tags.
1335
1336\end{funcdesc}
1337
1338\begin{funcdesc} {get_boundary_tags}{}
1339Module: \module{pyvolution.mesh}
1340\end{funcdesc}
1341
1342%%%
1343\subsection{Predefined boundary conditions}
1344
1345\begin{classdesc}{Reflective_boundary}{Boundary}
1346Module: \module{pyvolution.shallow\_water}
1347
1348Reflective boundary returns same conserved quantities as those present in
1349the neighbouring volume but reflected.
1350
1351This class is specific to the shallow water equation as it works with the
1352momentum quantities assumed to be the second and third conserved quantities.
1353\end{classdesc}
1354
1355%%%
1356\begin{classdesc}{Transmissive_boundary}{domain = None}
1357Module: \module{pyvolution.generic\_boundary\_conditions}
1358
1359A transmissive boundary returns the same conserved quantities as
1360those present in the neighbouring volume.
1361
1362The underlying domain must be specified when the boundary is instantiated.
1363\end{classdesc}
1364
1365%%%
1366\begin{classdesc}{Dirichlet_boundary}{conserved_quantities=None}
1367Module: \module{pyvolution.generic\_boundary\_conditions}
1368
1369A Dirichlet boundary returns constant values for the conserved
1370quantities.
1371\end{classdesc}
1372
1373%%%
1374\begin{classdesc}{Time_boundary}{domain = None, f = None}
1375Module: \module{pyvolution.generic\_boundary\_conditions}
1376
1377A time-dependent boundary returns values for the conserved
1378quantities as a function \code{f(t)} of time. The user must specify
1379the domain to get access to the model time.
1380\end{classdesc}
1381
1382%%%
1383\begin{classdesc}{File_boundary}{Boundary}
1384Module: \module{pyvolution.generic\_boundary\_conditions}
1385
1386The boundary values are obtained from a file and interpolated. The
1387file is assumed to contain a time series and possibly also spatial
1388information. The conserved quantities are given as a function of
1389time.
1390\end{classdesc}
1391
1392
1393\subsection{User-defined boundary conditions}
1394\label{sec:roll your own}
1395[How to roll your own]
1396
1397
1398
1399
1400
1401\section{Forcing Functions}
1402
1403\anuga provides a number of predefined forcing functions to be used with .....
1404
1405%\begin{itemize}
1406
1407
1408%  \item \indexedcode{}
1409%  [function, arguments]
1410
1411%  \item \indexedcode{}
1412
1413%\end{itemize}
1414
1415
1416
1417\section{Evolution}
1418
1419  \begin{funcdesc}{evolve}{yieldstep = None, finaltime = None, duration = None, skip_initial_step = False}
1420
1421  Module: \module{pyvolution.domain}
1422
1423  This function (a method of \class{domain}) is invoked once all the
1424  preliminaries have been completed, and causes the model to progress
1425  through successive steps in its evolution, storing results and
1426  outputting statistics whenever a user-specified period
1427  \code{yieldstep} is completed (generally during this period the
1428  model will evolve through several steps internally). The user
1429  specifies the total time period over which the evolution is to take
1430  place, by specifying values (in seconds) for either \code{duration}
1431  or \code{finaltime}, as well as the interval in seconds after which
1432  results are to be stored and statistics output.
1433
1434  You can include \method{evolve} in a statement of the type:
1435
1436  {\small \begin{verbatim}
1437      for t in domain.evolve(yieldstep, finaltime):
1438          <Do something with domain and t>
1439  \end{verbatim}}
1440
1441  \end{funcdesc}
1442
1443
1444
1445\subsection{Diagnostics}
1446
1447  \begin{funcdesc}{timestepping_statistics}{}
1448  Module: \module{pyvolution.domain}
1449
1450
1451  \end{funcdesc}
1452
1453
1454  \begin{funcdesc}{boundary\_statistics}{quantities = None, tags = None}
1455  Module: \module{pyvolution.domain}
1456
1457
1458  \end{funcdesc}
1459
1460
1461  \begin{funcdesc}{get_quantity}{name, location='vertices', indices = None}
1462  Module: \module{pyvolution.domain}
1463  Allow access to individual quantities and their methods
1464
1465  \end{funcdesc}
1466
1467
1468  \begin{funcdesc}{get_values}{location='vertices', indices = None}
1469  Module: \module{pyvolution.quantity}
1470
1471  Extract values for quantity as an array
1472
1473  \end{funcdesc}
1474
1475
1476  \begin{funcdesc}{get_integral}{}
1477  Module: \module{pyvolution.quantity}
1478
1479  Return computed integral over entire domain for this quantity
1480
1481  \end{funcdesc}
1482
1483
1484\section{Other}
1485
1486  \begin{funcdesc}{domain.create_quantity_from_expression}{???}
1487
1488  Handy for creating derived quantities on-the-fly.
1489  See \file{Analytical\_solution\_circular\_hydraulic\_jump.py} for an example of use.
1490  \end{funcdesc}
1491
1492
1493  \begin{funcdesc}{Geospatial_data}{???}
1494    Module: \module{geospatial_data.geo_spatial_data}
1495    Creates a georeferenced geospatial data object from either arrays or a file (pts or xya).
1496
1497    Objects of this class can be used with \method{set\_quantity}.
1498  \end{funcdesc}
1499
1500
1501
1502
1503
1504%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1505%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1506
1507\chapter{\anuga System Architecture}
1508
1509From pyvolution/documentation
1510
1511\section{File Formats}
1512\label{sec:file formats}
1513
1514\anuga makes use of a number of different file formats. The
1515following table lists all these formats, which are described in more
1516detail in the paragraphs below.
1517
1518\bigskip
1519
1520\begin{center}
1521
1522\begin{tabular}{|ll|}  \hline
1523
1524\textbf{Extension} & \textbf{Description} \\
1525\hline\hline
1526
1527\code{.sww} & NetCDF format for storing model output
1528\code{f(t,x,y)}\\
1529
1530\code{.tms} & NetCDF format for storing time series \code{f(t)}\\
1531
1532\code{.xya} & ASCII format for storing arbitrary points and
1533associated attributes\\
1534
1535\code{.pts} & NetCDF format for storing arbitrary points and
1536associated attributes\\
1537
1538\code{.asc} & ASCII format of regular DEMs as output from ArcView\\
1539
1540\code{.prj} & Associated ArcView file giving more metadata for
1541\code{.asc} format\\
1542
1543\code{.ers} & ERMapper header format of regular DEMs for ArcView\\
1544
1545\code{.dem} & NetCDF representation of regular DEM data\\
1546
1547\code{.tsh} & ASCII format for storing meshes and associated
1548boundary and region info\\
1549
1550\code{.msh} & NetCDF format for storing meshes and associated
1551boundary and region info\\
1552
1553\code{.nc} & Native ferret NetCDF format\\
1554
1555\code{.geo} & Houdinis ASCII geometry format (?) \\  \par \hline
1556%\caption{File formats used by \anuga}
1557\end{tabular}
1558
1559
1560\end{center}
1561
1562The above table shows the file extensions used to identify the
1563formats of files. However, typically, in referring to a format we
1564capitalise the extension and omit the initial full stop---thus, we
1565refer, for example, to `SWW files' or `PRJ files'.
1566
1567\bigskip
1568
1569A typical dataflow can be described as follows:
1570
1571\subsection{Manually Created Files}
1572
1573\begin{tabular}{ll}
1574ASC, PRJ & Digital elevation models (gridded)\\
1575TSH & Triangular meshes (e.g. created from \code{pmesh})\\
1576NC & Model outputs for use as boundary conditions (e.g. from MOST)
1577\end{tabular}
1578
1579\subsection{Automatically Created Files}
1580
1581\begin{tabular}{ll}
1582ASC, PRJ  $\rightarrow$  DEM  $\rightarrow$  PTS & Convert
1583DEMs to native \code{.pts} file\\
1584
1585NC $\rightarrow$ SWW & Convert MOST boundary files to
1586boundary \code{.sww}\\
1587
1588PTS + TSH $\rightarrow$ TSH with elevation & Least squares fit\\
1589
1590TSH $\rightarrow$ SWW & Convert TSH to \code{.sww}-viewable using
1591Swollen\\
1592
1593TSH + Boundary SWW $\rightarrow$ SWW & Simulation using
1594\code{pyvolution}
1595\end{tabular}
1596
1597
1598
1599
1600\bigskip
1601
1602\subsection{SWW and TMS Formats}
1603
1604The SWW and TMS formats are both NetCDF formats, and are of key
1605importance for \anuga.
1606
1607An SWW file is used for storing \anuga output and therefore pertains
1608to a set of points and a set of times at which a model is evaluated.
1609It contains, in addition to dimension information, the following
1610variables:
1611
1612\begin{itemize}
1613    \item \code{x} and \code{y}: coordinates of the points, represented as Numeric arrays
1614    \item \code{elevation}, a Numeric array storing bed-elevations
1615    \item \code{volumes}, a list specifying the points at the vertices of each of the
1616    triangles
1617    % Refer here to the example to be provided in describing the simple example
1618    \item \code{time}, a Numeric array containing times for model
1619    evaluation
1620\end{itemize}
1621
1622
1623The contents of an SWW file may be viewed using the visualisation
1624tool \code{swollen}, which creates an on-screen geometric
1625representation. See section \ref{sec:swollen} (page
1626\pageref{sec:swollen}) in Appendix \ref{ch:supportingtools} for more
1627on \code{swollen}.
1628
1629Alternatively, there are tools, such as \code{ncdump}, that allow
1630you to convert an NetCDF file into a readable format such as the
1631Class Definition Language (CDL). The following is an excerpt from a
1632CDL representation of the output file \file{bedslope.sww} generated
1633from running the simple example \file{bedslopephysical.py} of
1634Chapter \ref{ch:getstarted}:
1635
1636\verbatiminput{examples/bedslopeexcerpt.cdl}
1637
1638The SWW format is used not only for output but also serves as input
1639for functions such as \function{file_boundary} and
1640\function{file_function}, described in Chapter \ref{ch:interface}.
1641
1642A TMS file is used to store time series data that is independent of
1643position.
1644
1645
1646\subsection{Meshfile Formats}
1647
1648A meshfile is a file that has a specific format suited to specifying
1649mesh data for \anuga. A meshfile can have one of two formats: it can
1650be either a TSH file, which is an ASCII file, or an MSH file, which
1651is a NetCDF file. A meshfile can be generated from the function
1652\function{create_mesh_from_regions} (see ) and used to initialise a
1653domain.
1654
1655A meshfile describes the outline of the mesh---the vertices and line
1656segments that enclose the region in which the mesh is created---and
1657the triangular mesh itself, which is specified by listing the
1658triangles and their vertices, and the segments, which are those
1659sides of the triangles that are associated with boundary conditions.
1660
1661In addition, a meshfile may contain `holes' and/or `regions'. A hole
1662or region is defined by specifying a point and a number of segments
1663that enclose that point. A hole represents an area where no mesh is
1664to be created, while a region is a labelled area used for defining
1665properties of a mesh, such as friction values.
1666
1667A meshfile can also contain a georeference, which describes an
1668offset to be applied to $x$ and $y$ values---eg to the vertices.
1669
1670
1671\subsection{Formats for Storing Arbitrary Points and Attributes}
1672
1673An XYA file is used to store data representing arbitrary numerical
1674attributes associated with a set of points.
1675
1676The format for an XYA file is:
1677%\begin{verbatim}
1678
1679            first line:     \code{[attribute names]}\\
1680            other lines:  \code{x y [attributes]}\\
1681
1682            for example:\\
1683            \code{elevation, friction}\\
1684            \code{0.6, 0.7, 4.9, 0.3}\\
1685            \code{1.9, 2.8, 5, 0.3}\\
1686            \code{2.7, 2.4, 5.2, 0.3}
1687
1688        The first two columns are always implicitly assumed to be $x$, $y$ coordinates.
1689        Use the same delimiter for the attribute names and the data.
1690
1691        An XYA file can optionally end with lines of this type:
1692
1693            \code{\#geo reference}\\
1694            \code{56}\\
1695            \code{466600.0}\\
1696            \code{8644444.0}
1697
1698        Here the first number specifies the zone (in this case zone 56)  and other numbers specify the
1699        coordinates (in this case (466600.0, 8644444.0)) of the lower left corner.
1700
1701A PTS file is a NetCDF representation of the data held in an XYA
1702file. If the data is associated with a set of $N$ points, then the
1703data is stored using an $N \times 2$ Numeric array of float
1704variables for the points and an $N \times 1$ Numeric array for each
1705attribute.
1706
1707%\end{verbatim}
1708
1709\subsection{ArcView Formats}
1710
1711Files of the three formats ASC, PRJ and ERS are all associated with
1712data from ArcView.
1713
1714An ASC file is an ASCII representation of DEM output from ArcView.
1715It has the following format...
1716
1717A PRJ file is an ArcView file used in conjunction with an ASC file
1718to represent metadata for a DEM.
1719
1720
1721\subsection{DEM Format}
1722
1723A DEM file is a NetCDF representation of regular DEM data.
1724
1725
1726\subsection{Other Formats}
1727
1728
1729
1730
1731\subsection{Basic File Conversions}
1732
1733  \begin{funcdesc}{sww2dem}{basename_in, basename_out = None,
1734            quantity = None,
1735            timestep = None,
1736            reduction = None,
1737            cellsize = 10,
1738            NODATA_value = -9999,
1739            easting_min = None,
1740            easting_max = None,
1741            northing_min = None,
1742            northing_max = None,
1743            expand_search = False,
1744            verbose = False,
1745            origin = None,
1746            datum = 'WGS84',
1747            format = 'ers'}
1748  Module: \module{pyvolution.data\_manager}
1749
1750  Takes data from an SWW file and converts it to DEM format (ASC or
1751  ERS)
1752  \end{funcdesc}
1753
1754
1755  \begin{funcdesc}{dem2pts}{basename_in, basename_out=None,
1756            easting_min=None, easting_max=None,
1757            northing_min=None, northing_max=None,
1758            use_cache=False, verbose=False}
1759  Module: \module{pyvolution.data\_manager}
1760
1761  Takes DEM data (a NetCDF file representation of data from a regular Digital
1762  Elevation Model) and converts it to PTS format.
1763  \end{funcdesc}
1764
1765
1766
1767%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1768%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1769
1770\chapter{Basic \anuga Assumptions}
1771
1772(From pyvolution/documentation)
1773
1774
1775Physical model time cannot be earlier than 1 Jan 1970 00:00:00.
1776If one wished to recreate scenarios prior to that date it must be done
1777using some relative time (e.g. 0).
1778
1779
1780All spatial data relates to the WGS84 datum (or GDA94) and has been
1781projected into UTM with false easting of 500000 and false northing of
17821000000 on the southern hemisphere (0 on the northern).
1783
1784It is assumed that all computations take place within one UTM zone.
1785
1786DEMs, meshes and boundary conditions can have different origins within
1787one UTM zone. However, the computation will use that of the mesh for
1788numerical stability.
1789
1790
1791%OLD
1792%The dataflow is: (See data_manager.py and from scenarios)
1793%
1794%
1795%Simulation scenarios
1796%--------------------%
1797%%
1798%
1799%Sub directories contain scrips and derived files for each simulation.
1800%The directory ../source_data contains large source files such as
1801%DEMs provided externally as well as MOST tsunami simulations to be used
1802%as boundary conditions.
1803%
1804%Manual steps are:
1805%  Creation of DEMs from argcview (.asc + .prj)
1806%  Creation of mesh from pmesh (.tsh)
1807%  Creation of tsunami simulations from MOST (.nc)
1808%%
1809%
1810%Typical scripted steps are%
1811%
1812%  prepare_dem.py:  Convert asc and prj files supplied by arcview to
1813%                   native dem and pts formats%
1814%
1815%  prepare_pts.py: Convert netcdf output from MOST to an sww file suitable
1816%                  as boundary condition%
1817%
1818%  prepare_mesh.py: Merge DEM (pts) and mesh (tsh) using least squares
1819%                   smoothing. The outputs are tsh files with elevation data.%
1820%
1821%  run_simulation.py: Use the above together with various parameters to
1822%                     run inundation simulation.
1823
1824
1825%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1826%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1827
1828\appendix
1829
1830\chapter{Supporting Tools}
1831\label{ch:supportingtools}
1832
1833This section describes a number of supporting tools, supplied with \anuga, that offer a
1834variety of types of functionality and enhance the basic capabilities of \anuga.
1835
1836\section{caching}
1837
1838  The \code{cache} function is used to provide supervised caching of function results. A Python
1839  function call of the form
1840
1841      {\small \begin{verbatim}
1842      result = func(arg1,...,argn)
1843      \end{verbatim}}
1844
1845  can be replaced by
1846
1847      {\small \begin{verbatim}
1848      from caching import cache
1849      result = cache(func,(arg1,...,argn))
1850      \end{verbatim}}
1851
1852  which returns the same output but reuses cached
1853  results if the function has been computed previously in the same context.
1854  \code{result} and the arguments can be simple types, tuples, list, dictionaries or
1855  objects, but not unhashable types such as functions or open file objects.
1856  The function \code{func} may be a member function of an object or a module.
1857
1858  This type of caching is particularly useful for computationally intensive
1859  functions with few frequently used combinations of input arguments. Note that
1860  if the inputs or output are very large caching may not save time because
1861  disc access may dominate the execution time.
1862
1863  If the function definition changes after a result has been cached, this will be
1864  detected by examining the functions \code{bytecode (co_code, co_consts,
1865  func_defualts, co_argcount)} and the function will be recomputed.
1866
1867  Options are set by means of the function \code{set_option(key, value)},
1868  where \code{key} is a key associated with a
1869  Python dictionary \code{options}. This dictionary stores settings such as the name of
1870  the directory used, the maximum
1871  number of cached files allowed, and so on.
1872
1873  The \code{cache} function allows the user also to specify a list of dependent files. If any of these
1874  have been changed, the function is recomputed and the results stored again.
1875
1876  %Other features include support for compression and a capability to \ldots
1877
1878
1879   \textbf{USAGE:}
1880
1881    {\small \begin{verbatim}
1882    result = cache(func, args, kwargs, dependencies, cachedir, verbose,
1883                   compression, evaluate, test, return_filename)
1884    \end{verbatim}}
1885
1886
1887\section{swollen}
1888\label{sec:swollen}
1889 The output generated by \anuga may be viewed by
1890means of the visualisation tool \code{swollen}, which takes the
1891\code{sww} file output by \anuga and creates a visual representation
1892of the data. Examples may be seen in Figures \ref{fig:bedslopestart}
1893and \ref{fig:bedslope2}. To view an \code{sww} file with
1894\code{swollen} in the Windows environment, you can simply drag the
1895icon representing the file over an icon on the desktop for the
1896\code{swollen} executable file (or a shortcut to it). Alternatively,
1897you can operate \code{swollen} from the command line, in both
1898Windows and Linux environments.
1899
1900On successful operation, you will see an interactive moving-picture display. You can use keys and the mouse
1901to slow down, speed up or stop the display, change the viewing position or carry out a number of other
1902simple operations.
1903
1904The main keys operating the interactive screen are:\\
1905
1906\begin{center}
1907\begin{tabular}{|ll|}   \hline
1908
1909\code{w} & toggle wireframe\\
1910
1911space bar & start/stop\\
1912
1913up/down arrows & increase/decrease speed\\
1914
1915left/right arrows & direction in time \emph{(when running)}\\ & step through simulation \emph{(when stopped)}\\
1916
1917left mouse button & rotate\\
1918
1919middle mouse button & pan\\
1920
1921right mouse button & zoom\\  \hline
1922
1923\end{tabular}
1924\end{center}
1925
1926\vfill
1927
1928The following table describes how to operate swollen from the command line:
1929
1930Usage: \code{swollen [options] swwfile \ldots}\\  \nopagebreak
1931Options:\\  \nopagebreak
1932\begin{tabular}{ll}
1933  \code{--display <type>} & \code{MONITOR | POWERWALL | REALITY_CENTER |}\\
1934                                    & \code{HEAD_MOUNTED_DISPLAY}\\
1935  \code{--rgba} & Request a RGBA colour buffer visual\\
1936  \code{--stencil} & Request a stencil buffer visual\\
1937  \code{--stereo} & Use default stereo mode which is \code{ANAGLYPHIC} if not \\
1938                                    & overridden by environmental variable\\
1939  \code{--stereo <mode>} & \code{ANAGLYPHIC | QUAD_BUFFER | HORIZONTAL_SPLIT |}\\
1940                                    & \code{VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE |}\\
1941                                     & \code{ON | OFF} \\
1942  \code{-alphamax <float 0-1>} & Maximum transparency clamp value\\
1943  \code{-alphamin <float 0-1>} & Transparency value at \code{hmin}\\
1944  \code{-cullangle <float angle 0-90>} & Cull triangles steeper than this value\\
1945  \code{-help} & Display this information\\
1946  \code{-hmax <float>} & Height above which transparency is set to
1947                                     \code{alphamax}\\
1948  \code{-hmin <float>} & Height below which transparency is set to
1949                                     zero\\
1950  \code{-lightpos <float>,<float>,<float>} & $x,y,z$ of bedslope directional light ($z$ is
1951                                     up, default is overhead)\\
1952  \code{-loop}  & Repeated (looped) playback of \code{.swm} files\\
1953  \code{-movie <dirname>} & Save numbered images to named directory and
1954                                     quit\\
1955  \code{-nosky} & Omit background sky\\
1956  \code{-scale <float>} & Vertical scale factor\\
1957  \code{-texture <file>} & Image to use for bedslope topography\\
1958  \code{-tps <rate>} & Timesteps per second\\
1959  \code{-version} & Revision number and creation (not compile)
1960                                     date\\
1961\end{tabular}
1962
1963\section{utilities/polygons}
1964
1965  \begin{classdesc}{Polygon_function}{regions, default = 0.0, geo_reference = None}
1966  Module: \code{utilities.polygon}
1967
1968
1969  \end{classdesc}
1970
1971  \begin{funcdesc}{read_polygon}{filename}
1972  Module: \code{utilities.polygon}
1973
1974  Reads the specified file and returns a polygon. Each
1975  line of the file must contain exactly two numbers, separated by a comma, which are interpreted
1976  as coordinates of one vertex of the polygon.
1977  \end{funcdesc}
1978
1979  \begin{funcdesc}{populate_polygon}{polygon, number_of_points, seed = None, exclude = None}
1980  Module: \code{utilities.polygon}
1981
1982  Populates the interior of the specified polygon with the specified number of points,
1983  selected by means of a uniform distribution function.
1984  \end{funcdesc}
1985
1986  \begin{funcdesc}{point_in_polygon}{polygon, delta=1e-8}
1987  Module: \code{utilities.polygon}
1988
1989  Returns a point inside the specified polygon and close to the edge. The distance between
1990  the returned point and the nearest point of the polygon is less than $\sqrt{2}$ times the
1991  second argument \code{delta}, which is taken as $10^{-8}$ by default.
1992  \end{funcdesc}
1993
1994  \begin{funcdesc}{inside_polygon}{points, polygon, closed = True, verbose = False}
1995  Module: \code{utilities.polygon}
1996
1997  Used to test whether a single point---or the members of a list of points---
1998  are inside the specified polygon. If the first argument is a single point,
1999  returns \code{True} if the point is inside the polygon, or \code{False}
2000  otherwise. If the first argument is a list of points, returns a Numeric
2001  array comprising the indices of the points in the list that lie inside the polygon.
2002  (If none of the points are inside, returns \code{zeros((0,), 'l')}.)
2003  Points on the edges of the polygon are regarded as inside if
2004  \code{closed} is set to \code{True} or omitted; otherwise they are regarded as outside.
2005  \end{funcdesc}
2006
2007  \begin{funcdesc}{outside_polygon}{points, polygon, closed = True, verbose = False}
2008  Module: \code{utilities.polygon}
2009
2010  Exactly like \code{inside_polygon}, but with the words `inside' and `outside' interchanged.
2011  \end{funcdesc}
2012
2013  \begin{funcdesc}{point_on_line}{x, y, x0, y0, x1, y1}
2014  Module: \code{utilities.polygon}
2015
2016  Returns \code{True} or \code{False}, depending on whether the point with coordinates
2017  \code{x, y} is on the line passing through the points with coordinates \code{x0, y0}
2018  and \code{x1, y1} (extended if necessary at either end).
2019  \end{funcdesc}
2020
2021  \begin{funcdesc}{separate_points_by_polygon}{points, polygon,
2022                               closed = True, verbose = False}\indexedcode{separate_points_by_polygon}
2023  Module: \code{utilities.polygon}
2024
2025  \end{funcdesc}
2026
2027
2028
2029\section{coordinate_transforms}
2030
2031\section{geo_spatial_data}
2032
2033This describes a class that represents arbitrary point data in UTM
2034coordinates along with named attribute values.
2035
2036TBA
2037
2038\section{pmesh GUI}
2039
2040\section{alpha_shape}
2041
2042
2043\section{utilities/numerical_tools} Do now.
2044
2045\begin{itemize}
2046  \item \indexedcode{ensure_numeric}
2047  \item \indexedcode{mean}
2048  \item
2049\end{itemize}
2050
2051
2052\chapter{Modules available in \anuga}
2053
2054
2055\section{\module{pyvolution.general\_mesh} }
2056\declaremodule[pyvolution.generalmesh]{}{pyvolution.general\_mesh}
2057\label{mod:pyvolution.generalmesh}
2058
2059\section{\module{pyvolution.mesh} }
2060\declaremodule{}{pyvolution.mesh}
2061\label{mod:pyvolution.mesh}
2062
2063\section{\module{pyvolution.domain} --- Generic module for 2D triangular domains for finite-volume computations of conservation laws}
2064\declaremodule{}{pyvolution.domain}
2065\label{mod:pyvolution.domain}
2066
2067
2068\section{\module{pyvolution.quantity}}
2069\declaremodule{}{pyvolution.quantity}
2070\label{mod:pyvolution.quantity}
2071
2072
2073\section{\module{pyvolution.shallow\_water} --- 2D triangular domains for finite-volume computations of the shallow water wave equation. This module contains a specialisation of class Domain from module domain.py consisting of methods specific to the Shallow Water Wave Equation
2074}
2075\declaremodule[pyvolution.shallowwater]{}{pyvolution.shallow\_water}
2076\label{mod:pyvolution.shallowwater}
2077
2078
2079
2080
2081%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2082
2083\chapter{Frequently Asked Questions}
2084
2085
2086\section{General Questions}
2087
2088\subsubsection{What is \anuga?}
2089
2090\subsubsection{Why is it called \anuga?}
2091
2092\subsubsection{How do I obtain a copy of \anuga?}
2093
2094\subsubsection{What developments are expected for \anuga in the future?}
2095
2096\subsubsection{Are there any published articles about \anuga that I can reference?}
2097
2098\section{Modelling Questions}
2099
2100\subsubsection{Which type of problems are \anuga good for?}
2101
2102\subsubsection{Which type of problems are beyond the scope of \anuga?}
2103
2104\subsubsection{Can I start the simulation at an arbitrary time?}
2105Yes, using \code{domain.set_time()} you can specify an arbitrary starting time.
2106This is for example useful in conjunction with a file_boundary, which may start hours before anything hits the model boundary. By assigning a later time for the model to start, computational resources aren't wasted.
2107
2108\subsubsection{Can I change values for any quantity during the simulation?}
2109Yes, using \code{domain.set_quantity()} inside the domain.evolve loop you
2110can change values of any quantity. This is for example useful if you wish to
2111let the system settle for a while before assigning an initial condition. Another example would be changing the values for elevation to model e.g. erosion.
2112
2113\subsubsection{Can I change boundary conditions during the simulation?}
2114Not sure, but it would be nice :-)
2115
2116\subsubsection{Why does a file\_function return a list of numbers when evaluated?}
2117Currently, file\_function works by returning values for the conserved
2118quantities \code{stage}, \code{xmomentum} and \code{ymomentum} at a given point in time and space as a triplet. To access e.g.\ \code{stage} one must specify element 0 of the triplet returned by file\_function.
2119
2120\subsubsection{Which diagnostics are available to troubleshoot a simulation?}
2121
2122\subsubsection{How do I use a DEM in my simulation?}
2123You use \code{dem2pts} to convert your DEM to the required .pts format. This .pts file is then called When setting the elevation data to the mesh
2124in \code{domain.set_quantity}
2125
2126\subsubsection{What sort of DEM resolution should I use?}
2127Try and work with the "best" you have available. Onshore DEMs are typically available in 25m, 100m and 250m grids. Note, offshore data is often sparse,
2128or non-existant.
2129
2130\subsubsection{What sort of mesh resolution should I use?}
2131The mesh resolution should be commensurate with your DEM - it does not make sense to put in place a mesh which is finer than your DEM. As an example,
2132if your DEM is on a 25m grid, then the cell resolution should be of the order of 315$m^2$ (this represents half the area of the square grid). Ideally,
2133you need a fine mesh over regions where the DEM changes rapidly, and other areas of significant interest, such as the coast.
2134
2135\subsubsection{How often should I store the output?}
2136This will depend on what you are trying to answer with your model and how much memory you have available on your machine. If you need
2137to look in detail at the evolution, then you will need to balance against your storage requirements and the duration of the simulation.
2138If the sww file exceeds 1Gb, another sww file will be created until the end of the simulation. As an example, to store all the conserved
2139quantities on a mesh with approximately 300000 triangles on a 2 min interval for 5 hours will result in approximately 350Mb sww file.
2140
2141\subsection{Boundary Conditions}
2142
2143\subsubsection{How do I create a Dirichlet boundary condition?}
2144
2145\subsubsection{How do I know which boundary tags are available?}
2146The method \code{domain.get_boundary_tags()} will return a list of
2147available tags for use with \code{domain.set_boundary_condition()}.
2148
2149
2150
2151
2152
2153\chapter{Glossary}
2154
2155\begin{itemize}
2156    \item \indexedbold{\anuga} Name of software (joint development between ANU and GA)
2157
2158    \item \indexedbold{domain} The domain of a function is the set of all input values to the function.
2159
2160    \item \indexedbold{Dirichlet boundary} - A Dirichlet boundary condition imposed on a differential equation
2161 which specifies the values the solution is to take on the boundary of the domain.
2162
2163    \item \indexedbold{elevation} - refers to bathymetry and topography
2164
2165    \item \indexedbold{bathymetry} - offshore elevation
2166
2167    \item \indexedbold{topography} - onshore elevation
2168
2169    \item \indexedbold{evolution} - integration of the shallow water wave equations over time
2170
2171    \item \indexedbold{forcing term}
2172
2173    \item \indexedbold{IDLE} - Development environment shipped with Python
2174
2175    \item \indexedbold{Manning friction coefficient}
2176
2177    \item \indexedbold{mesh}    - Triangulation of domain
2178
2179    \item \indexedbold{meshfile}  [generic word for either .tsh or
2180    .msh file]
2181
2182    \item \indexedbold{points file}  [generic word for either .pts or
2183    .xya file]
2184
2185    \item \indexedbold{grid} - evenly spaced mesh
2186
2187    \item \indexedbold{NetCDF}
2188
2189    \item \indexedbold{pmesh} does this really need to be here? it's a class/module?
2190
2191    \item \indexedbold{pyvolution} does this really need to be here? it's a class/module?
2192
2193    \item \indexedbold{conserved quantity} conserved (stage, x and y momentum)
2194
2195    \item \indexedbold{reflective boundary}
2196
2197    \item \indexedbold{smoothing} is this really needed?
2198
2199    \item \indexedbold{stage}
2200
2201%    \item \indexedbold{try this}
2202
2203    \item \indexedbold{swollen} - visualisation tool
2204
2205    \item \indexedbold{time boundary} - defined in the manual (flog from there)
2206
2207    \item \indexedbold{transmissive boundary} - defined in the manual (flog from there)
2208
2209    \item \indexedbold{xmomentum} - conserved quantity (note, two-dimensional SWW equations say only x and y and NOT z)
2210
2211    \item \indexedbold{ymomentum}  - conserved quantity
2212
2213    \item \indexedbold{resolution} -  The maximal area of a triangular cell in a mesh
2214
2215    \item \indexedbold{polygon} - A sequence of points in the plane. (Arbitrary polygons can be created
2216    in this way.)
2217    \anuga represents a polygon in one of two ways. One way is to represent it as a
2218    list whose members are either Python tuples
2219    or Python lists of length 2. The unit square, for example, would be represented by the
2220    list
2221    [ [0,0], [1,0], [1,1], [0,1] ]. The alternative is to represent it as an
2222    $N \times 2$ Numeric array, where $N$ is the number of points.
2223
2224    NOTE: More can be read in the module utilities/polygon.py ....
2225
2226    \item \indexedbold{easting} - A rectangular (x,y) coordinate measurement of distance east from a north-south reference line,
2227usually a meridian used as the axis of origin within a map zone or projection. Easting is a UTM (Universal Transverse Mercator) Coordinate.
2228
2229    \item \indexedbold{northing} - A rectangular (x,y) coordinate measurement of distance north from a north-south reference line,
2230usually a meridian used as the axis of origin within a map zone or projection. Northing is a UTM (Universal Transverse Mercator) Coordinate.
2231
2232
2233    \item \indexedbold{latitude} - The angular distance on a mericlear north and south of the equator, expressed in degrees and minutes.
2234
2235    \item \indexedbold{longitude} - The angular distance east or west, between the meridian of a particular place on Earth and that of the
2236Prime Meridian (located in Greenwich, England) expressed in degrees or time.
2237
2238    \item \indexedbold{edge} - A triangulare cell within the computational mesh can be depicted as a set of vertices joined by lines (the edges).
2239
2240    \item \indexedbold{vertex} - A point at which edges meet.
2241
2242    \item \indexedbold{finite volume} - The method evaluates the terms in the shallow water wave equationas fluxes at the surfaces of each
2243finite volume. Because the flux entering a given volume is identical to that leaving the adjacent volume, these methods are conservative.
2244Another advantage of the finite volume method is that it is easily formulated to allow for unstructured meshes.
2245The method is used in many computational fluid dynamics packages.
2246
2247
2248    \item \indexedbold{flux} - the amount of flow through the volume per unit time
2249
2250    \item \indexedbold{Digital Elevation Model (DEM)} - DEMs are digital files consisting of points of elevations,
2251sampled systematically at equally spaced intervals.
2252
2253
2254\end{itemize}
2255
2256The \code{\e appendix} markup need not be repeated for additional
2257appendices.
2258
2259
2260%
2261%  The ugly "%begin{latexonly}" pseudo-environments are really just to
2262%  keep LaTeX2HTML quiet during the \renewcommand{} macros; they're
2263%  not really valuable.
2264%
2265%  If you don't want the Module Index, you can remove all of this up
2266%  until the second \input line.
2267%
2268
2269%begin{latexonly}
2270%\renewcommand{\indexname}{Module Index}
2271%end{latexonly}
2272%\input{mod\jobname.ind}        % Module Index
2273%
2274%begin{latexonly}
2275%\renewcommand{\indexname}{Index}
2276%end{latexonly}
2277%\input{\jobname.ind}            % Index
2278
2279
2280
2281\end{document}
Note: See TracBrowser for help on using the repository browser.