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