source: documentation/user_manual/anuga_user_manual.tex @ 2854

Last change on this file since 2854 was 2809, checked in by howard, 19 years ago

New material on file formats and some other minor changes

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