source: documentation/user_manual/anuga_user_manual.tex @ 2541

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

Note about domain.statistics

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 57.2 KB
Line 
1% Complete documentation on the extended LaTeX markup used for Python
2% documentation is available in ``Documenting Python'', which is part
3% of the standard documentation for Python.  It may be found online
4% at:
5%
6%     http://www.python.org/doc/current/doc/doc.html
7
8
9%labels
10%Sections and subsections \label{sec: }
11%Chapters \label{ch: }
12%Equations \label{eq: }
13%Figures \label{fig: }
14
15
16
17\documentclass{manual}
18
19\usepackage{graphicx}
20\input{definitions}
21
22\title{\anuga User Manual}
23\author{Howard Silcock, Ole Nielsen, Duncan Gray, Jane Sexton}
24
25% Please at least include a long-lived email address;
26% the rest is at your discretion.
27\authoraddress{Geoscience Australia \\
28  Email: \email{ole.nielsen@ga.gov.au}
29}
30
31%Draft date
32\date{\today}   % update before release!
33                % Use an explicit date so that reformatting
34                % doesn't cause a new date to be used.  Setting
35                % the date to \today can be used during draft
36                % stages to make it easier to handle versions.
37
38\release{1.0}   % release version; this is used to define the
39                % \version macro
40
41\makeindex          % tell \index to actually write the .idx file
42%\makemodindex          % If this contains a lot of module sections.
43
44\setcounter{tocdepth}{3}
45\setcounter{secnumdepth}{3}
46\begin{document}
47\maketitle
48
49% This makes the contents more accessible from the front page of the HTML.
50\ifhtml
51\chapter*{Front Matter\label{front}}
52\fi
53
54%Subversion keywords:
55%
56%$LastChangedDate: 2006-03-13 03:50:58 +0000 (Mon, 13 Mar 2006) $
57%$LastChangedRevision: 2536 $
58%$LastChangedBy: sexton $
59
60\input{copyright}
61
62
63\begin{abstract}
64
65\noindent \anuga\index{\anuga} is a hydrodynamic modelling tool that
66allows users to model realistic flow problems in complex geometries.
67Examples include dam breaks or the effects of natural hazards such
68as riverine flooding, storm surges and tsunami.
69
70The user must specify a study area represented by a mesh of triangular
71cells, the topography and bathymetry, frictional resistance, initial
72values for water level (called \emph{stage}\index{stage} within \anuga),
73boundary
74conditions and forces such as windstress or pressure gradients if
75applicable.
76
77\anuga tracks the evolution of water depth and horizontal momentum
78within each cell over time by solving the shallow water wave equation
79governing equation using a finite-volume method.
80
81\anuga cannot model details of breaking waves, flow under ceilings such
82as pipes, turbulence and vortices, vertical convection or viscous
83flows.
84
85\anuga also incorporates a mesh generator, called \code{pmesh}, that
86allows the user to set up the geometry of the problem interactively as
87well as tools for interpolation and surface fitting, and a number of
88auxiliary tools for visualising and interrogating the model output.
89
90Most \anuga components are written in the object-oriented programming
91language Python and most users will interact with \anuga by writing
92small Python programs based on the \anuga library
93functions. Computationally intensive components are written for
94efficiency in C routines working directly with the Numerical Python
95structures.
96
97
98\end{abstract}
99
100\tableofcontents
101
102
103\chapter{Introduction}
104
105
106\section{Purpose}
107
108The purpose of this user manual is to introduce the new user to
109the software, describe what it can do and give step-by-step
110instructions for setting up and running hydrodynamic simulations.
111
112\section{Scope}
113
114This manual covers only what is needed to operate the software
115after installation and configuration. It does not includes instructions for
116installing the software or detailed API documentation, both of
117which will be covered in separate publications.
118
119\section{Audience}
120
121Readers are assumed to be familiar with the operating environment
122and have a general understanding of the problem background, as
123well as enough programming experience to adapt the code to
124different requirements, as described in this manual,  and to
125understand the basic terminology of object-oriented programming.
126
127\section{Structure of This Manual}
128
129This manual is structured as follows:
130
131\begin{itemize}
132  \item Background (What \anuga does)
133  \item A \emph{Getting Started} section
134  \item A detailed description of the public interface
135  \item \anuga 's overall architecture, components and file formats
136  \item Assumptions
137\end{itemize}
138
139
140\pagebreak
141\chapter{Getting Started}
142
143This section is designed to assist the reader to get started with
144\anuga by working through simple examples. Two examples are discussed;
145the first is a simple but artificial example that is useful to illustrate
146many of the ideas, and the second is a more realistic example.
147
148\section{A Simple Example}
149
150\subsection{Overview}
151
152What follows is a discussion of the structure and operation of the file
153\code{bedslopephysical.py}, with just enough detail to allow the reader
154to appreciate what's involved in setting up a scenario like the
155one it depicts.
156
157This example carries out the solution of the shallow-water wave
158equation in the simple case of a configuration comprising a flat
159bed, sloping at a fixed angle in one direction and having a
160constant depth across each line in the perpendicular direction.
161
162The example demonstrates many of the basic ideas involved in
163setting up a more complex scenario. In the general case the user
164specifies the geometry (bathymetry and topography), the initial
165water level, boundary conditions such as tide, and any forcing
166terms that may drive the system such as wind stress or atmospheric
167pressure gradients. Frictional resistance from the different
168terrains in the model is represented by predefined forcing
169terms. The boundary is reflective on three sides and a time dependent wave on one side.
170
171The present example represents a simple scenario and does not
172include any forcing terms, nor is the data taken from a file as it
173would be in many typical cases.
174
175The conserved quantities involved in the
176problem are water depth, $x$-momentum and $y$-momentum. Other quantities
177involved in the computation are the friction, stage (absolute height of water surface)
178and elevation, the last two being related to
179the depth through the equation
180
181{\small \begin{verbatim}
182\code{stage} = \code{elevation} + \code{depth}
183\end{verbatim}}
184
185%\emph{[More details of the problem background]}
186
187\subsection{Outline of the Program}
188
189In outline, \code{bedslopephysical.py} performs the following steps:
190
191\begin{enumerate}
192
193   \item Sets up a triangular mesh.
194
195   \item Sets certain parameters governing the mode of
196operation of the model-specifying, for instance, where to store the model output.
197
198   \item Inputs various quantities describing physical measurements, such
199as the elevation, to be specified at each mesh point (vertex).
200
201   \item Sets up the boundary conditions.
202
203   \item Carries out the evolution of the model through a series of time
204steps and outputs the results, providing a results file that can
205be visualised.
206
207\end{enumerate}
208
209\subsection{The Code}
210
211%FIXME: we are using the \code function here.
212%This should be used wherever possible
213For reference we include below the complete code listing for
214\code{bedslopephysical.py}. Subsequent paragraphs provide a `commentary'
215that describes each step of the program and explains it significance.
216
217\verbatiminput{examples/bedslopephysical.py}
218
219\subsection{Establishing the Mesh}
220
221The first task is to set up the triangular mesh to be used for the
222scenario. This is carried out through the statement:
223
224{\small \begin{verbatim}
225    points, vertices, boundary = rectangular(10, 10)
226\end{verbatim}}
227
228The function \code{rectangular} is imported from a module
229\code{mesh\_factory} defined elsewhere. (\anuga also contains
230several other schemes that can be used for setting up meshes, but we
231shall not discuss these now.) The above assignment sets up a $10
232\times 10$ rectangular mesh, triangulated in a specific way. In
233general, the assignment
234
235{\small \begin{verbatim}
236    points, vertices, boundary = rectangular(m, n)
237\end{verbatim}}
238
239returns:
240
241\begin{itemize}
242
243   \item a list \code{points} of length $N$, where $N = (m + 1)(n + 1)$,
244comprising the coordinates $(x, y)$ of each of the $N$ mesh points,
245
246   \item a list \code{vertices} of length $2mn$ (each entry specifies the three
247vertices of one of the triangles used in the triangulation) , and
248
249   \item a dictionary \code{boundary}, used to tag the triangle edges on
250the boundaries. Each key corresponds to a triangle edge on one of
251the four boundaries and its value is one of \code{`left'},
252\code{`right'}, \code{`top'} and \code{`bottom'}, indicating
253which boundary the edge in question belongs to.
254
255\end{itemize}
256
257
258\subsection{Initialising the Domain}
259
260These variables are then used to set up a data structure
261\code{domain}, through the assignment:
262
263{\small \begin{verbatim}
264    domain = Domain(points, vertices, boundary)
265\end{verbatim}}
266
267This uses a Python class \code{Domain}, imported from
268\code{shallow\_water}, which is an extension of a more generic
269class of the same name in the module \code{domain}, and inherits
270some methods from the generic class but has others specific to the
271shallow-water scenarios in which it is used. Specific options for domain
272are set at this point. One of them is to set the basename for the output file:
273
274{\small \begin{verbatim}
275    domain.set_name('bedslope')
276\end{verbatim}}
277
278
279\subsection{Specifying the Quantities}
280
281The next task is to specify a number of quantities that we wish to set
282for each mesh point. The class \code{Domain} has a method
283\code{set\_quantity}, used to specify these quantities. It is a
284particularly flexible method that allows the user to set quantities in
285a variety of ways---using constants, functions, numeric arrays or
286expressions involving other quantities, arbitrary data points with
287associated values, all of which can be passed as arguments. All
288quantities can be initialised using \code{set\_quantity}. For
289conserved quantities (\code{stage, xmomentum, ymomentum}) this is
290called the \emph{initial condition}, for other quantities that aren't
291updated by the equation, the same interface is used to assign their
292values. The code in the present example demonstrates a number of forms
293in which we can invoke \code{set\_quantity}.
294
295
296\subsubsection{Elevation}
297
298The elevation, or height of the bed, is set using a function,
299defined through the statements below, which is specific to this
300example and specifies a particularly simple initial configuration
301for demonstration purposes:
302
303{\small \begin{verbatim}
304    def f(x,y):
305        return -x/2
306\end{verbatim}}
307
308This simply associates an elevation with each point \code{(x, y)} of
309the plane.  It specifies that the bed slopes linearly in the
310\code{x} direction, with slope $-\frac{1}{2}$,  and is constant in
311the \code{y} direction.  %[screen shot?]
312
313Once the function \code{f} is specified, the quantity
314\code{elevation} is assigned through the simple statement:
315
316{\small \begin{verbatim}
317    domain.set_quantity('elevation', f)
318\end{verbatim}}
319
320
321\subsubsection{Friction}
322
323The assignment of the friction quantity demonstrates another way
324we can use \code{set\_quantity} to set quantities---namely,
325assign them to a constant numerical value:
326
327{\small \begin{verbatim}
328    domain.set_quantity('friction', 0.1)
329\end{verbatim}}
330
331This just specifies that the Manning friction coefficient is set
332to 0.1 at every mesh point.
333
334\subsubsection{Stage}
335
336The stage (the height of the water surface) is related to the
337elevation and the depth at any time by the equation \[\code{stage} =
338\code{elevation} + \code{depth}\] 
339
340For this example, we simply assign a constant value to \code{stage},
341using the statement
342
343{\small \begin{verbatim}
344    domain.set_quantity('stage', -.4)
345\end{verbatim}}
346
347which specifies that the surface level is set to a height of $-0.4$, i.e. 0.4 units
348below the zero level.
349
350(Although it is not necessary for this example, it may be useful to digress here
351and mention a variant to this requirement, which allows us to illustrate
352another way to use \code{set\_quantity}---namely, incorporating an expression
353involving other quantities. Suppose, instead of setting a constant value
354for the stage, we wished
355to specify a constant value for the \emph{depth}. For such a case we 
356need to specify that \code{stage} is
357everywhere obtained by adding that value to the value already
358specified for \code{elevation}. We would do this by means of the statements:
359
360{\small \begin{verbatim}
361    h = 0.05 \# Constant depth
362    domain.set_quantity('stage', expression = 'elevation + %f' %h)
363\end{verbatim}}
364
365That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus the
366value of \code{elevation} already defined.
367
368The reader will probably appreciate that this capability to incorporate
369expressions into statements using \code{set\_quantity} greatly expands
370its power.)
371
372\subsubsection{Boundary Conditions}
373
374The boundary conditions are specified as follows:
375
376{\small \begin{verbatim}
377    Br = Reflective_boundary(domain)
378
379    Bt = Transmissive_boundary(domain)
380
381    Bd = Dirichlet_boundary([0.2,0.,0.])
382
383    Bw = Time_boundary(domain=domain,
384                f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
385\end{verbatim}}
386
387The effect of these statements is to set up four alternative
388boundary conditions and store them in variables that can be
389assigned as needed. Each boundary condition specifies the
390behaviour at a boundary in terms of the behaviour in neighbouring
391elements. The boundary conditions introduced here may be briefly described as
392follows:
393
394\begin{description}
395    \item[Reflective boundary] Returns same \code{stage} as
396    as present in its neighbour volume but momentum vector reversed 180 degrees (reflected).
397    Specific to the shallow water equation as it works with the
398    momentum quantities assumed to be the second and third conserved
399    quantities.
400
401    \item[Transmissive boundary]Returns same conserved quantities as
402    those present in its neighbour volume.
403
404    \item[Dirichlet boundary]Specifies a fixed value at the
405boundary and assigns initial values to the $x$-momentum and $y$-momentum. 
406
407    \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time.
408\end{description}
409
410Once the four boundary types have been specified through the
411statements above, they can be applied through a statement of the
412form
413
414{\small \begin{verbatim}
415    domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br})
416\end{verbatim}}
417
418This statement stipulates that, in the current example, the left
419boundary is fixed, with an elevation of 0.2, while the other
420boundaries are all reflective.
421
422The reader may wish to experiment by varying the choice of boundary types
423for one or more of the boundaries. In the case of \code{Bd} and \code{Bw},
424the three arguments in each case represent the
425
426{\small \begin{verbatim}
427    Bw = Time_boundary(domain=domain,
428                f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0])
429\end{verbatim}}
430
431
432
433\subsection{Evolution}
434
435The final statement \nopagebreak[3]
436{\small \begin{verbatim}
437    for t in domain.evolve(yieldstep = 0.1, duration = 4.0):
438        print domain.timestepping_statistics()
439\end{verbatim}}
440
441is the key step that causes the configuration of the domain to
442`evolve' in accordance with the model embodied in the code, over a
443series of steps indicated by the values of \code{yieldstep} and
444\code{duration}, which can be altered as required.
445The value of \code{yieldstep} controls the time interval between successive model outputs.
446Behind the scenes more time steps are generally taken.
447
448
449\subsection{Output}
450
451%Give details here of the form of the output and explain how it can
452%be used with swollen. Include screen shots.//
453
454The output is a NetCDF file with the extension \code{.sww}. It
455contains stage and momentum information and can be used with the
456\code{swollen} visualisation package to generate a visual display.
457
458
459\section{How to Run the Code}
460
461The code can be run in various ways:
462
463\begin{itemize}
464  \item{from a Windows command line} as in \code{python bedslopephysical.py}
465  \item{within the Python IDLE environment}
466  \item{within emacs}
467  \item{from a Linux command line} as in \code{python bedslopephysical.py}
468\end{itemize}
469
470
471\section{Exploring the model output}
472
473Figure \ref{fig:bedslopestart} shows the \\
474Figure \ref{fig:bedslope2} shows later snapshots...
475
476
477
478\begin{figure}[hbt]
479
480  \centerline{ \includegraphics[width=75mm, height=75mm]{examples/bedslope_start.eps}}
481 
482  \caption{Bedslope example viewed with Swollen}
483  \label{fig:bedslopestart}
484\end{figure} 
485
486
487\begin{figure}[hbt]
488
489  \centerline{ 
490    \includegraphics[width=75mm, height=75mm]{examples/bedslope_during.eps}
491    \includegraphics[width=75mm, height=75mm]{examples/bedslope_end.eps}
492   }   
493 
494  \caption{Bedslope example viewed with Swollen}
495  \label{fig:bedslope2}
496\end{figure} 
497
498
499
500
501\clearpage
502
503%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504
505\section{An Example with Real Data}
506
507The following discussion builds on the concepts introduced through
508the \code{bedslopephysical.py} example and introduces a second example,
509\code{run\_sydney\_smf.py}, that follows the same basic outline, but
510incorporates more complex features and refers to a real-life
511scenario, rather than the artificial illustrative one used in
512\code{bedslopephysical.py}. The domain of interest surrounds the Sydney region,
513and predominantly covers Sydney Harbour. A hypothetical tsunami wave is
514generated by a submarine mass failure situated on the edge of the
515continental shelf.
516
517\subsection{Overview}
518As in the case of \code{bedslopephysical.py}, the actions carried out by the
519program can be organised according to this outline:
520
521\begin{enumerate}
522
523   \item Set up a triangular mesh.
524
525   \item Set certain parameters governing the mode of
526operation of the model---specifying, for instance, where to store the
527model output.
528
529   \item Input various quantities describing physical measurements, such
530as the elevation, to be specified at each mesh point (vertex).
531
532   \item Set up the boundary conditions.
533
534   \item Carry out the evolution of the model through a series of time
535steps and outputs the results, providing a results file that can be
536visualised.
537
538\end{enumerate}
539
540
541
542\subsection{The Code}
543
544Here is the code for \code{run\_sydney\_smf.py}:
545
546%\verbatiminput{"runsydneysmf.py"}
547\verbatiminput{examples/runsydney.py}
548
549In discussing the details of this example, we follow the outline
550given above, discussing each major step of the code in turn.
551
552\subsection{Establishing the Mesh}
553
554One obvious way that the present example differs from
555\code{bedslopephysical.py} is in the use of a more complex method to create
556the mesh. Instead of imposing a mesh structure on a rectangular
557grid, the technique used for this example involves building mesh
558structures inside polygons specified by the user, using a
559mesh-generator referred to as \code{pmesh}.
560
561The following remarks may help the reader understand how
562\code{pmesh} is used.
563
564In its simplest form, \code{pmesh} creates the mesh within a single
565polygon whose vertices are at geographical locations specified by the
566user. The user specifies the \emph{resolution}---that is, the maximal
567area of a triangle used for triangulation---and mesh points are
568created inside the polygon through a random process. Figure
569\ref{fig:pentagon} shows a simple example of this, in which
570the triangulation is carried out within a pentagon.
571
572
573\begin{figure}[hbt]
574
575
576 
577  \caption{Mesh points are created inside the polygon}
578  \label{fig:pentagon} 
579\end{figure} 
580
581Boundary tags are not restricted to \code{`left'}, \code{`right'},
582\code{`bottom'} and \code{`top'}, as in the case of
583\code{bedslopephysical.py}. Instead the user specifies a list of tags
584appropriate to the configuration being modelled.
585
586While a mesh created inside a polygon offers more flexibility than
587one based on a rectangular grid, using \code{pmesh} in the limited
588form we have described so far still doesn't provide a way to adapt
589to geographic or other features in the landscape, whose presence may
590require us to vary the resolution in the neighbourhood of the
591features. To cope with this requirement, \code{pmesh} also allows
592the user to specify a number of \emph{interior polygons}, which are
593triangulated separately, each according to a separately specified
594resolution. See Figure \ref{fig:interior meshes}.
595
596\begin{figure}[hbt]
597
598
599 
600  \caption{Interior meshes with individual resolution}
601  \label{fig:interior meshes} 
602\end{figure} 
603
604In its general form, \code{pmesh} takes for its input a bounding
605polygon and (optionally) a list of interior polygons. The user
606specifies resolutions, both for the bounding polygon and for each of
607the interior polygons. Given this data, \code{pmesh} first creates a
608triangular mesh inside the bounding polygon, using the specified
609resolution, and then creates a separate triangulation inside each of
610the interior polygons, using the resolution specified for that
611polygon.
612
613The function used to implement this process is
614\code{create\_mesh\_from\_regions}. Its arguments include the
615bounding polygon and its resolution, a list of boundary tags, and a
616list of pairs \code{[polygon, resolution]}, specifying the interior
617polygons and their resolutions.
618
619In practice, the details of the polygons used are read from a
620separate file \code{project.py}. The resulting mesh is output to a
621\emph{meshfile}\index{meshfile}. This term is used to describe a
622file of a specific format used to store the data specifying a mesh.
623(There are in fact two possible formats for such a file: it can
624either be a binary file, with extension \code{.msh}, or an ASCII
625file, with extension \code{.tsh}. In the present case, the binary
626file format \code{.msh} is used. See Section \ref{sec:file formats}
627(p. \pageref{sec:file formats}) for more on file formats.)
628\code{pmesh} assigns a name to the file by appending the extension
629\code{.msh} to the name specified in the input file
630\code{project.py}. This name is stored in the variable
631\code{meshname}.
632
633The statements
634
635{\small \begin{verbatim}
636    interior_res = 5000%
637    interior_regions = [[project.harbour_polygon_2, interior_res],
638                    [project.botanybay_polygon_2, interior_res]]
639\end{verbatim}}
640
641are used to read in the specific polygons \code{project.harbour\_polygon\_2} and
642\code{botanybay\_polygon\_2} from \code{project.py} and assign a
643common resolution of 5000 to each. The statement
644
645{\small \begin{verbatim}
646    create_mesh_from_regions(project.diffpolygonall,%
647                         boundary_tags= {'bottom': [0],%
648                                         'right1': [1],%
649                                         'right0': [2],%
650                                         'right2': [3],%
651                                         'top': [4],%
652                                         'left1': [5],%
653                                         'left2': [6],%
654                                         'left3': [7]},%
655                         maximum_triangle_area=100000,%
656                         filename=meshname,%           
657                         interior_regions=interior_regions)
658\end{verbatim}}
659
660is then used to create the mesh, taking the bounding polygon to be the polygon
661\code{diffpolygonall} specified in \code{project.py}. The
662argument \code{boundary\_tags} assigns a dictionary, whose keys are the
663names of the boundary tags used for the bounding polygon---\code{`bottom'},
664`right0', `right1', `right2', `top', `left1', `left2' and `left3'---
665and whose values identify the indices of the segments associated with each of these
666tags. (The value associated with each boundary tag is a one-element list.)
667
668
669\subsection{Initialising the Domain}
670
671As with \code{bedslopephysical.py}, once we have created the mesh, the next
672step is to create the data structure \code{domain}. We did this for
673\code{bedslopephysical.py} by inputting lists of points and triangles and
674specifying the boundary tags directly. However, in the present case,
675we use a method that works directly with the meshfile
676\code{meshname}, as follows:
677
678{\small \begin{verbatim}
679    domain = pmesh_to_domain_instance(meshname,
680    Domain, use_cache = True, verbose = True)
681\end{verbatim}}
682
683The function \code{pmesh\_to\_domain\_instance} converts a meshfile
684\code{meshname} into an instance of the data structure
685\code{domain}, allowing us to use methods like \code{set\_quantity}
686to set quantities and to apply other operations. (In principle, the
687second argument of \code{pmesh\_to\_domain\_instance} can be any
688subclass of \code{Domain}, but for applications involving the
689shallow-water wave equation, the second argument of
690\code{pmesh\_to\_domain\_instance} can always be set simply to
691\code{Domain}.)
692
693The following statements specify a basename and data directory, and
694identify quantities to be stored. For the first two, values are
695taken from \code{project.py}.
696
697{\small \begin{verbatim} 
698    domain.set_name(project.basename)%
699    domain.set_datadir(project.outputdir)%
700    domain.set_quantities_to_be_stored(['stage', 'xmomentum',
701        'ymomentum'])
702\end{verbatim}}
703
704
705\subsection{Specifying the Quantities}
706Quantities for \code{run\_sydney\_smf.py} are set
707using similar methods to those in \code{bedslopephysical.py}. However,
708in this case, many of the values are read from the auxiliary file
709\code{project.py} or, in the case of \code{elevation}, from an
710ancillary points file.
711
712
713
714\subsubsection{Stage}
715
716For the scenario we are modelling in this case, we use a callable
717object \code{tsunami\_source}, assigned by means of a function
718\code{slump\_tsunami}. This is similar to how we set elevation in
719\code{bedslopephysical.py} using a function---however, in this case the
720function is both more complex and more interesting.
721
722The function returns the water displacement for all \code{x} 
723and \code{y} in the domain. The water displacement is a ?? function that depends
724on the characteristics of the slump (length, thickness, slope, etc), its
725location (origin) and the depth at that location.
726
727
728\subsubsection{Friction}
729
730We assign the friction exactly as we did for \code{bedslopephysical.py}:
731
732{\small \begin{verbatim}
733    domain.set_quantity('friction', 0.03)
734\end{verbatim}}
735
736
737\subsubsection{Elevation}
738
739The elevation is specified by reading data from a file:
740
741{\small \begin{verbatim}%
742    domain.set_quantity('elevation',%
743                    filename = project.combineddemname + '.pts',%
744                    use_cache = True,%
745                    verbose = True)%
746\end{verbatim}}
747
748However, before this step can be executed, some preliminary steps
749are needed to prepare the file from which the data is taken. Two
750source files are used for this data---their names are specified in
751the file \code{project.py}, in the variables \code{coarsedemname}
752and \code{finedemname}. They contain `coarse' and `fine' data,
753respectively---that is, data sampled at widely spaced points over a
754large region and data sampled at closely spaced points over a
755smaller subregion. The data in these files is combined through the
756statement
757
758{\small \begin{verbatim}
759combine_rectangular_points_files(project.finedemname + '.pts',
760                                 project.coarsedemname + '.pts',
761                                 project.combineddemname + '.pts')
762\end{verbatim}}
763
764The effect of this is simply to combine the datasets by eliminating
765any coarse data associated with points inside the smaller region
766common to both datasets. The name to be assigned to the resulting
767dataset is also derived from the name stored in the variable
768\code{combinedname} in the file \code{project.py}.
769
770\subsection{Boundary Conditions}
771
772Setting boundaries follows a similar pattern to the one used for
773\code{bedslopephysical.py}, except that in this case we need to associate a
774boundary type with each of the
775boundary tag names introduced when we established the mesh. In place of the four
776boundary types introduced for \code{bedslopephysical.py}, we use the reflective
777boundary for each of the
778eight tagged segments:
779
780{\small \begin{verbatim}
781    Br = Reflective_boundary(domain)
782    domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
783                          'right2': Br, 'top': Br, 'left1': Br,
784                          'left2': Br, 'left3': Br} )
785\end{verbatim}}
786
787\subsection{Evolution}
788
789With the basics established, the running of the `evolve' step is
790very similar to the corresponding step in \code{bedslopephysical.py}:
791
792{\small \begin{verbatim}
793    import time t0 = time.time()
794   
795    for t in domain.evolve(yieldstep = 120, duration = 18000):
796        print domain.timestepping_statistics()
797        print domain.boundary_statistics(tags = 'bottom')
798   
799    print 'That took %.2f seconds' %(time.time()
800\end{verbatim}}
801
802%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804
805\chapter{\anuga Public Interface}
806
807This chapter gives an overview of the features of \anuga available
808to the user at the public interface. These are grouped under the
809following headings:
810
811\begin{itemize}
812    \item Establishing the Mesh
813    \item Initialising the Domain
814    \item Specifying the Quantities
815    \item Initial Conditions
816    \item Boundary Conditions
817    \item Forcing Functions
818    \item Evolution
819\end{itemize}
820
821The listings are intended merely to give the reader an idea of what
822each feature is, where to find it and how it can be used---they do
823not give full specifications of the features. For these the reader
824may consult the code. The code for every function or class contains
825a documentation string, or `docstring', that specifies the precise
826syntax for its use. This appears immediately after the line
827introducing the code, between two sets of triple quotes.
828
829Each listing also describes the location of the module in which
830the code for the feature being described can be found. All modules
831are in the folder \code{inundation} or one of its subfolders, and the
832location of each module is described relative to \code{inundation}. Rather
833than using pathnames, whose syntax depends on the operating system,
834we use the format adopted for importing the function or class for
835use in Python code. For example, suppose we wish to specify that the
836function \code{create\_mesh\_from\_regions} is in a module called
837\code{mesh\_interface} in a subfolder of \code{inundation} called
838\code{pmesh}. In Linux or Unix syntax, the pathname of the file
839containing the function, relative to \code{inundation}, would be
840
841\begin{center}
842    \code{pmesh/mesh\_interface.py}
843\end{center}
844
845while in Windows syntax it would be
846
847\begin{center}
848    \code{pmesh}$\backslash$\code{mesh\_interface.py}
849\end{center}
850
851Rather than using either of these forms, in this chapter we specify
852the location simply as \code{pmesh.mesh_interface}, in keeping with
853the usage in the Python statement for importing the function,
854namely:
855\begin{center}
856    \code{from pmesh.mesh\_interface import create\_mesh\_from\_regions}
857\end{center}
858
859
860\section{Mesh Generation}
861
862\begin{funcdesc}  {create\_mesh\_from\_regions}{bounding_polygon,
863                             boundary_tags,
864                             maximum_triangle_area,
865                             filename=None,
866                             interior_regions=None,
867                             poly_geo_reference=None,
868                             mesh_geo_reference=None,
869                             minimum_triangle_angle=28.0}
870Module: \code{pmesh.mesh\_interface}
871
872% Translate following into layman's language
873Creates a triangular mesh based on a bounding polygon and a number
874of internal polygons. For each polygon the user specifies a
875resolution---that is, the maximal area of triangles in the mesh. The
876bounding polygon also has symbolic \code{tags} associated with it.
877\end{funcdesc}
878
879%%%%%%
880\section{Initialising Domain}
881
882\begin{funcdesc}  {pmesh\_to\_domain\_instance}{file_name, DomainClass, use_cache = False, verbose = False}
883Module: \code{pyvolution.pmesh2domain}
884
885Converts a generated mesh file to a domain object.
886
887\code{file\_name} is the name of the mesh file to be converted,
888including the extension. \code{DomainClass} is the class to be
889returned, which must be a subclass of \code{Domain} having the same
890interface as \code{Domain}---in practice, it can usually be set
891simply to \code{Domain}.
892\end{funcdesc}
893
894
895\subsection{Setters and getters of class Domain}
896
897\begin{funcdesc} {set_name}{??}
898\end{funcdesc}
899
900\begin{funcdesc} {get_name}{??}
901\end{funcdesc}
902
903\begin{funcdesc} {set_datadir}{??}
904\end{funcdesc}
905
906\begin{funcdesc} {get_datadir}{??}
907\end{funcdesc}
908
909\begin{funcdesc} {set_time}{??}
910\end{funcdesc}
911
912\begin{funcdesc} {set_default_order}{??}
913\end{funcdesc}
914
915
916%%%%%%
917\section{Setting Quantities}
918
919\begin{funcdesc}{set\_quantity}{name, numeric = None, quantity = None, function = None,
920                   geospatial_data = None, filename = None, attribute_name = None,
921                   alpha = None, location = 'vertices', indices = None, verbose = False,
922                   use_cache = False}
923Module: \code{pyvolution.domain}  (see also
924\code{pyvolution.quantity.set_values})
925
926numeric:\\
927Compatible list, Numeric array (see below) or constant. If callable
928it will treated as a function (see below) If instance of another
929Quantity it will be treated as such. If geo_spatial object it will
930be treated as such
931
932quantity:\\
933Another quantity (compatible quantity, e.g. obtained as a linear
934combination of quantities)
935
936function:\\
937  Any callable object that takes two one-dimensional arrays \code{x} and
938  \code{y}
939  each of length $N$ and returns an array also of length $N$.
940  The function will be evaluated at points determined by
941  location and indices in the underlying mesh.
942
943geospatial_data:\\
944  Arbitrary geospatial dataset in the form of the class
945  Geospatial_data. Mesh points are populated using least squares
946  fitting
947
948points:\\
949  $N \times 2$ array of data points for use with least squares fit
950  If points are present, an $N$ array of attribute
951  values corresponding to
952  each data point must be present.
953
954values:\\
955  If points is specified, values is an array of length N containing
956  attribute values for each point.
957
958data_georef:\\
959  If points is specified, geo_reference applies to each point.
960
961filename:\\
962  Name of a .pts file containing data points and attributes for
963  use with least squares.
964
965attribute_name:\\
966  If specified, any array matching that name
967  will be used. from file or geospatial_data.
968  Otherwise a default will be used.
969
970alpha:\\
971  Smoothing parameter to be used with least squares fits.
972  See module least_squares for further details about alpha.
973  Alpha will only be used with points, values or filename.
974  Otherwise it will be ignored.
975
976
977%location: Where values are to be stored.
978%  Permissible options are: vertices, edges, centroids
979%  Default is 'vertices'
980
981%  In case of location == 'centroids' the dimension values must
982%  be a list of a Numerical array of length N,
983%  N being the number of elements.
984%  Otherwise it must be of dimension Nx3
985
986
987%  The values will be stored in elements following their
988%  internal ordering.
989
990%  If location is not 'unique vertices' Indices is the
991%  set of element ids that the operation applies to.
992%  If location is 'unique vertices' Indices is the set
993%  of vertex ids that the operation applies to.
994
995%  If selected location is vertices, values for
996%  centroid and edges will be assigned interpolated
997%  values.  In any other case, only values for the
998%  specified locations will be assigned and the others
999%  will be left undefined.
1000
1001%verbose: True means that output to stdout is generated
1002
1003%use_cache: True means that caching of intermediate results is
1004%           attempted for least squares fit.
1005
1006Exactly one of the arguments
1007  numeric, quantity, function, points, filename
1008must be present.
1009\end{funcdesc}
1010
1011%%%
1012\anuga provides a number of predefined initial conditions to be used
1013with \code{set_quantity}.
1014
1015\begin{funcdesc}{tsunami_slump}{length, depth, slope, width=None, thickness=None, \
1016                x0=0.0, y0=0.0, alpha=0.0, \
1017                gravity=9.8, gamma=1.85, \
1018                massco=1, dragco=1, frictionco=0, psi=0, \
1019                dx=None, kappa=3.0, kappad=0.8, zsmall=0.01, \
1020                domain=None,
1021                verbose=False}
1022This function returns a callable object representing an initial water
1023displacement generated by a submarine sediment slide.
1024
1025The arguments include the downslope slide length, the water depth to the slide centre of mass,
1026and the bathymetric slope.
1027\end{funcdesc}
1028
1029
1030%%%
1031\begin{funcdesc}{file_function}{filename,
1032                  domain = None,
1033                  quantities = None,
1034                  interpolation_points = None,
1035                  verbose = False,
1036                  use_cache = False}
1037Module: \code{pyvolution.util}
1038
1039Reads the time history of spatial data from NetCDF file and returns
1040a callable object. Returns interpolated values based on the input
1041file using the underlying \code{interpolation\_function}.
1042
1043\code{quantities} is either the name of a single quantity to be
1044interpolated or a list of such quantity names. The resulting
1045function will return a tuple of values---one for each quantity.
1046
1047\code{interpolation\_points} is a list of absolute UTM coordinates
1048for points at which values are sought.
1049\end{funcdesc}
1050
1051%%%
1052\begin{classdesc}{Interpolation_function}{self,
1053                 time,
1054                 quantities,
1055                 quantity_names = None,
1056                 vertex_coordinates = None,
1057                 triangles = None,
1058                 interpolation_points = None,
1059                 verbose = False}
1060Module: \code{pyvolution.least\_squares}
1061
1062Creates a callable object \code{f(t, id)} or \code{f(t,x,y)}
1063interpolated from a time series defined at the vertices of a
1064triangular mesh (such as those stored in \code{sww} files).
1065
1066\code{time} is an array of monotonically increasing times and
1067\code{quantities} is an array, or dictionary of arrays, of values to
1068be interpolated. The parameter \code{interpolation_points} may be
1069used to specify at which points interpolated quantities are to be
1070computed whenever the object is called. If the default value
1071\code{None} is used, it returns an average value.
1072\end{classdesc}
1073
1074%%%
1075\begin{funcdesc}{set\_region}{functions}
1076[Low priority. Will be merged into set\_quantity]
1077
1078Module:\code{pyvolution.domain}
1079\end{funcdesc}
1080
1081
1082
1083%%%%%%
1084\section{Boundary Conditions}
1085
1086\anuga provides a large number of predefined boundary conditions to
1087be used with \code{set\_boundary}.
1088
1089\begin{funcdesc}{set\_boundary}{boundary_map}
1090Module: \code{pyvolution.domain}
1091
1092Associate boundary objects with tagged boundary segments.
1093
1094The input \code{boundary\_map} is a dictionary of boundary objects
1095keyed by symbolic tags.
1096
1097As result one pointer to a boundary object is stored for each vertex
1098in the list self.boundary_objects.
1099More entries may point to the same boundary object
1100
1101Schematically the mapping is from two dictionaries to one list where
1102the index is used as pointer to the \code{boundary\_values} arrays
1103within each quantity.
1104\end{funcdesc}
1105
1106
1107
1108\begin{funcdesc} {get_boundary_tags}{??}
1109\end{funcdesc}
1110
1111%%%
1112\subsection{Predefined boundary conditions}
1113
1114\begin{classdesc}{Reflective_boundary}{Boundary}
1115Module: \code{pyvolution.shallow\_water}
1116
1117Reflective boundary returns same conserved quantities as those present in
1118the neighbouring volume but reflected.
1119
1120This class is specific to the shallow water equation as it works with the
1121momentum quantities assumed to be the second and third conserved quantities.
1122\end{classdesc}
1123
1124%%%
1125\begin{classdesc}{Transmissive_boundary}{domain = None}
1126Module: \code{pyvolution.generic\_boundary\_conditions}
1127
1128A transmissive boundary returns the same conserved quantities as
1129those present in the neighbouring volume.
1130
1131The underlying domain must be specified when the boundary is instantiated.
1132\end{classdesc}
1133
1134%%%
1135\begin{classdesc}{Dirichlet_boundary}{conserved_quantities=None}
1136Module: \code{pyvolution.generic\_boundary\_conditions}
1137
1138A Dirichlet boundary returns constant values for the conserved
1139quantities.
1140\end{classdesc}
1141
1142%%%
1143\begin{classdesc}{Time_boundary}{domain = None, f = None}
1144Module: \code{pyvolution.generic\_boundary\_conditions}
1145
1146A time-dependent boundary returns values for the conserved
1147quantities as a function \code{f(t)} of time. The user must specify
1148the domain to get access to the model time.
1149\end{classdesc}
1150
1151%%%
1152\begin{classdesc}{File_boundary}{Boundary}
1153Module: \code{pyvolution.generic\_boundary\_conditions}
1154
1155The boundary values are obtained from a file and interpolated. The
1156file is assumed to contain a time series and possibly also spatial
1157information. The conserved quantities are given as a function of
1158time.
1159\end{classdesc}
1160
1161
1162\subsection{User-defined boundary conditions}
1163[How to roll your own]
1164
1165
1166
1167
1168
1169\section{Forcing Functions}
1170
1171\anuga provides a number of predefined forcing functions to be used with .....
1172
1173%\begin{itemize}
1174
1175
1176%  \item \indexedcode{}
1177%  [function, arguments]
1178
1179%  \item \indexedcode{}
1180
1181%\end{itemize}
1182
1183
1184
1185\section{Evolution}
1186
1187  \begin{funcdesc}{evolve}{???}
1188
1189  \end{funcdesc}
1190
1191
1192
1193\subsection{Diagnostics}
1194
1195  \begin{funcdesc}{timestepping_statistics}{???}
1196
1197  \end{funcdesc}
1198
1199
1200  \begin{funcdesc}{boundary\_statistics}{???}
1201
1202  \end{funcdesc}
1203 
1204 
1205  \begin{funcdesc}{statistics}{???}
1206
1207    print domain.statistics() will provide basic structural statistics about e.g.\ mesh in the form of an area histogram
1208  \end{funcdesc} 
1209 
1210 
1211  \begin{funcdesc}{get_quantity}{???}
1212  Module: \code{pyvolution.domain} 
1213  Allow access to individual quantities and their methods
1214 
1215  \end{funcdesc} 
1216 
1217 
1218  \begin{funcdesc}{get_values}{???}
1219  Module: \code{pyvolution.quantity}   
1220 
1221  Extract values for quantity as an array
1222 
1223  \end{funcdesc}   
1224 
1225 
1226  \begin{funcdesc}{get_integral}{???}
1227  Module: \code{pyvolution.quantity}   
1228 
1229  Return computed integral over entire domain for this quantity
1230 
1231  \end{funcdesc}     
1232 
1233 
1234\section{Other} 
1235
1236  \begin{funcdesc}{domain.create_quantity_from_expression}{???} 
1237 
1238  Handy for creating derived quantities on-the-fly. 
1239  See \code{Analytical\_solution\_circular\_hydraulic\_jump.py} for an example of use.
1240  \end{funcdesc}       
1241
1242%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1243%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1244
1245\chapter{\anuga System Architecture}
1246
1247From pyvolution/documentation
1248
1249\section{File Formats}
1250\label{sec:file formats}
1251
1252\anuga makes use of a number of different file formats. The
1253following table lists all these formats, which are described in more
1254detail in the paragraphs below.
1255
1256\bigskip
1257
1258\begin{center}
1259
1260\begin{tabular}{|ll|}  \hline
1261
1262\textbf{Extension} & \textbf{Description} \\
1263\hline\hline
1264
1265\code{.sww} & NetCDF format for storing model output
1266\code{f(t,x,y)}\\
1267
1268\code{.tms} & NetCDF format for storing time series \code{f(t)}\\
1269
1270\code{.xya} & ASCII format for storing arbitrary points and
1271associated attributes\\
1272
1273\code{.pts} & NetCDF format for storing arbitrary points and
1274associated attributes\\
1275
1276\code{.asc} & ASCII format of regular DEMs as output from ArcView\\
1277
1278\code{.prj} & Associated ArcView file giving more metadata for
1279\code{.asc} format\\
1280
1281\code{.ers} & ERMapper header format of regular DEMs for ArcView\\
1282
1283\code{.dem} & NetCDF representation of regular DEM data\\
1284
1285\code{.tsh} & ASCII format for storing meshes and associated
1286boundary and region info\\
1287
1288\code{.msh} & NetCDF format for storing meshes and associated
1289boundary and region info\\
1290
1291\code{.nc} & Native ferret NetCDF format\\
1292
1293\code{.geo} & Houdinis ASCII geometry format (?) \\  \par \hline
1294%\caption{File formats used by \anuga}
1295\end{tabular}
1296
1297
1298\end{center}
1299
1300\bigskip
1301
1302A typical dataflow can be described as follows:
1303
1304\subsection{Manually Created Files}
1305
1306\begin{tabular}{ll}
1307ASC, PRJ & Digital elevation models (gridded)\\
1308TSH & Triangular
1309meshes (e.g. created from \code{pmesh})\\
1310NC & Model outputs for use as boundary conditions (e.g. from MOST)
1311\end{tabular}
1312
1313\subsection{Automatically Created Files}
1314
1315\begin{tabular}{ll}
1316ASC, PRJ  $\rightarrow$  DEM  $\rightarrow$  PTS & Convert
1317DEMs to native \code{.pts} file\\
1318
1319NC $\rightarrow$ SWW & Convert MOST boundary files to
1320boundary \code{.sww}\\
1321
1322PTS + TSH $\rightarrow$ TSH with elevation & Least squares fit\\
1323
1324TSH $\rightarrow$ SWW & Convert TSH to \code{.sww}-viewable using
1325Swollen\\
1326
1327TSH + Boundary SWW $\rightarrow$ SWW & Simulation using
1328\code{pyvolution}
1329\end{tabular}
1330
1331
1332\subsection{Basic file conversions}
1333
1334  \begin{funcdesc}{sww2dem}{???}
1335  Module: \code{pyvolution.data\_manager}   
1336 
1337 
1338  \end{funcdesc}     
1339
1340 
1341  \begin{funcdesc}{dem2pts}{???}
1342  Module: \code{pyvolution.data_manager}   
1343 
1344 
1345  \end{funcdesc}       
1346
1347%\[
1348%  \left[
1349%  \begin{array}{ccr}
1350%  2 & 4 & 4\\
1351%  1 & 1 & 1
1352%  \end{array}
1353%  \right]
1354%\]
1355
1356%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1357%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1358
1359\chapter{Basic \anuga Assumptions}
1360
1361(From pyvolution/documentation)
1362
1363
1364Physical model time cannot be earlier than 1 Jan 1970 00:00:00.
1365If one wished to recreate scenarios prior to that date it must be done
1366using some relative time (e.g. 0).
1367
1368
1369All spatial data relates to the WGS84 datum (or GDA94) and has been
1370projected into UTM with false easting of 500000 and false northing of
13711000000 on the southern hemisphere (0 on the northern).
1372
1373It is assumed that all computations take place within one UTM zone.
1374
1375DEMs, meshes and boundary conditions can have different origins within
1376one UTM zone. However, the computation will use that of the mesh for
1377numerical stability.
1378
1379
1380%OLD
1381%The dataflow is: (See data_manager.py and from scenarios)
1382%
1383%
1384%Simulation scenarios
1385%--------------------%
1386%%
1387%
1388%Sub directories contain scrips and derived files for each simulation.
1389%The directory ../source_data contains large source files such as
1390%DEMs provided externally as well as MOST tsunami simulations to be used
1391%as boundary conditions.
1392%
1393%Manual steps are:
1394%  Creation of DEMs from argcview (.asc + .prj)
1395%  Creation of mesh from pmesh (.tsh)
1396%  Creation of tsunami simulations from MOST (.nc)
1397%%
1398%
1399%Typical scripted steps are%
1400%
1401%  prepare_dem.py:  Convert asc and prj files supplied by arcview to
1402%                   native dem and pts formats%
1403%
1404%  prepare_pts.py: Convert netcdf output from MOST to an sww file suitable
1405%                  as boundary condition%
1406%
1407%  prepare_mesh.py: Merge DEM (pts) and mesh (tsh) using least squares
1408%                   smoothing. The outputs are tsh files with elevation data.%
1409%
1410%  run_simulation.py: Use the above together with various parameters to
1411%                     run inundation simulation.
1412
1413
1414%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1415%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1416
1417\appendix
1418
1419\chapter{Supporting Tools}
1420
1421
1422\section{caching}
1423
1424  The \code{cache} function is used to provide supervised caching of function results. A Python
1425  function call of the form
1426
1427      {\small \begin{verbatim}
1428      result = func(arg1,...,argn)
1429      \end{verbatim}}
1430
1431  can be replaced by
1432
1433      {\small \begin{verbatim}
1434      from caching import cache
1435      result = cache(func,(arg1,...,argn))
1436      \end{verbatim}}
1437
1438  which returns the same output but reuses cached
1439  results if the function has been computed previously in the same context.
1440  \code{result} and the arguments can be simple types, tuples, list, dictionaries or
1441  objects, but not unhashable types such as functions or open file objects.
1442  The function \code{func} may be a member function of an object or a module.
1443
1444  This type of caching is particularly useful for computationally intensive
1445  functions with few frequently used combinations of input arguments. Note that
1446  if the inputs or output are very large caching might not save time because
1447  disc access may dominate the execution time.
1448
1449  If the function definition changes after a result has been cached it will be
1450  detected by examining the functions \code{bytecode (co_code, co_consts,
1451  func_defualts, co_argcount)} and it will be recomputed.
1452
1453  Options are set
1454  by means of the function \code{set_option(key, value)}, where \code{key} is a key associated with a
1455  Python dictionary \code{options} that stores settings such as the name of the directory used, the maximum
1456  number of cached files allowed, and so on.
1457
1458  The \code{cache} function allows the user also to specify a list of dependent files. If any of these
1459  have been changed, the function is recomputed and the results stored again.
1460
1461  Other features include support for compression and a capability to \ldots
1462
1463
1464   \textbf{USAGE:}
1465
1466    {\small \begin{verbatim}
1467    result = cache(func, args, kwargs, dependencies, cachedir, verbose,
1468                   compression, evaluate, test, return_filename)}
1469    \end{verbatim}}
1470
1471  \textbf{ARGUMENTS:}
1472
1473  \begin{tabular}{ll}
1474    \code{func} & Function object (Required)\\
1475    \code{args} & Arguments to func (Default: ())\\
1476    \code{kwargs} & Keyword arguments to func (Default: {}\\
1477    \code{dependencies} & Filenames that func depends on (Default: \code{None})\\
1478    \code{cachedir} & Directory for cache files (Default: \code{options['cachedir']})\\
1479    \code{verbose} & Flag verbose output to stdout
1480                       (Default: \code{options['verbose']})\\
1481    \code{compression} & Flag zlib compression (Default: \code{options['compression']})\\
1482    \code{evaluate} & Flag forced evaluation of func (Default: 0)\\
1483    \code{test} & Flag test for cached results (Default: 0)\\
1484    \code{clear} & Flag delete cached results (Default: 0)\\
1485    \code{return_filename} & Flag return of cache filename (Default: 0)\\
1486  \end{tabular}
1487
1488
1489  \textbf{LIMITATIONS:}
1490
1491  \begin{itemize}
1492   \item Caching uses the apply function and will work with anything that can be
1493      pickled, so any limitation in apply or pickle extends to caching.
1494
1495   \item A function to be cached should not depend on global variables
1496      as wrong results may occur if globals are changed after a result has
1497      been cached.
1498   \end{itemize}
1499
1500
1501
1502
1503\section{swollen}
1504
1505
1506The main keys operating the interactive screen are:\\
1507
1508\begin{tabular}{|ll|}   \hline
1509
1510\code{w} & toggle wireframe\\
1511
1512space bar & start/stop\\
1513
1514up/down arrows & increase/decrease speed\\
1515
1516left/right arrows & direction in time \emph{(when running)}\\ & step through simulation \emph{(when stopped)}\\
1517
1518left mouse button & rotate\\
1519
1520middle mouse button & pan\\
1521
1522right mouse button & zoom\\  \hline
1523
1524\end{tabular}
1525
1526\vfill
1527
1528The following table describes how to operate swollen from the command line:
1529
1530Usage: \code{swollen [options] swwfile \ldots}\\  \nopagebreak
1531Options:\\  \nopagebreak
1532\begin{tabular}{ll}
1533  \code{--display <type>} & \code{MONITOR | POWERWALL | REALITY_CENTER |}\\
1534                                    & \code{HEAD_MOUNTED_DISPLAY}\\
1535  \code{--rgba} & Request a RGBA colour buffer visual\\
1536  \code{--stencil} & Request a stencil buffer visual\\
1537  \code{--stereo} & Use default stereo mode which is \code{ANAGLYPHIC} if not \\
1538                                    & overridden by environmental variable\\
1539  \code{--stereo <mode>} & \code{ANAGLYPHIC | QUAD_BUFFER | HORIZONTAL_SPLIT |}\\
1540                                    & \code{VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE |}\\
1541                                     & \code{ON | OFF} \\
1542  \code{-alphamax <float 0-1>} & Maximum transparency clamp value\\
1543  \code{-alphamin <float 0-1>} & Transparency value at \code{hmin}\\
1544  \code{-cullangle <float angle 0-90>} & Cull triangles steeper than this value\\
1545  \code{-help} & Display this information\\
1546  \code{-hmax <float>} & Height above which transparency is set to
1547                                     \code{alphamax}\\
1548  \code{-hmin <float>} & Height below which transparency is set to
1549                                     zero\\
1550  \code{-lightpos <float>,<float>,<float>} & $x,y,z$ of bedslope directional light ($z$ is
1551                                     up, default is overhead)\\
1552  \code{-loop}  & Repeated (looped) playback of \code{.swm} files\\
1553  \code{-movie <dirname>} & Save numbered images to named directory and
1554                                     quit\\
1555  \code{-nosky} & Omit background sky\\
1556  \code{-scale <float>} & Vertical scale factor\\
1557  \code{-texture <file>} & Image to use for bedslope topography\\
1558  \code{-tps <rate>} & Timesteps per second\\
1559  \code{-version} & Revision number and creation (not compile)
1560                                     date\\
1561\end{tabular}
1562
1563\section{utilities/polygons} Could do now.
1564
1565\begin{itemize}
1566  \item \indexedcode{polygon_function}
1567  \item \indexedcode{read_polygon}
1568  \item \indexedcode{populate_polygon}
1569  \item \indexedcode{point_in_polygon}
1570  \item \indexedcode{inside_polygon}
1571  \item \indexedcode{outside_polygon}
1572  \item \indexedcode{point_on_line}
1573  \item \indexedcode{separate_points_by_polygon}
1574\end{itemize}
1575
1576\section{coordinate_transforms}
1577
1578\section{geo_spatial_data}
1579
1580This describes a class that represents arbitrary point data in UTM
1581coordinates along with named attribute values.
1582
1583TBA
1584
1585\section{pmesh GUI}
1586
1587\section{alpha_shape}
1588
1589
1590\section{utilities/numerical_tools} Do now.
1591
1592\begin{itemize}
1593  \item \indexedcode{ensure_numeric}
1594  \item \indexedcode{mean}
1595  \item
1596\end{itemize}
1597
1598%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1599
1600\chapter{Glossary}
1601
1602\begin{itemize}
1603    \item \indexedbold{\anuga} Name of software (joint development between ANU and GA)
1604
1605    \item \indexedbold{domain}
1606
1607    \item \indexedbold{Dirichlet boundary}
1608
1609    \item \indexedbold{elevation} - refers to bathymetry and topography
1610
1611    \item \indexedbold{bathymetry} offshore
1612
1613    \item \indexedbold{topography} onshore
1614
1615    \item \indexedbold{evolution} integration of the shallow water wave equations over time
1616
1617    \item \indexedbold{forcing term}
1618
1619    \item \indexedbold{IDLE} Development environment shipped with Python
1620
1621    \item \indexedbold{Manning friction coefficient}
1622
1623    \item \indexedbold{mesh}    Triangulation of domain
1624
1625    \item \indexedbold{meshfile}  [generic word for either .tsh or
1626    .msh file]
1627
1628    \item \indexedbold{points file}  [generic word for either .pts or
1629    .xya file]
1630
1631    \item \indexedbold{grid} evenly spaced
1632
1633    \item \indexedbold{NetCDF}
1634
1635    \item \indexedbold{pmesh} does this really need to be here? it's a class/module?
1636
1637    \item \indexedbold{pyvolution} does this really need to be here? it's a class/module?
1638
1639    \item \indexedbold{conserved quantity} conserved (state, x and y momentum)
1640
1641    \item \indexedbold{reflective boundary}
1642
1643    \item \indexedbold{smoothing} is this really needed?
1644
1645    \item \indexedbold{stage}
1646
1647%    \item \indexedbold{try this}
1648
1649    \item \indexedbold{swollen} visualisation tool
1650
1651    \item \indexedbold{time boundary} defined in the manual (flog from there)
1652
1653    \item \indexedbold{transmissive boundary} defined in the manual (flog from there)
1654
1655    \item \indexedbold{xmomentum} conserved quantity (note, two-dimensional SWW equations say only x and y and NOT z)
1656
1657    \item \indexedbold{ymomentum}  conserved quantity
1658
1659    \item \indexedbold{resolution}   The maximal area of a triangular cell in a mesh
1660
1661    \item \indexedbold{polygon} A sequence of points in the plane. (Arbitrary polygons can be created
1662    in this way.)
1663    \anuga represents a polygon in one of two ways. One way is to represent it as a
1664    list whose members are either Python tuples
1665    or Python lists of length 2. The unit square, for example, would be represented by the
1666    list
1667    [ [0,0], [1,0], [1,1], [0,1] ]. The alternative is to represent it as an
1668    $N \times 2$ Numeric array, where $N$ is the number of points.
1669
1670    NOTE: More can be read in the module utilities/polygon.py ....
1671
1672    \item \indexedbold{easting}
1673
1674    \item \indexedbold{northing}
1675
1676    \item \indexedbold{latitude}
1677
1678    \item \indexedbold{longitude}
1679
1680    \item \indexedbold{edge}
1681
1682    \item \indexedbold{vertex}
1683
1684    \item \indexedbold{finite volume}
1685
1686    \item \indexedbold{flux}
1687
1688    \item \indexedbold{Digital Elevation Model (DEM)}
1689
1690
1691\end{itemize}
1692
1693The \code{\e appendix} markup need not be repeated for additional
1694appendices.
1695
1696
1697%
1698%  The ugly "%begin{latexonly}" pseudo-environments are really just to
1699%  keep LaTeX2HTML quiet during the \renewcommand{} macros; they're
1700%  not really valuable.
1701%
1702%  If you don't want the Module Index, you can remove all of this up
1703%  until the second \input line.
1704%
1705
1706%begin{latexonly}
1707%\renewcommand{\indexname}{Module Index}
1708%end{latexonly}
1709%\input{mod\jobname.ind}        % Module Index
1710
1711%begin{latexonly}
1712\renewcommand{\indexname}{Index}
1713%end{latexonly}
1714\input{\jobname.ind}            % Index
1715
1716
1717
1718\end{document}
Note: See TracBrowser for help on using the repository browser.