source: anuga_core/documentation/user_manual/anuga_user_manual.tex @ 4003

Last change on this file since 4003 was 3986, checked in by ole, 18 years ago

Renamed swollen to animate

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 117.8 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% Is latex failing with;
16% `modanuga_user_manual.ind' not found?
17% try this command-line
18%   makeindex modanuga_user_manual.idx
19% To produce the modanuga_user_manual.ind file.
20
21
22\documentclass{manual}
23
24\usepackage{graphicx}
25\usepackage{datetime}
26
27\input{definitions}
28
29\title{\anuga User Manual}
30\author{Geoscience Australia and the Australian National University}
31
32% Please at least include a long-lived email address;
33% the rest is at your discretion.
34\authoraddress{Geoscience Australia \\
35  Email: \email{ole.nielsen@ga.gov.au}
36}
37
38%Draft date
39
40% update before release!
41% Use an explicit date so that reformatting
42% doesn't cause a new date to be used.  Setting
43% the date to \today can be used during draft
44% stages to make it easier to handle versions.
45
46
47\longdate       % Make date format long using datetime.sty
48%\settimeformat{xxivtime} % 24 hour Format
49\settimeformat{oclock} % Verbose
50\date{\today, \ \currenttime}
51%\hyphenation{set\_datadir}
52
53\ifhtml
54\date{\today} % latex2html does not know about datetime
55\fi
56
57
58
59
60
61\release{1.0}   % release version; this is used to define the
62                % \version macro
63
64\makeindex          % tell \index to actually write the .idx file
65\makemodindex       % If this contains a lot of module sections.
66
67\setcounter{tocdepth}{3}
68\setcounter{secnumdepth}{3}
69
70
71\begin{document}
72\maketitle
73
74
75% This makes the contents more accessible from the front page of the HTML.
76\ifhtml
77\chapter*{Front Matter\label{front}}
78\fi
79
80%Subversion keywords:
81%
82%$LastChangedDate: 2006-11-14 03:42:33 +0000 (Tue, 14 Nov 2006) $
83%$LastChangedRevision: 3986 $
84%$LastChangedBy: sexton $
85
86\input{copyright}
87
88
89\begin{abstract}
90\label{def:anuga}
91
92\noindent \anuga\index{\anuga} is a hydrodynamic modelling tool that
93allows users to model realistic flow problems in complex geometries.
94Examples include dam breaks or the effects of natural hazards such
95as riverine flooding, storm surges and tsunami.
96
97The user must specify a study area represented by a mesh of triangular
98cells, the topography and bathymetry, frictional resistance, initial
99values for water level (called \emph{stage}\index{stage} within \anuga),
100boundary
101conditions and forces such as windstress or pressure gradients if
102applicable.
103
104\anuga tracks the evolution of water depth and horizontal momentum
105within each cell over time by solving the shallow water wave equation
106governing equation using a finite-volume method.
107
108\anuga also incorporates a mesh generator, called \code{pmesh}, that
109allows the user to set up the geometry of the problem interactively as
110well as tools for interpolation and surface fitting, and a number of
111auxiliary tools for visualising and interrogating the model output.
112
113Most \anuga components are written in the object-oriented programming
114language Python and most users will interact with \anuga by writing
115small Python programs based on the \anuga library
116functions. Computationally intensive components are written for
117efficiency in C routines working directly with the Numerical Python
118structures.
119
120
121\end{abstract}
122
123\tableofcontents
124
125
126\chapter{Introduction}
127
128
129\section{Purpose}
130
131The purpose of this user manual is to introduce the new user to the
132inundation software, describe what it can do and give step-by-step
133instructions for setting up and running hydrodynamic simulations.
134
135\section{Scope}
136
137This manual covers only what is needed to operate the software after
138installation and configuration. It does not includes instructions
139for installing the software or detailed API documentation, both of
140which will be covered in separate publications and by documentation
141in the source code.
142
143\section{Audience}
144
145Readers are assumed to be familiar with the operating environment
146and have a general understanding of the subject matter, as well as
147enough programming experience to adapt the code to different
148requirements and to understand the basic terminology of
149object-oriented programming.
150
151\pagebreak
152\chapter{Background}
153
154
155Modelling the effects on the built environment of natural hazards such
156as riverine flooding, storm surges and tsunami is critical for
157understanding their economic and social impact on our urban
158communities.  Geoscience Australia and the Australian National
159University are developing a hydrodynamic inundation modelling tool
160called \anuga to help simulate the impact of these hazards.
161
162The core of \anuga is the fluid dynamics module, called \code{shallow\_water},
163which is based on a finite-volume method for solving the Shallow Water
164Wave Equation.  The study area is represented by a mesh of triangular
165cells.  By solving the governing equation within each cell, water
166depth and horizontal momentum are tracked over time.
167
168A major capability of \anuga is that it can model the process of
169wetting and drying as water enters and leaves an area.  This means
170that it is suitable for simulating water flow onto a beach or dry land
171and around structures such as buildings.  \anuga is also capable
172of modelling hydraulic jumps due to the ability of the finite-volume
173method to accommodate discontinuities in the solution.
174
175To set up a particular scenario the user specifies the geometry
176(bathymetry and topography), the initial water level (stage),
177boundary conditions such as tide, and any forcing terms that may
178drive the system such as wind stress or atmospheric pressure
179gradients. Gravity and frictional resistance from the different
180terrains in the model are represented by predefined forcing terms.
181
182A mesh generator, called pmesh, allows the user to set up the geometry
183of the problem interactively and to identify boundary segments and
184regions using symbolic tags.  These tags may then be used to set the
185actual boundary conditions and attributes for different regions
186(e.g. the Manning friction coefficient) for each simulation.
187
188Most \anuga components are written in the object-oriented programming
189language Python.  Software written in Python can be produced quickly
190and can be readily adapted to changing requirements throughout its
191lifetime.  Computationally intensive components are written for
192efficiency in C routines working directly with the Numerical Python
193structures.  The animation tool developed for \anuga is based on
194OpenSceneGraph, an Open Source Software (OSS) component allowing high
195level interaction with sophisticated graphics primitives.
196See \cite{nielsen2005} for more background on \anuga.
197
198\chapter{Restrictions and limitations on \anuga}
199
200Although a powerful and flexible tool for hydrodynamic modelling, \anuga has a
201number of limitations that any potential user need to be aware of. They are
202
203\begin{itemize}
204  \item The mathematical model is the 2D shallow water wave equation.
205  As such it cannot resolve vertical convection and consequently not breaking
206  waves or 3D turbulence (e.g.\ vorticity).
207  \item The surface is assumed to be open, e.g. \anuga cannot model
208  flow under ceilings or in pipes
209  \item All spatial coordinates are assumed to be UTM (meters). As such,
210  ANUGA is unsuitable for modelling flows in areas larger than one UTM zone
211  (6 degrees wide).
212  \item Fluid is assumed to be inviscid
213  \item The finite volume is a very robust and flexible numerical technique,
214  but it is not the fastest method around. If the geometry is sufficiently
215  simple and if there is no need for wetting or drying, a finite-difference
216  method may be able to solve the problem faster than \anuga.
217  %\item Mesh resolutions near coastlines with steep gradients need to be...   
218  \item Frictional resistance is implemented using Manning's formula, but
219  \anuga has not yet been validated in regard to bottom roughness
220\end{itemize}
221
222
223
224\chapter{Getting Started}
225\label{ch:getstarted}
226
227This section is designed to assist the reader to get started with
228\anuga by working through some examples. Two examples are discussed;
229the first is a simple example to illustrate many of the ideas, and
230the second is a more realistic example.
231
232\section{A Simple Example}
233\label{sec:simpleexample}
234
235\subsection{Overview}
236
237What follows is a discussion of the structure and operation of a
238script called \file{runup.py}.
239
240This example carries out the solution of the shallow-water wave
241equation in the simple case of a configuration comprising a flat
242bed, sloping at a fixed angle in one direction and having a
243constant depth across each line in the perpendicular direction.
244
245The example demonstrates the basic ideas involved in setting up a
246complex scenario. In general the user specifies the geometry
247(bathymetry and topography), the initial water level, boundary
248conditions such as tide, and any forcing terms that may drive the
249system such as wind stress or atmospheric pressure gradients.
250Frictional resistance from the different terrains in the model is
251represented by predefined forcing terms. In this example, the
252boundary is reflective on three sides and a time dependent wave on
253one side.
254
255The present example represents a simple scenario and does not
256include any forcing terms, nor is the data taken from a file as it
257would typically be.
258
259The conserved quantities involved in the
260problem are stage (absolute height of water surface),
261$x$-momentum and $y$-momentum. Other quantities
262involved in the computation are the friction and elevation.
263
264Water depth can be obtained through the equation
265
266\begin{tabular}{rcrcl}
267  \code{depth} &=& \code{stage} &$-$& \code{elevation}
268\end{tabular}
269
270
271\subsection{Outline of the Program}
272
273In outline, \file{runup.py} performs the following steps:
274
275\begin{enumerate}
276
277   \item Sets up a triangular mesh.
278
279   \item Sets certain parameters governing the mode of
280operation of the model-specifying, for instance, where to store the model output.
281
282   \item Inputs various quantities describing physical measurements, such
283as the elevation, to be specified at each mesh point (vertex).
284
285   \item Sets up the boundary conditions.
286
287   \item Carries out the evolution of the model through a series of time
288steps and outputs the results, providing a results file that can
289be visualised.
290
291\end{enumerate}
292
293\subsection{The Code}
294
295%FIXME: we are using the \code function here.
296%This should be used wherever possible
297For reference we include below the complete code listing for
298\file{runup.py}. Subsequent paragraphs provide a
299`commentary' that describes each step of the program and explains it
300significance.
301
302\verbatiminput{demos/runup.py}
303
304\subsection{Establishing the Mesh}\index{mesh, establishing}
305
306The first task is to set up the triangular mesh to be used for the
307scenario. This is carried out through the statement:
308
309{\small \begin{verbatim}
310    points, vertices, boundary = rectangular(10, 10)
311\end{verbatim}}
312
313The function \function{rectangular} is imported from a module
314\module{mesh\_factory} defined elsewhere. (\anuga also contains
315several other schemes that can be used for setting up meshes, but we
316shall not discuss these.) The above assignment sets up a $10 \times
31710$ rectangular mesh, triangulated in a regular way. The assignment
318
319{\small \begin{verbatim}
320    points, vertices, boundary = rectangular(m, n)
321\end{verbatim}}
322
323returns:
324
325\begin{itemize}
326
327   \item a list \code{points} giving the coordinates of each mesh point,
328
329   \item a list \code{vertices} specifying the three vertices of each triangle, and
330
331   \item a dictionary \code{boundary} that stores the edges on
332   the boundary and associates each with one of the symbolic tags \code{`left'}, \code{`right'},
333   \code{`top'} or \code{`bottom'}.
334
335\end{itemize}
336
337(For more details on symbolic tags, see page
338\pageref{ref:tagdescription}.)
339
340An example of a general unstructured mesh and the associated data
341structures \code{points}, \code{vertices} and \code{boundary} is
342given in Section \ref{sec:meshexample}.
343
344
345
346
347\subsection{Initialising the Domain}
348
349These variables are then used to set up a data structure
350\code{domain}, through the assignment:
351
352{\small \begin{verbatim}
353    domain = Domain(points, vertices, boundary)
354\end{verbatim}}
355
356This creates an instance of the \class{Domain} class, which
357represents the domain of the simulation. Specific options are set at
358this point, including the basename for the output file and the
359directory to be used for data:
360
361{\small \begin{verbatim}
362    domain.set_name('runup')
363\end{verbatim}}
364
365{\small \begin{verbatim}
366    domain.set_datadir('.')
367\end{verbatim}}
368
369In addition, the following statement now specifies that the
370quantities \code{stage}, \code{xmomentum} and \code{ymomentum} are
371to be stored:
372
373{\small \begin{verbatim}
374    domain.set_quantities_to_be_stored(['stage', 'xmomentum',
375    'ymomentum'])
376\end{verbatim}}
377
378
379\subsection{Initial Conditions}
380
381The next task is to specify a number of quantities that we wish to
382set for each mesh point. The class \class{Domain} has a method
383\method{set\_quantity}, used to specify these quantities. It is a
384flexible method that allows the user to set quantities in a variety
385of ways---using constants, functions, numeric arrays, expressions
386involving other quantities, or arbitrary data points with associated
387values, all of which can be passed as arguments. All quantities can
388be initialised using \method{set\_quantity}. For a conserved
389quantity (such as \code{stage, xmomentum, ymomentum}) this is called
390an \emph{initial condition}. However, other quantities that aren't
391updated by the equation are also assigned values using the same
392interface. The code in the present example demonstrates a number of
393forms in which we can invoke \method{set\_quantity}.
394
395
396\subsubsection{Elevation}
397
398The elevation, or height of the bed, is set using a function,
399defined through the statements below, which is specific to this
400example and specifies a particularly simple initial configuration
401for demonstration purposes:
402
403{\small \begin{verbatim}
404    def f(x,y):
405        return -x/2
406\end{verbatim}}
407
408This simply associates an elevation with each point \code{(x, y)} of
409the plane.  It specifies that the bed slopes linearly in the
410\code{x} direction, with slope $-\frac{1}{2}$,  and is constant in
411the \code{y} direction.
412
413Once the function \function{f} is specified, the quantity
414\code{elevation} is assigned through the simple statement:
415
416{\small \begin{verbatim}
417    domain.set_quantity('elevation', f)
418\end{verbatim}}
419
420
421\subsubsection{Friction}
422
423The assignment of the friction quantity (a forcing term)
424demonstrates another way we can use \method{set\_quantity} to set
425quantities---namely, assign them to a constant numerical value:
426
427{\small \begin{verbatim}
428    domain.set_quantity('friction', 0.1)
429\end{verbatim}}
430
431This specifies that the Manning friction coefficient is set to 0.1
432at every mesh point.
433
434\subsubsection{Stage}
435
436The stage (the height of the water surface) is related to the
437elevation and the depth at any time by the equation
438
439{\small \begin{verbatim}
440    stage = elevation + depth
441\end{verbatim}}
442
443
444For this example, we simply assign a constant value to \code{stage},
445using the statement
446
447{\small \begin{verbatim}
448    domain.set_quantity('stage', -.4)
449\end{verbatim}}
450
451which specifies that the surface level is set to a height of $-0.4$,
452i.e. 0.4 units (m) below the zero level.
453
454Although it is not necessary for this example, it may be useful to
455digress here and mention a variant to this requirement, which allows
456us to illustrate another way to use \method{set\_quantity}---namely,
457incorporating an expression involving other quantities. Suppose,
458instead of setting a constant value for the stage, we wished to
459specify a constant value for the \emph{depth}. For such a case we
460need to specify that \code{stage} is everywhere obtained by adding
461that value to the value already specified for \code{elevation}. We
462would do this by means of the statements:
463
464{\small \begin{verbatim}
465    h = 0.05 # Constant depth
466    domain.set_quantity('stage', expression = 'elevation + %f' %h)
467\end{verbatim}}
468
469That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus
470the value of \code{elevation} already defined.
471
472The reader will probably appreciate that this capability to
473incorporate expressions into statements using \method{set\_quantity}
474greatly expands its power.) See Section \ref{sec:Initial Conditions} for more
475details.
476
477\subsection{Boundary Conditions}\index{boundary conditions}
478
479The boundary conditions are specified as follows:
480
481{\small \begin{verbatim}
482    Br = Reflective_boundary(domain)
483
484    Bt = Transmissive_boundary(domain)
485
486    Bd = Dirichlet_boundary([0.2,0.,0.])
487
488    Bw = Time_boundary(domain=domain,
489                f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0])
490\end{verbatim}}
491
492The effect of these statements is to set up a selection of different
493alternative boundary conditions and store them in variables that can be
494assigned as needed. Each boundary condition specifies the
495behaviour at a boundary in terms of the behaviour in neighbouring
496elements. The boundary conditions introduced here may be briefly described as
497follows:
498
499\begin{itemize}
500    \item \textbf{Reflective boundary}\label{def:reflective boundary} Returns same \code{stage} as
501      as present in its neighbour volume but momentum vector
502      reversed 180 degrees (reflected).
503      Specific to the shallow water equation as it works with the
504      momentum quantities assumed to be the second and third conserved
505      quantities. A reflective boundary condition models a solid wall.
506    \item \textbf{Transmissive boundary}\label{def:transmissive boundary} Returns same conserved quantities as
507      those present in its neighbour volume. This is one way of modelling
508      outflow from a domain, but it should be used with caution if flow is
509      not steady state as replication of momentum at the boundary
510      may cause occasional spurious effects. If this occurs,
511      consider using e.g. a Dirichlet boundary condition.
512    \item \textbf{Dirichlet boundary}\label{def:dirichlet boundary} Specifies
513      constant values for stage, $x$-momentum and $y$-momentum at the boundary.
514    \item \textbf{Time boundary}\label{def:time boundary} Like a Dirichlet
515      boundary but with behaviour varying with time.
516\end{itemize}
517
518\label{ref:tagdescription}Before describing how these boundary
519conditions are assigned, we recall that a mesh is specified using
520three variables \code{points}, \code{vertices} and \code{boundary}.
521In the code we are discussing, these three variables are returned by
522the function \code{rectangular}; however, the example given in
523Section \ref{sec:realdataexample} illustrates another way of
524assigning the values, by means of the function
525\code{create\_mesh\_from\_regions}.
526
527These variables store the data determining the mesh as follows. (You
528may find that the example given in Section \ref{sec:meshexample}
529helps to clarify the following discussion, even though that example
530is a \emph{non-rectangular} mesh.)
531
532\begin{itemize}
533\item The variable \code{points} stores a list of 2-tuples giving the
534coordinates of the mesh points.
535
536\item The variable \code{vertices} stores a list of 3-tuples of
537numbers, representing vertices of triangles in the mesh. In this
538list, the triangle whose vertices are \code{points[i]},
539\code{points[j]}, \code{points[k]} is represented by the 3-tuple
540\code{(i, j, k)}.
541
542\item The variable \code{boundary} is a Python dictionary that
543not only stores the edges that make up the boundary but also assigns
544symbolic tags to these edges to distinguish different parts of the
545boundary. An edge with endpoints \code{points[i]} and
546\code{points[j]} is represented by the 2-tuple \code{(i, j)}. The
547keys for the dictionary are the 2-tuples \code{(i, j)} corresponding
548to boundary edges in the mesh, and the values are the tags are used
549to label them. In the present example, the value \code{boundary[(i,
550j)]} assigned to \code{(i, j)]} is one of the four tags
551\code{`left'}, \code{`right'}, \code{`top'} or \code{`bottom'},
552depending on whether the boundary edge represented by \code{(i, j)}
553occurs at the left, right, top or bottom of the rectangle bounding
554the mesh. The function \code{rectangular} automatically assigns
555these tags to the boundary edges when it generates the mesh.
556\end{itemize}
557
558The tags provide the means to assign different boundary conditions
559to an edge depending on which part of the boundary it belongs to.
560(In Section \ref{sec:realdataexample} we describe an example that
561uses different boundary tags---in general, the possible tags are not
562limited to `left', `right', `top' and `bottom', but can be specified
563by the user.)
564
565Using the boundary objects described above, we assign a boundary
566condition to each part of the boundary by means of a statement like
567
568{\small \begin{verbatim}
569    domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br})
570\end{verbatim}}
571
572This statement stipulates that, in the current example, the right
573boundary varies with time, as defined by the lambda function, while the other
574boundaries are all reflective.
575
576The reader may wish to experiment by varying the choice of boundary
577types for one or more of the boundaries. (In the case of \code{Bd}
578and \code{Bw}, the three arguments in each case represent the
579\code{stage}, $x$-momentum and $y$-momentum, respectively.)
580
581{\small \begin{verbatim}
582    Bw = Time_boundary(domain=domain,
583                       f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0])
584\end{verbatim}}
585
586
587
588\subsection{Evolution}\index{evolution}
589
590The final statement \nopagebreak[3]
591{\small \begin{verbatim}
592    for t in domain.evolve(yieldstep = 0.1, duration = 4.0):
593        print domain.timestepping_statistics()
594\end{verbatim}}
595
596causes the configuration of the domain to `evolve', over a series of
597steps indicated by the values of \code{yieldstep} and
598\code{duration}, which can be altered as required.  The value of
599\code{yieldstep} controls the time interval between successive model
600outputs.  Behind the scenes more time steps are generally taken.
601
602
603\subsection{Output}
604
605The output is a NetCDF file with the extension \code{.sww}. It
606contains stage and momentum information and can be used with the
607ANUGA viewer \code{animate} (see Section \ref{sec:animate})
608visualisation package
609to generate a visual display. See Section \ref{sec:file formats}
610(page \pageref{sec:file formats}) for more on NetCDF and other file
611formats.
612
613The following is a listing of the screen output seen by the user
614when this example is run:
615
616\verbatiminput{examples/runupoutput.txt}
617
618
619\section{How to Run the Code}
620
621The code can be run in various ways:
622
623\begin{itemize}
624  \item{from a Windows or Unix command line} as in\ \code{python runup.py}
625  \item{within the Python IDLE environment}
626  \item{within emacs}
627  \item{within Windows, by double-clicking the \code{runup.py}
628  file.}
629\end{itemize}
630
631
632\section{Exploring the Model Output}
633
634The following figures are screenshots from the \anuga visualisation
635tool \code{animate}. Figure \ref{fig:runupstart} shows the domain
636with water surface as specified by the initial condition, $t=0$.
637Figure \ref{fig:runup2} shows later snapshots for $t=2.3$ and
638$t=4$ where the system has been evolved and the wave is encroaching
639on the previously dry bed.  All figures are screenshots from an
640interactive animation tool called animate which is part of \anuga and
641distributed as in the package anuga\_viewer.
642Animate is described in more detail is Section \ref{sec:animate}.
643
644\begin{figure}[hbt]
645
646  \centerline{\includegraphics[width=75mm, height=75mm]
647    {graphics/bedslopestart.jpg}}
648
649  \caption{Runup example viewed with the ANUGA viewer}
650  \label{fig:runupstart}
651\end{figure}
652
653
654\begin{figure}[hbt]
655
656  \centerline{
657   \includegraphics[width=75mm, height=75mm]{graphics/bedslopeduring.jpg}
658    \includegraphics[width=75mm, height=75mm]{graphics/bedslopeend.jpg}
659   }
660
661  \caption{Runup example viewed with ANGUA viewer}
662  \label{fig:runup2}
663\end{figure}
664
665
666
667\clearpage
668
669%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
670
671\section{A slightly more complex example}
672\label{sec:channelexample}
673
674\subsection{Overview}
675
676The next example is about waterflow in a channel with varying boundary conditions and
677more complex topograhies. These examples build on the
678concepts introduced through the \file{runup.py} in Section \ref{sec:simpleexample}.
679The example will be built up through three progressively more complex scripts.
680
681\subsection{Overview}
682As in the case of \file{runup.py}, the actions carried
683out by the program can be organised according to this outline:
684
685\begin{enumerate}
686
687   \item Set up a triangular mesh.
688
689   \item Set certain parameters governing the mode of
690operation of the model---specifying, for instance, where to store the
691model output.
692
693   \item Set up initial conditions for various quantities such as the elevation, to be specified at each mesh point (vertex).
694
695   \item Set up the boundary conditions.
696
697   \item Carry out the evolution of the model through a series of time
698steps and output the results, providing a results file that can be
699visualised.
700
701\end{enumerate}
702
703
704\subsection{The Code}
705
706Here is the code for the first version of the channel flow \file{channel1.py}:
707
708\verbatiminput{demos/channel1.py}
709
710In discussing the details of this example, we follow the outline
711given above, discussing each major step of the code in turn.
712
713\subsection{Establishing the Mesh}\index{mesh, establishing}
714
715In this example we use a similar simple structured triangular mesh as in \code{runup.py} 
716for simplicity, but this time we will use a symmetric one and also
717change the physical extent of the domain. The assignment
718
719{\small \begin{verbatim}
720    points, vertices, boundary = rectangular_cross(m, n,
721                                                   len1=length, len2=width)
722\end{verbatim}}
723returns a m x n mesh similar to the one used in the previous example, except that now the
724extent in the x and y directions are given by the value of \code{length} and \code{width} 
725respectively.
726
727Defining m and n in terms of the extent as in this example provides a convenient way of
728controlling the resolution: By defining dx and dy to be the desired size of each hypothenuse in the mesh we can write the mesh generation as follows:
729
730{\small \begin{verbatim}
731length = 10.
732width = 5.
733dx = dy = 1           # Resolution: Length of subdivisions on both axes
734
735points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
736                                               len1=length, len2=width)
737\end{verbatim}}
738which yields a mesh of length=10m, width=5m with 1m spacings. To increase the resolution, as we will later in this example, one merely decrease the values of dx and dy.
739
740The rest of this script is as in the previous example.
741% except for an application of the 'expression' form of \code{set\_quantity} where we use the value of \code{elevation} to define the (dry) initial condition for \code{stage}:
742%{\small \begin{verbatim}
743%  domain.set_quantity('stage', expression='elevation')
744%\end{verbatim}}
745
746\section{Model Output}
747
748The following figure is a screenshot from the \anuga visualisation
749tool \code{animate} of output from this example.
750\begin{figure}[hbt]
751  \centerline{\includegraphics[height=75mm]
752    {graphics/channel1.png}}%
753
754  \caption{Simple channel example viewed with the ANUGA viewer.}
755  \label{fig:channel1}
756\end{figure}
757
758
759\subsection{Changing boundary conditions on the fly}
760
761Here is the code for the second version of the channel flow \file{channel2.py}:
762\verbatiminput{demos/channel2.py}
763This example differs from the first version in that a constant outflow boundary condition has
764been defined
765{\small \begin{verbatim}
766    Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow
767\end{verbatim}}
768and that it is applied to the right hand side boundary when the water level there exceeds 0m.
769{\small \begin{verbatim}
770for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0):
771    domain.write_time()
772
773    if domain.get_quantity('stage').get_values(interpolation_points=[[10, 2.5]]) > 0:       
774        print 'Stage > 0: Changing to outflow boundary'
775        domain.set_boundary({'right': Bo})
776\end{verbatim}}
777
778The if statement in the timestepping loop (evolve) gets the quantity
779\code{stage} and obtain the interpolated value at the point (10m,
7802.5m) which is on the right boundary. If the stage exceeds 0m a
781message is printed and the old boundary condition at tag 'right' is
782replaced by the outflow boundary using the method
783{\small \begin{verbatim} 
784    domain.set_boundary({'right': Bo})
785\end{verbatim}}
786This type of dynamically varying boundary could for example be used to model the
787breakdown of a sluice door when water exceeds a certain level.
788
789\subsection{Output}
790
791The text output from this example looks like this
792{\small \begin{verbatim} 
793...
794Time = 15.4000, delta t in [0.03789902, 0.03789916], steps=6 (6)
795Time = 15.6000, delta t in [0.03789896, 0.03789908], steps=6 (6)
796Time = 15.8000, delta t in [0.03789891, 0.03789903], steps=6 (6)
797Stage > 0: Changing to outflow boundary
798Time = 16.0000, delta t in [0.02709050, 0.03789898], steps=6 (6)
799Time = 16.2000, delta t in [0.03789892, 0.03789904], steps=6 (6)
800...
801\end{verbatim}}
802
803
804\subsection{Flow through more complex topograhies}
805
806Here is the code for the third version of the channel flow \file{channel3.py}:
807\verbatiminput{demos/channel3.py}
808
809This example differs from the first two versions in that the topography
810contains obstacles.
811
812This is accomplished here by defining the function \code{topography} as follows
813{\small \begin{verbatim}
814def topography(x,y):
815    """Complex topography defined by a function of vectors x and y
816    """
817   
818    z = -x/10                               
819
820    N = len(x)
821    for i in range(N):
822
823        # Step
824        if 10 < x[i] < 12:
825            z[i] += 0.4 - 0.05*y[i]       
826       
827        # Constriction
828        if 27 < x[i] < 29 and y[i] > 3:
829            z[i] += 2       
830       
831        # Pole
832        if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
833            z[i] += 2
834
835    return z
836\end{verbatim}}
837
838In addition, changing the resolution to dx=dy=0.1 creates a finer mesh resolving the new featurse better.
839
840A screenshot of this model at time == 15s is
841\begin{figure}[hbt]
842
843  \centerline{\includegraphics[height=75mm]
844    {graphics/channel3.png}}
845
846  \caption{More complex flow in a channel}
847  \label{fig:channel3}
848\end{figure}
849
850
851
852
853\clearpage
854
855%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
856
857\section{An Example with Real Data}
858\label{sec:realdataexample} The following discussion builds on the
859concepts introduced through the \file{runup.py} example and
860introduces a second example, \file{runcairns.py}.  This refers to
861a real-life scenario, in which the domain of interest surrounds the
862Cairns region. A
863hypothetical tsunami wave is generated by a submarine mass failure
864situated on the edge of the continental shelf.
865
866\subsection{Overview}
867As in the case of \file{runup.py}, the actions carried
868out by the program can be organised according to this outline:
869
870\begin{enumerate}
871
872   \item Set up a triangular mesh.
873
874   \item Set certain parameters governing the mode of
875operation of the model---specifying, for instance, where to store the
876model output.
877
878   \item Input various quantities describing physical measurements, such
879as the elevation, to be specified at each mesh point (vertex).
880
881   \item Set up the boundary conditions.
882
883   \item Carry out the evolution of the model through a series of time
884steps and output the results, providing a results file that can be
885visualised.
886
887\end{enumerate}
888
889
890
891\subsection{The Code}
892
893Here is the code for \file{runcairns.py}:
894
895\verbatiminput{demos/cairns/runcairns.py}
896
897In discussing the details of this example, we follow the outline
898given above, discussing each major step of the code in turn.
899
900\subsection{Establishing the Mesh}\index{mesh, establishing}
901
902One obvious way that the present example differs from
903\file{runup.py} is in the use of a more complex method to
904create the mesh. Instead of imposing a mesh structure on a
905rectangular grid, the technique used for this example involves
906building mesh structures inside polygons specified by the user,
907using a mesh-generator referred to as \code{pmesh}.
908
909In its simplest form, \code{pmesh} creates the mesh within a single
910polygon whose vertices are at geographical locations specified by
911the user. The user specifies the \emph{resolution}---that is, the
912maximal area of a triangle used for triangulation---and a triangular
913mesh is created inside the polygon using a mesh generation engine.
914On any given platform, the same mesh will be returned. Figure
915\ref{fig:pentagon} shows a simple example of this, in which the
916triangulation is carried out within a pentagon.
917
918
919\begin{figure}[hbt]
920
921  \caption{Mesh points are created inside the polygon}
922  \label{fig:pentagon}
923\end{figure}
924
925Boundary tags are not restricted to \code{`left'}, \code{`bottom'},
926\code{`right'} and \code{`top'}, as in the case of
927\file{runup.py}. Instead the user specifies a list of
928tags appropriate to the configuration being modelled.
929
930In addition, \code{pmesh} provides a way to adapt to geographic or
931other features in the landscape, whose presence may require an
932increase in resolution. This is done by allowing the user to specify
933a number of \emph{interior polygons}, each with a specified
934resolution, see Figure \ref{fig:interior meshes}. It is also
935possible to specify one or more `holes'---that is, areas bounded by
936polygons in which no triangulation is required.
937
938\begin{figure}[hbt]
939
940
941
942  \caption{Interior meshes with individual resolution}
943  \label{fig:interior meshes}
944\end{figure}
945
946In its general form, \code{pmesh} takes for its input a bounding
947polygon and (optionally) a list of interior polygons. The user
948specifies resolutions, both for the bounding polygon and for each of
949the interior polygons. Given this data, \code{pmesh} first creates a
950triangular mesh with varying resolution.
951
952The function used to implement this process is
953\function{create\_mesh\_from\_regions}. Its arguments include the
954bounding polygon and its resolution, a list of boundary tags, and a
955list of pairs \code{[polygon, resolution]}, specifying the interior
956polygons and their resolutions.
957
958In practice, the details of the polygons used are read from a
959separate file \file{project.py}. Here is a complete listing of
960\file{project.py}:
961
962\verbatiminput{demos/cairns/project.py}
963
964The resulting mesh is output to a \emph{mesh file}\index{mesh
965file}\label{def:mesh file}. This term is used to describe a file of
966a specific format used to store the data specifying a mesh. (There
967are in fact two possible formats for such a file: it can either be a
968binary file, with extension \code{.msh}, or an ASCII file, with
969extension \code{.tsh}. In the present case, the binary file format
970\code{.msh} is used. See Section \ref{sec:file formats} (page
971\pageref{sec:file formats}) for more on file formats.)
972
973Figure \ref{fig:cairns3d} illustrates the landscape of the region
974for the Cairns example. Understanding the landscape is important in
975determining the location and resolution of interior polygons. The
976supporting data is found in the ASCII grid, \code{cairns.asc}, which
977has been sourced from the publically available Australian Bathymetry
978and Topography Grid 2005, \cite{grid250:grid250}.
979
980\begin{figure}[hbt]
981\centerline{\includegraphics[scale=0.5]{graphics/cairns3.jpg}}
982\caption{Landscape of the Cairns scenario.}
983\label{fig:cairns3d}
984
985\end{figure}
986The following statements are used to read in the specific polygons
987from \code{project.cairns} and assign a defined resolution to
988each polygon.
989
990{\small \begin{verbatim}
991    islands_res = 100000
992    cairns_res = 100000
993    shallow_res = 500000
994    interior_regions = [[project.poly_cairns, cairns_res],
995                        [project.poly_island0, islands_res],
996                        [project.poly_island1, islands_res],
997                        [project.poly_island2, islands_res],
998                        [project.poly_island3, islands_res],
999                        [project.poly_shallow, shallow_res]]
1000\end{verbatim}}
1001
1002Figure \ref{fig:cairnspolys}
1003illustrates the polygons used for the Cairns scenario.
1004
1005\begin{figure}[hbt]
1006
1007  \centerline{\includegraphics[scale=0.5]
1008      {graphics/cairnsmodel.jpg}}
1009  \caption{Interior and bounding polygons for the Cairns example.}
1010  \label{fig:cairnspolys}
1011\end{figure}
1012
1013The statement
1014
1015{\small \begin{verbatim}
1016remainder_res = 10000000 
1017_ = cache(create_mesh_from_regions,
1018          project.polyAll,
1019           {'boundary_tags': {'top': [0], 'ocean_east': [1],
1020                              'bottom': [2], 'onshore': [3]},
1021           'maximum_triangle_area': remainder_res,
1022           'filename': meshname,
1023           'interior_regions': interior_regions},
1024          verbose = True, evaluate=False)
1025\end{verbatim}}
1026
1027is then used to create the mesh, taking the bounding polygon to be
1028the polygon \code{polyAll} specified in \file{project.py}.
1029The argument \code{boundary\_tags} assigns a dictionary, whose keys
1030are the names of the boundary tags used for the bounding
1031polygon---\code{`top'}, \code{`ocean\_east'}, \code{`bottom'}, and
1032\code{`onshore'}--- and whose values identify the indices of the
1033segments associated with each of these tags. (The value associated
1034with each boundary tag is a one-element list.)
1035
1036
1037\subsection{Initialising the Domain}
1038
1039As with \file{runup.py}, once we have created the mesh, the next
1040step is to create the data structure \code{domain}. We did this for
1041\file{runup.py} by inputting lists of points and triangles and
1042specifying the boundary tags directly. However, in the present case,
1043we use a method that works directly with the mesh file
1044\code{meshname}, as follows:
1045
1046
1047{\small \begin{verbatim}
1048    domain = Domain(meshname, use_cache=True, verbose=True)
1049\end{verbatim}}
1050
1051Providing a filename instead of the lists used in \file{runup.py}
1052above causes \code{Domain} to convert a mesh file \code{meshname}
1053into an instance of \code{Domain}, allowing us to use methods like
1054\method{set\_quantity} to set quantities and to apply other
1055operations.
1056
1057%(In principle, the
1058%second argument of \function{pmesh\_to\_domain\_instance} can be any
1059%subclass of \class{Domain}, but for applications involving the
1060%shallow-water wave equation, the second argument of
1061%\function{pmesh\_to\_domain\_instance} can always be set simply to
1062%\class{Domain}.)
1063
1064The following statements specify a basename and data directory, and
1065identify quantities to be stored. For the first two, values are
1066taken from \file{project.py}.
1067
1068{\small \begin{verbatim}
1069    domain.set_name(project.basename)
1070    domain.set_datadir(project.outputdir)
1071    domain.set_quantities_to_be_stored(['stage', 'xmomentum',
1072        'ymomentum'])
1073\end{verbatim}}
1074
1075
1076\subsection{Initial Conditions}
1077Quantities for \file{runcairns.py} are set
1078using similar methods to those in \file{runup.py}. However,
1079in this case, many of the values are read from the auxiliary file
1080\file{project.py} or, in the case of \code{elevation}, from an
1081ancillary points file.
1082
1083
1084
1085\subsubsection{Stage}
1086
1087For the scenario we are modelling in this case, we use a callable
1088object \code{tsunami\_source}, assigned by means of a function
1089\function{slump\_tsunami}. This is similar to how we set elevation in
1090\file{runup.py} using a function---however, in this case the
1091function is both more complex and more interesting.
1092
1093The function returns the water displacement for all \code{x} and
1094\code{y} in the domain. The water displacement is a double Gaussian
1095function that depends on the characteristics of the slump (length,
1096thickness, slope, etc), its location (origin) and the depth at that
1097location.
1098
1099
1100\subsubsection{Friction}
1101
1102We assign the friction exactly as we did for \file{runup.py}:
1103
1104{\small \begin{verbatim}
1105    domain.set_quantity('friction', 0.0)
1106\end{verbatim}}
1107
1108
1109\subsubsection{Elevation}
1110
1111The elevation is specified by reading data from a file:
1112
1113{\small \begin{verbatim}
1114    domain.set_quantity('elevation',
1115                        filename = project.dem_name + '.pts',
1116                        use_cache = True,
1117                        verbose = True)
1118\end{verbatim}}
1119
1120%However, before this step can be executed, some preliminary steps
1121%are needed to prepare the file from which the data is taken. Two
1122%source files are used for this data---their names are specified in
1123%the file \file{project.py}, in the variables \code{coarsedemname}
1124%and \code{finedemname}. They contain `coarse' and `fine' data,
1125%respectively---that is, data sampled at widely spaced points over a
1126%large region and data sampled at closely spaced points over a
1127%smaller subregion. The data in these files is combined through the
1128%statement
1129
1130%{\small \begin{verbatim}
1131%combine_rectangular_points_files(project.finedemname + '.pts',
1132%                                 project.coarsedemname + '.pts',
1133%                                 project.combineddemname + '.pts')
1134%\end{verbatim}}
1135%The effect of this is simply to combine the datasets by eliminating
1136%any coarse data associated with points inside the smaller region
1137%common to both datasets. The name to be assigned to the resulting
1138%dataset is also derived from the name stored in the variable
1139%\code{combinedname} in the file \file{project.py}.
1140
1141\subsection{Boundary Conditions}\index{boundary conditions}
1142
1143Setting boundaries follows a similar pattern to the one used for
1144\file{runup.py}, except that in this case we need to associate a
1145boundary type with each of the
1146boundary tag names introduced when we established the mesh. In place of the four
1147boundary types introduced for \file{runup.py}, we use the reflective
1148boundary for each of the
1149eight tagged segments defined by \code{create_mesh_from_regions}:
1150
1151{\small \begin{verbatim}
1152Bd = Dirichlet_boundary([0.0,0.0,0.0])
1153domain.set_boundary( {'ocean_east': Bd, 'bottom': Bd, 'onshore': Bd,
1154                          'top': Bd} )
1155\end{verbatim}}
1156
1157\subsection{Evolution}
1158
1159With the basics established, the running of the `evolve' step is
1160very similar to the corresponding step in \file{runup.py}. Here,
1161the simulation is run for five hours (10000 seconds) with
1162the output stored every two minutes (120 seconds).
1163
1164{\small \begin{verbatim}
1165    import time t0 = time.time()
1166
1167    for t in domain.evolve(yieldstep = 120, duration = 10000):
1168        print domain.timestepping_statistics()
1169        print domain.boundary_statistics(tags = 'bottom')
1170
1171    print 'That took %.2f seconds' %(time.time()
1172\end{verbatim}}
1173
1174%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1175%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1176
1177\chapter{\anuga Public Interface}
1178\label{ch:interface}
1179
1180This chapter gives an overview of the features of \anuga available
1181to the user at the public interface. These are grouped under the
1182following headings, which correspond to the outline of the examples
1183described in Chapter \ref{ch:getstarted}:
1184
1185\begin{itemize}
1186    \item Establishing the Mesh
1187    \item Initialising the Domain
1188    \item Specifying the Quantities
1189    \item Initial Conditions
1190    \item Boundary Conditions
1191    \item Forcing Functions
1192    \item Evolution
1193\end{itemize}
1194
1195The listings are intended merely to give the reader an idea of what
1196each feature is, where to find it and how it can be used---they do
1197not give full specifications; for these the reader
1198may consult the code. The code for every function or class contains
1199a documentation string, or `docstring', that specifies the precise
1200syntax for its use. This appears immediately after the line
1201introducing the code, between two sets of triple quotes.
1202
1203Each listing also describes the location of the module in which
1204the code for the feature being described can be found. All modules
1205are in the folder \file{inundation} or one of its subfolders, and the
1206location of each module is described relative to \file{inundation}. Rather
1207than using pathnames, whose syntax depends on the operating system,
1208we use the format adopted for importing the function or class for
1209use in Python code. For example, suppose we wish to specify that the
1210function \function{create\_mesh\_from\_regions} is in a module called
1211\module{mesh\_interface} in a subfolder of \module{inundation} called
1212\code{pmesh}. In Linux or Unix syntax, the pathname of the file
1213containing the function, relative to \file{inundation}, would be
1214
1215\begin{center}
1216%    \code{pmesh/mesh\_interface.py}
1217    \code{pmesh}$\slash$\code{mesh\_interface.py}
1218\end{center}
1219
1220while in Windows syntax it would be
1221
1222\begin{center}
1223    \code{pmesh}$\backslash$\code{mesh\_interface.py}
1224\end{center}
1225
1226Rather than using either of these forms, in this chapter we specify
1227the location simply as \code{pmesh.mesh\_interface}, in keeping with
1228the usage in the Python statement for importing the function,
1229namely:
1230\begin{center}
1231    \code{from pmesh.mesh\_interface import create\_mesh\_from\_regions}
1232\end{center}
1233
1234Each listing details the full set of parameters for the class or
1235function; however, the description is generally limited to the most
1236important parameters and the reader is again referred to the code
1237for more details.
1238
1239The following parameters are common to many functions and classes
1240and are omitted from the descriptions given below:
1241
1242%\begin{center}
1243\begin{tabular}{ll}  %\hline
1244%\textbf{Name } & \textbf{Description}\\
1245%\hline
1246\emph{use\_cache} & Specifies whether caching is to be used for improved performance. See Section \ref{sec:caching} for details on the underlying caching functionality\\
1247\emph{verbose} & If \code{True}, provides detailed terminal output
1248to the user\\  % \hline
1249\end{tabular}
1250%\end{center}
1251
1252\section{Mesh Generation}
1253
1254Before discussing the part of the interface relating to mesh
1255generation, we begin with a description of a simple example of a
1256mesh and use it to describe how mesh data is stored.
1257
1258\label{sec:meshexample} Figure \ref{fig:simplemesh} represents a
1259very simple mesh comprising just 11 points and 10 triangles.
1260
1261
1262\begin{figure}[h]
1263  \begin{center}
1264    %\includegraphics[width=90mm, height=90mm]{triangularmesh.eps}
1265  \end{center}
1266
1267  \caption{A simple mesh}
1268  \label{fig:simplemesh}
1269\end{figure}
1270
1271
1272The variables \code{points}, \code{vertices} and \code{boundary}
1273represent the data displayed in Figure \ref{fig:simplemesh} as
1274follows. The list \code{points} stores the coordinates of the
1275points, and may be displayed schematically as in Table
1276\ref{tab:points}.
1277
1278
1279\begin{table}
1280  \begin{center}
1281    \begin{tabular}[t]{|c|cc|} \hline
1282      index & \code{x} & \code{y}\\  \hline
1283      0 & 1 & 1\\
1284      1 & 4 & 2\\
1285      2 & 8 & 1\\
1286      3 & 1 & 3\\
1287      4 & 5 & 5\\
1288      5 & 8 & 6\\
1289      6 & 11 & 5\\
1290      7 & 3 & 6\\
1291      8 & 1 & 8\\
1292      9 & 4 & 9\\
1293      10 & 10 & 7\\  \hline
1294    \end{tabular}
1295  \end{center}
1296
1297  \caption{Point coordinates for mesh in
1298    Figure \protect \ref{fig:simplemesh}}
1299  \label{tab:points}
1300\end{table}
1301
1302The list \code{vertices} specifies the triangles that make up the
1303mesh. It does this by specifying, for each triangle, the indices
1304(the numbers shown in the first column above) that correspond to the
1305three points at its vertices, taken in an anti-clockwise order
1306around the triangle. Thus, in the example shown in Figure
1307\ref{fig:simplemesh}, the variable \code{vertices} contains the
1308entries shown in Table \ref{tab:vertices}. The starting point is
1309arbitrary so triangle $(0,1,3)$ is considered the same as $(1,3,0)$
1310and $(3,0,1)$.
1311
1312
1313\begin{table}
1314  \begin{center}
1315    \begin{tabular}{|c|ccc|} \hline
1316      index & \multicolumn{3}{c|}{\code{vertices}}\\ \hline
1317      0 & 0 & 1 & 3\\
1318      1 & 1 & 2 & 4\\
1319      2 & 2 & 5 & 4\\
1320      3 & 2 & 6 & 5\\
1321      4 & 4 & 5 & 9\\
1322      5 & 4 & 9 & 7\\
1323      6 & 3 & 4 & 7\\
1324      7 & 7 & 9 & 8\\
1325      8 & 1 & 4 & 3\\
1326      9 & 5 & 10 & 9\\  \hline
1327    \end{tabular}
1328  \end{center}
1329
1330  \caption{Vertices for mesh in Figure \protect \ref{fig:simplemesh}}
1331  \label{tab:vertices}
1332\end{table}
1333
1334Finally, the variable \code{boundary} identifies the boundary
1335triangles and associates a tag with each.
1336
1337\refmodindex[pmesh.meshinterface]{pmesh.mesh\_interface}\label{sec:meshgeneration}
1338
1339\begin{funcdesc}  {create\_mesh\_from\_regions}{bounding_polygon,
1340                             boundary_tags,
1341                             maximum_triangle_area,
1342                             filename=None,
1343                             interior_regions=None,
1344                             poly_geo_reference=None,
1345                             mesh_geo_reference=None,
1346                             minimum_triangle_angle=28.0}
1347Module: \module{pmesh.mesh\_interface}
1348
1349This function allows a user to initiate the automatic creation of a
1350mesh inside a specified polygon (input \code{bounding_polygon}).
1351Among the parameters that can be set are the \emph{resolution}
1352(maximal area for any triangle in the mesh) and the minimal angle
1353allowable in any triangle. The user can specify a number of internal
1354polygons within each of which a separate mesh is to be created,
1355generally with a smaller resolution. \code{interior_regions} is a
1356paired list containing the interior polygon and its resolution.
1357Additionally, the user specifies a list of boundary tags, one for
1358each edge of the bounding polygon.
1359
1360\textbf{WARNING}. Note that the dictionary structure used for the
1361parameter \code{boundary\_tags} is different from that used for the
1362variable \code{boundary} that occurs in the specification of a mesh.
1363In the case of \code{boundary}, the tags are the \emph{values} of
1364the dictionary, whereas in the case of \code{boundary_tags}, the
1365tags are the \emph{keys} and the \emph{value} corresponding to a
1366particular tag is a list of numbers identifying boundary edges
1367labelled with that tag. Because of this, it is theoretically
1368possible to assign the same edge to more than one tag. However, an
1369attempt to do this will cause an error.
1370\end{funcdesc}
1371
1372
1373
1374
1375\begin{classdesc}  {Mesh}{userSegments=None,
1376                 userVertices=None,
1377                 holes=None,
1378                 regions=None,
1379                 geo_reference=None}
1380Module: \module{pmesh.mesh}
1381
1382A class used to build a mesh outline and generate a two-dimensional
1383triangular mesh. The mesh outline is used to describe features on the
1384mesh, such as the mesh boundary. Many of this classes methods are used
1385to build a mesh outline, such as \code{add\_vertices} and
1386\code{add\_region\_from\_polygon}.
1387
1388\end{classdesc}
1389
1390
1391\subsection{Key Methods of Class Mesh}
1392
1393
1394\begin{methoddesc} {add\_hole}{x,y, geo_reference=None}
1395Module: \module{pmesh.mesh},  Class: \class{Mesh}
1396
1397This method is used to build the mesh outline.  It defines a hole,
1398when the boundary of the hole has already been defined, by selecting a
1399point within the boundary.
1400
1401\end{methoddesc}
1402
1403
1404\begin{methoddesc}  {add\_hole\_from\_polygon}{self, polygon, tags=None,
1405    geo_reference=None}
1406Module: \module{pmesh.mesh},  Class: \class{Mesh}
1407
1408This method is used to add a `hole' within a region ---that is, to
1409define a interior region where the triangular mesh will not be
1410generated---to a \class{Mesh} instance. The region boundary is described by
1411the polygon passed in.  Additionally, the user specifies a list of
1412boundary tags, one for each edge of the bounding polygon.
1413\end{methoddesc}
1414
1415
1416\begin{methoddesc}  {add\_points_and_segments}{self, points, segments,
1417    segment\_tags=None}
1418Module: \module{pmesh.mesh},  Class: \class{Mesh}
1419
1420This method is used to build the mesh outline. It adds some points and
1421segments connecting some points.  A tag for each point can optionally
1422be added.
1423
1424\end{methoddesc}
1425
1426\begin{methoddesc} {add\_region}{x,y, geo_reference=None}
1427Module: \module{pmesh.mesh},  Class: \class{Mesh}
1428
1429This method is used to build the mesh outline.  It defines a region,
1430when the boundary of the region has already been defined, by selecting
1431a point within the boundary.  A region instance is returned.  This can
1432be used to set the resolution.
1433
1434\end{methoddesc}
1435
1436\begin{methoddesc}  {add\_region\_from\_polygon}{self, polygon, tags=None,
1437                                max_triangle_area=None, geo_reference=None}
1438Module: \module{pmesh.mesh},  Class: \class{Mesh}
1439
1440This method is used to build the mesh outline.  It adds a region to a
1441\class{Mesh} instance.  Regions are commonly used to describe an area
1442with an increased density of triangles, by setting
1443\code{max_triangle_area}.  The
1444region boundary is described by the input \code{polygon}.  Additionally, the
1445user specifies a list of boundary tags, one for each edge of the
1446bounding polygon.
1447
1448\end{methoddesc}
1449
1450
1451
1452
1453
1454\begin{methoddesc} {add\_vertices}{point_data}
1455Module: \module{pmesh.mesh},  Class: \class{Mesh}
1456Add user vertices. The point_data can be a list of (x,y) values, a numeric
1457array or a geospatial_data instance.   
1458\end{methoddesc}
1459
1460\begin{methoddesc} {auto\_segment}{raw_boundary=raw_boundary,
1461                    remove_holes=remove_holes,
1462                    smooth_indents=smooth_indents,
1463                    expand_pinch=expand_pinch}
1464Module: \module{pmesh.mesh},  Class: \class{Mesh}
1465Add segments between the user vertices to give the vertices an
1466outline.  The outline is an alpha shape. This method is
1467useful since a set of user vertices need to be outlined by segments
1468before generate_mesh is called.
1469       
1470\end{methoddesc}
1471
1472\begin{methoddesc}  {export\_mesh_file}{self,ofile}
1473Module: \module{pmesh.mesh},  Class: \class{Mesh}
1474
1475This method is used to save the mesh to a file. \code{ofile} is the
1476name of the mesh file to be written, including the extension.  Use
1477the extension \code{.msh} for the file to be in NetCDF format and
1478\code{.tsh} for the file to be ASCII format.
1479\end{methoddesc}
1480
1481\begin{methoddesc}  {generate\_mesh}{self,
1482                      maximum_triangle_area=None,
1483                      minimum_triangle_angle=28.0,
1484                      verbose=False}
1485Module: \module{pmesh.mesh},  Class: \class{Mesh}
1486
1487This method is used to generate the triangular mesh.  The  maximal
1488area of any triangle in the mesh can be specified, which is used to
1489control the triangle density, along with the
1490minimum angle in any triangle.
1491\end{methoddesc}
1492
1493
1494
1495\begin{methoddesc}  {import_ungenerate_file}{self,ofile, tag=None}
1496Module: \module{pmesh.mesh},  Class: \class{Mesh}
1497
1498This method is used to import a polygon file in the ungenerate
1499format, which is used by arcGIS. The polygons from the file are converted to
1500vertices and segments. \code{ofile} is the name of the polygon file.
1501\code{tag} is the tag given to all the polygon's segments.
1502
1503This function can be used to import building footprints.
1504\end{methoddesc}
1505
1506%%%%%%
1507\section{Initialising the Domain}
1508
1509%Include description of the class Domain and the module domain.
1510
1511%FIXME (Ole): This is also defined in a later chapter
1512%\declaremodule{standard}{...domain}
1513
1514\begin{classdesc} {Domain} {source=None,
1515                 triangles=None,
1516                 boundary=None,
1517                 conserved_quantities=None,
1518                 other_quantities=None,
1519                 tagged_elements=None,
1520                 geo_reference=None,
1521                 use_inscribed_circle=False,
1522                 mesh_filename=None,
1523                 use_cache=False,
1524                 verbose=False,
1525                 full_send_dict=None,
1526                 ghost_recv_dict=None,
1527                 processor=0,
1528                 numproc=1}
1529Module: \refmodule{abstract_2d_finite_volumes.domain}
1530
1531This class is used to create an instance of a data structure used to
1532store and manipulate data associated with a mesh. The mesh is
1533specified either by assigning the name of a mesh file to
1534\code{source} or by
1535\end{classdesc}
1536
1537\begin{funcdesc}  {pmesh\_to\_domain\_instance}{file_name, DomainClass, use_cache = False, verbose = False}
1538Module: \module{abstract\_2d\_finite\_volumes.pmesh2domain}
1539
1540Once the initial mesh file has been created, this function is
1541applied to convert it to a domain object---that is, to a member of
1542the special Python class \class{Domain} (or a subclass of
1543\class{Domain}), which provides access to properties and methods
1544that allow quantities to be set and other operations to be carried
1545out.
1546
1547\code{file\_name} is the name of the mesh file to be converted,
1548including the extension. \code{DomainClass} is the class to be
1549returned, which must be a subclass of \class{Domain} having the same
1550interface as \class{Domain}---in practice, it can usually be set
1551simply to \class{Domain}.
1552
1553This is now superseded by Domain(mesh_filename).
1554\end{funcdesc}
1555
1556
1557\subsection{Key Methods of Domain}
1558
1559\begin{methoddesc} {set\_name}{name}
1560    Module: \refmodule{abstract\_2d\_finite\_volumes.domain},
1561    page \pageref{mod:domain} 
1562
1563    Assigns the name \code{name} to the domain.
1564\end{methoddesc}
1565
1566\begin{methoddesc} {get\_name}{}
1567    Module: \module{abstract\_2d\_finite\_volumes.domain}
1568
1569    Returns the name assigned to the domain by \code{set\_name}. If no name has been
1570    assigned, returns \code{`domain'}.
1571\end{methoddesc}
1572
1573\begin{methoddesc} {set\_datadir}{name}
1574    Module: \module{abstract\_2d\_finite\_volumes.domain}
1575
1576    Specifies the directory used for SWW files, assigning it to the
1577    pathname \code{name}. The default value, before
1578    \code{set\_datadir} has been run, is the value \code{default\_datadir}
1579    specified in \code{config.py}.
1580
1581    Since different operating systems use different formats for specifying pathnames,
1582    it is necessary to specify path separators using the Python code \code{os.sep}, rather than
1583    the operating-specific ones such as `$\slash$' or `$\backslash$'.
1584    For this to work you will need to include the statement \code{import os}
1585    in your code, before the first appearance of \code{set\_datadir}.
1586
1587    For example, to set the data directory to a subdirectory
1588    \code{data} of the directory \code{project}, you could use
1589    the statements:
1590
1591    {\small \begin{verbatim}
1592        import os
1593        domain.set_datadir{'project' + os.sep + 'data'}
1594    \end{verbatim}}
1595\end{methoddesc}
1596
1597\begin{methoddesc} {get\_datadir}{}
1598    Module: \module{abstract\_2d\_finite\_volumes.domain}
1599
1600    Returns the data directory set by \code{set\_datadir} or,
1601    if \code{set\_datadir} has not
1602    been run, returns the value \code{default\_datadir} specified in
1603    \code{config.py}.
1604\end{methoddesc}
1605
1606\begin{methoddesc} {set\_minimum_storable_height}{time=0.0}
1607    Module: \module{shallow\_water.shallow\_water\_domain}
1608
1609    Sets the minimum depth that will be recognised when writing
1610    to an sww file. This is useful for removing thin water layers
1611    that seems to be caused by friction creep.
1612\end{methoddesc}
1613
1614\begin{methoddesc} {set\_time}{time=0.0}
1615    Module: \module{abstract\_2d\_finite\_volumes.domain}
1616
1617    Sets the initial time, in seconds, for the simulation. The
1618    default is 0.0.
1619\end{methoddesc}
1620
1621\begin{methoddesc} {set\_default\_order}{n}
1622    Sets the default (spatial) order to the value specified by
1623    \code{n}, which must be either 1 or 2. (Assigning any other value
1624    to \code{n} will cause an error.)
1625\end{methoddesc}
1626
1627
1628%%%%%%
1629\section{Initial Conditions}
1630\label{sec:Initial Conditions}
1631In standard usage of partial differential equations, initial conditions
1632refers to the values associated to the system variables (the conserved
1633quantities here) for \code{time = 0}. In setting up a scenario script
1634as described in Sections \ref{sec:simpleexample} and \ref{sec:realdataexample},
1635\code{set_quantity} is used to define the initial conditions of variables
1636other than the conserved quantities, such as friction. Here, we use the terminology
1637of initial conditions to refer to initial values for variables which need
1638prescription to solve the shallow water wave equation. Further, it must be noted
1639that \code{set_quantity} does not necessarily have to be used in the initial
1640condition setting; it can be used at any time throughout the simulation.
1641
1642\begin{methoddesc}{set\_quantity}{name,
1643    numeric = None,
1644    quantity = None,
1645    function = None,
1646    geospatial_data = None,
1647    filename = None,
1648    attribute_name = None,
1649    alpha = None,
1650    location = 'vertices',
1651    indices = None,
1652    verbose = False,
1653    use_cache = False}
1654  Module: \module{abstract\_2d\_finite\_volumes.domain}
1655  (see also \module{abstract\_2d\_finite\_volumes.quantity.set\_values})
1656
1657This function is used to assign values to individual quantities for a
1658domain. It is very flexible and can be used with many data types: a
1659statement of the form \code{domain.set\_quantity(name, x)} can be used
1660to define a quantity having the name \code{name}, where the other
1661argument \code{x} can be any of the following:
1662
1663\begin{itemize}
1664\item a number, in which case all vertices in the mesh gets that for
1665the quantity in question.
1666\item a list of numbers or a Numeric array ordered the same way as the mesh vertices.
1667\item a function (e.g.\ see the samples introduced in Chapter 2)
1668\item an expression composed of other quantities and numbers, arrays, lists (for
1669example, a linear combination of quantities, such as
1670\code{domain.set\_quantity('stage','elevation'+x))}
1671\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.
1672\item a geospatial dataset (See ?????). Optional argument attribute\_name applies here as with files.
1673\end{itemize}
1674
1675
1676Exactly one of the arguments
1677  numeric, quantity, function, points, filename
1678must be present.
1679
1680
1681Set quantity will look at the type of the second argument (\code{numeric}) and
1682determine what action to take.
1683
1684Values can also be set using the appropriate keyword arguments.
1685If 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)}
1686are all equivalent.
1687
1688
1689Other optional arguments are
1690\begin{itemize}
1691\item \code{indices} which is a list of ids of triangles to which set\_quantity should apply its assignment of values.
1692\item \code{location} determines which part of the triangles to assign
1693  to. Options are 'vertices' (default), 'edges', 'unique vertices', and 'centroids'.
1694\end{itemize}
1695
1696%%%
1697\anuga provides a number of predefined initial conditions to be used
1698with \code{set\_quantity}.
1699
1700\end{methoddesc}
1701
1702
1703
1704
1705\begin{funcdesc}{set_region}{tag, quantity, X, location='vertices'}
1706  Module: \module{abstract\_2d\_finite\_volumes.domain}
1707 
1708  (see also \module{abstract\_2d\_finite\_volumes.quantity.set\_values})
1709 
1710This function is used to assign values to individual quantities given
1711a regional tag.   It is similar to \code{set\_quantity}.
1712For example, if in pmesh a regional tag of 'ditch' was
1713used, set\_region can be used to set elevation of this region to
1714-10m. X is the constant or function to be applied to the quantity,
1715over the tagged region.  Location describes how the values will be
1716applied.  Options are 'vertices' (default), 'edges', 'unique
1717vertices', and 'centroids'.
1718
1719This method can also be called with a list of region objects.  This is
1720useful for adding quantities in regions, and having one quantity
1721value based on another quantity. See  \module{abstract\_2d\_finite\_volumes.region} for
1722more details.
1723\end{funcdesc}
1724
1725
1726
1727
1728\begin{funcdesc}{slump_tsunami}{length, depth, slope, width=None, thickness=None,
1729                x0=0.0, y0=0.0, alpha=0.0,
1730                gravity=9.8, gamma=1.85,
1731                massco=1, dragco=1, frictionco=0, psi=0,
1732                dx=None, kappa=3.0, kappad=0.8, zsmall=0.01,
1733                domain=None,
1734                verbose=False}
1735Module: \module{shallow\_water.smf}
1736
1737This function returns a callable object representing an initial water
1738displacement generated by a submarine sediment failure. These failures can take the form of
1739a submarine slump or slide. In the case of a slide, use \code{slide_tsunami} instead.
1740
1741The arguments include as a minimum, the slump or slide length, the water depth to the centre of sediment
1742mass, and the bathymetric slope. Other slump or slide parameters can be included if they are known.
1743\end{funcdesc}
1744
1745
1746%%%
1747\begin{funcdesc}{file\_function}{filename,
1748    domain = None,
1749    quantities = None,
1750    interpolation_points = None,
1751    verbose = False,
1752    use_cache = False}
1753Module: \module{abstract\_2d\_finite\_volumes.util}
1754
1755Reads the time history of spatial data for
1756specified interpolation points from a NetCDF file (\code{filename})
1757and returns
1758a callable object. \code{filename} could be a \code{sww} file.
1759Returns interpolated values based on the input
1760file using the underlying \code{interpolation\_function}.
1761
1762\code{quantities} is either the name of a single quantity to be
1763interpolated or a list of such quantity names. In the second case, the resulting
1764function will return a tuple of values---one for each quantity.
1765
1766\code{interpolation\_points} is a list of absolute UTM coordinates
1767for points at which values are sought.
1768
1769The model time stored within the file function can be accessed using
1770the method \code{f.get\_time()}
1771\end{funcdesc}
1772
1773%%%
1774\begin{classdesc}{Interpolation\_function}{self,
1775    time,
1776    quantities,
1777    quantity_names = None,
1778    vertex_coordinates = None,
1779    triangles = None,
1780    interpolation_points = None,
1781    verbose = False}
1782Module: \module{abstract\_2d\_finite\_volumes.least\_squares}
1783
1784Given a time series (i.e. a series of values associated with
1785different times), whose values are either just numbers or a set of
1786numbers defined at the vertices of a triangular mesh (such as those
1787stored in SWW files), \code{Interpolation\_function} is used to
1788create a callable object that interpolates a value for an arbitrary
1789time \code{t} within the model limits and possibly a point \code{(x,
1790y)} within a mesh region.
1791
1792The actual time series at which data is available is specified by
1793means of an array \code{time} of monotonically increasing times. The
1794quantities containing the values to be interpolated are specified in
1795an array---or dictionary of arrays (used in conjunction with the
1796optional argument \code{quantity\_names}) --- called
1797\code{quantities}. The optional arguments \code{vertex\_coordinates}
1798and \code{triangles} represent the spatial mesh associated with the
1799quantity arrays. If omitted the function created by
1800\code{Interpolation\_function} will be a function of \code{t} only.
1801
1802Since, in practice, values need to be computed at specified points,
1803the syntax allows the user to specify, once and for all, a list
1804\code{interpolation\_points} of points at which values are required.
1805In this case, the function may be called using the form \code{f(t,
1806id)}, where \code{id} is an index for the list
1807\code{interpolation\_points}.
1808
1809\end{classdesc}
1810
1811%%%
1812%\begin{funcdesc}{set\_region}{functions}
1813%[Low priority. Will be merged into set\_quantity]
1814
1815%Module:\module{abstract\_2d\_finite\_volumes.domain}
1816%\end{funcdesc}
1817
1818
1819
1820%%%%%%
1821\section{Boundary Conditions}\index{boundary conditions}
1822
1823\anuga provides a large number of predefined boundary conditions,
1824represented by objects such as \code{Reflective\_boundary(domain)} and
1825\code{Dirichlet\_boundary([0.2, 0.0, 0.0])}, described in the examples
1826in Chapter 2. Alternatively, you may prefer to ``roll your own'',
1827following the method explained in Section \ref{sec:roll your own}.
1828
1829These boundary objects may be used with the function \code{set\_boundary} described below
1830to assign boundary conditions according to the tags used to label boundary segments.
1831
1832\begin{methoddesc}{set\_boundary}{boundary_map}
1833Module: \module{abstract\_2d\_finite\_volumes.domain}
1834
1835This function allows you to assign a boundary object (corresponding to a
1836pre-defined or user-specified boundary condition) to every boundary segment that
1837has been assigned a particular tag.
1838
1839This is done by specifying a dictionary \code{boundary\_map}, whose values are the boundary objects
1840and whose keys are the symbolic tags.
1841
1842\end{methoddesc}
1843
1844\begin{methoddesc} {get\_boundary\_tags}{}
1845Module: \module{abstract\_2d\_finite\_volumes.mesh}
1846
1847Returns a list of the available boundary tags.
1848\end{methoddesc}
1849
1850%%%
1851\subsection{Predefined boundary conditions}
1852
1853\begin{classdesc}{Reflective\_boundary}{Boundary}
1854Module: \module{shallow\_water}
1855
1856Reflective boundary returns same conserved quantities as those present in
1857the neighbouring volume but reflected.
1858
1859This class is specific to the shallow water equation as it works with the
1860momentum quantities assumed to be the second and third conserved quantities.
1861\end{classdesc}
1862
1863%%%
1864\begin{classdesc}{Transmissive\_boundary}{domain = None}
1865Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}
1866
1867A transmissive boundary returns the same conserved quantities as
1868those present in the neighbouring volume.
1869
1870The underlying domain must be specified when the boundary is instantiated.
1871\end{classdesc}
1872
1873%%%
1874\begin{classdesc}{Dirichlet\_boundary}{conserved_quantities=None}
1875Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}
1876
1877A Dirichlet boundary returns constant values for each of conserved
1878quantities. In the example of \code{Dirichlet\_boundary([0.2, 0.0, 0.0])},
1879the \code{stage} value at the boundary is 0.2 and the \code{xmomentum} and
1880\code{ymomentum} at the boundary are set to 0.0. The list must contain
1881a value for each conserved quantity.
1882\end{classdesc}
1883
1884%%%
1885\begin{classdesc}{Time\_boundary}{domain = None, f = None}
1886Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}
1887
1888A time-dependent boundary returns values for the conserved
1889quantities as a function \code{f(t)} of time. The user must specify
1890the domain to get access to the model time.
1891\end{classdesc}
1892
1893%%%
1894\begin{classdesc}{File\_boundary}{Boundary}
1895Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}
1896
1897This method may be used if the user wishes to apply a SWW file or
1898a time series file to a boundary segment or segments.
1899The boundary values are obtained from a file and interpolated to the
1900appropriate segments for each conserved quantity.
1901\end{classdesc}
1902
1903
1904
1905%%%
1906\begin{classdesc}{Transmissive\_Momentum\_Set\_Stage\_boundary}{Boundary}
1907Module: \module{shallow\_water}
1908
1909This boundary returns same momentum conserved quantities as
1910those present in its neighbour volume but sets stage as in a Time\_boundary.
1911The underlying domain must be specified when boundary is instantiated
1912
1913This type of boundary is useful when stage is known at the boundary as a
1914function of time, but momenta (or speeds) aren't.
1915
1916This class is specific to the shallow water equation as it works with the
1917momentum quantities assumed to be the second and third conserved quantities.
1918\end{classdesc}
1919
1920
1921
1922\subsection{User-defined boundary conditions}
1923\label{sec:roll your own}
1924[How to roll your own] TBA
1925
1926
1927
1928
1929
1930\section{Forcing Functions}
1931
1932\anuga provides a number of predefined forcing functions to be used with .....
1933
1934%\begin{itemize}
1935
1936
1937%  \item \indexedcode{}
1938%  [function, arguments]
1939
1940%  \item \indexedcode{}
1941
1942%\end{itemize}
1943
1944
1945
1946\section{Evolution}\index{evolution}
1947
1948  \begin{methoddesc}{evolve}{yieldstep = None, finaltime = None, duration = None, skip_initial_step = False}
1949
1950  Module: \module{abstract\_2d\_finite\_volumes.domain}
1951
1952  This function (a method of \class{domain}) is invoked once all the
1953  preliminaries have been completed, and causes the model to progress
1954  through successive steps in its evolution, storing results and
1955  outputting statistics whenever a user-specified period
1956  \code{yieldstep} is completed (generally during this period the
1957  model will evolve through several steps internally
1958  as the method forces the water speed to be calculated
1959  on successive new cells). The user
1960  specifies the total time period over which the evolution is to take
1961  place, by specifying values (in seconds) for either \code{duration}
1962  or \code{finaltime}, as well as the interval in seconds after which
1963  results are to be stored and statistics output.
1964
1965  You can include \method{evolve} in a statement of the type:
1966
1967  {\small \begin{verbatim}
1968      for t in domain.evolve(yieldstep, finaltime):
1969          <Do something with domain and t>
1970  \end{verbatim}}
1971
1972  \end{methoddesc}
1973
1974
1975
1976\subsection{Diagnostics}
1977
1978
1979  \begin{funcdesc}{statistics}{}
1980  Module: \module{abstract\_2d\_finite\_volumes.domain}
1981
1982  \end{funcdesc}
1983
1984  \begin{funcdesc}{timestepping\_statistics}{}
1985  Module: \module{abstract\_2d\_finite\_volumes.domain}
1986
1987  Returns a string of the following type for each
1988  timestep:
1989
1990  \code{Time = 0.9000, delta t in [0.00598964, 0.01177388], steps=12
1991  (12)}
1992
1993  Here the numbers in \code{steps=12 (12)} indicate the number of steps taken and
1994  the number of first-order steps, respectively.
1995  \end{funcdesc}
1996
1997
1998  \begin{funcdesc}{boundary\_statistics}{quantities = None, tags = None}
1999  Module: \module{abstract\_2d\_finite\_volumes.domain}
2000
2001  Returns a string of the following type when \code{quantities = 'stage'} and \code{tags = ['top', 'bottom']}:
2002
2003  {\small \begin{verbatim}
2004 Boundary values at time 0.5000:
2005    top:
2006        stage in [ -0.25821218,  -0.02499998]
2007    bottom:
2008        stage in [ -0.27098821,  -0.02499974]
2009  \end{verbatim}}
2010
2011  \end{funcdesc}
2012
2013
2014  \begin{funcdesc}{get\_quantity}{name, location='vertices', indices = None}
2015  Module: \module{abstract\_2d\_finite\_volumes.domain}
2016  Allow access to individual quantities and their methods
2017
2018  \end{funcdesc}
2019
2020
2021  \begin{funcdesc}{get\_values}{location='vertices', indices = None}
2022  Module: \module{abstract\_2d\_finite\_volumes.quantity}
2023
2024  Extract values for quantity as an array
2025
2026  \end{funcdesc}
2027
2028
2029  \begin{funcdesc}{get\_integral}{}
2030  Module: \module{abstract\_2d\_finite\_volumes.quantity}
2031
2032  Return computed integral over entire domain for this quantity
2033
2034  \end{funcdesc}
2035
2036  %FIXME (Ole): Document these new funcs in shallow_water_domain and the also the ones they use in quantity.py
2037  %  w = domain.get_maximum_inundation_elevation()
2038  %  x, y = domain.get_maximum_inundation_location() 
2039
2040\section{Other}
2041
2042  \begin{funcdesc}{domain.create\_quantity\_from\_expression}{???}
2043
2044  Handy for creating derived quantities on-the-fly.
2045  See \file{Analytical\_solution\_circular\_hydraulic\_jump.py} for an example of use.
2046  \end{funcdesc}
2047
2048
2049
2050
2051
2052%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2053%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2054
2055\chapter{\anuga System Architecture}
2056
2057
2058\section{File Formats}
2059\label{sec:file formats}
2060
2061\anuga makes use of a number of different file formats. The
2062following table lists all these formats, which are described in more
2063detail in the paragraphs below.
2064
2065\bigskip
2066
2067\begin{center}
2068
2069\begin{tabular}{|ll|}  \hline
2070
2071\textbf{Extension} & \textbf{Description} \\
2072\hline\hline
2073
2074\code{.sww} & NetCDF format for storing model output
2075\code{f(t,x,y)}\\
2076
2077\code{.tms} & NetCDF format for storing time series \code{f(t)}\\
2078
2079\code{.xya} & ASCII format for storing arbitrary points and
2080associated attributes\\
2081
2082\code{.pts} & NetCDF format for storing arbitrary points and
2083associated attributes\\
2084
2085\code{.asc} & ASCII format of regular DEMs as output from ArcView\\
2086
2087\code{.prj} & Associated ArcView file giving more metadata for
2088\code{.asc} format\\
2089
2090\code{.ers} & ERMapper header format of regular DEMs for ArcView\\
2091
2092\code{.dem} & NetCDF representation of regular DEM data\\
2093
2094\code{.tsh} & ASCII format for storing meshes and associated
2095boundary and region info\\
2096
2097\code{.msh} & NetCDF format for storing meshes and associated
2098boundary and region info\\
2099
2100\code{.nc} & Native ferret NetCDF format\\
2101
2102\code{.geo} & Houdinis ASCII geometry format (?) \\  \par \hline
2103%\caption{File formats used by \anuga}
2104\end{tabular}
2105
2106
2107\end{center}
2108
2109The above table shows the file extensions used to identify the
2110formats of files. However, typically, in referring to a format we
2111capitalise the extension and omit the initial full stop---thus, we
2112refer, for example, to `SWW files' or `PRJ files'.
2113
2114\bigskip
2115
2116A typical dataflow can be described as follows:
2117
2118\subsection{Manually Created Files}
2119
2120\begin{tabular}{ll}
2121ASC, PRJ & Digital elevation models (gridded)\\
2122NC & Model outputs for use as boundary conditions (e.g. from MOST)
2123\end{tabular}
2124
2125\subsection{Automatically Created Files}
2126
2127\begin{tabular}{ll}
2128ASC, PRJ  $\rightarrow$  DEM  $\rightarrow$  PTS & Convert
2129DEMs to native \code{.pts} file\\
2130
2131NC $\rightarrow$ SWW & Convert MOST boundary files to
2132boundary \code{.sww}\\
2133
2134PTS + TSH $\rightarrow$ TSH with elevation & Least squares fit\\
2135
2136TSH $\rightarrow$ SWW & Convert TSH to \code{.sww}-viewable using
2137\code{animate}\\
2138
2139TSH + Boundary SWW $\rightarrow$ SWW & Simulation using
2140\code{\anuga}\\
2141
2142Polygonal mesh outline $\rightarrow$ & TSH or MSH
2143\end{tabular}
2144
2145
2146
2147
2148\bigskip
2149
2150\subsection{SWW and TMS Formats}
2151
2152The SWW and TMS formats are both NetCDF formats, and are of key
2153importance for \anuga.
2154
2155An SWW file is used for storing \anuga output and therefore pertains
2156to a set of points and a set of times at which a model is evaluated.
2157It contains, in addition to dimension information, the following
2158variables:
2159
2160\begin{itemize}
2161    \item \code{x} and \code{y}: coordinates of the points, represented as Numeric arrays
2162    \item \code{elevation}, a Numeric array storing bed-elevations
2163    \item \code{volumes}, a list specifying the points at the vertices of each of the
2164    triangles
2165    % Refer here to the example to be provided in describing the simple example
2166    \item \code{time}, a Numeric array containing times for model
2167    evaluation
2168\end{itemize}
2169
2170
2171The contents of an SWW file may be viewed using the anuga viewer
2172\code{animate}, which creates an on-screen geometric
2173representation. See section \ref{sec:animate} (page
2174\pageref{sec:animate}) in Appendix \ref{ch:supportingtools} for more
2175on \code{animate}.
2176
2177Alternatively, there are tools, such as \code{ncdump}, that allow
2178you to convert an NetCDF file into a readable format such as the
2179Class Definition Language (CDL). The following is an excerpt from a
2180CDL representation of the output file \file{runup.sww} generated
2181from running the simple example \file{runup.py} of
2182Chapter \ref{ch:getstarted}:
2183
2184\verbatiminput{examples/bedslopeexcerpt.cdl}
2185
2186The SWW format is used not only for output but also serves as input
2187for functions such as \function{file\_boundary} and
2188\function{file\_function}, described in Chapter \ref{ch:interface}.
2189
2190A TMS file is used to store time series data that is independent of
2191position.
2192
2193
2194\subsection{Mesh File Formats}
2195
2196A mesh file is a file that has a specific format suited to
2197triangular meshes and their outlines. A mesh file can have one of
2198two formats: it can be either a TSH file, which is an ASCII file, or
2199an MSH file, which is a NetCDF file. A mesh file can be generated
2200from the function \function{create\_mesh\_from\_regions} (see
2201Section \ref{sec:meshgeneration}) and used to initialise a domain.
2202
2203A mesh file can define the outline of the mesh---the vertices and
2204line segments that enclose the region in which the mesh is
2205created---and the triangular mesh itself, which is specified by
2206listing the triangles and their vertices, and the segments, which
2207are those sides of the triangles that are associated with boundary
2208conditions.
2209
2210In addition, a mesh file may contain `holes' and/or `regions'. A
2211hole represents an area where no mesh is to be created, while a
2212region is a labelled area used for defining properties of a mesh,
2213such as friction values.  A hole or region is specified by a point
2214and bounded by a number of segments that enclose that point.
2215
2216A mesh file can also contain a georeference, which describes an
2217offset to be applied to $x$ and $y$ values---eg to the vertices.
2218
2219
2220\subsection{Formats for Storing Arbitrary Points and Attributes}
2221
2222An XYA file is used to store data representing arbitrary numerical
2223attributes associated with a set of points.
2224
2225The format for an XYA file is:\\
2226%\begin{verbatim}
2227
2228            first line:     \code{[attribute names]}\\
2229            other lines:  \code{x y [attributes]}\\
2230
2231            for example:\\
2232            \code{elevation, friction}\\
2233            \code{0.6, 0.7, 4.9, 0.3}\\
2234            \code{1.9, 2.8, 5, 0.3}\\
2235            \code{2.7, 2.4, 5.2, 0.3}
2236
2237        The first two columns are always implicitly assumed to be $x$, $y$ coordinates.
2238        Use the same delimiter for the attribute names and the data.
2239
2240        An XYA file can optionally end with a description of the georeference:
2241
2242            \code{\#geo reference}\\
2243            \code{56}\\
2244            \code{466600.0}\\
2245            \code{8644444.0}
2246
2247        Here the first number specifies the UTM zone (in this case zone 56)  and other numbers specify the
2248        easting and northing
2249        coordinates (in this case (466600.0, 8644444.0)) of the lower left corner.
2250
2251A PTS file is a NetCDF representation of the data held in an XYA
2252file. If the data is associated with a set of $N$ points, then the
2253data is stored using an $N \times 2$ Numeric array of float
2254variables for the points and an $N \times 1$ Numeric array for each
2255attribute.
2256
2257%\end{verbatim}
2258
2259\subsection{ArcView Formats}
2260
2261Files of the three formats ASC, PRJ and ERS are all associated with
2262data from ArcView.
2263
2264An ASC file is an ASCII representation of DEM output from ArcView.
2265It contains a header with the following format:
2266
2267\begin{tabular}{l l}
2268\code{ncols}      &   \code{753}\\
2269\code{nrows}      &   \code{766}\\
2270\code{xllcorner}  &   \code{314036.58727982}\\
2271\code{yllcorner}  & \code{6224951.2960092}\\
2272\code{cellsize}   & \code{100}\\
2273\code{NODATA_value} & \code{-9999}
2274\end{tabular}
2275
2276The remainder of the file contains the elevation data for each grid point
2277in the grid defined by the above information.
2278
2279A PRJ file is an ArcView file used in conjunction with an ASC file
2280to represent metadata for a DEM.
2281
2282
2283\subsection{DEM Format}
2284
2285A DEM file is a NetCDF representation of regular DEM data.
2286
2287
2288\subsection{Other Formats}
2289
2290
2291
2292
2293\subsection{Basic File Conversions}
2294
2295  \begin{funcdesc}{sww2dem}{basename_in, basename_out = None,
2296            quantity = None,
2297            timestep = None,
2298            reduction = None,
2299            cellsize = 10,
2300            NODATA_value = -9999,
2301            easting_min = None,
2302            easting_max = None,
2303            northing_min = None,
2304            northing_max = None,
2305            expand_search = False,
2306            verbose = False,
2307            origin = None,
2308            datum = 'WGS84',
2309            format = 'ers'}
2310  Module: \module{shallow\_water.data\_manager}
2311
2312  Takes data from an SWW file \code{basename_in} and converts it to DEM format (ASC or
2313  ERS) of a desired grid size \code{cellsize} in metres.
2314  The easting and northing values are used if the user wished to clip the output
2315  file to a specified rectangular area. The \code{reduction} input refers to a function
2316  to reduce the quantities over all time step of the SWW file, example, maximum.
2317  \end{funcdesc}
2318
2319
2320  \begin{funcdesc}{dem2pts}{basename_in, basename_out=None,
2321            easting_min=None, easting_max=None,
2322            northing_min=None, northing_max=None,
2323            use_cache=False, verbose=False}
2324  Module: \module{shallow\_water.data\_manager}
2325
2326  Takes DEM data (a NetCDF file representation of data from a regular Digital
2327  Elevation Model) and converts it to PTS format.
2328  \end{funcdesc}
2329
2330
2331
2332%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2333%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2334
2335\chapter{Basic \anuga Assumptions}
2336
2337
2338Physical model time cannot be earlier than 1 Jan 1970 00:00:00.
2339If one wished to recreate scenarios prior to that date it must be done
2340using some relative time (e.g. 0).
2341
2342
2343All spatial data relates to the WGS84 datum (or GDA94) and has been
2344projected into UTM with false easting of 500000 and false northing of
23451000000 on the southern hemisphere (0 on the northern).
2346
2347It is assumed that all computations take place within one UTM zone.
2348
2349DEMs, meshes and boundary conditions can have different origins within
2350one UTM zone. However, the computation will use that of the mesh for
2351numerical stability.
2352
2353When generating a mesh it is assumed that polygons do not cross.
2354Having polygons tht cross can cause the mesh generation to fail or bad
2355meshes being produced.
2356
2357
2358%OLD
2359%The dataflow is: (See data_manager.py and from scenarios)
2360%
2361%
2362%Simulation scenarios
2363%--------------------%
2364%%
2365%
2366%Sub directories contain scrips and derived files for each simulation.
2367%The directory ../source_data contains large source files such as
2368%DEMs provided externally as well as MOST tsunami simulations to be used
2369%as boundary conditions.
2370%
2371%Manual steps are:
2372%  Creation of DEMs from argcview (.asc + .prj)
2373%  Creation of mesh from pmesh (.tsh)
2374%  Creation of tsunami simulations from MOST (.nc)
2375%%
2376%
2377%Typical scripted steps are%
2378%
2379%  prepare_dem.py:  Convert asc and prj files supplied by arcview to
2380%                   native dem and pts formats%
2381%
2382%  prepare_pts.py: Convert netcdf output from MOST to an sww file suitable
2383%                  as boundary condition%
2384%
2385%  prepare_mesh.py: Merge DEM (pts) and mesh (tsh) using least squares
2386%                   smoothing. The outputs are tsh files with elevation data.%
2387%
2388%  run_simulation.py: Use the above together with various parameters to
2389%                     run inundation simulation.
2390
2391
2392%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2393%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2394
2395\appendix
2396
2397\chapter{Supporting Tools}
2398\label{ch:supportingtools}
2399
2400This section describes a number of supporting tools, supplied with \anuga, that offer a
2401variety of types of functionality and enhance the basic capabilities of \anuga.
2402
2403\section{caching}
2404\label{sec:caching}
2405
2406The \code{cache} function is used to provide supervised caching of function
2407results. A Python function call of the form
2408
2409      {\small \begin{verbatim}
2410      result = func(arg1,...,argn)
2411      \end{verbatim}}
2412
2413  can be replaced by
2414
2415      {\small \begin{verbatim}
2416      from caching import cache
2417      result = cache(func,(arg1,...,argn))
2418      \end{verbatim}}
2419
2420  which returns the same output but reuses cached
2421  results if the function has been computed previously in the same context.
2422  \code{result} and the arguments can be simple types, tuples, list, dictionaries or
2423  objects, but not unhashable types such as functions or open file objects.
2424  The function \code{func} may be a member function of an object or a module.
2425
2426  This type of caching is particularly useful for computationally intensive
2427  functions with few frequently used combinations of input arguments. Note that
2428  if the inputs or output are very large caching may not save time because
2429  disc access may dominate the execution time.
2430
2431  If the function definition changes after a result has been cached, this will be
2432  detected by examining the functions \code{bytecode (co\_code, co\_consts,
2433  func\_defaults, co\_argcount)} and the function will be recomputed.
2434  However, caching will not detect changes in modules used by \code{func}.
2435  In this case cache must be cleared manually.
2436
2437  Options are set by means of the function \code{set\_option(key, value)},
2438  where \code{key} is a key associated with a
2439  Python dictionary \code{options}. This dictionary stores settings such as the name of
2440  the directory used, the maximum
2441  number of cached files allowed, and so on.
2442
2443  The \code{cache} function allows the user also to specify a list of dependent files. If any of these
2444  have been changed, the function is recomputed and the results stored again.
2445
2446  %Other features include support for compression and a capability to \ldots
2447
2448
2449   \textbf{USAGE:} \nopagebreak
2450
2451    {\small \begin{verbatim}
2452    result = cache(func, args, kwargs, dependencies, cachedir, verbose,
2453                   compression, evaluate, test, return_filename)
2454    \end{verbatim}}
2455
2456
2457\section{ANUGA viewer - animate}
2458\label{sec:animate}
2459 The output generated by \anuga may be viewed by
2460means of the visualisation tool \code{animate}, which takes the
2461\code{SWW} file output by \anuga and creates a visual representation
2462of the data. Examples may be seen in Figures \ref{fig:runupstart}
2463and \ref{fig:runup2}. To view an \code{SWW} file with
2464\code{animate} in the Windows environment, you can simply drag the
2465icon representing the file over an icon on the desktop for the
2466\code{animate} executable file (or a shortcut to it), or set up a
2467file association to make files with the extension \code{.sww} open
2468with \code{animate}. Alternatively, you can operate \code{animate}
2469from the command line, in both Windows and Linux environments.
2470
2471On successful operation, you will see an interactive moving-picture
2472display. You can use keys and the mouse to slow down, speed up or
2473stop the display, change the viewing position or carry out a number
2474of other simple operations. Help is also displayed when you press
2475the \code{h} key.
2476
2477The main keys operating the interactive screen are:\\
2478
2479\begin{center}
2480\begin{tabular}{|ll|}   \hline
2481
2482\code{w} & toggle wireframe \\
2483
2484space bar & start/stop\\
2485
2486up/down arrows & increase/decrease speed\\
2487
2488left/right arrows & direction in time \emph{(when running)}\\
2489& step through simulation \emph{(when stopped)}\\
2490
2491left mouse button & rotate\\
2492
2493middle mouse button & pan\\
2494
2495right mouse button & zoom\\  \hline
2496
2497\end{tabular}
2498\end{center}
2499
2500\vfill
2501
2502The following table describes how to operate animate from the command line:
2503
2504Usage: \code{animate [options] swwfile \ldots}\\  \nopagebreak
2505Options:\\  \nopagebreak
2506\begin{tabular}{ll}
2507  \code{--display <type>} & \code{MONITOR | POWERWALL | REALITY\_CENTER |}\\
2508                                    & \code{HEAD\_MOUNTED\_DISPLAY}\\
2509  \code{--rgba} & Request a RGBA colour buffer visual\\
2510  \code{--stencil} & Request a stencil buffer visual\\
2511  \code{--stereo} & Use default stereo mode which is \code{ANAGLYPHIC} if not \\
2512                                    & overridden by environmental variable\\
2513  \code{--stereo <mode>} & \code{ANAGLYPHIC | QUAD\_BUFFER | HORIZONTAL\_SPLIT |}\\
2514                                    & \code{VERTICAL\_SPLIT | LEFT\_EYE | RIGHT\_EYE |}\\
2515                                     & \code{ON | OFF} \\
2516  \code{-alphamax <float 0-1>} & Maximum transparency clamp value\\
2517  \code{-alphamin <float 0-1>} & Transparency value at \code{hmin}\\
2518\end{tabular}
2519
2520\begin{tabular}{ll}
2521  \code{-cullangle <float angle 0-90>} & Cull triangles steeper than this value\\
2522  \code{-help} & Display this information\\
2523  \code{-hmax <float>} & Height above which transparency is set to
2524                                     \code{alphamax}\\
2525\end{tabular}
2526
2527\begin{tabular}{ll}
2528
2529  \code{-hmin <float>} & Height below which transparency is set to
2530                                     zero\\
2531\end{tabular}
2532
2533\begin{tabular}{ll}
2534  \code{-lightpos <float>,<float>,<float>} & $x,y,z$ of bedslope directional light ($z$ is
2535                                     up, default is overhead)\\
2536\end{tabular}
2537
2538\begin{tabular}{ll}
2539  \code{-loop}  & Repeated (looped) playback of \code{.swm} files\\
2540
2541\end{tabular}
2542
2543\begin{tabular}{ll}
2544  \code{-movie <dirname>} & Save numbered images to named directory and
2545                                     quit\\
2546
2547  \code{-nosky} & Omit background sky\\
2548
2549
2550  \code{-scale <float>} & Vertical scale factor\\
2551  \code{-texture <file>} & Image to use for bedslope topography\\
2552  \code{-tps <rate>} & Timesteps per second\\
2553  \code{-version} & Revision number and creation (not compile)
2554                                     date\\
2555\end{tabular}
2556
2557\section{utilities/polygons}
2558
2559  \declaremodule{standard}{utilities.polygon}
2560  \refmodindex{utilities.polygon}
2561
2562  \begin{classdesc}{Polygon\_function}{regions, default = 0.0, geo_reference = None}
2563  Module: \code{utilities.polygon}
2564
2565  Creates a callable object that returns one of a specified list of values when
2566  evaluated at a point \code{x, y}, depending on which polygon, from a specified list of polygons, the
2567  point belongs to. The parameter \code{regions} is a list of pairs
2568  \code{(P, v)}, where each \code{P} is a polygon and each \code{v}
2569  is either a constant value or a function of coordinates \code{x}
2570  and \code{y}, specifying the return value for a point inside \code{P}. The
2571  optional parameter \code{default} may be used to specify a value
2572  for a point not lying inside any of the specified polygons. When a
2573  point lies in more than one polygon, the return value is taken to
2574  be the value for whichever of these polygon appears later in the
2575  list.
2576  %FIXME (Howard): CAN x, y BE VECTORS?
2577
2578  \end{classdesc}
2579
2580  \begin{funcdesc}{read\_polygon}{filename}
2581  Module: \code{utilities.polygon}
2582
2583  Reads the specified file and returns a polygon. Each
2584  line of the file must contain exactly two numbers, separated by a comma, which are interpreted
2585  as coordinates of one vertex of the polygon.
2586  \end{funcdesc}
2587
2588  \begin{funcdesc}{populate\_polygon}{polygon, number_of_points, seed = None, exclude = None}
2589  Module: \code{utilities.polygon}
2590
2591  Populates the interior of the specified polygon with the specified number of points,
2592  selected by means of a uniform distribution function.
2593  \end{funcdesc}
2594
2595  \begin{funcdesc}{point\_in\_polygon}{polygon, delta=1e-8}
2596  Module: \code{utilities.polygon}
2597
2598  Returns a point inside the specified polygon and close to the edge. The distance between
2599  the returned point and the nearest point of the polygon is less than $\sqrt{2}$ times the
2600  second argument \code{delta}, which is taken as $10^{-8}$ by default.
2601  \end{funcdesc}
2602
2603  \begin{funcdesc}{inside\_polygon}{points, polygon, closed = True, verbose = False}
2604  Module: \code{utilities.polygon}
2605
2606  Used to test whether the members of a list of points
2607  are inside the specified polygon. Returns a Numeric
2608  array comprising the indices of the points in the list that lie inside the polygon.
2609  (If none of the points are inside, returns \code{zeros((0,), 'l')}.)
2610  Points on the edges of the polygon are regarded as inside if
2611  \code{closed} is set to \code{True} or omitted; otherwise they are regarded as outside.
2612  \end{funcdesc}
2613
2614  \begin{funcdesc}{outside\_polygon}{points, polygon, closed = True, verbose = False}
2615  Module: \code{utilities.polygon}
2616
2617  Exactly like \code{inside\_polygon}, but with the words `inside' and `outside' interchanged.
2618  \end{funcdesc}
2619
2620  \begin{funcdesc}{is\_inside\_polygon}{point, polygon, closed=True, verbose=False}
2621  Module: \code{utilities.polygon}
2622
2623  Returns \code{True} if \code{point} is inside \code{polygon} or
2624  \code{False} otherwise. Points on the edges of the polygon are regarded as inside if
2625  \code{closed} is set to \code{True} or omitted; otherwise they are regarded as outside.
2626  \end{funcdesc}
2627
2628  \begin{funcdesc}{is\_outside\_polygon}{point, polygon, closed=True, verbose=False}
2629  Module: \code{utilities.polygon}
2630
2631  Exactly like \code{is\_outside\_polygon}, but with the words `inside' and `outside' interchanged.
2632  \end{funcdesc}
2633
2634  \begin{funcdesc}{point\_on\_line}{x, y, x0, y0, x1, y1}
2635  Module: \code{utilities.polygon}
2636
2637  Returns \code{True} or \code{False}, depending on whether the point with coordinates
2638  \code{x, y} is on the line passing through the points with coordinates \code{x0, y0}
2639  and \code{x1, y1} (extended if necessary at either end).
2640  \end{funcdesc}
2641
2642  \begin{funcdesc}{separate\_points\_by\_polygon}{points, polygon, closed = True, verbose = False}
2643    \indexedcode{separate\_points\_by\_polygon}
2644  Module: \code{utilities.polygon}
2645
2646  \end{funcdesc}
2647
2648  \begin{funcdesc}{polygon\_area}{polygon}
2649  Module: \code{utilities.polygon}
2650
2651  Returns area of arbitrary polygon (reference http://mathworld.wolfram.com/PolygonArea.html)
2652  \end{funcdesc}
2653
2654  \begin{funcdesc}{plot\_polygons}{polygons, figname, verbose = False}
2655  Module: \code{utilities.polygon}
2656
2657  Plots each polygon contained in input polygon list, e.g.
2658 \code{polygons = [poly1, poly2, poly3]} where \code{poly1 = [[x11,y11],[x12,y12],[x13,y13]]}
2659 etc.  Each polygon is closed for plotting purposes and subsequent plot saved to \code{figname}.
2660  Returns list containing the minimum and maximum of \code{x} and \code{y},
2661  i.e. \code{[x_{min}, x_{max}, y_{min}, y_{max}]}.
2662  \end{funcdesc}
2663
2664\section{coordinate\_transforms}
2665
2666\section{geospatial\_data}
2667
2668This describes a class that represents arbitrary point data in UTM
2669coordinates along with named attribute values.
2670
2671%FIXME (Ole): This gives a LaTeX error
2672%\declaremodule{standard}{geospatial_data}
2673%\refmodindex{geospatial_data}
2674
2675
2676
2677\begin{classdesc}{Geospatial\_data}
2678  {data_points = None,
2679    attributes = None,
2680    geo_reference = None,
2681    default_attribute_name = None,
2682    file_name = None}
2683Module: \code{geospatial\_data}
2684
2685This class is used to store a set of data points and associated
2686attributes, allowing these to be manipulated by methods defined for
2687the class.
2688
2689The data points are specified either by reading them from a NetCDF
2690or XYA file, identified through the parameter \code{file\_name}, or
2691by providing their \code{x}- and \code{y}-coordinates in metres,
2692either as a sequence of 2-tuples of floats or as an $M \times 2$
2693Numeric array of floats, where $M$ is the number of points.
2694Coordinates are interpreted relative to the origin specified by the
2695object \code{geo\_reference}, which contains data indicating the UTM
2696zone, easting and northing. If \code{geo\_reference} is not
2697specified, a default is used.
2698
2699Attributes are specified through the parameter \code{attributes},
2700set either to a list or array of length $M$ or to a dictionary whose
2701keys are the attribute names and whose values are lists or arrays of
2702length $M$. One of the attributes may be specified as the default
2703attribute, by assigning its name to \code{default\_attribute\_name}.
2704If no value is specified, the default attribute is taken to be the
2705first one.
2706\end{classdesc}
2707
2708
2709\begin{methoddesc}{import\_points\_file}{delimiter = None, verbose = False}
2710
2711\end{methoddesc}
2712
2713
2714\begin{methoddesc}{export\_points\_file}{ofile, absolute=False}
2715
2716\end{methoddesc}
2717
2718
2719\begin{methoddesc}{get\_data\_points}{absolute = True}
2720
2721\end{methoddesc}
2722
2723
2724\begin{methoddesc}{set\_attributes}{attributes}
2725
2726\end{methoddesc}
2727
2728
2729\begin{methoddesc}{get\_attributes}{attribute_name = None}
2730
2731\end{methoddesc}
2732
2733
2734\begin{methoddesc}{get\_all\_attributes}{}
2735
2736\end{methoddesc}
2737
2738
2739\begin{methoddesc}{set\_default\_attribute\_name}{default_attribute_name}
2740
2741\end{methoddesc}
2742
2743
2744\begin{methoddesc}{set\_geo\_reference}{geo_reference}
2745
2746\end{methoddesc}
2747
2748
2749\begin{methoddesc}{add}{}
2750
2751\end{methoddesc}
2752
2753
2754\begin{methoddesc}{clip}{}
2755Clip geospatial data by a polygon
2756
2757Inputs are \code{polygon} which is either a list of points, an Nx2 array or
2758a Geospatial data object and \code{closed}(optional) which determines
2759whether points on boundary should be regarded as belonging to the polygon
2760(\code{closed=True}) or not (\code{closed=False}).
2761Default is \code{closed=True}.
2762         
2763Returns new Geospatial data object representing points
2764inside specified polygon.
2765\end{methoddesc}
2766
2767
2768\section{pmesh GUI}
2769 \emph{Pmesh}
2770allows the user to set up the mesh of the problem interactively.
2771It can be used to build the outline of a mesh or to visualise a mesh
2772automatically generated.
2773
2774Pmesh will let the user select various modes. The current allowable
2775modes are vertex, segment, hole or region.  The mode describes what
2776sort of object is added or selected in response to mouse clicks.  When
2777changing modes any prior selected objects become deselected.
2778
2779In general the left mouse button will add an object and the right
2780mouse button will select an object.  A selected object can de deleted
2781by pressing the the middle mouse button (scroll bar).
2782
2783\section{alpha\_shape}
2784\emph{Alpha shapes} are used to generate close-fitting boundaries
2785around sets of points. The alpha shape algorithm produces a shape
2786that approximates to the `shape formed by the points'---or the shape
2787that would be seen by viewing the points from a coarse enough
2788resolution. For the simplest types of point sets, the alpha shape
2789reduces to the more precise notion of the convex hull. However, for
2790many sets of points the convex hull does not provide a close fit and
2791the alpha shape usually fits more closely to the original point set,
2792offering a better approximation to the shape being sought.
2793
2794In \anuga, an alpha shape is used to generate a polygonal boundary
2795around a set of points before mesh generation. The algorithm uses a
2796parameter $\alpha$ that can be adjusted to make the resultant shape
2797resemble the shape suggested by intuition more closely. An alpha
2798shape can serve as an initial boundary approximation that the user
2799can adjust as needed.
2800
2801The following paragraphs describe the class used to model an alpha
2802shape and some of the important methods and attributes associated
2803with instances of this class.
2804
2805\begin{classdesc}{Alpha\_Shape}{points, alpha = None}
2806Module: \code{alpha\_shape}
2807
2808To instantiate this class the user supplies the points from which
2809the alpha shape is to be created (in the form of a list of 2-tuples
2810\code{[[x1, y1],[x2, y2]}\ldots\code{]}, assigned to the parameter
2811\code{points}) and, optionally, a value for the parameter
2812\code{alpha}. The alpha shape is then computed and the user can then
2813retrieve details of the boundary through the attributes defined for
2814the class.
2815\end{classdesc}
2816
2817
2818\begin{funcdesc}{alpha\_shape\_via\_files}{point_file, boundary_file, alpha= None}
2819Module: \code{alpha\_shape}
2820
2821This function reads points from the specified point file
2822\code{point\_file}, computes the associated alpha shape (either
2823using the specified value for \code{alpha} or, if no value is
2824specified, automatically setting it to an optimal value) and outputs
2825the boundary to a file named \code{boundary\_file}. This output file
2826lists the coordinates \code{x, y} of each point in the boundary,
2827using one line per point.
2828\end{funcdesc}
2829
2830
2831\begin{methoddesc}{set\_boundary\_type}{self,raw_boundary=True,
2832                          remove_holes=False,
2833                          smooth_indents=False,
2834                          expand_pinch=False,
2835                          boundary_points_fraction=0.2}
2836Module: \code{alpha\_shape},  Class: \class{Alpha\_Shape}
2837
2838This function sets flags that govern the operation of the algorithm
2839that computes the boundary, as follows:
2840
2841\code{raw\_boundary = True} returns raw boundary, i.e. the regular edges of the
2842                alpha shape.\\
2843\code{remove\_holes = True} removes small holes (`small' is defined by
2844\code{boundary\_points\_fraction})\\
2845\code{smooth\_indents = True} removes sharp triangular indents in
2846boundary\\
2847\code{expand\_pinch = True} tests for pinch-off and
2848corrects---preventing a boundary vertex from having more than two edges.
2849\end{methoddesc}
2850
2851
2852\begin{methoddesc}{get\_boundary}{}
2853Module: \code{alpha\_shape},  Class: \class{Alpha\_Shape}
2854
2855Returns a list of tuples representing the boundary of the alpha
2856shape. Each tuple represents a segment in the boundary by providing
2857the indices of its two endpoints.
2858\end{methoddesc}
2859
2860
2861\begin{methoddesc}{write\_boundary}{file_name}
2862Module: \code{alpha\_shape},  Class: \class{Alpha\_Shape}
2863
2864Writes the list of 2-tuples returned by \code{get\_boundary} to the
2865file \code{file\_name}, using one line per tuple.
2866\end{methoddesc}
2867
2868\section{Numerical Tools}
2869
2870The following table describes some useful numerical functions that
2871may be found in the module \module{utilities.numerical\_tools}:
2872
2873\begin{tabular}{|p{8cm} p{8cm}|}  \hline
2874\code{angle(v1, v2=None)} & Angle between two-dimensional vectors
2875\code{v1} and \code{v2}, or between \code{v1} and the $x$-axis if
2876\code{v2} is \code{None}. Value is in range $0$ to $2\pi$. \\
2877
2878\code{normal\_vector(v)} & Normal vector to \code{v}.\\
2879
2880\code{mean(x)} & Mean value of a vector \code{x}.\\
2881
2882\code{cov(x, y=None)} & Covariance of vectors \code{x} and \code{y}.
2883If \code{y} is \code{None}, returns \code{cov(x, x)}.\\
2884
2885\code{err(x, y=0, n=2, relative=True)} & Relative error of
2886$\parallel$\code{x}$-$\code{y}$\parallel$ to
2887$\parallel$\code{y}$\parallel$ (2-norm if \code{n} = 2 or Max norm
2888if \code{n} = \code{None}). If denominator evaluates to zero or if
2889\code{y}
2890is omitted or if \code{relative = False}, absolute error is returned.\\
2891
2892\code{norm(x)} & 2-norm of \code{x}.\\
2893
2894\code{corr(x, y=None)} & Correlation of \code{x} and \code{y}. If
2895\code{y} is \code{None} returns autocorrelation of \code{x}.\\
2896
2897\code{ensure\_numeric(A, typecode = None)} & Returns a Numeric array
2898for any sequence \code{A}. If \code{A} is already a Numeric array it
2899will be returned unaltered. Otherwise, an attempt is made to convert
2900it to a Numeric array. (Needed because \code{array(A)} can
2901cause memory overflow.)\\
2902
2903\code{histogram(a, bins, relative=False)} & Standard histogram. If
2904\code{relative} is \code{True}, values will be normalised against
2905the total and thus represent frequencies rather than counts.\\
2906
2907\code{create\_bins(data, number\_of\_bins = None)} & Safely create
2908bins for use with histogram. If \code{data} contains only one point
2909or is constant, one bin will be created. If \code{number\_of\_bins}
2910is omitted, 10 bins will be created.\\  \hline
2911
2912\end{tabular}
2913
2914
2915\chapter{Modules available in \anuga}
2916
2917
2918\section{\module{abstract\_2d\_finite\_volumes.general\_mesh} }
2919\declaremodule[generalmesh]{}{general\_mesh}
2920\label{mod:generalmesh}
2921
2922\section{\module{abstract\_2d\_finite\_volumes.neighbour\_mesh} }
2923\declaremodule[neighbourmesh]{}{neighbour\_mesh}
2924\label{mod:neighbourmesh}
2925
2926\section{\module{abstract\_2d\_finite\_volumes.domain} --- Generic module for 2D triangular domains for finite-volume computations of conservation laws}
2927\declaremodule{}{domain}
2928\label{mod:domain}
2929
2930
2931\section{\module{abstract\_2d\_finite\_volumes.quantity}}
2932\declaremodule{}{quantity}
2933\label{mod:quantity}
2934
2935
2936Class Quantity - Implements values at each triangular element
2937
2938To create:
2939
2940   Quantity(domain, vertex_values)
2941
2942   domain: Associated domain structure. Required.
2943
2944   vertex_values: N x 3 array of values at each vertex for each element.
2945                  Default None
2946
2947   If vertex_values are None Create array of zeros compatible with domain.
2948   Otherwise check that it is compatible with dimenions of domain.
2949   Otherwise raise an exception
2950
2951
2952
2953\section{\module{shallow\_water} --- 2D triangular domains for finite-volume
2954computations of the shallow water wave equation. This module contains a specialisation
2955of class Domain from module domain.py consisting of methods specific to the Shallow Water
2956Wave Equation
2957}
2958\declaremodule[shallowwater]{}{shallow\_water}
2959\label{mod:shallowwater}
2960
2961
2962
2963
2964%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2965
2966\chapter{Frequently Asked Questions}
2967
2968
2969\section{General Questions}
2970
2971\subsubsection{What is \anuga?}
2972
2973\subsubsection{Why is it called \anuga?}
2974
2975\subsubsection{How do I obtain a copy of \anuga?}
2976
2977\subsubsection{What developments are expected for \anuga in the future?}
2978
2979\subsubsection{Are there any published articles about \anuga that I can reference?}
2980
2981\section{Modelling Questions}
2982
2983\subsubsection{Which type of problems are \anuga good for?}
2984
2985\subsubsection{Which type of problems are beyond the scope of \anuga?}
2986
2987\subsubsection{Can I start the simulation at an arbitrary time?}
2988Yes, using \code{domain.set\_time()} you can specify an arbitrary
2989starting time. This is for example useful in conjunction with a
2990file\_boundary, which may start hours before anything hits the model
2991boundary. By assigning a later time for the model to start,
2992computational resources aren't wasted.
2993
2994\subsubsection{Can I change values for any quantity during the simulation?}
2995Yes, using \code{domain.set\_quantity()} inside the domain.evolve
2996loop you can change values of any quantity. This is for example
2997useful if you wish to let the system settle for a while before
2998assigning an initial condition. Another example would be changing
2999the values for elevation to model e.g. erosion.
3000
3001\subsubsection{Can I change boundary conditions during the simulation?}
3002Not sure, but it would be nice :-)
3003
3004\subsubsection{Why does a file\_function return a list of numbers when evaluated?}
3005Currently, file\_function works by returning values for the conserved
3006quantities \code{stage}, \code{xmomentum} and \code{ymomentum} at a given point in time
3007and space as a triplet. To access e.g.\ \code{stage} one must specify element 0 of the
3008triplet returned by file\_function.
3009
3010\subsubsection{Which diagnostics are available to troubleshoot a simulation?}
3011
3012\subsubsection{How do I use a DEM in my simulation?}
3013You use \code{dem2pts} to convert your DEM to the required .pts format. This .pts file is then called
3014when setting the elevation data to the mesh in \code{domain.set_quantity}
3015
3016\subsubsection{What sort of DEM resolution should I use?}
3017Try and work with the \emph{best} you have available. Onshore DEMs
3018are typically available in 25m, 100m and 250m grids. Note, offshore
3019data is often sparse, or non-existent.
3020
3021\subsubsection{What sort of mesh resolution should I use?}
3022The 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,
3023if 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,
3024you need a fine mesh over regions where the DEM changes rapidly, and other areas of significant interest, such as the coast.
3025
3026
3027\subsubsection{How do I tag interior polygons?}
3028At the moment create_mesh_from_regions does not allow interior
3029polygons with symbolic tags. If tags are needed, the interior
3030polygons must be created subsequently. For example, given a filename
3031of polygons representing solid walls (in Arc Ungenerate format) can
3032be tagged as such using the code snippet:
3033\begin{verbatim}
3034  # Create mesh outline with tags
3035  mesh = create_mesh_from_regions(bounding_polygon,
3036                                  boundary_tags=boundary_tags)
3037  # Add buildings outlines with tags set to 'wall'. This would typically
3038  # bind to a Reflective boundary
3039  mesh.import_ungenerate_file(buildings_filename, tag='wall')
3040
3041  # Generate and write mesh to file
3042  mesh.generate_mesh(maximum_triangle_area=max_area)
3043  mesh.export_mesh_file(mesh_filename)
3044\end{verbatim}
3045
3046Note that a mesh object is returned from \code{create_mesh_from_regions}
3047when file name is omitted.
3048
3049\subsubsection{How often should I store the output?}
3050This 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
3051to look in detail at the evolution, then you will need to balance your storage requirements and the duration of the simulation.
3052If 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
3053quantities on a mesh with approximately 300000 triangles on a 2 min interval for 5 hours will result in approximately 350Mb SWW file
3054(as for the \file{run\_sydney\_smf.py} example).
3055
3056\subsection{Boundary Conditions}
3057
3058\subsubsection{How do I create a Dirichlet boundary condition?}
3059
3060A Dirichlet boundary condition sets a constant value for the
3061conserved quantities at the boundaries. A list containing
3062the constant values for stage, xmomentum and ymomentum is constructed
3063and used in the function call, e.g. \code{Dirichlet_boundary([0.2,0.,0.])}
3064
3065\subsubsection{How do I know which boundary tags are available?}
3066The method \code{domain.get\_boundary\_tags()} will return a list of
3067available tags for use with
3068\code{domain.set\_boundary\_condition()}.
3069
3070
3071
3072
3073
3074\chapter{Glossary}
3075
3076\begin{tabular}{|lp{10cm}|c|}  \hline
3077%\begin{tabular}{|llll|}  \hline
3078    \emph{Term} & \emph{Definition} & \emph{Page}\\  \hline
3079
3080    \indexedbold{\anuga} & Name of software (joint development between ANU and
3081    GA) & \pageref{def:anuga}\\
3082
3083    \indexedbold{bathymetry} & offshore elevation &\\
3084
3085    \indexedbold{conserved quantity} & conserved (stage, x and y
3086    momentum) & \\
3087
3088%    \indexedbold{domain} & The domain of a function is the set of all input values to the
3089%    function.&\\
3090
3091    \indexedbold{Digital Elevation Model (DEM)} & DEMs are digital files consisting of points of elevations,
3092sampled systematically at equally spaced intervals.& \\
3093
3094    \indexedbold{Dirichlet boundary} & A boundary condition imposed on a differential equation
3095 that specifies the values the solution is to take on the boundary of the
3096 domain. & \pageref{def:dirichlet boundary}\\
3097
3098    \indexedbold{edge} & A triangular cell within the computational mesh can be depicted
3099    as a set of vertices joined by lines (the edges). & \\
3100
3101    \indexedbold{elevation} & refers to bathymetry and topography &\\
3102
3103    \indexedbold{evolution} & integration of the shallow water wave equations
3104    over time &\\
3105
3106    \indexedbold{finite volume method} & The method evaluates the terms in the shallow water
3107    wave equation as fluxes at the surfaces of each finite volume. Because the
3108    flux entering a given volume is identical to that leaving the adjacent volume,
3109    these methods are conservative. Another advantage of the finite volume method is
3110    that it is easily formulated to allow for unstructured meshes. The method is used
3111    in many computational fluid dynamics packages. & \\
3112
3113    \indexedbold{forcing term} & &\\
3114
3115    \indexedbold{flux} & the amount of flow through the volume per unit
3116    time & \\
3117
3118    \indexedbold{grid} & Evenly spaced mesh & \\
3119
3120    \indexedbold{latitude} & The angular distance on a mericlear north and south of the
3121    equator, expressed in degrees and minutes. & \\
3122
3123    \indexedbold{longitude} & The angular distance east or west, between the meridian
3124    of a particular place on Earth and that of the Prime Meridian (located in Greenwich,
3125    England) expressed in degrees or time.& \\
3126
3127    \indexedbold{Manning friction coefficient} & &\\
3128
3129    \indexedbold{mesh} & Triangulation of domain &\\
3130
3131    \indexedbold{mesh file} & A TSH or MSH file & \pageref{def:mesh file}\\
3132
3133    \indexedbold{NetCDF} & &\\
3134   
3135    \indexedbold{node} & A point at which edges meet & \\   
3136
3137    \indexedbold{northing} & A rectangular (x,y) coordinate measurement of distance
3138    north from a north-south reference line, usually a meridian used as the axis of
3139    origin within a map zone or projection. Northing is a UTM (Universal Transverse
3140    Mercator) coordinate. & \\
3141
3142    \indexedbold{points file} & A PTS or XYA file & \\  \hline
3143
3144    \end{tabular}
3145
3146    \begin{tabular}{|lp{10cm}|c|}  \hline
3147
3148    \indexedbold{polygon} & A sequence of points in the plane. \anuga represents a polygon
3149    either as a list consisting of Python tuples or lists of length 2 or as an $N \times 2$
3150    Numeric array, where $N$ is the number of points.
3151
3152    The unit square, for example, would be represented either as
3153    \code{[ [0,0], [1,0], [1,1], [0,1] ]} or as \code{array( [0,0], [1,0], [1,1],
3154    [0,1] )}.
3155
3156    NOTE: For details refer to the module \module{utilities/polygon.py}. &
3157    \\     \indexedbold{resolution} &  The maximal area of a triangular cell in a
3158    mesh & \\
3159
3160
3161    \indexedbold{reflective boundary} & Models a solid wall. Returns same conserved
3162    quantities as those present in the neighbouring volume but reflected. Specific to the
3163    shallow water equation as it works with the momentum quantities assumed to be the
3164    second and third conserved quantities. & \pageref{def:reflective boundary}\\
3165
3166    \indexedbold{stage} & &\\
3167
3168%    \indexedbold{try this}
3169
3170    \indexedbold{animate} & visualisation tool used with \anuga & 
3171    \pageref{sec:animate}\\
3172
3173    \indexedbold{time boundary} & Returns values for the conserved
3174quantities as a function of time. The user must specify
3175the domain to get access to the model time. & \pageref{def:time boundary}\\
3176
3177    \indexedbold{topography} & onshore elevation &\\
3178
3179    \indexedbold{transmissive boundary} & & \pageref{def:transmissive boundary}\\
3180
3181    \indexedbold{vertex} & A point at which edges meet. & \\
3182
3183    \indexedbold{xmomentum} & conserved quantity (note, two-dimensional SWW equations say
3184    only \code{x} and \code{y} and NOT \code{z}) &\\
3185
3186    \indexedbold{ymomentum}  & conserved quantity & \\  \hline
3187
3188    \end{tabular}
3189
3190
3191%The \code{\e appendix} markup need not be repeated for additional
3192%appendices.
3193
3194
3195%
3196%  The ugly "%begin{latexonly}" pseudo-environments are really just to
3197%  keep LaTeX2HTML quiet during the \renewcommand{} macros; they're
3198%  not really valuable.
3199%
3200%  If you don't want the Module Index, you can remove all of this up
3201%  until the second \input line.
3202%
3203
3204%begin{latexonly}
3205%\renewcommand{\indexname}{Module Index}
3206%end{latexonly}
3207\input{mod\jobname.ind}        % Module Index
3208%
3209%begin{latexonly}
3210%\renewcommand{\indexname}{Index}
3211%end{latexonly}
3212\input{\jobname.ind}            % Index
3213
3214
3215
3216\begin{thebibliography}{99}
3217\bibitem[nielsen2005]{nielsen2005} 
3218{\it Hydrodynamic modelling of coastal inundation}.
3219Nielsen, O., S. Roberts, D. Gray, A. McPherson and A. Hitchman.
3220In Zerger, A. and Argent, R.M. (eds) MODSIM 2005 International Congress on
3221Modelling and Simulation. Modelling and Simulation Society of Australia and
3222New Zealand, December 2005, pp. 518-523. ISBN: 0-9758400-2-9.\\
3223http://www.mssanz.org.au/modsim05/papers/nielsen.pdf
3224
3225\bibitem[grid250]{grid250}
3226Australian Bathymetry and Topography Grid, June 2005.
3227Webster, M.A. and Petkovic, P.
3228Geoscience Australia Record 2005/12. ISBN: 1-920871-46-2.\\
3229http://www.ga.gov.au/meta/ANZCW0703008022.html
3230
3231
3232\end{thebibliography}{99}
3233
3234\end{document}
Note: See TracBrowser for help on using the repository browser.