Changeset 7064
- Timestamp:
- May 22, 2009, 4:40:11 PM (14 years ago)
- Location:
- anuga_core/documentation/user_manual
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/anuga_user_manual.tex
r6887 r7064 1 1 % Complete documentation on the extended LaTeX markup used for Python 2 % documentation is available in ``Documenting Python'', which is part2 % documentation is available in ''Documenting Python'', which is part 3 3 % of the standard documentation for Python. It may be found online 4 4 % at: 5 5 % 6 6 % http://www.python.org/doc/current/doc/doc.html 7 8 7 9 8 %labels … … 14 13 15 14 % Is latex failing with; 16 % `modanuga_user_manual.ind' not found?15 % 'modanuga_user_manual.ind' not found? 17 16 % try this command-line 18 17 % makeindex modanuga_user_manual.idx 19 18 % To produce the modanuga_user_manual.ind file. 20 21 19 22 20 %%%%%%%%%%%%%% TODO %%%%%%%%%%%%%%%% … … 26 24 % set_geo_reference 27 25 28 29 30 31 26 \documentclass{manual} 32 27 … … 36 31 37 32 \input{definitions} 33 34 %%%%% 35 % Set penalties for widows, etc, very high 36 %%%%% 37 38 \widowpenalty=10000 39 \clubpenalty=10000 40 \raggedbottom 38 41 39 42 \title{\anuga User Manual} … … 54 57 % stages to make it easier to handle versions. 55 58 56 57 59 \longdate % Make date format long using datetime.sty 58 60 %\settimeformat{xxivtime} % 24 hour Format … … 62 64 63 65 \ifhtml 64 \date{\today} % latex2html does not know about datetime66 \date{\today} % latex2html does not know about datetime 65 67 \fi 66 67 68 69 68 70 69 \input{version} % Get version info - this file may be modified by 71 70 % update_anuga_user_manual.py - if not a dummy 72 73 71 % will be used. 72 74 73 %\release{1.0} % release version; this is used to define the 75 74 % % \version macro … … 81 80 \setcounter{secnumdepth}{3} 82 81 82 % experimental code to get fig/table placement correct. 83 % doesn't have much effect. 84 %% Alter some LaTeX defaults for better treatment of figures: 85 % % See p.105 of "TeX Unbound" for suggested values. 86 % % See pp. 199-200 of Lamport's "LaTeX" book for details. 87 % % General parameters, for ALL pages: 88 % \renewcommand{\topfraction}{0.9} % max fraction of floats at top 89 % \renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom 90 % % Parameters for TEXT pages (not float pages): 91 % \setcounter{topnumber}{2} 92 % \setcounter{bottomnumber}{2} 93 % \setcounter{totalnumber}{4} % 2 may work better 94 % \setcounter{dbltopnumber}{2} % for 2-column pages 95 % \renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text 96 % \renewcommand{\textfraction}{0.07} % allow minimal text w. figs 97 % % Parameters for FLOAT pages (not text pages): 98 % \renewcommand{\floatpagefraction}{0.7} % require fuller float pages 99 % % N.B.: floatpagefraction MUST be less than topfraction !! 100 % \renewcommand{\dblfloatpagefraction}{0.7} % require fuller float pages 101 % 102 % % remember to use [htp] or [htpb] for placement 103 104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83 105 84 106 \begin{document} 85 107 \maketitle 86 108 87 88 89 109 % This makes the contents more accessible from the front page of the HTML. 90 110 \ifhtml 91 \chapter*{Front Matter\label{front}}111 \chapter*{Front Matter\label{front}} 92 112 \fi 93 113 … … 100 120 \input{copyright} 101 121 102 103 122 \begin{abstract} 104 123 \label{def:anuga} … … 118 137 governing equation using a finite-volume method. 119 138 120 \anuga also incorporates a mesh generator %, called \code{graphical 121 %mesh generator}, 122 that 139 \anuga also incorporates a mesh generator that 123 140 allows the user to set up the geometry of the problem interactively as 124 141 well as tools for interpolation and surface fitting, and a number of … … 129 146 small Python programs based on the \anuga library 130 147 functions. Computationally intensive components are written for 131 efficiency in C routines working directly with the Numerical Python 132 structures. 133 148 efficiency in C routines working directly with Python numpy structures. 134 149 135 150 \end{abstract} … … 137 152 \tableofcontents 138 153 154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 139 155 140 156 \chapter{Introduction} … … 144 160 145 161 The purpose of this user manual is to introduce the new user to the 146 inundation software , describe what it can do and give step-by-step162 inundation software system, describe what it can do and give step-by-step 147 163 instructions for setting up and running hydrodynamic simulations. 148 The stable release of \anuga and this manual are available on sourceforge at \url{http://sourceforge.net/projects/anuga}. A snapshot of work in progress is available through the \anuga software repository at \url{https://datamining.anu.edu.au/svn/ga/anuga_core} where the more adventurous reader might like to go. 164 The stable release of \anuga and this manual are available on sourceforge ati 165 \url{http://sourceforge.net/projects/anuga}. A snapshot of work in progress is 166 available through the \anuga software repository at 167 \url{https://datamining.anu.edu.au/svn/ga/anuga_core} 168 where the more adventurous reader might like to go. 149 169 150 170 … … 156 176 which will be covered in separate publications and by documentation 157 177 in the source code. 178 158 179 159 180 \section{Audience} … … 167 188 \url{http://datamining.anu.edu.au/\~{}ole/work/teaching/ctac2006/exercise1.pdf}. 168 189 169 170 190 Readers also need to have a general understanding of scientific modelling, 171 as well as 172 enough programming experience to adapt the code to different 191 as well as enough programming experience to adapt the code to different 173 192 requirements. 174 193 175 176 177 194 \pagebreak 195 196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 197 178 198 \chapter{Background} 179 180 199 181 200 Modelling the effects on the built environment of natural hazards such … … 197 216 and around structures such as buildings. \anuga is also capable 198 217 of modelling hydraulic jumps due to the ability of the finite-volume 199 method to accommodate discontinuities in the solution/footnote{While \anuga works with discontinuities in the conserved quantities stage, xmomentum and ymomentum, it does not allow discontinuities in the bed elevation}. 218 method to accommodate discontinuities in the solution 219 \footnote{While \anuga works with discontinuities in the conserved quantities stage, 220 xmomentum and ymomentum, it does not allow discontinuities in the bed elevation}. 200 221 201 222 To set up a particular scenario the user specifies the geometry 202 223 (bathymetry and topography), the initial water level (stage), 203 224 boundary conditions such as tide, and any forcing terms that may 204 drive the system such as rain _fall, abstraction of water, wind stress or atmospheric pressure225 drive the system such as rainfall, abstraction of water, wind stress or atmospheric pressure 205 226 gradients. Gravity and frictional resistance from the different 206 227 terrains in the model are represented by predefined forcing terms. 207 See section \ref{sec:forcing terms} for details on forcing terms available in ANUGA.228 See section \ref{sec:forcing terms} for details on forcing terms available in \anuga. 208 229 209 230 The built-in mesh generator, called \code{graphical\_mesh\_generator}, … … 218 239 and can be readily adapted to changing requirements throughout its 219 240 lifetime. Computationally intensive components are written for 220 efficiency in C routines working directly with the Numerical Python241 efficiency in C routines working directly with Python numeric 221 242 structures. The animation tool developed for \anuga is based on 222 243 OpenSceneGraph, an Open Source Software (OSS) component allowing high … … 228 249 229 250 Although a powerful and flexible tool for hydrodynamic modelling, \anuga has a 230 number of limitations that any potential user need to be aware of. They are251 number of limitations that any potential user needs to be aware of. They are: 231 252 232 253 \begin{itemize} … … 237 258 %flow under ceilings or in pipes 238 259 \item All spatial coordinates are assumed to be UTM (meters). As such, 239 ANUGAis unsuitable for modelling flows in areas larger than one UTM zone260 \anuga is unsuitable for modelling flows in areas larger than one UTM zone 240 261 (6 degrees wide). 241 \item Fluid is assumed to be inviscid - i.e.\ no kinematic viscosity included.262 \item Fluid is assumed to be inviscid -- i.e.\ no kinematic viscosity included. 242 263 \item The finite volume is a very robust and flexible numerical technique, 243 264 but it is not the fastest method around. If the geometry is sufficiently 244 265 simple and if there is no need for wetting or drying, a finite-difference 245 266 method may be able to solve the problem faster than \anuga. 246 267 %\item Mesh resolutions near coastlines with steep gradients need to be... 247 268 \item Frictional resistance is implemented using Manning's formula, but 248 \anuga has not yet been fully validated in regard to bottom roughness 249 %\item ANUGA contains no tsunami-genic functionality relating to 250 %earthquakes. 269 \anuga has not yet been fully validated in regard to bottom roughness. 270 %\item ANUGA contains no tsunami-genic functionality relating to earthquakes. 251 271 \end{itemize} 252 272 253 273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 254 274 255 275 \chapter{Getting Started} … … 261 281 the second is a more realistic example. 262 282 283 263 284 \section{A Simple Example} 264 285 \label{sec:simpleexample} … … 278 299 (bathymetry and topography), the initial water level, boundary 279 300 conditions such as tide, and any forcing terms that may drive the 280 system such as rain _fall, abstraction of water, wind stress or atmospheric pressure gradients.301 system such as rainfall, abstraction of water, wind stress or atmospheric pressure gradients. 281 302 Frictional resistance from the different terrains in the model is 282 303 represented by predefined forcing terms. In this example, the … … 293 314 involved in the computation are the friction and elevation. 294 315 295 Water depth can be obtained through the equation 296 297 \begin{tabular}{rcrcl} 298 \code{depth} &=& \code{stage} &$-$& \code{elevation} 299 \end{tabular} 300 316 Water depth can be obtained through the equation: 317 318 \begin{verbatim} 319 depth = stage - elevation 320 \end{verbatim} 301 321 302 322 \subsection{Outline of the Program} 303 323 304 324 In outline, \file{runup.py} performs the following steps: 305 306 325 \begin{enumerate} 307 308 326 \item Sets up a triangular mesh. 309 310 327 \item Sets certain parameters governing the mode of 311 operation of the model-specifying, for instance, where to store the model output. 312 328 operation of the model, specifying, for instance, 329 where to store the model output. 313 330 \item Inputs various quantities describing physical measurements, such 314 as the elevation, to be specified at each mesh point (vertex). 315 331 as the elevation, to be specified at each mesh point (vertex). 316 332 \item Sets up the boundary conditions. 317 318 333 \item Carries out the evolution of the model through a series of time 319 steps and outputs the results, providing a results file that can 320 be visualised. 321 334 steps and outputs the results, providing a results file that can 335 be viewed. 322 336 \end{enumerate} 323 337 … … 328 342 For reference we include below the complete code listing for 329 343 \file{runup.py}. Subsequent paragraphs provide a 330 `commentary' that describes each step of the program and explains it344 'commentary' that describes each step of the program and explains it 331 345 significance. 332 346 … … 338 352 scenario. This is carried out through the statement: 339 353 340 {\small\begin{verbatim}341 342 \end{verbatim} }354 \begin{verbatim} 355 points, vertices, boundary = rectangular_cross(10, 10) 356 \end{verbatim} 343 357 344 358 The function \function{rectangular_cross} is imported from a module … … 346 360 several other schemes that can be used for setting up meshes, but we 347 361 shall not discuss these.) The above assignment sets up a $10 \times 348 10$ rectangular mesh, triangulated in a regular way. The assignment 349 350 {\small\begin{verbatim}351 352 \end{verbatim} }362 10$ rectangular mesh, triangulated in a regular way. The assignment: 363 364 \begin{verbatim} 365 points, vertices, boundary = rectangular_cross(m, n) 366 \end{verbatim} 353 367 354 368 returns: 355 369 356 370 \begin{itemize} 357 358 371 \item a list \code{points} giving the coordinates of each mesh point, 359 360 372 \item a list \code{vertices} specifying the three vertices of each triangle, and 361 362 373 \item a dictionary \code{boundary} that stores the edges on 363 the boundary and associates each with one of the symbolic tags \code{`left'}, \code{`right'}, 364 \code{`top'} or \code{`bottom'}. 365 374 the boundary and associates each with one of the symbolic tags \code{'left'}, \code{'right'}, 375 \code{'top'} or \code{'bottom'}. 366 376 \end{itemize} 367 377 … … 373 383 given in Section \ref{sec:meshexample}. 374 384 375 376 377 378 385 \subsection{Initialising the Domain} 379 386 … … 381 388 \code{domain}, through the assignment: 382 389 383 {\small\begin{verbatim}384 385 \end{verbatim} }390 \begin{verbatim} 391 domain = Domain(points, vertices, boundary) 392 \end{verbatim} 386 393 387 394 This creates an instance of the \class{Domain} class, which … … 390 397 directory to be used for data: 391 398 392 {\small \begin{verbatim} 393 domain.set_name('runup') 394 \end{verbatim}} 395 396 {\small \begin{verbatim} 397 domain.set_datadir('.') 398 \end{verbatim}} 399 \begin{verbatim} 400 domain.set_name('runup') 401 domain.set_datadir('.') 402 \end{verbatim} 399 403 400 404 In addition, the following statement now specifies that the … … 402 406 to be stored: 403 407 404 {\small \begin{verbatim} 405 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 406 'ymomentum']) 407 \end{verbatim}} 408 408 \begin{verbatim} 409 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) 410 \end{verbatim} 409 411 410 412 \subsection{Initial Conditions} … … 414 416 \method{set\_quantity}, used to specify these quantities. It is a 415 417 flexible method that allows the user to set quantities in a variety 416 of ways ---using constants, functions, numeric arrays, expressions418 of ways -- using constants, functions, numeric arrays, expressions 417 419 involving other quantities, or arbitrary data points with associated 418 420 values, all of which can be passed as arguments. All quantities can … … 424 426 forms in which we can invoke \method{set\_quantity}. 425 427 426 427 428 \subsubsection{Elevation} 428 429 429 The elevation, or height of the bed, is set using a function ,430 The elevation, or height of the bed, is set using a function 430 431 defined through the statements below, which is specific to this 431 432 example and specifies a particularly simple initial configuration 432 433 for demonstration purposes: 433 434 434 {\small\begin{verbatim}435 436 437 \end{verbatim} }435 \begin{verbatim} 436 def f(x,y): 437 return -x/2 438 \end{verbatim} 438 439 439 440 This simply associates an elevation with each point \code{(x, y)} of … … 445 446 \code{elevation} is assigned through the simple statement: 446 447 447 {\small\begin{verbatim}448 449 \end{verbatim} }448 \begin{verbatim} 449 domain.set_quantity('elevation', f) 450 \end{verbatim} 450 451 451 452 NOTE: If using function to set \code{elevation} it must be vector … … 456 457 The assignment of the friction quantity (a forcing term) 457 458 demonstrates another way we can use \method{set\_quantity} to set 458 quantities ---namely, assign them to a constant numerical value:459 460 {\small\begin{verbatim}461 462 \end{verbatim} }459 quantities -- namely, assign them to a constant numerical value: 460 461 \begin{verbatim} 462 domain.set_quantity('friction', 0.1) 463 \end{verbatim} 463 464 464 465 This specifies that the Manning friction coefficient is set to 0.1 … … 468 469 469 470 The stage (the height of the water surface) is related to the 470 elevation and the depth at any time by the equation 471 472 {\small \begin{verbatim} 473 stage = elevation + depth 474 \end{verbatim}} 475 471 elevation and the depth at any time by the equation: 472 473 \begin{verbatim} 474 stage = elevation + depth 475 \end{verbatim} 476 476 477 477 For this example, we simply assign a constant value to \code{stage}, 478 using the statement 479 480 {\small\begin{verbatim}481 domain.set_quantity('stage', -.4)482 \end{verbatim} }478 using the statement: 479 480 \begin{verbatim} 481 domain.set_quantity('stage', -0.4) 482 \end{verbatim} 483 483 484 484 which specifies that the surface level is set to a height of $-0.4$, … … 487 487 Although it is not necessary for this example, it may be useful to 488 488 digress here and mention a variant to this requirement, which allows 489 us to illustrate another way to use \method{set\_quantity} ---namely,489 us to illustrate another way to use \method{set\_quantity} -- namely, 490 490 incorporating an expression involving other quantities. Suppose, 491 491 instead of setting a constant value for the stage, we wished to … … 495 495 would do this by means of the statements: 496 496 497 {\small\begin{verbatim}498 h = 0.05# Constant depth499 domain.set_quantity('stage', expression = 'elevation + %f' %h)500 \end{verbatim} }497 \begin{verbatim} 498 h = 0.05 # Constant depth 499 domain.set_quantity('stage', expression='elevation + %f' % h) 500 \end{verbatim} 501 501 502 502 That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus … … 505 505 The reader will probably appreciate that this capability to 506 506 incorporate expressions into statements using \method{set\_quantity} 507 greatly expands its power. )See Section \ref{sec:initial conditions} for more507 greatly expands its power. See Section \ref{sec:initial conditions} for more 508 508 details. 509 509 … … 512 512 The boundary conditions are specified as follows: 513 513 514 {\small \begin{verbatim} 515 Br = Reflective_boundary(domain) 516 517 Bt = Transmissive_boundary(domain) 518 519 Bd = Dirichlet_boundary([0.2,0.,0.]) 520 521 Bw = Time_boundary(domain=domain, 522 f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0]) 523 \end{verbatim}} 514 \begin{verbatim} 515 Br = Reflective_boundary(domain) 516 517 Bt = Transmissive_boundary(domain) 518 519 Bd = Dirichlet_boundary([0.2, 0.0, 0.0]) 520 521 Bw = Time_boundary(domain=domain, f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0]) 522 \end{verbatim} 524 523 525 524 The effect of these statements is to set up a selection of different … … 529 528 elements. The boundary conditions introduced here may be briefly described as 530 529 follows: 531 532 530 \begin{itemize} 533 531 \item \textbf{Reflective boundary}\label{def:reflective boundary} Returns same \code{stage} as 534 as present in its neighbour volume but momentum vector535 reversed 180 degrees (reflected).536 Specific to the shallow water equation as it works with the537 momentum quantities assumed to be the second and third conserved538 quantities. A reflective boundary condition models a solid wall.532 as present in its neighbour volume but momentum vector 533 reversed 180 degrees (reflected). 534 Specific to the shallow water equation as it works with the 535 momentum quantities assumed to be the second and third conserved 536 quantities. A reflective boundary condition models a solid wall. 539 537 \item \textbf{Transmissive boundary}\label{def:transmissive boundary} 540 Returns same conserved quantities as541 those present in its neighbour volume. This is one way of modelling542 outflow from a domain, but it should be used with caution if flow is543 not steady state as replication of momentum at the boundary544 may cause numerical instabilities propagating into the domain and545 eventually causing ANUGA to crash. If this occurs,546 consider using e.g. a Dirichlet boundary condition with a stage value547 less than the elevation at the boundary.538 Returns same conserved quantities as 539 those present in its neighbour volume. This is one way of modelling 540 outflow from a domain, but it should be used with caution if flow is 541 not steady state as replication of momentum at the boundary 542 may cause numerical instabilities propagating into the domain and 543 eventually causing ANUGA to crash. If this occurs, 544 consider using e.g. a Dirichlet boundary condition with a stage value 545 less than the elevation at the boundary. 548 546 \item \textbf{Dirichlet boundary}\label{def:dirichlet boundary} Specifies 549 constant values for stage, $x$-momentum and $y$-momentum at the boundary.547 constant values for stage, $x$-momentum and $y$-momentum at the boundary. 550 548 \item \textbf{Time boundary}\label{def:time boundary} Like a Dirichlet 551 boundary but with behaviour varying with time.549 boundary but with behaviour varying with time. 552 550 \end{itemize} 553 551 … … 556 554 three variables \code{points}, \code{vertices} and \code{boundary}. 557 555 In the code we are discussing, these three variables are returned by 558 the function \code{rectangular} ; however, the example given in556 the function \code{rectangular}. The example given in 559 557 Section \ref{sec:realdataexample} illustrates another way of 560 558 assigning the values, by means of the function 561 \code{create \_mesh\_from\_regions}.559 \code{create_mesh_from_regions}. 562 560 563 561 These variables store the data determining the mesh as follows. (You … … 565 563 helps to clarify the following discussion, even though that example 566 564 is a \emph{non-rectangular} mesh.) 567 568 565 \begin{itemize} 569 \item The variable \code{points} stores a list of 2-tuples giving the 570 coordinates of the mesh points. 571 572 \item The variable \code{vertices} stores a list of 3-tuples of 573 numbers, representing vertices of triangles in the mesh. In this 574 list, the triangle whose vertices are \code{points[i]}, 575 \code{points[j]}, \code{points[k]} is represented by the 3-tuple 576 \code{(i, j, k)}. 577 578 \item The variable \code{boundary} is a Python dictionary that 579 not only stores the edges that make up the boundary but also assigns 580 symbolic tags to these edges to distinguish different parts of the 581 boundary. An edge with endpoints \code{points[i]} and 582 \code{points[j]} is represented by the 2-tuple \code{(i, j)}. The 583 keys for the dictionary are the 2-tuples \code{(i, j)} corresponding 584 to boundary edges in the mesh, and the values are the tags are used 585 to label them. In the present example, the value \code{boundary[(i, 586 j)]} assigned to \code{(i, j)]} is one of the four tags 587 \code{`left'}, \code{`right'}, \code{`top'} or \code{`bottom'}, 588 depending on whether the boundary edge represented by \code{(i, j)} 589 occurs at the left, right, top or bottom of the rectangle bounding 590 the mesh. The function \code{rectangular} automatically assigns 591 these tags to the boundary edges when it generates the mesh. 566 \item The variable \code{points} stores a list of 2-tuples giving the 567 coordinates of the mesh points. 568 \item The variable \code{vertices} stores a list of 3-tuples of 569 numbers, representing vertices of triangles in the mesh. In this 570 list, the triangle whose vertices are \code{points[i]}, 571 \code{points[j]}, \code{points[k]} is represented by the 3-tuple 572 \code{(i, j, k)}. 573 \item The variable \code{boundary} is a Python dictionary that 574 not only stores the edges that make up the boundary but also assigns 575 symbolic tags to these edges to distinguish different parts of the 576 boundary. An edge with endpoints \code{points[i]} and 577 \code{points[j]} is represented by the 2-tuple \code{(i, j)}. The 578 keys for the dictionary are the 2-tuples \code{(i, j)} corresponding 579 to boundary edges in the mesh, and the values are the tags are used 580 to label them. In the present example, the value \code{boundary[(i, j)]} 581 assigned to \code{(i, j)]} is one of the four tags 582 \code{'left'}, \code{'right'}, \code{'top'} or \code{'bottom'}, 583 depending on whether the boundary edge represented by \code{(i, j)} 584 occurs at the left, right, top or bottom of the rectangle bounding 585 the mesh. The function \code{rectangular} automatically assigns 586 these tags to the boundary edges when it generates the mesh. 592 587 \end{itemize} 593 588 … … 595 590 to an edge depending on which part of the boundary it belongs to. 596 591 (In Section \ref{sec:realdataexample} we describe an example that 597 uses different boundary tags -- -in general, the possible tags are entirely selectable by the user when generating the mesh and not598 limited to `left', `right', `top' and `bottom' as in this example.)592 uses different boundary tags -- in general, the possible tags are entirely selectable by the user when generating the mesh and not 593 limited to 'left', 'right', 'top' and 'bottom' as in this example.) 599 594 All segments in bounding polygon must be tagged. If a tag is not supplied, the default tag name 'exterior' will be assigned by ANUGA. 600 595 601 602 596 Using the boundary objects described above, we assign a boundary 603 condition to each part of the boundary by means of a statement like 604 605 {\small \begin{verbatim} 606 domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br}) 607 \end{verbatim}} 608 609 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 597 condition to each part of the boundary by means of a statement like: 610 598 611 599 \begin{verbatim} 612 600 domain.set_boundary({'left': Br, 'right': Bw, 'top': Br, 'bottom': Br}) 601 \end{verbatim} 602 603 It is critical that all tags are associated with a boundary condition in this statement. 604 If not the program will halt with a statement like: 605 606 \begin{verbatim} 613 607 Traceback (most recent call last): 614 608 File "mesh_test.py", line 114, in ? … … 621 615 \end{verbatim} 622 616 623 624 The command \code{set\_boundary} stipulates that, in the current example, the right 617 The command \code{set_boundary} stipulates that, in the current example, the right 625 618 boundary varies with time, as defined by the lambda function, while the other 626 619 boundaries are all reflective. … … 631 624 \code{stage}, $x$-momentum and $y$-momentum, respectively.) 632 625 633 {\small \begin{verbatim} 634 Bw = Time_boundary(domain=domain, 635 f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0]) 636 \end{verbatim}} 637 638 626 \begin{verbatim} 627 Bw = Time_boundary(domain=domain, f=lambda t: [(0.1*sin(t*2*pi)-0.3), 0.0, 0.0]) 628 \end{verbatim} 639 629 640 630 \subsection{Evolution}\index{evolution} 641 631 642 The final statement \nopagebreak[3] 643 {\small \begin{verbatim} 644 for t in domain.evolve(yieldstep = 0.1, duration = 4.0): 645 print domain.timestepping_statistics() 646 \end{verbatim}} 647 648 causes the configuration of the domain to `evolve', over a series of 632 The final statement: 633 634 \begin{verbatim} 635 for t in domain.evolve(yieldstep=0.1, duration=4.0): 636 print domain.timestepping_statistics() 637 \end{verbatim} 638 639 causes the configuration of the domain to 'evolve', over a series of 649 640 steps indicated by the values of \code{yieldstep} and 650 641 \code{duration}, which can be altered as required. The value of … … 652 643 outputs. Behind the scenes more time steps are generally taken. 653 644 654 655 645 \subsection{Output} 656 646 657 647 The output is a NetCDF file with the extension \code{.sww}. It 658 648 contains stage and momentum information and can be used with the 659 ANUGA viewer \code{animate} (see Section \ref{sec:animate}) 660 visualisation package 661 to generate a visual display. See Section \ref{sec:file formats} 649 ANUGA viewer \code{animate} visualisation package to generate a visual 650 display (see Section \ref{sec:animate}). See Section \ref{sec:file formats} 662 651 (page \pageref{sec:file formats}) for more on NetCDF and other file 663 652 formats. … … 672 661 673 662 The code can be run in various ways: 674 675 663 \begin{itemize} 676 664 \item{from a Windows or Unix command line} as in\ \code{python runup.py} … … 689 677 Figure \ref{fig:runup2} shows later snapshots for $t=2.3$ and 690 678 $t=4$ where the system has been evolved and the wave is encroaching 691 on the previously dry bed. All figures are screenshots from an692 interactive animation tool called animate which is part of \anuga and 693 distributed as in the package anuga\_viewer. 694 Animate is described in more detail is Section \ref{sec:animate}.695 696 \begin{figure}[hbt] 697 679 on the previously dry bed. 680 681 All figures are screenshots from an interactive animation tool called \code{animate} 682 which is part of \anuga and distributed as in the package anuga\_viewer. 683 \code{animate} is described in more detail is Section \ref{sec:animate}. 684 685 \begin{figure}[htp] 698 686 \centerline{\includegraphics[width=75mm, height=75mm] 699 687 {graphics/bedslopestart.jpg}} 700 701 688 \caption{Runup example viewed with the ANUGA viewer} 702 689 \label{fig:runupstart} 703 690 \end{figure} 704 691 705 706 \begin{figure}[hbt] 707 692 \begin{figure}[htp] 708 693 \centerline{ 709 \includegraphics[width=75mm, height=75mm]{graphics/bedslopeduring.jpg}694 \includegraphics[width=75mm, height=75mm]{graphics/bedslopeduring.jpg} 710 695 \includegraphics[width=75mm, height=75mm]{graphics/bedslopeend.jpg} 711 696 } 712 713 697 \caption{Runup example viewed with ANGUA viewer} 714 698 \label{fig:runup2} 715 699 \end{figure} 716 700 717 718 719 701 \clearpage 720 702 721 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%722 703 723 704 \section{A slightly more complex example} … … 727 708 728 709 The next example is about waterflow in a channel with varying boundary conditions and 729 more complex topogra hies. These examples build on the710 more complex topographies. These examples build on the 730 711 concepts introduced through the \file{runup.py} in Section \ref{sec:simpleexample}. 731 712 The example will be built up through three progressively more complex scripts. 732 713 733 714 \subsection{Overview} 715 734 716 As in the case of \file{runup.py}, the actions carried 735 717 out by the program can be organised according to this outline: 736 737 718 \begin{enumerate} 738 739 719 \item Set up a triangular mesh. 740 741 720 \item Set certain parameters governing the mode of 742 operation of the model---specifying, for instance, where to store the 743 model output. 744 721 operation of the model -- specifying, for instance, where to store the 722 model output. 745 723 \item Set up initial conditions for various quantities such as the elevation, to be specified at each mesh point (vertex). 746 747 724 \item Set up the boundary conditions. 748 749 725 \item Carry out the evolution of the model through a series of time 750 steps and output the results, providing a results file that can be 751 visualised. 752 726 steps and output the results, providing a results file that can be 727 viewed. 753 728 \end{enumerate} 754 729 755 756 730 \subsection{The Code} 757 731 758 732 Here is the code for the first version of the channel flow \file{channel1.py}: 759 760 733 \verbatiminput{demos/channel1.py} 761 762 734 In discussing the details of this example, we follow the outline 763 735 given above, discussing each major step of the code in turn. … … 765 737 \subsection{Establishing the Mesh}\index{mesh, establishing} 766 738 767 In this example we use a similar simple structured triangular mesh as in \ code{runup.py}739 In this example we use a similar simple structured triangular mesh as in \file{runup.py} 768 740 for simplicity, but this time we will use a symmetric one and also 769 change the physical extent of the domain. The assignment 770 771 {\small\begin{verbatim}772 points, vertices, boundary = rectangular_cross(m, n, 773 len1=length, len2=width) 774 \end{verbatim}} 775 returns a m x nmesh similar to the one used in the previous example, except that now the741 change the physical extent of the domain. The assignment: 742 743 \begin{verbatim} 744 points, vertices, boundary = rectangular_cross(m, n, len1=length, len2=width) 745 \end{verbatim} 746 747 returns an \code{m x n} mesh similar to the one used in the previous example, except that now the 776 748 extent in the x and y directions are given by the value of \code{length} and \code{width} 777 749 respectively. 778 750 779 Defining m and n in terms of the extent as in this example provides a convenient way of 780 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: 781 782 {\small \begin{verbatim} 783 length = 10. 784 width = 5. 751 Defining \code{m} and \code{n} in terms of the extent as in this example provides a convenient way of 752 controlling the resolution: By defining \code{dx} and \code{dy} to be the desired size of each 753 hypothenuse in the mesh we can write the mesh generation as follows: 754 755 \begin{verbatim} 756 length = 10.0 757 width = 5.0 785 758 dx = dy = 1 # Resolution: Length of subdivisions on both axes 786 759 787 760 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 788 761 len1=length, len2=width) 789 \end{verbatim}} 790 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. 762 \end{verbatim} 763 764 which yields a mesh of length=10m, width=5m with 1m spacings. To increase the resolution, 765 as we will later in this example, one merely decreases the values of \code{dx} and \code{dy}. 791 766 792 767 The rest of this script is as in the previous example. 793 % 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}: 794 %{\small \begin{verbatim} 768 % except for an application of the 'expression' form of \code{set\_quantity} where we use 769 % the value of \code{elevation} to define the (dry) initial condition for \code{stage}: 770 %\begin{verbatim} 795 771 % domain.set_quantity('stage', expression='elevation') 796 %\end{verbatim}} 772 %\end{verbatim} 773 797 774 798 775 \section{Model Output} … … 800 777 The following figure is a screenshot from the \anuga visualisation 801 778 tool \code{animate} of output from this example. 802 \begin{figure}[hbt] 779 780 \begin{figure}[htp] 803 781 \centerline{\includegraphics[height=75mm] 804 782 {graphics/channel1.png}}% 805 806 783 \caption{Simple channel example viewed with the ANUGA viewer.} 807 784 \label{fig:channel1} 808 785 \end{figure} 809 786 810 811 787 \subsection{Changing boundary conditions on the fly} 812 788 \label{sec:change boundary} 813 789 814 790 Here is the code for the second version of the channel flow \file{channel2.py}: 791 815 792 \verbatiminput{demos/channel2.py} 793 816 794 This example differs from the first version in that a constant outflow boundary condition has 817 been defined 818 {\small \begin{verbatim} 819 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow 820 \end{verbatim}} 795 been defined: 796 797 \begin{verbatim} 798 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow 799 \end{verbatim} 800 821 801 and that it is applied to the right hand side boundary when the water level there exceeds 0m. 822 {\small \begin{verbatim} 802 803 \begin{verbatim} 823 804 for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0): 824 805 domain.write_time() … … 827 808 print 'Stage > 0: Changing to outflow boundary' 828 809 domain.set_boundary({'right': Bo}) 829 \end{verbatim}} 810 \end{verbatim} 811 830 812 \label{sec:change boundary code} 831 832 The if statement in the timestepping loop (evolve) gets the quantity 833 \code{stage} and obtain the interpolated value at the point (10m, 813 The \code{if} statement in the timestepping loop (evolve) gets the quantity 814 \code{stage} and obtains the interpolated value at the point (10m, 834 815 2.5m) which is on the right boundary. If the stage exceeds 0m a 835 816 message is printed and the old boundary condition at tag 'right' is 836 replaced by the outflow boundary using the method 837 {\small \begin{verbatim} 838 domain.set_boundary({'right': Bo}) 839 \end{verbatim}} 817 replaced by the outflow boundary using the method: 818 819 \begin{verbatim} 820 domain.set_boundary({'right': Bo}) 821 \end{verbatim} 822 840 823 This type of dynamically varying boundary could for example be 841 used to model the 842 breakdown of a sluice door when water exceeds a certain level. 824 used to model the breakdown of a sluice door when water exceeds a certain level. 843 825 844 826 \subsection{Output} 845 827 846 The text output from this example looks like this 847 {\small \begin{verbatim} 828 The text output from this example looks like this: 829 830 \begin{verbatim} 848 831 ... 849 832 Time = 15.4000, delta t in [0.03789902, 0.03789916], steps=6 (6) … … 854 837 Time = 16.2000, delta t in [0.03789892, 0.03789904], steps=6 (6) 855 838 ... 856 \end{verbatim}} 857 839 \end{verbatim} 858 840 859 841 \subsection{Flow through more complex topograhies} 860 842 861 843 Here is the code for the third version of the channel flow \file{channel3.py}: 844 862 845 \verbatiminput{demos/channel3.py} 863 846 … … 865 848 contains obstacles. 866 849 867 This is accomplished here by defining the function \code{topography} as follows 868 {\small \begin{verbatim} 850 This is accomplished here by defining the function \code{topography} as follows: 851 852 \begin{verbatim} 869 853 def topography(x,y): 870 """Complex topography defined by a function of vectors x and y 871 """ 854 """Complex topography defined by a function of vectors x and y.""" 872 855 873 856 z = -x/10 … … 875 858 N = len(x) 876 859 for i in range(N): 877 878 860 # Step 879 861 if 10 < x[i] < 12: … … 889 871 890 872 return z 891 \end{verbatim}} 892 893 In addition, changing the resolution to dx=dy=0.1 creates a finer mesh resolving the new featurse better. 894 895 A screenshot of this model at time == 15s is 896 \begin{figure}[hbt] 897 873 \end{verbatim} 874 875 In addition, changing the resolution to \code{dx = dy = 0.1} creates a finer mesh resolving the new features better. 876 877 A screenshot of this model at time 15s is: 878 \begin{figure}[htp] 898 879 \centerline{\includegraphics[height=75mm] 899 880 {graphics/channel3.png}} 900 901 881 \caption{More complex flow in a channel} 902 882 \label{fig:channel3} … … 904 884 905 885 906 907 908 \clearpage909 910 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%911 912 886 \section{An Example with Real Data} 887 913 888 \label{sec:realdataexample} The following discussion builds on the 914 889 concepts introduced through the \file{runup.py} example and … … 931 906 As in the case of \file{runup.py}, the actions carried 932 907 out by the program can be organised according to this outline: 933 934 908 \begin{enumerate} 935 936 909 \item Set up a triangular mesh. 937 910 938 911 \item Set certain parameters governing the mode of 939 operation of the model---specifying, for instance, where to store the940 model output.912 operation of the model -- specifying, for instance, where to store the 913 model output. 941 914 942 915 \item Input various quantities describing physical measurements, such 943 as the elevation, to be specified at each mesh point (vertex).916 as the elevation, to be specified at each mesh point (vertex). 944 917 945 918 \item Set up the boundary conditions. 946 919 947 920 \item Carry out the evolution of the model through a series of time 948 steps and output the results, providing a results file that can be 949 visualised. 950 921 steps and output the results, providing a results file that can be 922 visualised. 951 923 \end{enumerate} 952 953 954 924 955 925 \subsection{The Code} … … 973 943 In its simplest form, the mesh-generator creates the mesh within a single 974 944 polygon whose vertices are at geographical locations specified by 975 the user. The user specifies the \emph{resolution} ---that is, the976 maximal area of a triangle used for triangulation ---and a triangular945 the user. The user specifies the \emph{resolution} -- that is, the 946 maximal area of a triangle used for triangulationR -- and a triangular 977 947 mesh is created inside the polygon using a mesh generation engine. 978 948 On any given platform, the same mesh will be returned. … … 981 951 %triangulation is carried out within a pentagon. 982 952 983 984 %\begin{figure}[hbt] 985 953 %\begin{figure}[htp] 986 954 % \caption{Mesh points are created inside the polygon} 987 955 %\label{fig:pentagon} 988 956 %\end{figure} 989 957 990 Boundary tags are not restricted to \code{ `left'}, \code{`bottom'},991 \code{ `right'} and \code{`top'}, as in the case of958 Boundary tags are not restricted to \code{'left'}, \code{'bottom'}, 959 \code{'right'} and \code{'top'}, as in the case of 992 960 \file{runup.py}. Instead the user specifies a list of 993 961 tags appropriate to the configuration being modelled. … … 998 966 a number of \emph{interior polygons}, each with a specified 999 967 resolution. It is also 1000 possible to specify one or more `holes'---that is, areas bounded by968 possible to specify one or more 'holes' -- that is, areas bounded by 1001 969 polygons in which no triangulation is required. 1002 970 1003 %\begin{figure}[h bt]971 %\begin{figure}[htp] 1004 972 % \caption{Interior meshes with individual resolution} 1005 973 % \label{fig:interior meshes} … … 1025 993 extension \code{.tsh}. In the present case, the binary file format 1026 994 \code{.msh} is used. See Section \ref{sec:file formats} (page 1027 \pageref{sec:file formats}) for more on file formats. )995 \pageref{sec:file formats}) for more on file formats. 1028 996 1029 997 In practice, the details of the polygons used are read from a … … 1043 1011 would decrease to the order of tens of metres. 1044 1012 1045 \begin{figure}[hbt] 1046 \centerline{\includegraphics[scale=0.5]{graphics/cairns3.jpg}} 1047 \caption{Landscape of the Cairns scenario.} 1048 \label{fig:cairns3d} 1049 1013 \clearpage 1014 1015 \begin{figure}[htp] 1016 \centerline{\includegraphics[scale=0.5]{graphics/cairns3.jpg}} 1017 \caption{Landscape of the Cairns scenario.} 1018 \label{fig:cairns3d} 1050 1019 \end{figure} 1020 1051 1021 The following statements are used to read in the specific polygons 1052 1022 from \code{project.cairns} and assign a defined resolution to 1053 1023 each polygon. 1054 1024 1055 {\small\begin{verbatim}1056 1057 1058 1059 interior_regions = [[project.poly_cairns,cairns_res],1060 1061 1062 1063 1064 1065 \end{verbatim} }1025 \begin{verbatim} 1026 islands_res = 100000 1027 cairns_res = 100000 1028 shallow_res = 500000 1029 interior_regions = [[project.poly_cairns, cairns_res], 1030 [project.poly_island0, islands_res], 1031 [project.poly_island1, islands_res], 1032 [project.poly_island2, islands_res], 1033 [project.poly_island3, islands_res], 1034 [project.poly_shallow, shallow_res]] 1035 \end{verbatim} 1066 1036 1067 1037 Figure \ref{fig:cairnspolys} 1068 1038 illustrates the polygons used for the Cairns scenario. 1069 1039 1070 \begin{figure}[hbt] 1071 1040 \clearpage 1041 1042 \begin{figure}[htp] 1072 1043 \centerline{\includegraphics[scale=0.5] 1073 1044 {graphics/cairnsmodel.jpg}} … … 1076 1047 \end{figure} 1077 1048 1078 The statement 1079 1080 1081 {\small \begin{verbatim} 1049 The statement: 1050 1051 \begin{verbatim} 1082 1052 remainder_res = 10000000 1083 1053 create_mesh_from_regions(project.bounding_polygon, … … 1091 1061 use_cache=True, 1092 1062 verbose=True) 1093 \end{verbatim}} 1063 \end{verbatim} 1064 1094 1065 is then used to create the mesh, taking the bounding polygon to be 1095 1066 the polygon \code{bounding\_polygon} specified in \file{project.py}. 1096 1067 The argument \code{boundary\_tags} assigns a dictionary, whose keys 1097 1068 are the names of the boundary tags used for the bounding 1098 polygon ---\code{`top'}, \code{`ocean\_east'}, \code{`bottom'}, and1099 \code{ `onshore'}--- and whose values identify the indices of the1069 polygon -- \code{'top'}, \code{'ocean\_east'}, \code{'bottom'}, and 1070 \code{'onshore'} -- and whose values identify the indices of the 1100 1071 segments associated with each of these tags. 1101 1072 The polygon may be arranged either clock-wise or counter clock-wise and the … … 1103 1074 (Here, the values associated with each boundary tag are one-element lists, but they can have as many indices as there are edges) 1104 1075 If polygons intersect, or edges coincide (or are even very close) the resolution may be undefined in some regions. 1105 Use the underlying mesh interface for such cases. See Section1106 \ref{sec:mesh interface}.1076 Use the underlying mesh interface for such cases. 1077 See Section \ref{sec:mesh interface}. 1107 1078 If a segment is omitted in the tags definition an Exception is raised. 1108 1079 … … 1111 1082 areas to be generated irrespective of the requested resolution. 1112 1083 Make sure points on polygons are spaced to be no closer than the smallest resolution requested. 1113 1114 1084 1115 1085 \subsection{Initialising the Domain} … … 1122 1092 \code{meshname}, as follows: 1123 1093 1124 1125 {\small \begin{verbatim} 1126 domain = Domain(meshname, use_cache=True, verbose=True) 1127 \end{verbatim}} 1094 \begin{verbatim} 1095 domain = Domain(meshname, use_cache=True, verbose=True) 1096 \end{verbatim} 1128 1097 1129 1098 Providing a filename instead of the lists used in \file{runup.py} … … 1144 1113 taken from \file{project.py}. 1145 1114 1146 {\small \begin{verbatim} 1147 domain.set_name(project.basename) 1148 domain.set_datadir(project.outputdir) 1149 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 1150 'ymomentum']) 1151 \end{verbatim}} 1152 1115 \begin{verbatim} 1116 domain.set_name(project.basename) 1117 domain.set_datadir(project.outputdir) 1118 domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum']) 1119 \end{verbatim} 1153 1120 1154 1121 \subsection{Initial Conditions} 1122 1155 1123 Quantities for \file{runcairns.py} are set 1156 1124 using similar methods to those in \file{runup.py}. However, … … 1159 1127 ancillary points file. 1160 1128 1161 1162 1163 1129 \subsubsection{Stage} 1164 1130 … … 1166 1132 object \code{tsunami\_source}, assigned by means of a function 1167 1133 \function{slide\_tsunami}. This is similar to how we set elevation in 1168 \file{runup.py} using a function ---however, in this case the1134 \file{runup.py} using a function -- however, in this case the 1169 1135 function is both more complex and more interesting. 1170 1136 … … 1182 1148 We assign the friction exactly as we did for \file{runup.py}: 1183 1149 1184 {\small \begin{verbatim} 1185 domain.set_quantity('friction', 0.0) 1186 \end{verbatim}} 1187 1150 \begin{verbatim} 1151 domain.set_quantity('friction', 0.0) 1152 \end{verbatim} 1188 1153 1189 1154 \subsubsection{Elevation} … … 1191 1156 The elevation is specified by reading data from a file: 1192 1157 1193 {\small\begin{verbatim}1194 1195 filename = project.dem_name +'.pts',1196 use_cache =True,1197 verbose =True)1198 \end{verbatim} }1158 \begin{verbatim} 1159 domain.set_quantity('elevation', 1160 filename=project.dem_name+'.pts', 1161 use_cache=True, 1162 verbose=True) 1163 \end{verbatim} 1199 1164 1200 1165 %However, before this step can be executed, some preliminary steps 1201 1166 %are needed to prepare the file from which the data is taken. Two 1202 %source files are used for this data ---their names are specified in1167 %source files are used for this data -- their names are specified in 1203 1168 %the file \file{project.py}, in the variables \code{coarsedemname} 1204 %and \code{finedemname}. They contain `coarse' and `fine' data,1205 %respectively ---that is, data sampled at widely spaced points over a1169 %and \code{finedemname}. They contain 'coarse' and 'fine' data, 1170 %respectively -- that is, data sampled at widely spaced points over a 1206 1171 %large region and data sampled at closely spaced points over a 1207 1172 %smaller subregion. The data in these files is combined through the 1208 1173 %statement 1209 1174 1210 % {\small\begin{verbatim}1175 %\begin{verbatim} 1211 1176 %combine_rectangular_points_files(project.finedemname + '.pts', 1212 1177 % project.coarsedemname + '.pts', 1213 1178 % project.combineddemname + '.pts') 1214 %\end{verbatim}} 1179 %\end{verbatim} 1180 % 1215 1181 %The effect of this is simply to combine the datasets by eliminating 1216 1182 %any coarse data associated with points inside the smaller region … … 1226 1192 boundary tag names introduced when we established the mesh. In place of the four 1227 1193 boundary types introduced for \file{runup.py}, we use the reflective 1228 boundary for each of the 1229 eight tagged segments defined by \code{create_mesh_from_regions}: 1230 1231 {\small \begin{verbatim} 1194 boundary for each of the eight tagged segments defined by \code{create_mesh_from_regions}: 1195 1196 \begin{verbatim} 1232 1197 Bd = Dirichlet_boundary([0.0,0.0,0.0]) 1233 domain.set_boundary( {'ocean_east': Bd, 'bottom': Bd, 'onshore': Bd, 1234 'top': Bd} ) 1235 \end{verbatim}} 1198 domain.set_boundary({'ocean_east': Bd, 'bottom': Bd, 'onshore': Bd, 'top': Bd}) 1199 \end{verbatim} 1236 1200 1237 1201 \subsection{Evolution} 1238 1202 1239 With the basics established, the running of the `evolve' step is1203 With the basics established, the running of the 'evolve' step is 1240 1204 very similar to the corresponding step in \file{runup.py}. For the slide 1241 scenario, 1242 the simulation is run for 5000 seconds with the output stored every ten seconds. 1243 For this example, we choose to apply the slide at 60 seconds into the simulation. 1244 1245 {\small \begin{verbatim} 1246 import time t0 = time.time() 1247 1248 1249 for t in domain.evolve(yieldstep = 10, finaltime = 60): 1250 domain.write_time() 1251 domain.write_boundary_statistics(tags = 'ocean_east') 1252 1253 # add slide 1254 thisstagestep = domain.get_quantity('stage') 1255 if allclose(t, 60): 1256 slide = Quantity(domain) 1257 slide.set_values(tsunami_source) 1258 domain.set_quantity('stage', slide + thisstagestep) 1259 1260 for t in domain.evolve(yieldstep = 10, finaltime = 5000, 1261 skip_initial_step = True): 1262 domain.write_time() 1205 scenario, the simulation is run for 5000 seconds with the output stored every ten seconds. 1206 For this example, we choose to apply the slide at 60 seconds into the simulation: 1207 1208 \begin{verbatim} 1209 import time 1210 1211 t0 = time.time() 1212 1213 for t in domain.evolve(yieldstep=10, finaltime=60): 1214 domain.write_time() 1263 1215 domain.write_boundary_statistics(tags = 'ocean_east') 1264 \end{verbatim}} 1216 1217 # add slide 1218 thisstagestep = domain.get_quantity('stage') 1219 if allclose(t, 60): 1220 slide = Quantity(domain) 1221 slide.set_values(tsunami_source) 1222 domain.set_quantity('stage', slide + thisstagestep) 1223 1224 for t in domain.evolve(yieldstep=10, finaltime=5000, 1225 skip_initial_ste=True): 1226 domain.write_time() 1227 1228 domain.write_boundary_statistics(tags = 'ocean_east') 1229 \end{verbatim} 1265 1230 1266 1231 For the fixed wave scenario, the simulation is run to 10000 seconds, … … 1270 1235 parts of the simulation to be viewed at higher time resolution. 1271 1236 1272 1273 {\small \begin{verbatim} 1274 1237 \begin{verbatim} 1275 1238 # save every two mins leading up to wave approaching land 1276 for t in domain.evolve(yieldstep = 120, finaltime = 5000): 1277 domain.write_time() 1278 domain.write_boundary_statistics(tags = 'ocean_east') 1279 1280 # save every 30 secs as wave starts inundating ashore 1281 for t in domain.evolve(yieldstep = 10, finaltime = 10000, 1282 skip_initial_step = True): 1283 domain.write_time() 1284 domain.write_boundary_statistics(tags = 'ocean_east') 1285 1286 \end{verbatim}} 1239 for t in domain.evolve(yieldstep=120, finaltime=5000): 1240 domain.write_time() 1241 domain.write_boundary_statistics(tags='ocean_east') 1242 1243 # save every 30 secs as wave starts inundating ashore 1244 for t in domain.evolve(yieldstep=10, finaltime=10000, skip_initial_step=True): 1245 domain.write_time() 1246 domain.write_boundary_statistics(tags='ocean_east') 1247 \end{verbatim} 1248 1287 1249 1288 1250 \section{Exploring the Model Output} 1289 1251 1290 1252 Now that the scenario has been run, the user can view the output in a number of ways. 1291 As described earlier, the user may run animateto view a three-dimensional representation1253 As described earlier, the user may run \code{animate} to view a three-dimensional representation 1292 1254 of the simulation. 1293 1255 1294 1256 The user may also be interested in a maximum inundation map. This simply shows the 1295 maximum water depth over the domain and is achieved with the function sww2dem (described in1296 Section \ref{sec:basicfileconversions}).1257 maximum water depth over the domain and is achieved with the function \code{sww2dem} 1258 described in Section \ref{sec:basicfileconversions}). 1297 1259 \file{ExportResults.py} demonstrates how this function can be used: 1298 1260 1299 1261 \verbatiminput{demos/cairns/ExportResults.py} 1300 1262 1301 The script generates a nmaximum water depth ASCII grid at a defined1263 The script generates a maximum water depth ASCII grid at a defined 1302 1264 resolution (here 100 m$^2$) which can then be viewed in a GIS environment, for 1303 1265 example. The parameters used in the function are defined in \file{project.py}. … … 1315 1277 coastline. 1316 1278 1317 \begin{figure}[hbt] 1318 \centerline{\includegraphics[scale=0.5]{graphics/slidedepth.jpg}} 1319 \caption{Maximum inundation map for the Cairns slide scenario. \bf Note, this 1320 inundation map has been based on a purely hypothetical scenario which was 1321 designed explictiy for demonstration purposes only.} 1322 \label{fig:maxdepthcairnsslide} 1279 \clearpage 1280 1281 \begin{figure}[htp] 1282 \centerline{\includegraphics[scale=0.5]{graphics/slidedepth.jpg}} 1283 \caption{Maximum inundation map for the Cairns slide scenario. \bf Note, this 1284 inundation map has been based on a purely hypothetical scenario which was 1285 designed explictiy for demonstration purposes only.} 1286 \label{fig:maxdepthcairnsslide} 1323 1287 \end{figure} 1324 1288 1325 \begin{figure}[hbt] 1326 \centerline{\includegraphics[scale=0.5]{graphics/fixedwavedepth.jpg}} 1327 \caption{Maximum inundation map for the Cairns fixed wave scenario. 1328 \bf Note, this 1329 inundaiton map has been based on a purely hypothetical scenario which was 1330 designed explictiy for demonstration purposes only.} 1331 \label{fig:maxdepthcairnsfixedwave} 1289 \clearpage 1290 1291 \begin{figure}[htp] 1292 \centerline{\includegraphics[scale=0.5]{graphics/fixedwavedepth.jpg}} 1293 \caption{Maximum inundation map for the Cairns fixed wave scenario. 1294 \bf Note, this inundation map has been based on a purely hypothetical scenario which was 1295 designed explictiy for demonstration purposes only.} 1296 \label{fig:maxdepthcairnsfixedwave} 1332 1297 \end{figure} 1298 1299 \clearpage 1333 1300 1334 1301 The user may also be interested in interrogating the solution at a particular spatial … … 1337 1304 identified for the Cairns scenario, as shown in Figure \ref{fig:cairnsgauges}. 1338 1305 1339 \begin{figure}[h bt]1340 \centerline{\includegraphics[scale=0.5]{graphics/cairnsgauges.jpg}}1341 \caption{Point locations to show time series information for the Cairns scenario.}1342 \label{fig:cairnsgauges}1306 \begin{figure}[htp] 1307 \centerline{\includegraphics[scale=0.5]{graphics/cairnsgauges.jpg}} 1308 \caption{Point locations to show time series information for the Cairns scenario.} 1309 \label{fig:cairnsgauges} 1343 1310 \end{figure} 1344 1311 1345 1312 These locations 1346 1313 must be stored in either a .csv or .txt file. The corresponding .csv file for 1347 the gauges shown in Figure \ref{fig:cairnsgauges} is \file{gauges.csv} 1314 the gauges shown in Figure \ref{fig:cairnsgauges} is \file{gauges.csv}: 1348 1315 1349 1316 \verbatiminput{demos/cairns/gauges.csv} … … 1352 1319 northings, and each gauge is given a name. The elevation column can be zero here. 1353 1320 This information is then passed to the function \code{sww2csv_gauges} (shown in 1354 \file{GetTimeseries.py} which generates the csv files for each point location. The csvfiles1321 \file{GetTimeseries.py} which generates the csv files for each point location. The CSV files 1355 1322 can then be used in \code{csv2timeseries_graphs} to create the timeseries plot for each desired 1356 1323 quantity. \code{csv2timeseries_graphs} relies on \code{pylab} to be installed which is not part … … 1371 1338 Airport in Figure \ref{fig:airportboth}. 1372 1339 1373 \begin{figure}[h bt]1374 \centerline{\includegraphics[scale=0.5]{graphics/gaugeElfordReefstage.png}}1375 \caption{Time series information of the quantity stage for the Elford Reef location for the1376 fixed wave and slide scenario.}1377 \label{fig:reef}1340 \begin{figure}[htp] 1341 \centerline{\includegraphics[scale=0.5]{graphics/gaugeElfordReefstage.png}} 1342 \caption{Time series information of the quantity stage for the Elford Reef location for the 1343 fixed wave and slide scenario.} 1344 \label{fig:reef} 1378 1345 \end{figure} 1379 1346 1380 \begin{figure}[h bt]1381 \centerline{\includegraphics[scale=0.5]{graphics/gaugeCairnsAirportdepth.png}}1382 \caption{Time series information of the quantity depth for the Cairns Airport1383 location for the slide and fixed wave scenario.}1384 \label{fig:airportboth}1347 \begin{figure}[htp] 1348 \centerline{\includegraphics[scale=0.5]{graphics/gaugeCairnsAirportdepth.png}} 1349 \caption{Time series information of the quantity depth for the Cairns Airport 1350 location for the slide and fixed wave scenario.} 1351 \label{fig:airportboth} 1385 1352 \end{figure} 1386 1353 1387 1388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1389 1354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1390 1355 … … 1396 1361 following headings, which correspond to the outline of the examples 1397 1362 described in Chapter \ref{ch:getstarted}: 1398 1399 1363 \begin{itemize} 1400 1364 \item Establishing the Mesh: Section \ref{sec:establishing the mesh} 1401 1365 \item Initialising the Domain: Section \ref{sec:initialising the domain} 1402 \item Specifying the Quantities: Section \ref{sec:quantitis}1366 % \item Specifying the Quantities: Section \ref{sec:quantities} 1403 1367 \item Initial Conditions: Section \ref{sec:initial conditions} 1404 1368 \item Boundary Conditions: Section \ref{sec:boundary conditions} … … 1408 1372 1409 1373 The listings are intended merely to give the reader an idea of what 1410 each feature is, where to find it and how it can be used ---they do1374 each feature is, where to find it and how it can be used -- they do 1411 1375 not give full specifications; for these the reader 1412 1376 may consult the code. The code for every function or class contains 1413 a documentation string, or `docstring', that specifies the precise1377 a documentation string, or 'docstring', that specifies the precise 1414 1378 syntax for its use. This appears immediately after the line 1415 1379 introducing the code, between two sets of triple quotes. … … 1425 1389 \module{mesh\_interface} in a subfolder of \module{inundation} called 1426 1390 \code{pmesh}. In Linux or Unix syntax, the pathname of the file 1427 containing the function, relative to \file{inundation}, would be 1428 1429 \begin{ center}1430 % \code{pmesh/mesh\_interface.py} 1431 \code{pmesh}$\slash$\code{mesh\_interface.py}1432 \end{center} 1391 containing the function, relative to \file{inundation}, would be: 1392 1393 \begin{verbatim} 1394 pmesh/mesh_interface.py 1395 \end{verbatim} 1396 1433 1397 \label{sec:mesh interface} 1434 1435 while in Windows syntax it would be 1436 1437 \begin{center} 1438 \code{pmesh}$\backslash$\code{mesh\_interface.py} 1439 \end{center} 1398 while in Windows syntax it would be: 1399 1400 \begin{verbatim} 1401 pmesh\mesh_interface.py 1402 \end{verbatim} 1440 1403 1441 1404 Rather than using either of these forms, in this chapter we specify 1442 the location simply as \code{pmesh.mesh \_interface}, in keeping with1405 the location simply as \code{pmesh.mesh_interface}, in keeping with 1443 1406 the usage in the Python statement for importing the function, 1444 1407 namely: 1445 \begin{center} 1446 \code{from pmesh.mesh\_interface import create\_mesh\_from\_regions} 1447 \end{center} 1408 1409 \begin{verbatim} 1410 from pmesh.mesh_interface import create_mesh_from_regions 1411 \end{verbatim} 1448 1412 1449 1413 Each listing details the full set of parameters for the class or … … 1455 1419 and are omitted from the descriptions given below: 1456 1420 1457 %\begin{center} 1458 \begin{tabular}{ll} %\hline 1459 %\textbf{Name } & \textbf{Description}\\ 1460 %\hline 1461 \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\\ 1462 \emph{verbose} & If \code{True}, provides detailed terminal output 1463 to the user\\ % \hline 1421 %\begin{tabular}{ll} 1422 \begin{tabular}{p{2.0cm} p{14.0cm}} 1423 \emph{use\_cache} & Specifies whether caching is to be used for improved performance. 1424 See Section \ref{sec:caching} for details on the underlying caching functionality\\ 1425 \emph{verbose} & If \code{True}, provides detailed terminal output to the user\\ 1464 1426 \end{tabular} 1465 %\end{center} 1427 1466 1428 1467 1429 \section{Mesh Generation}\index{Mesh!generation} … … 1474 1436 very simple mesh comprising just 11 points and 10 triangles. 1475 1437 1476 1477 \begin{figure}[h] 1438 \begin{figure}[htp] 1478 1439 \begin{center} 1479 1440 \includegraphics[width=90mm, height=90mm]{triangularmesh.jpg} 1480 1441 \end{center} 1481 1482 1442 \caption{A simple mesh} 1483 1443 \label{fig:simplemesh} 1484 1444 \end{figure} 1485 1445 1446 \clearpage 1486 1447 1487 1448 The variables \code{points}, \code{triangles} and \code{boundary} 1488 1449 represent the data displayed in Figure \ref{fig:simplemesh} as 1489 1450 follows. The list \code{points} stores the coordinates of the 1490 points, and may be displayed schematically as in Table 1491 \ref{tab:points}. 1492 1493 1494 \begin{table} 1451 points, and may be displayed schematically as in Table \ref{tab:points}. 1452 1453 \begin{table}[htp] 1495 1454 \begin{center} 1496 1455 \begin{tabular}[t]{|c|cc|} \hline … … 1509 1468 \end{tabular} 1510 1469 \end{center} 1511 1512 \caption{Point coordinates for mesh in 1513 Figure \protect \ref{fig:simplemesh}} 1470 \caption{Point coordinates for mesh in Figure \protect \ref{fig:simplemesh}} 1514 1471 \label{tab:points} 1515 1472 \end{table} … … 1525 1482 and $(3,0,1)$. 1526 1483 1527 1528 \begin{table} 1484 \begin{table}[htp] 1529 1485 \begin{center} 1530 \begin{tabular}{|c|ccc|} \hline 1531 index & \multicolumn{3}{c|}{\code{points}}\\ \hline 1486 \begin{tabular}{|c|ccc|} 1487 \hline 1488 index & \multicolumn{3}{c|}{\code{points}}\\ 1489 \hline 1532 1490 0 & 0 & 1 & 3\\ 1533 1491 1 & 1 & 2 & 4\\ … … 1539 1497 7 & 7 & 9 & 8\\ 1540 1498 8 & 1 & 4 & 3\\ 1541 9 & 5 & 10 & 9\\ \hline 1499 9 & 5 & 10 & 9\\ 1500 \hline 1542 1501 \end{tabular} 1543 1502 \end{center} … … 1550 1509 triangles and associates a tag with each. 1551 1510 1552 \refmodindex[pmesh.meshinterface]{pmesh.mesh\_interface}\label{sec:meshgeneration} 1553 1554 \begin{funcdesc} {create\_mesh\_from\_regions}{bounding_polygon, 1511 % \refmodindex[pmesh.meshinterface]{pmesh.mesh\_interface} 1512 \label{sec:meshgeneration} 1513 1514 \begin{funcdesc} {create\_mesh\_from\_regions}{bounding_polygon, 1555 1515 boundary_tags, 1556 1516 maximum_triangle_area, … … 1591 1551 \end{funcdesc} 1592 1552 1593 1594 1595 1553 \subsection{Advanced mesh generation} 1596 1554 … … 1610 1568 to build a mesh outline, such as \code{add\_vertices} and 1611 1569 \code{add\_region\_from\_polygon}. 1612 1613 1570 \end{classdesc} 1614 1571 1615 1616 1572 \subsubsection{Key Methods of Class Mesh} 1617 1573 1618 1619 \begin{methoddesc} {add\_hole}{x,y} 1574 \begin{methoddesc} {add\_hole}{self, x, y} 1620 1575 Module: \module{pmesh.mesh}, Class: \class{Mesh} 1621 1576 … … 1623 1578 when the boundary of the hole has already been defined, by selecting a 1624 1579 point within the boundary. 1625 1626 \end{methoddesc} 1627 1580 \end{methoddesc} 1628 1581 1629 1582 \begin{methoddesc} {add\_hole\_from\_polygon}{self, polygon, tags=None} 1630 1583 Module: \module{pmesh.mesh}, Class: \class{Mesh} 1631 1584 1632 This method is used to add a `hole' within a region ---that is, to1585 This method is used to add a 'hole' within a region -- that is, to 1633 1586 define a interior region where the triangular mesh will not be 1634 generated ---to a \class{Mesh} instance. The region boundary is described by1587 generated -- to a \class{Mesh} instance. The region boundary is described by 1635 1588 the polygon passed in. Additionally, the user specifies a list of 1636 1589 boundary tags, one for each edge of the bounding polygon. 1637 1590 \end{methoddesc} 1638 1639 1591 1640 1592 \begin{methoddesc} {add\_points_and_segments}{self, points, segments, … … 1648 1600 [[0,1],[1,2]]} to make a polyline between points 0, 1 and 2. A tag for 1649 1601 each segment can optionally be added. 1650 1651 \end{methoddesc} 1652 1653 \begin{methoddesc} {add\_region}{x,y} 1602 \end{methoddesc} 1603 1604 \begin{methoddesc} {add\_region}{self, x, y} 1654 1605 Module: \module{pmesh.mesh}, Class: \class{Mesh} 1655 1606 … … 1658 1609 a point within the boundary. A region instance is returned. This can 1659 1610 be used to set the resolution. 1660 1661 1611 \end{methoddesc} 1662 1612 1663 1613 \begin{methoddesc} {add\_region\_from\_polygon}{self, polygon, 1664 segment_tags=None, region_tag=None 1665 max_triangle_area=None} 1614 segment_tags=None, region_tag=None, max_triangle_area=None} 1666 1615 Module: \module{pmesh.mesh}, Class: \class{Mesh} 1667 1616 … … 1673 1622 user specifies a list of segment tags, one for each edge of the 1674 1623 bounding polygon. The regional tag is set using \code{region}. 1675 1676 \end{methoddesc} 1677 1678 1679 1680 1681 1682 \begin{methoddesc} {add\_vertices}{point_data} 1624 \end{methoddesc} 1625 1626 \begin{methoddesc} {add\_vertices}{self, point_data} 1683 1627 Module: \module{pmesh.mesh}, Class: \class{Mesh} 1684 1628 … … 1687 1631 \end{methoddesc} 1688 1632 1689 \begin{methoddesc} {auto\_segment}{ raw_boundary=raw_boundary,1633 \begin{methoddesc} {auto\_segment}{self, raw_boundary=raw_boundary, 1690 1634 remove_holes=remove_holes, 1691 1635 smooth_indents=smooth_indents, … … 1697 1641 useful since a set of user vertices need to be outlined by segments 1698 1642 before generate_mesh is called. 1699 1700 \end{methoddesc} 1701 1702 \begin{methoddesc} {export\_mesh_file}{self,ofile} 1643 \end{methoddesc} 1644 1645 \begin{methoddesc} {export\_mesh_file}{self, ofile} 1703 1646 Module: \module{pmesh.mesh}, Class: \class{Mesh} 1704 1647 … … 1721 1664 \end{methoddesc} 1722 1665 1723 1724 1725 \begin{methoddesc} {import_ungenerate_file}{self,ofile, tag=None, 1666 \begin{methoddesc} {import_ungenerate_file}{self, ofile, tag=None, 1726 1667 region_tag=None} 1727 1668 Module: \module{pmesh.mesh}, Class: \class{Mesh} … … 1741 1682 \end{methoddesc} 1742 1683 1743 %%%%%% 1684 1744 1685 \section{Initialising the Domain}\index{Initialising the Domain} 1745 1686 \label{sec:initialising the domain} … … 1786 1727 1787 1728 Returns the name assigned to the domain by \code{set\_name}. If no name has been 1788 assigned, returns \code{ `domain'}.1729 assigned, returns \code{'domain'}. 1789 1730 \end{methoddesc} 1790 1731 … … 1799 1740 Since different operating systems use different formats for specifying pathnames, 1800 1741 it is necessary to specify path separators using the Python code \code{os.sep}, rather than 1801 the operating-specific ones such as `$\slash$' or `$\backslash$'.1742 the operating-specific ones such as '$\slash$' or '$\backslash$'. 1802 1743 For this to work you will need to include the statement \code{import os} 1803 1744 in your code, before the first appearance of \code{set\_datadir}. … … 1807 1748 the statements: 1808 1749 1809 {\small\begin{verbatim}1810 1811 1812 \end{verbatim} }1750 \begin{verbatim} 1751 import os 1752 domain.set_datadir{'project' + os.sep + 'data'} 1753 \end{verbatim} 1813 1754 \end{methoddesc} 1814 1755 … … 1822 1763 \end{methoddesc} 1823 1764 1824 1825 1765 \begin{methoddesc} {set\_minimum_allowed_height}{} 1826 1766 Module: \module{shallow\_water.shallow\_water\_domain} … … 1834 1774 \end{methoddesc} 1835 1775 1836 1837 1776 \begin{methoddesc} {set\_minimum_storable_height}{} 1838 1777 Module: \module{shallow\_water.shallow\_water\_domain} … … 1842 1781 that seems to be caused by friction creep. 1843 1782 \end{methoddesc} 1844 1845 1783 1846 1784 \begin{methoddesc} {set\_maximum_allowed_speed}{} … … 1853 1791 \end{methoddesc} 1854 1792 1855 1856 1793 \begin{methoddesc} {set\_time}{time=0.0} 1857 1794 Module: \module{abstract\_2d\_finite\_volumes.domain} … … 1866 1803 to \code{n} will cause an error.) 1867 1804 \end{methoddesc} 1868 1869 1805 1870 1806 \begin{methoddesc} {set\_store\_vertices\_uniquely}{flag} … … 1896 1832 file and the same data stored in the model domain. This must be borne in mind when comparing 1897 1833 data from the sww files with that of the model internally. 1898 1899 \end{methoddesc} 1900 1834 \end{methoddesc} 1901 1835 1902 1836 % Structural methods … … 1913 1847 \end{methoddesc} 1914 1848 1915 1916 1849 \begin{methoddesc}{get\_vertex\_coordinates}{absolute=False} 1917 1850 \label{pg:get vertex coordinates} … … 1926 1859 Default is False as many parts of ANUGA expects relative coordinates. 1927 1860 \end{methoddesc} 1928 1929 1861 1930 1862 \begin{methoddesc}{get\_centroid\_coordinates}{absolute=False} … … 1939 1871 \end{methoddesc} 1940 1872 1941 1942 1873 \begin{methoddesc}{get\_triangles}{indices=None} 1943 1874 1944 1945 1946 1947 1948 1949 1875 Return Mx3 integer array where M is the number of triangles. 1876 Each row corresponds to one triangle and the three entries are 1877 indices into the mesh nodes which can be obtained using the method 1878 get\_nodes() 1879 1880 Optional argument, indices is the set of triangle ids of interest. 1950 1881 \end{methoddesc} 1951 1882 1952 1883 \begin{methoddesc}{get\_disconnected\_triangles}{} 1953 1954 Get mesh based on nodes obtained from get_vertex_coordinates. 1955 1956 Return array Mx3 array of integers where each row corresponds to 1957 a triangle. A triangle is a triplet of indices into 1958 point coordinates obtained from get_vertex_coordinates and each 1959 index appears only once.\\ 1960 1961 This provides a mesh where no triangles share nodes 1962 (hence the name disconnected triangles) and different 1963 nodes may have the same coordinates.\\ 1964 1965 This version of the mesh is useful for storing meshes with 1966 discontinuities at each node and is e.g. used for storing 1967 data in sww files.\\ 1968 1969 The triangles created will have the format 1970 1971 {\small \begin{verbatim} 1972 [[0,1,2], 1973 [3,4,5], 1974 [6,7,8], 1975 ... 1976 [3*M-3 3*M-2 3*M-1]] 1977 \end{verbatim}} 1978 \end{methoddesc} 1979 1980 1981 1982 %%%%%% 1884 Get mesh based on nodes obtained from get_vertex_coordinates. 1885 1886 Return array Mx3 array of integers where each row corresponds to 1887 a triangle. A triangle is a triplet of indices into 1888 point coordinates obtained from get_vertex_coordinates and each 1889 index appears only once.\\ 1890 1891 This provides a mesh where no triangles share nodes 1892 (hence the name disconnected triangles) and different 1893 nodes may have the same coordinates.\\ 1894 1895 This version of the mesh is useful for storing meshes with 1896 discontinuities at each node and is e.g. used for storing 1897 data in sww files.\\ 1898 1899 The triangles created will have the format: 1900 1901 \begin{verbatim} 1902 [[0,1,2], 1903 [3,4,5], 1904 [6,7,8], 1905 ... 1906 [3*M-3 3*M-2 3*M-1]] 1907 \end{verbatim} 1908 \end{methoddesc} 1909 1910 1983 1911 \section{Initial Conditions}\index{Initial Conditions} 1984 1912 \label{sec:initial conditions} … … 1995 1923 1996 1924 \begin{methoddesc}{set\_quantity}{name, 1997 numeric =None,1998 quantity =None,1999 function =None,2000 geospatial_data =None,2001 expression =None,2002 filename =None,2003 attribute_name =None,2004 alpha =None,2005 location ='vertices',2006 indices =None,2007 verbose =False,2008 use_cache =False}1925 numeric=None, 1926 quantity=None, 1927 function=None, 1928 geospatial_data=None, 1929 expression=None, 1930 filename=None, 1931 attribute_name=None, 1932 alpha=None, 1933 location='vertices', 1934 indices=None, 1935 verbose=False, 1936 use_cache=False} 2009 1937 Module: \module{abstract\_2d\_finite\_volumes.domain} 2010 1938 (see also \module{abstract\_2d\_finite\_volumes.quantity.set\_values}) 2011 1939 2012 This function is used to assign values to individual quantities for a 2013 domain. It is very flexible and can be used with many data types: a 2014 statement of the form \code{domain.set\_quantity(name, x)} can be used 2015 to define a quantity having the name \code{name}, where the other 2016 argument \code{x} can be any of the following: 2017 2018 \begin{itemize} 2019 \item a number, in which case all vertices in the mesh gets that for 2020 the quantity in question. 2021 \item a list of numbers or a Numeric array ordered the same way as the mesh vertices. 2022 \item a function (e.g.\ see the samples introduced in Chapter 2) 2023 \item an expression composed of other quantities and numbers, arrays, lists (for 2024 example, a linear combination of quantities, such as 2025 \code{domain.set\_quantity('stage','elevation'+x))} 2026 \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. 2027 \item a geospatial dataset (See Section \ref{sec:geospatial}). 2028 Optional argument attribute\_name applies here as with files. 2029 \end{itemize} 2030 2031 2032 Exactly one of the arguments 2033 numeric, quantity, function, points, filename 2034 must be present. 2035 2036 2037 Set quantity will look at the type of the second argument (\code{numeric}) and 2038 determine what action to take. 2039 2040 Values can also be set using the appropriate keyword arguments. 2041 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)} 2042 are all equivalent. 2043 2044 2045 Other optional arguments are 2046 \begin{itemize} 2047 \item \code{indices} which is a list of ids of triangles to which set\_quantity should apply its assignment of values. 2048 \item \code{location} determines which part of the triangles to assign 2049 to. Options are 'vertices' (default), 'edges', 'unique vertices', and 'centroids'. 2050 If 'vertices' are use, edge and centroid values are automatically computed as the appropriate averages. This option ensures continuity of the surface. 2051 If, on the other hand, 'centroids' is used vertex and edge values will be set to the same value effectively creating a piecewise constant surface with possible discontinuities at the edges. 2052 \end{itemize} 2053 2054 %%% 2055 \anuga provides a number of predefined initial conditions to be used 2056 with \code{set\_quantity}. See for example callable object 2057 \code{slump\_tsunami} below. 2058 2059 \end{methoddesc} 2060 2061 2062 1940 This function is used to assign values to individual quantities for a 1941 domain. It is very flexible and can be used with many data types: a 1942 statement of the form \code{domain.set\_quantity(name, x)} can be used 1943 to define a quantity having the name \code{name}, where the other 1944 argument \code{x} can be any of the following: 1945 1946 \begin{itemize} 1947 \item a number, in which case all vertices in the mesh gets that for 1948 the quantity in question. 1949 \item a list of numbers or a numeric array ordered the same way as the mesh vertices. 1950 \item a function (e.g.\ see the samples introduced in Chapter 2) 1951 \item an expression composed of other quantities and numbers, arrays, lists (for 1952 example, a linear combination of quantities, such as 1953 \code{domain.set\_quantity('stage','elevation'+x))} 1954 \item the name of a file from which the data can be read. In this case, the optional 1955 argument attribute\_name will select which attribute to use from the file. If left out, 1956 set\_quantity will pick one. This is useful in cases where there is only one attribute. 1957 \item a geospatial dataset (See Section \ref{sec:geospatial}). 1958 Optional argument attribute\_name applies here as with files. 1959 \end{itemize} 1960 1961 Exactly one of the arguments 1962 numeric, quantity, function, points, filename 1963 must be present. 1964 1965 \code{set_quantity} will look at the type of the second argument (\code{numeric}) and 1966 determine what action to take. 1967 1968 Values can also be set using the appropriate keyword arguments. 1969 If x is a function, for example, \code{domain.set\_quantity(name, x)}, \code{domain.set\_quantity(name, numeric=x)}, 1970 and \code{domain.set\_quantity(name, function=x)} are all equivalent. 1971 1972 Other optional arguments are 1973 \begin{itemize} 1974 \item \code{indices} which is a list of ids of triangles to which set\_quantity should apply its assignment of values. 1975 \item \code{location} determines which part of the triangles to assign 1976 to. Options are 'vertices' (default), 'edges', 'unique vertices', and 'centroids'. 1977 If 'vertices' are use, edge and centroid values are automatically computed as the 1978 appropriate averages. This option ensures continuity of the surface. 1979 If, on the other hand, 'centroids' is used vertex and edge values will be set to the 1980 same value effectively creating a piecewise constant surface with possible discontinuities at the edges. 1981 \end{itemize} 1982 1983 \anuga provides a number of predefined initial conditions to be used 1984 with \code{set\_quantity}. See for example callable object \code{slump\_tsunami} below. 1985 \end{methoddesc} 2063 1986 2064 1987 \begin{methoddesc}{add\_quantity}{name, 2065 numeric =None,2066 quantity =None,2067 function =None,2068 geospatial_data =None,2069 expression =None,2070 filename =None,2071 attribute_name =None,2072 alpha =None,2073 location ='vertices',2074 indices =None,2075 verbose =False,2076 use_cache =False}1988 numeric=None, 1989 quantity=None, 1990 function=None, 1991 geospatial_data=None, 1992 expression=None, 1993 filename=None, 1994 attribute_name=None, 1995 alpha=None, 1996 location='vertices', 1997 indices=None, 1998 verbose=False, 1999 use_cache=False} 2077 2000 Module: \module{abstract\_2d\_finite\_volumes.domain} 2078 2001 (see also \module{abstract\_2d\_finite\_volumes.domain.set\_quantity}) 2079 2002 2080 \label{add quantity} 2081 This function is used to \emph{add} values to individual quantities for a 2082 domain. It has the same syntax as \code{domain.set\_quantity(name, x)}. 2083 2084 A typical use of this function is to add structures to an existing elevation model: 2085 2086 {\small 2087 \begin{verbatim} 2088 # Create digital elevation model from points file 2089 domain.set_quantity('elevation', 2090 filename = 'elevation_file.pts, 2091 verbose = True) 2092 2093 # Add buildings from file 2094 building_polygons, building_heights = csv2building_polygons(building_file) 2095 2096 B = [] 2097 for key in building_polygons: 2098 poly = building_polygons[key] 2099 elev = building_heights[key] 2100 B.append((poly, elev)) 2101 2102 domain.add_quantity('elevation', Polygon_function(B, default=0.0)) 2103 2104 \end{verbatim}} 2105 2106 \end{methoddesc} 2107 2108 2109 2110 2111 2003 \label{add quantity} 2004 This function is used to \emph{add} values to individual quantities for a 2005 domain. It has the same syntax as \code{domain.set\_quantity(name, x)}. 2006 2007 A typical use of this function is to add structures to an existing elevation model: 2008 2009 \begin{verbatim} 2010 # Create digital elevation model from points file 2011 domain.set_quantity('elevation', filename='elevation_file.pts, verbose=True) 2012 2013 # Add buildings from file 2014 building_polygons, building_heights = csv2building_polygons(building_file) 2015 2016 B = [] 2017 for key in building_polygons: 2018 poly = building_polygons[key] 2019 elev = building_heights[key] 2020 B.append((poly, elev)) 2021 2022 domain.add_quantity('elevation', Polygon_function(B, default=0.0)) 2023 \end{verbatim} 2024 \end{methoddesc} 2112 2025 2113 2026 \begin{funcdesc}{set_region}{tag, quantity, X, location='vertices'} … … 2116 2029 (see also \module{abstract\_2d\_finite\_volumes.quantity.set\_values}) 2117 2030 2118 This function is used to assign values to individual quantities given2119 a regional tag. It is similar to \code{set\_quantity}.2120 For example, if in the mesh-generator a regional tag of 'ditch' was2121 used, set\_region can be used to set elevation of this region to2122 -10m. X is the constant or function to be applied to the quantity,2123 over the tagged region. Location describes how the values will be2124 applied. Options are 'vertices' (default), 'edges', 'unique2125 vertices', and 'centroids'.2126 2127 This method can also be called with a list of region objects. This is2128 useful for adding quantities in regions, and having one quantity2129 value based on another quantity. See \module{abstract\_2d\_finite\_volumes.region} for2130 more details.2031 This function is used to assign values to individual quantities given 2032 a regional tag. It is similar to \code{set\_quantity}. 2033 For example, if in the mesh-generator a regional tag of 'ditch' was 2034 used, set\_region can be used to set elevation of this region to 2035 -10m. X is the constant or function to be applied to the quantity, 2036 over the tagged region. Location describes how the values will be 2037 applied. Options are 'vertices' (default), 'edges', 'unique 2038 vertices', and 'centroids'. 2039 2040 This method can also be called with a list of region objects. This is 2041 useful for adding quantities in regions, and having one quantity 2042 value based on another quantity. See \module{abstract\_2d\_finite\_volumes.region} for 2043 more details. 2131 2044 \end{funcdesc} 2132 2133 2134 2135 2045 2136 2046 \begin{funcdesc}{slump_tsunami}{length, depth, slope, width=None, thickness=None, … … 2141 2051 domain=None, 2142 2052 verbose=False} 2143 Module: \module{shallow\_water.smf}2144 2145 This function returns a callable object representing an initial water2146 displacement generated by a submarine sediment failure. These failures can take the form of2147 a submarine slump or slide. In the case of a slide, use \code{slide_tsunami} instead.2148 2149 The arguments include as a minimum, the slump or slide length, the water depth to the centre of sediment2150 mass, and the bathymetric slope. Other slump or slide parameters can be included if they are known.2053 Module: \module{shallow\_water.smf} 2054 2055 This function returns a callable object representing an initial water 2056 displacement generated by a submarine sediment failure. These failures can take the form of 2057 a submarine slump or slide. In the case of a slide, use \code{slide_tsunami} instead. 2058 2059 The arguments include as a minimum, the slump or slide length, the water depth to the centre of sediment 2060 mass, and the bathymetric slope. Other slump or slide parameters can be included if they are known. 2151 2061 \end{funcdesc} 2152 2062 2153 2154 %%%2155 2063 \begin{funcdesc}{file\_function}{filename, 2156 domain = None, 2157 quantities = None, 2158 interpolation_points = None, 2159 verbose = False, 2160 use_cache = False} 2161 Module: \module{abstract\_2d\_finite\_volumes.util} 2162 2163 Reads the time history of spatial data for 2164 specified interpolation points from a NetCDF file (\code{filename}) 2165 and returns 2166 a callable object. \code{filename} could be a \code{sww} or \code{sts} file. 2167 Returns interpolated values based on the input 2168 file using the underlying \code{interpolation\_function}. 2169 2170 \code{quantities} is either the name of a single quantity to be 2171 interpolated or a list of such quantity names. In the second case, the resulting 2172 function will return a tuple of values---one for each quantity. 2173 2174 \code{interpolation\_points} is a list of absolute coordinates or a 2175 geospatial object 2176 for points at which values are sought. 2177 2178 \code{boundary_polygon} is a list of coordinates specifying the vertices of the boundary. This must be the same polygon as used when calling \code{create_mesh_from_regions}. This argument can only be used when reading boundary data from the STS format. 2179 2180 The model time stored within the file function can be accessed using 2181 the method \code{f.get\_time()} 2182 2183 2184 The underlying algorithm used is as follows:\\ 2185 Given a time series (i.e.\ a series of values associated with 2186 different times), whose values are either just numbers, a set of 2187 numbers defined at the vertices of a triangular mesh (such as those 2188 stored in SWW files) or a set of 2189 numbers defined at a number of points on the boundary (such as those 2190 stored in STS files), \code{Interpolation\_function} is used to 2191 create a callable object that interpolates a value for an arbitrary 2192 time \code{t} within the model limits and possibly a point \code{(x, 2193 y)} within a mesh region. 2194 2195 The actual time series at which data is available is specified by 2196 means of an array \code{time} of monotonically increasing times. The 2197 quantities containing the values to be interpolated are specified in 2198 an array---or dictionary of arrays (used in conjunction with the 2199 optional argument \code{quantity\_names}) --- called 2200 \code{quantities}. The optional arguments \code{vertex\_coordinates} 2201 and \code{triangles} represent the spatial mesh associated with the 2202 quantity arrays. If omitted the function must be created using an STS file 2203 or a TMS file. 2204 2205 Since, in practice, values need to be computed at specified points, 2206 the syntax allows the user to specify, once and for all, a list 2207 \code{interpolation\_points} of points at which values are required. 2208 In this case, the function may be called using the form \code{f(t, 2209 id)}, where \code{id} is an index for the list 2210 \code{interpolation\_points}. 2211 2212 2064 domain=None, 2065 quantities=None, 2066 interpolation_points=None, 2067 verbose=False, 2068 use_cache=False} 2069 Module: \module{abstract\_2d\_finite\_volumes.util} 2070 2071 Reads the time history of spatial data for 2072 specified interpolation points from a NetCDF file (\code{filename}) 2073 and returns 2074 a callable object. \code{filename} could be a \code{sww} or \code{sts} file. 2075 Returns interpolated values based on the input 2076 file using the underlying \code{interpolation\_function}. 2077 2078 \code{quantities} is either the name of a single quantity to be 2079 interpolated or a list of such quantity names. In the second case, the resulting 2080 function will return a tuple of values -- one for each quantity. 2081 2082 \code{interpolation\_points} is a list of absolute coordinates or a 2083 geospatial object 2084 for points at which values are sought. 2085 2086 \code{boundary_polygon} is a list of coordinates specifying the vertices of the boundary. 2087 This must be the same polygon as used when calling \code{create_mesh_from_regions}. 2088 This argument can only be used when reading boundary data from the STS format. 2089 2090 The model time stored within the file function can be accessed using 2091 the method \code{f.get\_time()} 2092 2093 The underlying algorithm used is as follows:\\ 2094 Given a time series (i.e.\ a series of values associated with 2095 different times), whose values are either just numbers, a set of 2096 numbers defined at the vertices of a triangular mesh (such as those 2097 stored in SWW files) or a set of 2098 numbers defined at a number of points on the boundary (such as those 2099 stored in STS files), \code{Interpolation\_function} is used to 2100 create a callable object that interpolates a value for an arbitrary 2101 time \code{t} within the model limits and possibly a point \code{(x, 2102 y)} within a mesh region. 2103 2104 The actual time series at which data is available is specified by 2105 means of an array \code{time} of monotonically increasing times. The 2106 quantities containing the values to be interpolated are specified in 2107 an array -- or dictionary of arrays (used in conjunction with the 2108 optional argument \code{quantity\_names}) -- called 2109 \code{quantities}. The optional arguments \code{vertex\_coordinates} 2110 and \code{triangles} represent the spatial mesh associated with the 2111 quantity arrays. If omitted the function must be created using an STS file 2112 or a TMS file. 2113 2114 Since, in practice, values need to be computed at specified points, 2115 the syntax allows the user to specify, once and for all, a list 2116 \code{interpolation\_points} of points at which values are required. 2117 In this case, the function may be called using the form \code{f(t, 2118 id)}, where \code{id} is an index for the list 2119 \code{interpolation\_points}. 2213 2120 \end{funcdesc} 2214 2121 … … 2236 2143 %% means of an array \code{time} of monotonically increasing times. The 2237 2144 %% quantities containing the values to be interpolated are specified in 2238 %% an array ---or dictionary of arrays (used in conjunction with the2239 %% optional argument \code{quantity\_names}) -- -called2145 %% an array -- or dictionary of arrays (used in conjunction with the 2146 %% optional argument \code{quantity\_names}) -- called 2240 2147 %% \code{quantities}. The optional arguments \code{vertex\_coordinates} 2241 2148 %% and \code{triangles} represent the spatial mesh associated with the … … 2260 2167 2261 2168 2262 2263 %%%%%%2264 2169 \section{Boundary Conditions}\index{boundary conditions} 2265 2170 \label{sec:boundary conditions} … … 2268 2173 represented by objects such as \code{Reflective\_boundary(domain)} and 2269 2174 \code{Dirichlet\_boundary([0.2, 0.0, 0.0])}, described in the examples 2270 in Chapter 2. Alternatively, you may prefer to ``roll your own'',2175 in Chapter 2. Alternatively, you may prefer to ''roll your own'', 2271 2176 following the method explained in Section \ref{sec:roll your own}. 2272 2177 … … 2275 2180 2276 2181 \begin{methoddesc}{set\_boundary}{boundary_map} 2277 Module: \module{abstract\_2d\_finite\_volumes.domain} 2278 2279 This function allows you to assign a boundary object (corresponding to a 2280 pre-defined or user-specified boundary condition) to every boundary segment that 2281 has been assigned a particular tag. 2282 2283 This is done by specifying a dictionary \code{boundary\_map}, whose values are the boundary objects 2284 and whose keys are the symbolic tags. 2285 2182 Module: \module{abstract\_2d\_finite\_volumes.domain} 2183 2184 This function allows you to assign a boundary object (corresponding to a 2185 pre-defined or user-specified boundary condition) to every boundary segment that 2186 has been assigned a particular tag. 2187 2188 This is done by specifying a dictionary \code{boundary\_map}, whose values are the boundary objects 2189 and whose keys are the symbolic tags. 2286 2190 \end{methoddesc} 2287 2191 2288 2192 \begin{methoddesc} {get\_boundary\_tags}{} 2289 Module: \module{abstract\_2d\_finite\_volumes.domain} 2290 2291 Returns a list of the available boundary tags. 2292 \end{methoddesc} 2293 2294 %%% 2193 Module: \module{abstract\_2d\_finite\_volumes.domain} 2194 2195 Returns a list of the available boundary tags. 2196 \end{methoddesc} 2197 2295 2198 \subsection{Predefined boundary conditions} 2296 2199 2297 2200 \begin{classdesc}{Reflective\_boundary}{Boundary} 2298 Module: \module{shallow\_water}2299 2300 Reflective boundary returns same conserved quantities as those present in2301 the neighbouring volume but reflected.2302 2303 This class is specific to the shallow water equation as it works with the2304 momentum quantities assumed to be the second and third conserved quantities.2201 Module: \module{shallow\_water} 2202 2203 Reflective boundary returns same conserved quantities as those present in 2204 the neighbouring volume but reflected. 2205 2206 This class is specific to the shallow water equation as it works with the 2207 momentum quantities assumed to be the second and third conserved quantities. 2305 2208 \end{classdesc} 2306 2209 2307 %%% 2308 \begin{classdesc}{Transmissive\_boundary}{domain = None} 2309 \label{pg: transmissive boundary} 2310 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions} 2311 2312 A transmissive boundary returns the same conserved quantities as 2313 those present in the neighbouring volume. 2314 2315 The underlying domain must be specified when the boundary is instantiated. 2210 \begin{classdesc}{Transmissive\_boundary}{domain=None} 2211 \label{pg: transmissive boundary} 2212 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions} 2213 2214 A transmissive boundary returns the same conserved quantities as 2215 those present in the neighbouring volume. 2216 2217 The underlying domain must be specified when the boundary is instantiated. 2316 2218 \end{classdesc} 2317 2219 2318 %%%2319 2220 \begin{classdesc}{Dirichlet\_boundary}{conserved_quantities=None} 2320 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}2321 2322 A Dirichlet boundary returns constant values for each of conserved2323 quantities. In the example of \code{Dirichlet\_boundary([0.2, 0.0, 0.0])},2324 the \code{stage} value at the boundary is 0.2 and the \code{xmomentum} and2325 \code{ymomentum} at the boundary are set to 0.0. The list must contain2326 a value for each conserved quantity.2221 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions} 2222 2223 A Dirichlet boundary returns constant values for each of conserved 2224 quantities. In the example of \code{Dirichlet\_boundary([0.2, 0.0, 0.0])}, 2225 the \code{stage} value at the boundary is 0.2 and the \code{xmomentum} and 2226 \code{ymomentum} at the boundary are set to 0.0. The list must contain 2227 a value for each conserved quantity. 2327 2228 \end{classdesc} 2328 2229 2329 %%%2330 2230 \begin{classdesc}{Time\_boundary}{domain = None, f = None} 2331 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}2332 2333 A time-dependent boundary returns values for the conserved2334 quantities as a function \code{f(t)} of time. The user must specify2335 the domain to get access to the model time.2336 2337 Optional argument \code{default\_boundary} can be used to specify another boundary object to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}. 2338 The \code{default\_boundary} could be a simple Dirichlet condition or 2339 even another \code{Time\_boundary} 2340 typically using data pertaining to another time interval.2231 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions} 2232 2233 A time-dependent boundary returns values for the conserved 2234 quantities as a function \code{f(t)} of time. The user must specify 2235 the domain to get access to the model time. 2236 2237 Optional argument \code{default\_boundary} can be used to specify another boundary object 2238 to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}. 2239 The \code{default\_boundary} could be a simple Dirichlet condition or 2240 even another \code{Time\_boundary} typically using data pertaining to another time interval. 2341 2241 \end{classdesc} 2342 2242 2343 %%%2344 2243 \begin{classdesc}{File\_boundary}{Boundary} 2345 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions}2346 2347 This method may be used if the user wishes to apply a SWW file, STS file or2348 a time series file (TMS) to a boundary segment or segments.2349 The boundary values are obtained from a file and interpolated to the2350 appropriate segments for each conserved quantity.2351 2352 Optional argument \code{default\_boundary} can be used to specify another boundary object to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}. 2353 The \code{default\_boundary} could be a simple Dirichlet condition or 2354 even another \code{File\_boundary} 2355 typically using data pertaining to another time interval.2244 Module: \module{abstract\_2d\_finite\_volumes.generic\_boundary\_conditions} 2245 2246 This method may be used if the user wishes to apply a SWW file, STS file or 2247 a time series file (TMS) to a boundary segment or segments. 2248 The boundary values are obtained from a file and interpolated to the 2249 appropriate segments for each conserved quantity. 2250 2251 Optional argument \code{default\_boundary} can be used to specify another boundary object 2252 to be used in case model time exceeds the time availabel in the file used by \code{File\_boundary}. 2253 The \code{default\_boundary} could be a simple Dirichlet condition or 2254 even another \code{File\_boundary} typically using data pertaining to another time interval. 2356 2255 \end{classdesc} 2357 2256 2358 2257 \begin{classdesc}{Field\_boundary}{Boundary} 2359 Module: \module{shallow\_water.shallow\_water\_domain} 2360 2361 This method works in the same way as \code{File\_boundary} except that it 2362 allows for the value of stage to be offset by a constant specified in the 2363 keyword argument \code{mean\_stage}. 2364 2365 This functionality allows for models to be run for a range of tides using 2366 the same boundary information (from .sts, .sww or .tms files). The tidal value 2367 for each run would then be specified in the keyword argument 2368 \code{mean\_stage}. 2369 If \code{mean\_stage} = 0.0, \code{Field\_boundary} and \code{File\_boundary} 2370 behave identically. 2371 2372 2373 Note that if the optional argument \code{default\_boundary} is specified 2374 it's stage value will be adjusted by \code{mean\_stage} just like the values 2375 obtained from the file. 2376 2377 See \code{File\_boundary} for further details. 2258 Module: \module{shallow\_water.shallow\_water\_domain} 2259 2260 This method works in the same way as \code{File\_boundary} except that it 2261 allows for the value of stage to be offset by a constant specified in the 2262 keyword argument \code{mean\_stage}. 2263 2264 This functionality allows for models to be run for a range of tides using 2265 the same boundary information (from .sts, .sww or .tms files). The tidal value 2266 for each run would then be specified in the keyword argument 2267 \code{mean\_stage}. 2268 If \code{mean\_stage} = 0.0, \code{Field\_boundary} and \code{File\_boundary} 2269 behave identically. 2270 2271 Note that if the optional argument \code{default\_boundary} is specified 2272 it's stage value will be adjusted by \code{mean\_stage} just like the values 2273 obtained from the file. 2274 2275 See \code{File\_boundary} for further details. 2378 2276 \end{classdesc} 2379 2277 2380 %%%2381 %\begin{classdesc}{Transmissive\_Momentum\_Set\_Stage\_boundary}{Boundary}2382 2278 \begin{classdesc}{Transmissive\_momentum\_set\_stage\_boundary}{Boundary} 2383 Module: \module{shallow\_water} 2384 \label{pg: transmissive momentum set stage boundary} 2385 2386 This boundary returns same momentum conserved quantities as 2387 those present in its neighbour volume but sets stage as in a Time\_boundary. 2388 The underlying domain must be specified when boundary is instantiated 2389 2390 This type of boundary is useful when stage is known at the boundary as a 2391 function of time, but momenta (or speeds) aren't. 2392 2393 This class is specific to the shallow water equation as it works with the 2394 momentum quantities assumed to be the second and third conserved quantities. 2395 2396 In some circumstances, this boundary condition may cause numerical instabilities for similar reasons as what has been observed with the simple fully transmissive boundary condition (see Page \pageref{pg: transmissive boundary}). 2397 This could for example be the case if a planar wave is reflected out through this boundary. 2279 Module: \module{shallow\_water} 2280 \label{pg: transmissive momentum set stage boundary} 2281 2282 This boundary returns same momentum conserved quantities as 2283 those present in its neighbour volume but sets stage as in a Time\_boundary. 2284 The underlying domain must be specified when boundary is instantiated 2285 2286 This type of boundary is useful when stage is known at the boundary as a 2287 function of time, but momenta (or speeds) aren't. 2288 2289 This class is specific to the shallow water equation as it works with the 2290 momentum quantities assumed to be the second and third conserved quantities. 2291 2292 In some circumstances, this boundary condition may cause numerical instabilities for similar 2293 reasons as what has been observed with the simple fully transmissive boundary condition 2294 (see Page \pageref{pg: transmissive boundary}). 2295 This could for example be the case if a planar wave is reflected out through this boundary. 2398 2296 \end{classdesc} 2399 2297 2400 2401 2298 \begin{classdesc}{Transmissive\_stage\_zero\_momentum\_boundary}{Boundary} 2402 Module: \module{shallow\_water} 2403 \label{pg: transmissive stage zero momentum boundary} 2404 2405 This boundary returns same stage conserved quantities as 2406 those present in its neighbour volume but sets momentum to zero. 2407 The underlying domain must be specified when boundary is instantiated 2408 2409 This type of boundary is useful when stage is known at the boundary as a 2410 function of time, but momentum should be set to zero. This is for example the case where a boundary is needed in the ocean on the two sides perpendicular to the coast to maintain the wave height of the incoming wave. 2411 2412 This class is specific to the shallow water equation as it works with the 2413 momentum quantities assumed to be the second and third conserved quantities. 2414 2415 This boundary condition should not cause the numerical instabilities seen with the transmissive momentum 2416 boundary conditions (see Page \pageref{pg: transmissive boundary} and Page \pageref{pg: transmissive momentum set stage boundary}). 2417 2299 Module: \module{shallow\_water} 2300 \label{pg: transmissive stage zero momentum boundary} 2301 2302 This boundary returns same stage conserved quantities as 2303 those present in its neighbour volume but sets momentum to zero. 2304 The underlying domain must be specified when boundary is instantiated 2305 2306 This type of boundary is useful when stage is known at the boundary as a 2307 function of time, but momentum should be set to zero. This is for example 2308 the case where a boundary is needed in the ocean on the two sides perpendicular 2309 to the coast to maintain the wave height of the incoming wave. 2310 2311 This class is specific to the shallow water equation as it works with the 2312 momentum quantities assumed to be the second and third conserved quantities. 2313 2314 This boundary condition should not cause the numerical instabilities seen with the transmissive momentum 2315 boundary conditions (see Page \pageref{pg: transmissive boundary} and 2316 Page \pageref{pg: transmissive momentum set stage boundary}). 2418 2317 \end{classdesc} 2419 2318 2420 2421 2319 \begin{classdesc}{Dirichlet\_discharge\_boundary}{Boundary} 2422 Module: \module{shallow\_water}2423 2424 Sets stage (stage0)2425 Sets momentum (wh0) in the inward normal direction.2320 Module: \module{shallow\_water} 2321 2322 Sets stage (stage0) 2323 Sets momentum (wh0) in the inward normal direction. 2426 2324 \end{classdesc} 2427 2428 2429 2325 2430 2326 \subsection{User-defined boundary conditions} … … 2445 2341 2446 2342 2447 2448 2343 \section{Forcing Terms}\index{Forcing terms} 2449 2344 \label{sec:forcing terms} 2450 2345 2451 2346 \anuga provides a number of predefined forcing functions to be used with simulations. 2452 Gravity and friction are always calculated using the elevation and friction quantities, but the user may additionally add forcing terms to the list 2347 Gravity and friction are always calculated using the elevation and friction quantities, 2348 but the user may additionally add forcing terms to the list 2453 2349 \code{domain.forcing\_terms} and have them affect the model. 2454 2350 2455 Currently, predefined forcing terms are 2456 2351 Currently, predefined forcing terms are: 2457 2352 \begin{funcdesc}{General\_forcing}{} 2458 2353 Module: \module{shallow\_water.shallow\_water\_domain} … … 2470 2365 The parametr \code{rate} can be \code{None} at initialisation but must be specified 2471 2366 before forcing term is applied (i.e. simulation has started). 2472 The default value is 0.0- i.e.\ no forcing.2367 The default value is 0.0 -- i.e.\ no forcing. 2473 2368 \item \code{center, radius}: Optionally restrict forcing to a circle with given center and radius. 2474 \item \code{polygon}: Optionally restrict forcing to an area enclosed by given polygon. 2369 \item \code{polygon}: Optionally restrict forcing to an area enclosed by given polygon. 2475 2370 \end{itemize} 2476 2371 Note specifying both center, radius and polygon will cause an exception to be thrown. … … 2479 2374 \bigskip 2480 2375 Example: 2481 {\scriptsize \begin{verbatim} 2482 P = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]] # Square polygon 2483 2484 xmom = General_forcing(domain, 'xmomentum', polygon=P) 2485 ymom = General_forcing(domain, 'ymomentum', polygon=P) 2486 2487 xmom.rate = f 2488 ymom.rate = g 2489 2490 domain.forcing_terms.append(xmom) 2491 domain.forcing_terms.append(ymom) 2492 \end{verbatim}} 2493 Here, \code{f}, \code{g} are assumed to be defined as functions of time providing a time dependent rate of change for xmomentum and ymomentum respectively. 2376 2377 \begin{verbatim} 2378 P = [[x0, y0], [x1, y0], [x1, y1], [x0, y1]] # Square polygon 2379 2380 xmom = General_forcing(domain, 'xmomentum', polygon=P) 2381 ymom = General_forcing(domain, 'ymomentum', polygon=P) 2382 2383 xmom.rate = f 2384 ymom.rate = g 2385 2386 domain.forcing_terms.append(xmom) 2387 domain.forcing_terms.append(ymom) 2388 \end{verbatim} 2389 2390 Here, \code{f}, \code{g} are assumed to be defined as functions of time providing 2391 a time dependent rate of change for xmomentum and ymomentum respectively. 2494 2392 P is assumed to be polygon, specified as a list of points. 2495 2496 2393 \end{funcdesc} 2497 2498 2394 2499 2395 \begin{funcdesc}{Inflow}{} … … 2511 2407 function of time. Positive values indicate inflow, 2512 2408 negative values indicate outflow. 2513 2409 2514 2410 Note: The specified flow will be divided by the area of 2515 2411 the inflow region and then applied to update the 2516 2412 stage quantity. 2517 2413 \item \code{center, radius}: Optionally restrict forcing to a circle with given center and radius. 2518 \item \code{polygon}: Optionally restrict forcing to an area enclosed by given polygon. 2414 \item \code{polygon}: Optionally restrict forcing to an area enclosed by given polygon. 2519 2415 \end{itemize} 2520 2416 2521 2417 \bigskip 2522 2418 Example: 2523 {\scriptsize \begin{verbatim} 2524 hydrograph = Inflow(center=(320, 300), radius=10, 2525 rate=file_function('QPMF_Rot_Sub13.tms')) 2526 2527 domain.forcing_terms.append(hydrograph) 2528 \end{verbatim}} 2419 2420 \begin{verbatim} 2421 hydrograph = Inflow(center=(320, 300), radius=10, rate=file_function('QPMF_Rot_Sub13.tms')) 2422 2423 domain.forcing_terms.append(hydrograph) 2424 \end{verbatim} 2425 2529 2426 Here, \code{'QPMF_Rot_Sub13.tms'} is assumed to be a NetCDF file in the format \code{tms} defining a timeseries for a hydrograph. 2530 2427 \end{funcdesc} 2531 2532 2428 2533 2429 \begin{funcdesc}{Rainfall}{} … … 2543 2439 \item \code{domain}: a reference to the domain being evolved 2544 2440 \item \code{rate}: Total rain rate over the specified domain. 2545 2546 2441 Note: Raingauge Data needs to reflect the time step. 2442 For example: if rain gauge is mm read every \code{dt} seconds, then the input 2547 2443 here is as \code{mm/dt} so 10 mm in 5 minutes becomes 2548 2444 10/(5x60) = 0.0333mm/s. 2549 2445 2550 2446 This parameter can be either a constant or a 2551 2447 function of time. Positive values indicate rain being added (or be used for general infiltration), 2552 2448 negative values indicate outflow at the specified rate (presumably this could model evaporation or abstraction). 2553 2449 \item \code{center, radius}: Optionally restrict forcing to a circle with given center and radius. 2554 \item \code{polygon}: Optionally restrict forcing to an area enclosed by given polygon. 2450 \item \code{polygon}: Optionally restrict forcing to an area enclosed by given polygon. 2555 2451 \end{itemize} 2556 2452 2557 2453 \bigskip 2558 2454 Example: 2559 {\scriptsize \begin{verbatim} 2560 2561 2562 2563 2564 \end{verbatim}} 2455 2456 \begin{verbatim} 2457 catchmentrainfall = Rainfall(rate=file_function('Q100_2hr_Rain.tms')) 2458 domain.forcing_terms.append(catchmentrainfall) 2459 \end{verbatim} 2460 2565 2461 Here, \code{'Q100_2hr_Rain.tms'} is assumed to be a NetCDF file in the format \code{tms} defining a timeseries for the rainfall. 2566 2462 \end{funcdesc} 2567 2463 2568 2569 2570 2464 \begin{funcdesc}{Culvert\_flow}{} 2571 2465 Module: \module{culver\_flows.culvert\_class} … … 2574 2468 This class modifies the quantities \code{stage, xmomentum, ymomentum} in areas at both ends of the culvert. 2575 2469 2576 The Culvert\_flow forcing term uses \code{Inflow} and {General\_forcing} to update the quantities. The flow drection is determined on-the-fly so 2577 openings are referenced simple as opening0 and opening1 with either being able to take the role as Inflow and Outflow. 2470 The Culvert\_flow forcing term uses \code{Inflow} and {General\_forcing} to update the quantities. 2471 The flow drection is determined on-the-fly so openings are referenced simple as opening0 and opening1 2472 with either being able to take the role as Inflow and Outflow. 2578 2473 2579 2474 The Culvert\_flow class takes as input: … … 2594 2489 \end{itemize} 2595 2490 2596 The user can specify different culvert routines. Hower ANUGA currently provides only one, namely the \code{boyd\_generalised\_culvert\_model} as used in the example below.2597 2598 \bigskip 2491 The user can specify different culvert routines. Hower ANUGA currently provides only one, namely the 2492 \code{boyd\_generalised\_culvert\_model} as used in the example below. 2493 2599 2494 Example: 2600 {\scriptsize \begin{verbatim} 2601 from anuga.culvert_flows.culvert_class import Culvert_flow 2602 from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model 2603 2604 culvert1 = Culvert_flow(domain, 2605 label='Culvert No. 1', 2606 description='This culvert is a test unit 1.2m Wide by 0.75m High', 2607 end_point0=[9.0, 2.5], 2608 end_point1=[13.0, 2.5], 2609 width=1.20,height=0.75, 2610 culvert_routine=boyd_generalised_culvert_model, 2611 number_of_barrels=1, 2612 verbose=True) 2613 2614 culvert2 = Culvert_flow(domain, 2615 label='Culvert No. 2', 2616 description='This culvert is a circular test with d=1.2m', 2617 end_point0=[9.0, 1.5], 2618 end_point1=[30.0, 3.5], 2619 diameter=1.20, 2620 invert_level0=7, 2621 culvert_routine=boyd_generalised_culvert_model, 2622 number_of_barrels=1, 2623 verbose=True) 2624 2625 domain.forcing_terms.append(culvert1) 2626 domain.forcing_terms.append(culvert2) 2627 2628 2629 \end{verbatim}} 2495 2496 \begin{verbatim} 2497 from anuga.culvert_flows.culvert_class import Culvert_flow 2498 from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model 2499 2500 culvert1 = Culvert_flow(domain, 2501 label='Culvert No. 1', 2502 description='This culvert is a test unit 1.2m Wide by 0.75m High', 2503 end_point0=[9.0, 2.5], 2504 end_point1=[13.0, 2.5], 2505 width=1.20,height=0.75, 2506 culvert_routine=boyd_generalised_culvert_model, 2507 number_of_barrels=1, 2508 verbose=True) 2509 2510 culvert2 = Culvert_flow(domain, 2511 label='Culvert No. 2', 2512 description='This culvert is a circular test with d=1.2m', 2513 end_point0=[9.0, 1.5], 2514 end_point1=[30.0, 3.5], 2515 diameter=1.20, 2516 invert_level0=7, 2517 culvert_routine=boyd_generalised_culvert_model, 2518 number_of_barrels=1, 2519 verbose=True) 2520 2521 domain.forcing_terms.append(culvert1) 2522 domain.forcing_terms.append(culvert2) 2523 \end{verbatim} 2630 2524 \end{funcdesc} 2631 2632 2633 2634 2635 2525 2636 2526 … … 2638 2528 \label{sec:evolution} 2639 2529 2640 \begin{methoddesc}{evolve}{yieldstep = None, finaltime = None, duration = None, skip_initial_step = False} 2641 2530 \begin{methoddesc}{evolve}{yieldstep=None, finaltime=None, duration=None, skip_initial_step=False} 2642 2531 Module: \module{abstract\_2d\_finite\_volumes.domain} 2643 2532 … … 2662 2551 You can include \method{evolve} in a statement of the type: 2663 2552 2664 {\small \begin{verbatim} 2665 for t in domain.evolve(yieldstep, finaltime): 2666 <Do something with domain and t> 2667 \end{verbatim}} 2668 2669 \end{methoddesc} 2670 2671 2553 \begin{verbatim} 2554 for t in domain.evolve(yieldstep, finaltime): 2555 <Do something with domain and t> 2556 \end{verbatim} 2557 \end{methoddesc} 2672 2558 2673 2559 \subsection{Diagnostics} 2674 2560 \label{sec:diagnostics} 2675 2561 2676 2677 \begin{funcdesc}{statistics}{} 2562 \begin{funcdesc}{statistics}{} 2678 2563 Module: \module{abstract\_2d\_finite\_volumes.domain} 2679 2564 2680 2681 2682 2565 \end{funcdesc} 2566 2567 \begin{funcdesc}{timestepping\_statistics}{} 2683 2568 Module: \module{abstract\_2d\_finite\_volumes.domain} 2684 2569 2685 Returns a string of the following type for each 2686 timestep: 2687 2570 Returns a string of the following type for each timestep: 2688 2571 \code{Time = 0.9000, delta t in [0.00598964, 0.01177388], steps=12 2689 2572 (12)} … … 2697 2580 this diagnostics may help pinpoint problem areas where excessive speeds 2698 2581 are generated. 2699 2700 \end{funcdesc} 2701 2702 2703 \begin{funcdesc}{boundary\_statistics}{quantities = None, tags = None} 2582 \end{funcdesc} 2583 2584 \begin{funcdesc}{boundary\_statistics}{quantities=None, tags=None} 2704 2585 Module: \module{abstract\_2d\_finite\_volumes.domain} 2705 2586 2706 Returns a string of the following type when \code{quantities = 'stage'} and \code{tags = ['top', 'bottom']}: 2707 2708 {\small \begin{verbatim} 2709 Boundary values at time 0.5000: 2587 Returns a string of the following type when \code{quantities = 'stage'} 2588 and \code{tags = ['top', 'bottom']}: 2589 2590 \begin{verbatim} 2591 Boundary values at time 0.5000: 2710 2592 top: 2711 2593 stage in [ -0.25821218, -0.02499998] 2712 2594 bottom: 2713 2595 stage in [ -0.27098821, -0.02499974] 2714 \end{verbatim}} 2715 2716 \end{funcdesc} 2717 2718 2719 \begin{funcdesc}{get\_quantity}{name, location='vertices', indices = None} 2596 \end{verbatim} 2597 \end{funcdesc} 2598 2599 \begin{funcdesc}{get\_quantity}{name, location='vertices', indices=None} 2720 2600 Module: \module{abstract\_2d\_finite\_volumes.domain} 2721 2601 2722 2602 This function returns a Quantity object Q. 2723 Access to it's values should be done through Q.get\__values documented on Page \pageref{pg:get values}. 2724 2725 \end{funcdesc} 2726 2727 2728 \begin{funcdesc}{set\_quantities\_to\_be\_monitored}{} 2603 Access to its values should be done through Q.get\__values documented on Page \pageref{pg:get values}. 2604 \end{funcdesc} 2605 2606 \begin{funcdesc}{set\_quantities\_to\_be\_monitored}{} 2729 2607 Module: \module{abstract\_2d\_finite\_volumes.domain} 2730 2608 … … 2737 2615 Optional parameters \code{polygon} and \code{time\_interval} may be specified to restrict the 2738 2616 extremum computation. 2739 2740 2741 2617 \end{funcdesc} 2618 2619 \begin{funcdesc}{quantity\_statistics}{} 2742 2620 Module: \module{abstract\_2d\_finite\_volumes.domain} 2743 2621 … … 2748 2626 2749 2627 \begin{verbatim} 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2628 Monitored quantities at time 1.0000: 2629 stage-elevation: 2630 values since time = 0.00 in [0.00000000, 0.30000000] 2631 minimum attained at time = 0.00000000, location = (0.16666667, 0.33333333) 2632 maximum attained at time = 0.00000000, location = (0.83333333, 0.16666667) 2633 ymomentum: 2634 values since time = 0.00 in [0.00000000, 0.06241221] 2635 minimum attained at time = 0.00000000, location = (0.33333333, 0.16666667) 2636 maximum attained at time = 0.22472667, location = (0.83333333, 0.66666667) 2637 xmomentum: 2638 values since time = 0.00 in [-0.06062178, 0.47886313] 2639 minimum attained at time = 0.00000000, location = (0.16666667, 0.33333333) 2640 maximum attained at time = 0.35103646, location = (0.83333333, 0.16666667) 2763 2641 \end{verbatim} 2764 2642 … … 2771 2649 at every internal timestep. 2772 2650 2773 These values are also stored in the sww file for post processing. 2774 2775 \end{funcdesc} 2776 2777 2778 2779 \begin{funcdesc}{get\_values}{location='vertices', indices = None} 2651 These values are also stored in the SWW file for post processing. 2652 \end{funcdesc} 2653 2654 \begin{funcdesc}{get\_values}{location='vertices', indices=None} 2780 2655 \label{pg:get values} 2781 2656 Module: \module{abstract\_2d\_finite\_volumes.quantity} 2782 2657 2783 Extract values for quantity as a Numeric array.2784 2785 {\small\begin{verbatim}2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 \end{verbatim} }2658 Extract values for quantity as a numeric array. 2659 2660 \begin{verbatim} 2661 Inputs: 2662 interpolation_points: List of x, y coordinates where value is 2663 sought (using interpolation). If points 2664 are given, values of location and indices 2665 are ignored. Assume either absolute UTM 2666 coordinates or geospatial data object. 2667 2668 location: Where values are to be stored. 2669 Permissible options are: vertices, edges, centroids 2670 and unique vertices. Default is 'vertices' 2671 \end{verbatim} 2797 2672 2798 2673 The returned values will have the leading dimension equal to length of the indices list or 2799 2674 N (all values) if indices is None. 2800 2675 2801 2676 In case of location == 'centroids' the dimension of returned 2802 values will be a list or a Numericalarray of length N, N being2677 values will be a list or a numeric array of length N, N being 2803 2678 the number of elements. 2804 2679 … … 2814 2689 The values will be stored in elements following their 2815 2690 internal ordering. 2816 2817 \end{funcdesc} 2818 2819 2820 2821 \begin{funcdesc}{set\_values}{location='vertices', indices = None} 2691 \end{funcdesc} 2692 2693 \begin{funcdesc}{set\_values}{location='vertices', indices=None} 2822 2694 Module: \module{abstract\_2d\_finite\_volumes.quantity} 2823 2695 … … 2830 2702 The method \code{set\_values} is always called by \code{set\_quantity} 2831 2703 behind the scenes. 2832 2833 \end{funcdesc} 2834 2835 2836 2837 \begin{funcdesc}{get\_integral}{} 2704 \end{funcdesc} 2705 2706 \begin{funcdesc}{get\_integral}{} 2838 2707 Module: \module{abstract\_2d\_finite\_volumes.quantity} 2839 2708 2840 2709 Return computed integral over entire domain for this quantity 2841 2842 \end{funcdesc} 2843 2844 2845 2846 2847 \begin{funcdesc}{get\_maximum\_value}{indices = None} 2710 \end{funcdesc} 2711 2712 \begin{funcdesc}{get\_maximum\_value}{indices=None} 2848 2713 Module: \module{abstract\_2d\_finite\_volumes.quantity} 2849 2714 … … 2854 2719 2855 2720 We do not seek the maximum at vertices as each vertex can 2856 have multiple values - one for each triangle sharing it. 2857 \end{funcdesc} 2858 2859 2860 2861 \begin{funcdesc}{get\_maximum\_location}{indices = None} 2721 have multiple values -- one for each triangle sharing it. 2722 \end{funcdesc} 2723 2724 \begin{funcdesc}{get\_maximum\_location}{indices=None} 2862 2725 Module: \module{abstract\_2d\_finite\_volumes.quantity} 2863 2726 … … 2868 2731 2869 2732 We do not seek the maximum at vertices as each vertex can 2870 have multiple values - one for each triangle sharing it.2733 have multiple values -- one for each triangle sharing it. 2871 2734 2872 2735 If there are multiple cells with same maximum value, the 2873 2736 first cell encountered in the triangle array is returned. 2874 \end{funcdesc} 2875 2876 2877 2878 \begin{funcdesc}{get\_wet\_elements}{indices=None} 2737 \end{funcdesc} 2738 2739 \begin{funcdesc}{get\_wet\_elements}{indices=None} 2879 2740 Module: \module{shallow\_water.shallow\_water\_domain} 2880 2741 2881 2742 Return indices for elements where h $>$ minimum_allowed_height 2882 2743 Optional argument indices is the set of element ids that the operation applies to. 2883 \end{funcdesc} 2884 2885 2886 \begin{funcdesc}{get\_maximum\_inundation\_elevation}{indices=None} 2744 \end{funcdesc} 2745 2746 \begin{funcdesc}{get\_maximum\_inundation\_elevation}{indices=None} 2887 2747 Module: \module{shallow\_water.shallow\_water\_domain} 2888 2748 … … 2892 2752 Example to find maximum runup elevation:\\ 2893 2753 z = domain.get_maximum_inundation_elevation() 2894 \end{funcdesc} 2895 2896 2897 \begin{funcdesc}{get\_maximum\_inundation\_location}{indices=None} 2754 \end{funcdesc} 2755 2756 \begin{funcdesc}{get\_maximum\_inundation\_location}{indices=None} 2898 2757 Module: \module{shallow\_water.shallow\_water\_domain} 2899 2758 … … 2903 2762 Example to find maximum runup location:\\ 2904 2763 x, y = domain.get_maximum_inundation_location() 2905 2764 \end{funcdesc} 2906 2765 2907 2766 … … 2909 2768 After a model has been run, it is often useful to extract various information from the sww 2910 2769 output file (see Section \ref{sec:sww format}). This is typically more convenient than using the 2911 diagnostics described in Section \ref{sec:diagnostics} which rely on the model running - something2770 diagnostics described in Section \ref{sec:diagnostics} which rely on the model running -- something 2912 2771 that can be very time consuming. The sww files are easy and quick to read and offer much information 2913 2772 about the model results such as runup heights, time histories of selected quantities, … … 2920 2779 Return highest elevation where depth is positive ($h > 0$) 2921 2780 2922 Example to find maximum runup elevation:\\ 2923 max_runup = get_maximum_inundation_elevation(filename, 2924 polygon=None, 2925 time_interval=None, 2926 verbose=False) 2927 2781 Example to find maximum runup elevation: 2782 2783 \begin{verbatim} 2784 max_runup = get_maximum_inundation_elevation(filename, 2785 polygon=None, 2786 time_interval=None, 2787 verbose=False) 2788 \end{verbatim} 2928 2789 2929 2790 filename is a NetCDF sww file containing ANUGA model output. … … 2937 2798 \end{funcdesc} 2938 2799 2939 2940 2800 \begin{funcdesc}{get\_maximum\_inundation\_location}{filename, polygon=None, 2941 2801 time_interval=None, verbose=False} … … 2944 2804 Return location (x,y) of highest elevation where depth is positive ($h > 0$) 2945 2805 2946 Example to find maximum runup location:\\ 2947 max_runup_location = get_maximum_inundation_location(filename, 2948 polygon=None, 2949 time_interval=None, 2950 verbose=False) 2951 2952 2953 filename is a NetCDF sww file containing ANUGA model output. 2954 Optional arguments polygon and time_interval restricts the maximum runup calculation 2806 Example to find maximum runup location: 2807 2808 \begin{verbatim} 2809 max_runup_location = get_maximum_inundation_location(filename, 2810 polygon=None, 2811 time_interval=None, 2812 verbose=False) 2813 \end{verbatim} 2814 2815 \code{filename} is a NetCDF sww file containing ANUGA model output. 2816 Optional arguments \code{polygon} and \code{time_interval} restricts the maximum runup calculation 2955 2817 to a points that lie within the specified polygon and time interval. 2956 2818 … … 2958 2820 is None signifying "No Runup" or "Everything is dry". 2959 2821 2960 See doc string for general function get_maximum_inundation_datafor details.2822 See the 'doc' string for general function \code{get_maximum_inundation_data} for details. 2961 2823 \end{funcdesc} 2962 2824 2963 2964 \begin{funcdesc}{sww2timeseries}{swwfiles, gauge_filename, production_dirs, report = None, reportname = None, 2965 plot_quantity = None, generate_fig = False, surface = None, time_min = None, time_max = None, time_thinning = 1, 2966 time_unit = None, title_on = None, use_cache = False, verbose = False} 2967 2825 \begin{funcdesc}{sww2timeseries}{swwfiles, gauge_filename, production_dirs, report=None, reportname=None, 2826 plot_quantity=None, generate_fig=False, surface=None, time_min=None, time_max=None, time_thinning=1, 2827 time_unit=None, title_on=None, use_cache=False, verbose=False} 2968 2828 Module: \module{anuga.abstract\_2d\_finite\_volumes.util} 2969 2829 2970 2830 Return csv files for the location in the \code{gauge_filename} and can also return plots of them 2971 2831 2972 See doc string for general function sww2timeseries for details. 2973 2832 See the 'doc' string for general function \code{sww2timeseries} for details. 2974 2833 \end{funcdesc} 2975 2976 2834 2977 2835 \begin{funcdesc}{get\_flow\_through\_cross\_section}{filename, cross\_section, verbose=False} … … 2983 2841 \begin{itemize} 2984 2842 \item filename: Name of sww file containing ANUGA model output. 2985 \item polyline: Representation of desired cross section - it may contain multiple2986 sections allowing for complex shapes. Assume absolute UTM coordinates.2843 \item polyline: Representation of desired cross section -- it may contain multiple 2844 sections allowing for complex shapes. Assume absolute UTM coordinates. 2987 2845 \end{itemize} 2988 2846 … … 3000 2858 3001 2859 \begin{verbatim} 3002 3003 3004 3005 2860 cross_section = [[x, 0], [x, width]] 2861 time, Q = get_flow_through_cross_section(filename, 2862 cross_section, 2863 verbose=False) 3006 2864 \end{verbatim} 3007 2865 3008 3009 See doc string for general function get\_maximum\_inundation\_data for details. 3010 2866 See the 'doc' string for general function \code{get_maximum_inundation_data} for details. 3011 2867 \end{funcdesc} 3012 2868 3013 2869 3014 3015 2870 \section{Other} 3016 3017 \begin{funcdesc}{domain.create\_quantity\_from\_expression}{string} 3018 3019 Handy for creating derived quantities on-the-fly as for example 2871 \begin{funcdesc}{domain.create\_quantity\_from\_expression}{string} 2872 Handy for creating derived quantities on-the-fly as for example: 2873 3020 2874 \begin{verbatim} 3021 3022 3023 exp = '(xmomentum*xmomentum + ymomentum*ymomentum)**0.5') 3024 2875 Depth = domain.create_quantity_from_expression('stage-elevation') 2876 2877 exp = '(xmomentum*xmomentum + ymomentum*ymomentum)**0.5' 2878 Absolute_momentum = domain.create_quantity_from_expression(exp) 3025 2879 \end{verbatim} 3026 2880 3027 2881 %See also \file{Analytical\_solution\_circular\_hydraulic\_jump.py} for an example of use. 3028 \end{funcdesc} 3029 3030 3031 3032 2882 \end{funcdesc} 3033 2883 3034 2884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3036 2885 3037 2886 \chapter{\anuga System Architecture} 3038 3039 2887 3040 2888 \section{File Formats} … … 3046 2894 3047 2895 \bigskip 3048 3049 2896 \begin{center} 3050 3051 2897 \begin{tabular}{|ll|} \hline 3052 3053 \textbf{Extension} & \textbf{Description} \\ 3054 \hline\hline 3055 3056 \code{.sww} & NetCDF format for storing model output with mesh information 3057 \code{f(t,x,y)}\\ 3058 3059 \code{.sts} & NetCDF format for storing model ouput \code{f(t,x,y)} without any mesh information\\ 3060 3061 \code{.tms} & NetCDF format for storing time series \code{f(t)}\\ 3062 3063 \code{.csv/.txt} & ASCII format called points csv for storing 3064 arbitrary points and associated attributes\\ 3065 3066 \code{.pts} & NetCDF format for storing arbitrary points and 3067 associated attributes\\ 3068 3069 \code{.asc} & ASCII format of regular DEMs as output from ArcView\\ 3070 3071 \code{.prj} & Associated ArcView file giving more metadata for 3072 \code{.asc} format\\ 3073 3074 \code{.ers} & ERMapper header format of regular DEMs for ArcView\\ 3075 3076 \code{.dem} & NetCDF representation of regular DEM data\\ 3077 3078 \code{.tsh} & ASCII format for storing meshes and associated 3079 boundary and region info\\ 3080 3081 \code{.msh} & NetCDF format for storing meshes and associated 3082 boundary and region info\\ 3083 3084 \code{.nc} & Native ferret NetCDF format\\ 3085 3086 \code{.geo} & Houdinis ASCII geometry format (?) \\ \par \hline 3087 %\caption{File formats used by \anuga} 2898 \textbf{Extension} & \textbf{Description} \\ 2899 \hline\hline 2900 \code{.sww} & NetCDF format for storing model output with mesh information \code{f(t,x,y)}\\ 2901 \code{.sts} & NetCDF format for storing model ouput \code{f(t,x,y)} without any mesh information\\ 2902 \code{.tms} & NetCDF format for storing time series \code{f(t)}\\ 2903 \code{.csv/.txt} & ASCII format called points csv for storing arbitrary points and associated attributes\\ 2904 \code{.pts} & NetCDF format for storing arbitrary points and associated attributes\\ 2905 \code{.asc} & ASCII format of regular DEMs as output from ArcView\\ 2906 \code{.prj} & Associated ArcView file giving more metadata for \code{.asc} format\\ 2907 \code{.ers} & ERMapper header format of regular DEMs for ArcView\\ 2908 \code{.dem} & NetCDF representation of regular DEM data\\ 2909 \code{.tsh} & ASCII format for storing meshes and associated boundary and region info\\ 2910 \code{.msh} & NetCDF format for storing meshes and associated boundary and region info\\ 2911 \code{.nc} & Native ferret NetCDF format\\ 2912 \code{.geo} & Houdinis ASCII geometry format (?) \\ \par \hline 2913 %\caption{File formats used by \anuga} 3088 2914 \end{tabular} 3089 3090 3091 2915 \end{center} 3092 2916 3093 2917 The above table shows the file extensions used to identify the 3094 2918 formats of files. However, typically, in referring to a format we 3095 capitalise the extension and omit the initial full stop ---thus, we3096 refer, for example, to `SWW files' or `PRJ files'.2919 capitalise the extension and omit the initial full stop -- thus, we 2920 refer, for example, to 'SWW files' or 'PRJ files'. 3097 2921 3098 2922 \bigskip … … 3110 2934 3111 2935 \begin{tabular}{ll} 3112 ASC, PRJ $\rightarrow$ DEM $\rightarrow$ PTS & Convert 3113 DEMs to native \code{.pts} file\\ 3114 3115 NC $\rightarrow$ SWW & Convert MOST boundary files to 3116 boundary \code{.sww}\\ 3117 3118 PTS + TSH $\rightarrow$ TSH with elevation & Least squares fit\\ 3119 3120 TSH $\rightarrow$ SWW & Convert TSH to \code{.sww}-viewable using 3121 \code{animate}\\ 3122 3123 TSH + Boundary SWW $\rightarrow$ SWW & Simulation using 3124 \code{\anuga}\\ 3125 3126 Polygonal mesh outline $\rightarrow$ & TSH or MSH 2936 ASC, PRJ $\rightarrow$ DEM $\rightarrow$ PTS & Convert DEMs to native \code{.pts} file\\ 2937 NC $\rightarrow$ SWW & Convert MOST boundary files to boundary \code{.sww}\\ 2938 PTS + TSH $\rightarrow$ TSH with elevation & Least squares fit\\ 2939 TSH $\rightarrow$ SWW & Convert TSH to \code{.sww}-viewable using \code{animate}\\ 2940 TSH + Boundary SWW $\rightarrow$ SWW & Simulation using \code{\anuga}\\ 2941 Polygonal mesh outline $\rightarrow$ & TSH or MSH 3127 2942 \end{tabular} 3128 3129 3130 3131 2943 3132 2944 \bigskip … … 3134 2946 \subsection{SWW, STS and TMS Formats} 3135 2947 \label{sec:sww format} 3136 3137 The SWW, STS and TMS formats are all NetCDF formats, and are of key 3138 importance for \anuga. 2948 The SWW, STS and TMS formats are all NetCDF formats, and are of key importance for \anuga. 3139 2949 3140 2950 An SWW file is used for storing \anuga output and therefore pertains … … 3144 2954 3145 2955 \begin{itemize} 3146 \item \code{x} and \code{y}: coordinates of the points, represented as Numeric arrays 3147 \item \code{elevation}, a Numeric array storing bed-elevations 3148 \item \code{volumes}, a list specifying the points at the vertices of each of the 3149 triangles 2956 \item \code{x} and \code{y}: coordinates of the points, represented as numeric arrays 2957 \item \code{elevation}, a numeric array storing bed-elevations 2958 \item \code{volumes}, a list specifying the points at the vertices of each of the triangles 3150 2959 % Refer here to the example to be provided in describing the simple example 3151 \item \code{time}, a Numeric array containing times for model 3152 evaluation 2960 \item \code{time}, a numeric array containing times for model evaluation 3153 2961 \end{itemize} 3154 3155 2962 3156 2963 The contents of an SWW file may be viewed using the anuga viewer … … 3178 2985 variables: 3179 2986 \begin{itemize} 3180 \item \code{x} and \code{y}: coordinates of the points, represented as Numeric arrays 3181 \item \code{permutation}: Original indices of the points as specified by 3182 the optional \code{ordering\_file} 3183 (see the function \code{urs2sts} in Section \ref{sec:basicfileconversions}). 3184 3185 \item \code{elevation}, a Numeric array storing bed-elevations 2987 \item \code{x} and \code{y}: coordinates of the points, represented as numeric arrays 2988 \item \code{permutation}: Original indices of the points as specified by the optional \code{ordering\_file} 2989 (see the function \code{urs2sts} in Section \ref{sec:basicfileconversions}). 2990 \item \code{elevation}: a numeric array storing bed-elevations 3186 2991 % Refer here to the example to be provided in describing the simple example 3187 \item \code{time}, a Numeric array containing times for model 3188 evaluation 2992 \item \code{time}: a numeric array containing times for model evaluation 3189 2993 \end{itemize} 3190 The only difference between the STS format and the SWW format is the former does not contain a list specifying the points at the vertices of each of the triangles (\code{volumes}). Consequenlty information (arrays) stored within an STS file such as \code{elevation} can be accessed in exactly the same way as it would be extraced from an SWW file. 3191 3192 A TMS file is used to store time series data that is independent of 3193 position. 3194 2994 2995 The only difference between the STS format and the SWW format is the former does 2996 not contain a list specifying the points at the vertices of each of the triangles 2997 (\code{volumes}). Consequently information (arrays) stored within an STS file such 2998 as \code{elevation} can be accessed in exactly the same way as it would be extracted 2999 from an SWW file. 3000 3001 A TMS file is used to store time series data that is independent of position. 3195 3002 3196 3003 \subsection{Mesh File Formats} … … 3201 3008 an MSH file, which is a NetCDF file. A mesh file can be generated 3202 3009 from the function \function{create\_mesh\_from\_regions} (see 3203 Section \ref{sec:meshgeneration}) and used to initialise a domain.3204 3205 A mesh file can define the outline of the mesh ---the vertices and3010 Section \ref{sec:meshgeneration}) and be used to initialise a domain. 3011 3012 A mesh file can define the outline of the mesh -- the vertices and 3206 3013 line segments that enclose the region in which the mesh is 3207 created ---and the triangular mesh itself, which is specified by3014 created -- and the triangular mesh itself, which is specified by 3208 3015 listing the triangles and their vertices, and the segments, which 3209 3016 are those sides of the triangles that are associated with boundary 3210 3017 conditions. 3211 3018 3212 In addition, a mesh file may contain `holes' and/or `regions'. A3019 In addition, a mesh file may contain 'holes' and/or 'regions'. A 3213 3020 hole represents an area where no mesh is to be created, while a 3214 3021 region is a labelled area used for defining properties of a mesh, … … 3217 3024 3218 3025 A mesh file can also contain a georeference, which describes an 3219 offset to be applied to $x$ and $y$ values --- e.g.\ to the vertices. 3220 3026 offset to be applied to $x$ and $y$ values -- e.g.\ to the vertices. 3221 3027 3222 3028 \subsection{Formats for Storing Arbitrary Points and Attributes} 3223 3224 3029 3225 3030 A CSV/TXT file is used to store data representing … … 3227 3032 3228 3033 The format for an CSV/TXT file is:\\ 3229 %\begin{verbatim} 3230 3231 first line: \code{[column names]}\\ 3232 other lines: \code{[x value], [y value], [attributes]}\\ 3233 3234 for example:\\ 3235 \code{x, y, elevation, friction}\\ 3236 \code{0.6, 0.7, 4.9, 0.3}\\ 3237 \code{1.9, 2.8, 5, 0.3}\\ 3238 \code{2.7, 2.4, 5.2, 0.3} 3239 3240 The delimiter is a comma. The first two columns are assumed to 3241 be x, y coordinates. 3242 3034 \\ 3035 first line: \code{[column names]}\\ 3036 other lines: \code{[x value], [y value], [attributes]}\\ 3037 3038 for example: 3039 3040 \begin{verbatim} 3041 x, y, elevation, friction} 3042 0.6, 0.7, 4.9, 0.3} 3043 1.9, 2.8, 5, 0.3} 3044 2.7, 2.4, 5.2, 0.3} 3045 \end{verbatim} 3046 3047 The delimiter is a comma. The first two columns are assumed to 3048 be x, y coordinates. 3243 3049 3244 3050 A PTS file is a NetCDF representation of the data held in an points CSV 3245 3051 file. If the data is associated with a set of $N$ points, then the 3246 data is stored using an $N \times 2$ Numeric array of float3247 variables for the points and an $N \times 1$ Numeric array for each3052 data is stored using an $N \times 2$ numeric array of float 3053 variables for the points and an $N \times 1$ numeric array for each 3248 3054 attribute. 3249 3250 %\end{verbatim}3251 3055 3252 3056 \subsection{ArcView Formats} … … 3273 3077 to represent metadata for a DEM. 3274 3078 3275 3276 3079 \subsection{DEM Format} 3277 3080 3278 3081 A DEM file in \anuga is a NetCDF representation of regular DEM data. 3279 3082 3280 3281 3083 \subsection{Other Formats} 3282 3283 3284 3285 3084 3286 3085 \subsection{Basic File Conversions} 3287 3086 \label{sec:basicfileconversions} 3288 3087 3289 \begin{funcdesc}{sww2dem}{basename_in, basename_out =None,3290 quantity =None,3291 timestep =None,3292 reduction =None,3293 cellsize =10,3294 number_of_decimal_places =None,3295 NODATA_value =-9999,3296 easting_min =None,3297 easting_max =None,3298 northing_min =None,3299 northing_max =None,3300 expand_search =False,3301 verbose =False,3302 origin =None,3303 datum ='WGS84',3304 format ='ers'}3088 \begin{funcdesc}{sww2dem}{basename_in, basename_out=None, 3089 quantity=None, 3090 timestep=None, 3091 reduction=None, 3092 cellsize=10, 3093 number_of_decimal_places=None, 3094 NODATA_value=-9999, 3095 easting_min=None, 3096 easting_max=None, 3097 northing_min=None, 3098 northing_max=None, 3099 expand_search=False, 3100 verbose=False, 3101 origin=None, 3102 datum='WGS84', 3103 format='ers'} 3305 3104 Module: \module{shallow\_water.data\_manager} 3306 3105 … … 3312 3111 within a specified rectangular area. The \code{reduction} input refers to a function 3313 3112 to reduce the quantities over all time step of the SWW file, example, maximum. 3314 \end{funcdesc} 3315 3316 3317 \begin{funcdesc}{dem2pts}{basename_in, basename_out=None, 3113 \end{funcdesc} 3114 3115 \begin{funcdesc}{dem2pts}{basename_in, basename_out=None, 3318 3116 easting_min=None, easting_max=None, 3319 3117 northing_min=None, northing_max=None, … … 3323 3121 Takes DEM data (a NetCDF file representation of data from a regular Digital 3324 3122 Elevation Model) and converts it to PTS format. 3325 3326 3327 3123 \end{funcdesc} 3124 3125 \begin{funcdesc}{urs2sts}{basename_in, basename_out=None, 3328 3126 weights=None, verbose=False, 3329 3127 origin=None,mean_stage=0.0, … … 3331 3129 Module: \module{shallow\_water.data\_manager} 3332 3130 3333 Takes urs data in (timeseries data in mux2 format) and converts it to STS format. The optional filename \code{ordering\_filename} specifies the permutation of indices of points to select along with their longitudes and latitudes. This permutation will also be3334 stored in the STS file. If absent, all points are taken and the permutation will be trivial, i.e. $0, 1, \ldots, N-1$, where $N$ is the total number of points stored.3335 \end{funcdesc}3336 3337 3338 3339 3131 Takes URS data (timeseries data in mux2 format) and converts it to STS format. 3132 The optional filename \code{ordering\_filename} specifies the permutation of indices 3133 of points to select along with their longitudes and latitudes. This permutation will also be 3134 stored in the STS file. If absent, all points are taken and the permutation will be trivial, 3135 i.e. $0, 1, \ldots, N-1$, where $N$ is the total number of points stored. 3136 \end{funcdesc} 3137 3340 3138 \begin{funcdesc}{csv2building\_polygons}{file\_name, floor\_height=3} 3341 3342 Module: \module{shallow\_water.data\_manager} 3343 3344 Convert CSV files of the form: 3345 {\small 3346 \begin{verbatim} 3347 easting,northing,id,floors 3348 422664.22,870785.46,2,0 3349 422672.48,870780.14,2,0 3350 422668.17,870772.62,2,0 3351 422660.35,870777.17,2,0 3352 422664.22,870785.46,2,0 3353 422661.30,871215.06,3,1 3354 422667.50,871215.70,3,1 3355 422668.30,871204.86,3,1 3356 422662.21,871204.33,3,1 3357 422661.30,871215.06,3,1 3358 \end{verbatim} } 3359 3360 to a dictionary of polygons with id as key. 3361 The associated number of floors are converted to m above MSL and 3362 returned as a separate dictionary also keyed by id. 3139 Module: \module{shallow\_water.data\_manager} 3140 3141 Convert CSV files of the form: 3142 3143 \begin{verbatim} 3144 easting,northing,id,floors 3145 422664.22,870785.46,2,0 3146 422672.48,870780.14,2,0 3147 422668.17,870772.62,2,0 3148 422660.35,870777.17,2,0 3149 422664.22,870785.46,2,0 3150 422661.30,871215.06,3,1 3151 422667.50,871215.70,3,1 3152 422668.30,871204.86,3,1 3153 422662.21,871204.33,3,1 3154 422661.30,871215.06,3,1 3155 \end{verbatim} 3156 3157 to a dictionary of polygons with \code{id} as key. 3158 The associated number of \code{floors} are converted to m above MSL and 3159 returned as a separate dictionary also keyed by \code{id}. 3363 3160 3364 Optional parameter floor_heightis the height of each building story.3365 3366 These can e.g. be converted to a Polygon\_function for use with add\_quantity 3367 as shown on page \pageref{add quantity}.3161 Optional parameter \code{floor_height} is the height of each building story. 3162 3163 These can e.g. be converted to a \code{Polygon_function} for use with \code{add_quantity} 3164 as shown on page \pageref{add quantity}. 3368 3165 \end{funcdesc} 3369 3166 3370 3371 3372 3373 3374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3375 3167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3376 3168 … … 3378 3170 \label{cd:mathematical background} 3379 3171 3172 3380 3173 \section{Introduction} 3381 3174 3382 3175 This chapter outlines the mathematics underpinning \anuga. 3383 3384 3176 3385 3177 … … 3436 3228 and tsunamis. 3437 3229 3230 3438 3231 \section{Finite Volume Method} 3439 3232 \label{sec:fvm} … … 3447 3240 particular interest. 3448 3241 3449 \begin{figure} 3450 \begin{center} 3451 \includegraphics[width=8.0cm,keepaspectratio=true]{graphics/step-five} 3452 \caption{Triangular mesh used in our finite volume method. Conserved 3453 quantities $h$, $uh$ and $vh$ are associated with the centroid of 3454 each triangular cell.} \label{fig:mesh} 3455 \end{center} 3456 \end{figure} 3242 \begin{figure}[htp] \begin{center} 3243 \includegraphics[width=8.0cm,keepaspectratio=true]{graphics/step-five} 3244 \caption{Triangular mesh used in our finite volume method. Conserved 3245 quantities $h$, $uh$ and $vh$ are associated with the centroid of 3246 each triangular cell.} 3247 \label{fig:mesh} 3248 \end{center} \end{figure} 3457 3249 3458 3250 The equations constituting the finite-volume method are obtained by … … 3474 3266 where 3475 3267 \begin{itemize} 3476 \item $\UU_i$ the vector of conserved quantities averaged over the $i$th cell, 3477 \item $\SSS_i$ is the source term associated with the $i$th cell, 3478 and 3479 \item $\HH_{ij}$ is the outward normal flux of 3480 material across the \textit{ij}th edge. 3268 \item $\UU_i$ the vector of conserved quantities averaged over the $i$th cell, 3269 \item $\SSS_i$ is the source term associated with the $i$th cell, and 3270 \item $\HH_{ij}$ is the outward normal flux of material across the \textit{ij}th edge. 3481 3271 \end{itemize} 3482 3483 3272 3484 3273 %\item $l_{ij}$ is the length of the edge between the $i$th and $j$th … … 3510 3299 We use a second order reconstruction to produce a piece-wise linear 3511 3300 function construction of the conserved quantities for all $x \in 3512 T_i$ for each cell (see Figure~\ref{fig:mesh:reconstruct} . This3301 T_i$ for each cell (see Figure~\ref{fig:mesh:reconstruct}). This 3513 3302 function is allowed to be discontinuous across the edges of the 3514 3303 cells, but the slope of this function is limited to avoid … … 3521 3310 calculate an approximation of the flux across each edge. 3522 3311 3523 \begin{figure} 3524 \begin{center} 3525 \includegraphics[width=8.0cm,keepaspectratio=true]{graphics/step-reconstruct} 3526 \caption{From the values of the conserved quantities at the centroid 3527 of the cell and its neighbouring cells, a discontinuous piecewise 3528 linear reconstruction of the conserved quantities is obtained.} 3529 \label{fig:mesh:reconstruct} 3530 \end{center} 3531 \end{figure} 3312 \begin{figure}[htp] \begin{center} 3313 \includegraphics[width=8.0cm,keepaspectratio=true]{graphics/step-reconstruct} 3314 \caption{From the values of the conserved quantities at the centroid 3315 of the cell and its neighbouring cells, a discontinuous piecewise 3316 linear reconstruction of the conserved quantities is obtained.} 3317 \label{fig:mesh:reconstruct} 3318 \end{center} \end{figure} 3532 3319 3533 3320 In the computations presented in this paper we use an explicit Euler … … 3546 3333 of each triangle. 3547 3334 3335 3548 3336 \section{Flux limiting} 3549 3337 3550 3338 The shallow water equations are solved numerically using a 3551 finite volume method on unstructured triangular grid.3339 finite volume method on an unstructured triangular grid. 3552 3340 The upwind central scheme due to Kurganov and Petrova is used as an 3553 3341 approximate Riemann solver for the computation of inviscid flux functions. … … 3557 3345 small water depths near a wet/dry boundary we employ a new flux limiter that 3558 3346 ensures that unphysical fluxes are never encounted. 3559 3560 3347 3561 3348 Let $u$ and $v$ be the velocity components in the $x$ and $y$ direction, … … 3599 3386 \] 3600 3387 3601 3602 3388 ANUGA has a global parameter $H_0$ that controls the minimal depth which 3603 3389 is considered in the various equations. This parameter is typically set to … … 3618 3404 which converges quadratically to the true value with the multiple N. 3619 3405 3620 3621 %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. 3622 3623 3624 3406 %The developed numerical model has been applied to several test cases 3407 %as well as to real flows. numeric tests prove the robustness and accuracy of the model. 3625 3408 3626 3409 3627 3410 \section{Slope limiting} 3628 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. 3629 3630 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. 3631 3411 A multidimensional slope-limiting technique is employed to achieve second-order spatial 3412 accuracy and to prevent spurious oscillations. This is using the MinMod limiter and is 3413 documented elsewhere. 3414 3415 However close to the bed, the limiter must ensure that no negative depths occur. 3416 On the other hand, in deep water, the bed topography should be ignored for the 3417 purpose of the limiter. 3632 3418 3633 3419 Let $w, z, h$ be the stage, bed elevation and depth at the centroid and … … 3649 3435 \] 3650 3436 3651 3652 3437 Similarly, let $\bar{w_i}$ be the stage obtained from a gradient 3653 3438 limiter limiting on depth respecting the bed slope. … … 3656 3441 \bar{h_i} = \bar{w_i} - z_i 3657 3442 \] 3658 3659 3443 3660 3444 We introduce the concept of a balanced stage $w_i$ which is obtained as … … 3730 3514 %provides a numerical safety {??) 3731 3515 3732 3733 3734 3735 3736 3516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3738 3517 3739 3518 \chapter{Basic \anuga Assumptions} 3740 3519 3741 \section{Time} 3520 3521 \section{Time} 3522 3742 3523 Physical model time cannot be earlier than 1 Jan 1970 00:00:00. 3743 3524 If one wished to recreate scenarios prior to that date it must be done 3744 3525 using some relative time (e.g. 0). 3745 3526 3746 The ANUGA domain has an attribute \code{starttime} which is used in cases where the simulation should be started later than the beginning of some input data such as those obtained from boundaries or forcing functions (hydrographs, file\_boundary etc) 3747 3748 The \code{file\_boundary} may adjust domain.startime in case the input data does not itself start until a later time. 3527 The ANUGA domain has an attribute \code{starttime} which is used in cases where the 3528 simulation should be started later than the beginning of some input data such as those 3529 obtained from boundaries or forcing functions (hydrographs, file\_boundary etc). 3530 3531 The \code{domain.startime} may be adjusted in \code{file_boundary} in the case the 3532 input data does not itself start until a later time. 3749 3533 3750 3534 … … 3752 3536 3753 3537 \subsection{Projection} 3754 All spatial data relates to the WGS84 datum (or GDA94) and assumes a projection into UTM with false easting of 500000 and false northing of 3538 All spatial data relates to the WGS84 datum (or GDA94) and assumes a projection 3539 into UTM with false easting of 500000 and false northing of 3755 3540 1000000 on the southern hemisphere (0 on the northern hemisphere). 3756 3541 All locations must consequently be specified in Cartesian coordinates … … 3762 3547 It is important to realise that ANUGA for numerical precision uses coordinates that are relative 3763 3548 to the lower left node of the rectangle containing the mesh ($x_{\mbox{min}}$, $y_{\mbox{min}}$). 3764 This origin is referred to internally as xllcorner, yllcorner following the ESRI asciigrid notation.3765 The sww file format also includes xllcorner, yllcornerand any coordinate in the file should be adjusted3549 This origin is referred to internally as \code{xllcorner}, \code{yllcorner} following the ESRI ASCII grid notation. 3550 The sww file format also includes \code{xllcorner}, \code{yllcorner} and any coordinate in the file should be adjusted 3766 3551 by adding this origin. See Section \ref{sec:sww format}. 3767 3552 3768 Throughout the ANUGA interface functions have optional boolean arguments \code{absolute} which control3769 whether spatial data received is using the internal representation ( absolute=False) or the3770 user coordinate set ( absolute=True). See e.g. \code{get\_vertex\_coordinates} on \pageref{pg:get vertex coordinates}.3553 Throughout the ANUGA interface, functions have optional boolean arguments \code{absolute} which controls 3554 whether spatial data received is using the internal representation (\code{absolute=False}) or the 3555 user coordinate set (\code{absolute=True}). See e.g. \code{get_vertex_coordinates} on \pageref{pg:get vertex coordinates}. 3771 3556 3772 3557 DEMs, meshes and boundary conditions can have different origins. However, the internal representation in ANUGA … … 3775 3560 \subsection{Polygons} 3776 3561 When generating a mesh it is assumed that polygons do not cross. 3777 Having polygons tht cross can cause the mesh generation to fail or bad 3778 meshes being produced. 3779 3562 Having polygons that cross can cause bad meshes to be produced or the mesh generation itself may fail. 3780 3563 3781 3564 %OLD … … 3812 3595 % run inundation simulation. 3813 3596 3814 3815 3597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3817 3598 3818 3599 \appendix 3600 3819 3601 3820 3602 \chapter{Supporting Tools} … … 3822 3604 3823 3605 This section describes a number of supporting tools, supplied with \anuga, that offer a 3824 variety of types of functionality and enhance the basic capabilities of \anuga. 3606 variety of types of functionality and can enhance the basic capabilities of \anuga. 3607 3825 3608 3826 3609 \section{caching} … … 3828 3611 3829 3612 The \code{cache} function is used to provide supervised caching of function 3830 results. A Python function call of the form 3831 3832 {\small \begin{verbatim} 3833 result = func(arg1,...,argn) 3834 \end{verbatim}} 3835 3836 can be replaced by 3837 3838 {\small \begin{verbatim} 3839 from caching import cache 3840 result = cache(func,(arg1,...,argn)) 3841 \end{verbatim}} 3842 3843 which returns the same output but reuses cached 3844 results if the function has been computed previously in the same context. 3845 \code{result} and the arguments can be simple types, tuples, list, dictionaries or 3846 objects, but not unhashable types such as functions or open file objects. 3847 The function \code{func} may be a member function of an object or a module. 3848 3849 This type of caching is particularly useful for computationally intensive 3850 functions with few frequently used combinations of input arguments. Note that 3851 if the inputs or output are very large caching may not save time because 3852 disc access may dominate the execution time. 3853 3854 If the function definition changes after a result has been cached, this will be 3855 detected by examining the functions \code{bytecode (co\_code, co\_consts, 3856 func\_defaults, co\_argcount)} and the function will be recomputed. 3857 However, caching will not detect changes in modules used by \code{func}. 3858 In this case cache must be cleared manually. 3859 3860 Options are set by means of the function \code{set\_option(key, value)}, 3861 where \code{key} is a key associated with a 3862 Python dictionary \code{options}. This dictionary stores settings such as the name of 3863 the directory used, the maximum 3864 number of cached files allowed, and so on. 3865 3866 The \code{cache} function allows the user also to specify a list of dependent files. If any of these 3867 have been changed, the function is recomputed and the results stored again. 3868 3869 %Other features include support for compression and a capability to \ldots 3870 3871 3872 \textbf{USAGE:} \nopagebreak 3873 3874 {\small \begin{verbatim} 3875 result = cache(func, args, kwargs, dependencies, cachedir, verbose, 3876 compression, evaluate, test, return_filename) 3877 \end{verbatim}} 3878 3879 3880 \section{ANUGA viewer - animate} 3613 results. A Python function call of the form: 3614 3615 \begin{verbatim} 3616 result = func(arg1, ..., argn) 3617 \end{verbatim} 3618 3619 can be replaced by: 3620 3621 \begin{verbatim} 3622 from caching import cache 3623 result = cache(func,(arg1, ..., argn)) 3624 \end{verbatim} 3625 3626 which returns the same output but reuses cached 3627 results if the function has been computed previously in the same context. 3628 \code{result} and the arguments can be simple types, tuples, list, dictionaries or 3629 objects, but not unhashable types such as functions or open file objects. 3630 The function \code{func} may be a member function of an object or a module. 3631 3632 This type of caching is particularly useful for computationally intensive 3633 functions with few frequently used combinations of input arguments. Note that 3634 if the inputs or output are very large caching may not save time because 3635 disc access may dominate the execution time. 3636 3637 If the function definition changes after a result has been cached, this will be 3638 detected by examining the functions \code{bytecode (co\_code, co\_consts, 3639 func\_defaults, co\_argcount)} and the function will be recomputed. 3640 However, caching will not detect changes in modules used by \code{func}. 3641 In this case cache must be cleared manually. 3642 3643 Options are set by means of the function \code{set\_option(key, value)}, 3644 where \code{key} is a key associated with a 3645 Python dictionary \code{options}. This dictionary stores settings such as the name of 3646 the directory used, the maximum number of cached files allowed, and so on. 3647 3648 The \code{cache} function allows the user also to specify a list of dependent files. If any of these 3649 have been changed, the function is recomputed and the results stored again. 3650 3651 %Other features include support for compression and a capability to \ldots 3652 3653 \textbf{USAGE:} \nopagebreak 3654 3655 \begin{verbatim} 3656 result = cache(func, args, kwargs, dependencies, cachedir, verbose, 3657 compression, evaluate, test, return_filename) 3658 \end{verbatim} 3659 3660 3661 \section{ANUGA viewer -- animate} 3881 3662 \label{sec:animate} 3882 The output generated by \anuga may be viewed by 3663 3664 The output generated by \anuga may be viewed by 3883 3665 means of the visualisation tool \code{animate}, which takes the 3884 \code{SWW} file outputby \anuga and creates a visual representation3666 \code{SWW} file generated by \anuga and creates a visual representation 3885 3667 of the data. Examples may be seen in Figures \ref{fig:runupstart} 3886 3668 and \ref{fig:runup2}. To view an \code{SWW} file with … … 3890 3672 file association to make files with the extension \code{.sww} open 3891 3673 with \code{animate}. Alternatively, you can operate \code{animate} 3892 from the command line , in both Windows and Linux environments.3893 3894 On successful operation, you will see an interactive moving-picture3895 display. You can use keysand the mouse to slow down, speed up or3674 from the command line. 3675 3676 Upon starting the viewer, you will see an interactive moving-picture 3677 display. You can use the keyboard and the mouse to slow down, speed up or 3896 3678 stop the display, change the viewing position or carry out a number 3897 3679 of other simple operations. Help is also displayed when you press 3898 3680 the \code{h} key. 3899 3681 3900 The main keys operating the interactive screen are:\\ 3901 3682 The main keys operating the interactive screen are: 3902 3683 \begin{center} 3903 3684 \begin{tabular}{|ll|} \hline 3904 3905 \code{w} & toggle wireframe \\ 3906 3907 space bar & start/stop\\ 3908 3909 up/down arrows & increase/decrease speed\\ 3910 3911 left/right arrows & direction in time \emph{(when running)}\\ 3912 & step through simulation \emph{(when stopped)}\\ 3913 3914 left mouse button & rotate\\ 3915 3916 middle mouse button & pan\\ 3917 3918 right mouse button & zoom\\ \hline 3919 3685 \code{h} & toggle on-screen help display \\ 3686 \code{w} & toggle wireframe \\ 3687 space bar & start/stop\\ 3688 up/down arrows & increase/decrease speed\\ 3689 left/right arrows & direction in time \emph{(when running)}\\ 3690 & step through simulation \emph{(when stopped)}\\ 3691 left mouse button & rotate\\ 3692 middle mouse button & pan\\ 3693 right mouse button & zoom\\ \hline 3920 3694 \end{tabular} 3921 3695 \end{center} 3922 3696 3923 \vfill3924 3925 The following table describes how to operate animatefrom the command line:3697 % \vfill 3698 3699 The following table describes how to operate \code{animate} from the command line: 3926 3700 3927 3701 Usage: \code{animate [options] swwfile \ldots}\\ \nopagebreak … … 3949 3723 3950 3724 \begin{tabular}{ll} 3951 3952 3725 \code{-hmin <float>} & Height below which transparency is set to 3953 3726 zero\\ … … 3961 3734 \begin{tabular}{ll} 3962 3735 \code{-loop} & Repeated (looped) playback of \code{.swm} files\\ 3963 3964 3736 \end{tabular} 3965 3737 … … 3967 3739 \code{-movie <dirname>} & Save numbered images to named directory and 3968 3740 quit\\ 3969 3970 3741 \code{-nosky} & Omit background sky\\ 3971 3972 3973 3742 \code{-scale <float>} & Vertical scale factor\\ 3974 3743 \code{-texture <file>} & Image to use for bedslope topography\\ … … 3978 3747 \end{tabular} 3979 3748 3749 3750 /pagebreak 3980 3751 \section{utilities/polygons} 3981 3752 3982 3983 3984 3985 3753 \declaremodule{standard}{utilities.polygon} 3754 \refmodindex{utilities.polygon} 3755 3756 \begin{classdesc}{Polygon\_function}{regions, default=0.0, geo_reference=None} 3986 3757 Module: \code{utilities.polygon} 3987 3758 … … 4002 3773 that are passed into the function. Typically they will be relative to 4003 3774 some origin. In ANUGA, a typical call will take the form: 4004 {\small \begin{verbatim} 4005 set_quantity('elevation', 4006 Polygon_function([(P1, v1), (P2, v2)], 4007 default=v3, 4008 geo_reference=domain.geo_reference)) 4009 \end{verbatim}} 4010 4011 4012 \end{classdesc} 4013 4014 \begin{funcdesc}{read\_polygon}{filename} 3775 3776 \begin{verbatim} 3777 set_quantity('elevation', 3778 Polygon_function([(P1, v1), (P2, v2)], 3779 default=v3, 3780 geo_reference=domain.geo_reference)) 3781 \end{verbatim} 3782 \end{classdesc} 3783 3784 \begin{funcdesc}{read\_polygon}{filename} 4015 3785 Module: \code{utilities.polygon} 4016 3786 … … 4018 3788 line of the file must contain exactly two numbers, separated by a comma, which are interpreted 4019 3789 as coordinates of one vertex of the polygon. 4020 4021 4022 3790 \end{funcdesc} 3791 3792 \begin{funcdesc}{populate\_polygon}{polygon, number_of_points, seed = None, exclude = None} 4023 3793 Module: \code{utilities.polygon} 4024 3794 4025 3795 Populates the interior of the specified polygon with the specified number of points, 4026 3796 selected by means of a uniform distribution function. 4027 4028 4029 3797 \end{funcdesc} 3798 3799 \begin{funcdesc}{point\_in\_polygon}{polygon, delta=1e-8} 4030 3800 Module: \code{utilities.polygon} 4031 3801 … … 4033 3803 the returned point and the nearest point of the polygon is less than $\sqrt{2}$ times the 4034 3804 second argument \code{delta}, which is taken as $10^{-8}$ by default. 4035 4036 4037 3805 \end{funcdesc} 3806 3807 \begin{funcdesc}{inside\_polygon}{points, polygon, closed = True, verbose = False} 4038 3808 Module: \code{utilities.polygon} 4039 3809 4040 3810 Used to test whether the members of a list of points 4041 are inside the specified polygon. Returns a Numeric3811 are inside the specified polygon. Returns a numeric 4042 3812 array comprising the indices of the points in the list that lie inside the polygon. 4043 3813 (If none of the points are inside, returns \code{zeros((0,), 'l')}.) 4044 3814 Points on the edges of the polygon are regarded as inside if 4045 3815 \code{closed} is set to \code{True} or omitted; otherwise they are regarded as outside. 4046 4047 4048 3816 \end{funcdesc} 3817 3818 \begin{funcdesc}{outside\_polygon}{points, polygon, closed = True, verbose = False} 4049 3819 Module: \code{utilities.polygon} 4050 3820 4051 Exactly like \code{inside\_polygon}, but with the words `inside' and `outside' interchanged.4052 4053 4054 3821 Exactly like \code{inside\_polygon}, but with the words 'inside' and 'outside' interchanged. 3822 \end{funcdesc} 3823 3824 \begin{funcdesc}{is\_inside\_polygon}{point, polygon, closed=True, verbose=False} 4055 3825 Module: \code{utilities.polygon} 4056 3826 … … 4058 3828 \code{False} otherwise. Points on the edges of the polygon are regarded as inside if 4059 3829 \code{closed} is set to \code{True} or omitted; otherwise they are regarded as outside. 4060 4061 4062 3830 \end{funcdesc} 3831 3832 \begin{funcdesc}{is\_outside\_polygon}{point, polygon, closed=True, verbose=False} 4063 3833 Module: \code{utilities.polygon} 4064 3834 4065 Exactly like \code{is\_outside\_polygon}, but with the words `inside' and `outside' interchanged.4066 4067 4068 3835 Exactly like \code{is\_outside\_polygon}, but with the words 'inside' and 'outside' interchanged. 3836 \end{funcdesc} 3837 3838 \begin{funcdesc}{point\_on\_line}{x, y, x0, y0, x1, y1} 4069 3839 Module: \code{utilities.polygon} 4070 3840 … … 4072 3842 \code{x, y} is on the line passing through the points with coordinates \code{x0, y0} 4073 3843 and \code{x1, y1} (extended if necessary at either end). 4074 4075 4076 3844 \end{funcdesc} 3845 3846 \begin{funcdesc}{separate\_points\_by\_polygon}{points, polygon, closed = True, verbose = False} 4077 3847 \indexedcode{separate\_points\_by\_polygon} 4078 3848 Module: \code{utilities.polygon} 4079 3849 4080 4081 4082 3850 \end{funcdesc} 3851 3852 \begin{funcdesc}{polygon\_area}{polygon} 4083 3853 Module: \code{utilities.polygon} 4084 3854 4085 3855 Returns area of arbitrary polygon (reference http://mathworld.wolfram.com/PolygonArea.html) 4086 \end{funcdesc} 4087 4088 \begin{funcdesc}{plot\_polygons}{polygons, style, figname, verbose = False} 4089 Module: \code{utilities.polygon} 4090 4091 Plots each polygon contained in input polygon list, e.g. 4092 \code{polygons = [poly1, poly2, poly3]} where \code{poly1 = [[x11,y11],[x12,y12],[x13,y13]]} 4093 etc. Each polygon can be closed for plotting purposes by assigning the style type to each 4094 polygon in the list, e.g. \code{style = ['line','line','line']}. The default will be a line 4095 type when \code{style = None}. 4096 The subsequent plot will be saved to \code{figname} or defaulted to \code{test_image.png}. 4097 The function returns a list containing the minimum and maximum of \code{x} and \code{y}, 4098 i.e. \code{[x_{min}, x_{max}, y_{min}, y_{max}]}. 4099 \end{funcdesc} 3856 \end{funcdesc} 3857 3858 \begin{funcdesc}{plot\_polygons}{polygons, style, figname, verbose = False} 3859 Module: \code{utilities.polygon} 3860 3861 Plots each polygon contained in input polygon list, e.g. 3862 \code{polygons = [poly1, poly2, poly3]} where \code{poly1 = [[x11,y11],[x12,y12],[x13,y13]]} 3863 etc. Each polygon can be closed for plotting purposes by assigning the style type to each 3864 polygon in the list, e.g. \code{style = ['line','line','line']}. The default will be a line 3865 type when \code{style = None}. 3866 The subsequent plot will be saved to \code{figname} or defaulted to \code{test_image.png}. 3867 The function returns a list containing the minimum and maximum of \code{x} and \code{y}, 3868 i.e. \code{[x_{min}, x_{max}, y_{min}, y_{max}]}. 3869 \end{funcdesc} 3870 4100 3871 4101 3872 \section{coordinate\_transforms} 3873 4102 3874 4103 3875 \section{geospatial\_data} … … 4111 3883 %\refmodindex{geospatial_data} 4112 3884 4113 4114 4115 3885 \begin{classdesc}{Geospatial\_data} 4116 {data_points = None, 4117 attributes = None, 4118 geo_reference = None, 4119 default_attribute_name = None, 4120 file_name = None} 4121 Module: \code{geospatial\_data} 4122 4123 This class is used to store a set of data points and associated 4124 attributes, allowing these to be manipulated by methods defined for 4125 the class. 4126 4127 The data points are specified either by reading them from a NetCDF 4128 or CSV file, identified through the parameter \code{file\_name}, or 4129 by providing their \code{x}- and \code{y}-coordinates in metres, 4130 either as a sequence of 2-tuples of floats or as an $M \times 2$ 4131 Numeric array of floats, where $M$ is the number of points. 4132 Coordinates are interpreted relative to the origin specified by the 4133 object \code{geo\_reference}, which contains data indicating the UTM 4134 zone, easting and northing. If \code{geo\_reference} is not 4135 specified, a default is used. 4136 4137 Attributes are specified through the parameter \code{attributes}, 4138 set either to a list or array of length $M$ or to a dictionary whose 4139 keys are the attribute names and whose values are lists or arrays of 4140 length $M$. One of the attributes may be specified as the default 4141 attribute, by assigning its name to \code{default\_attribute\_name}. 4142 If no value is specified, the default attribute is taken to be the 4143 first one. 4144 4145 Note that the Geospatial\_data object currently reads entire datasets 4146 into memory i.e.\ no memomry blocking takes place. 4147 For this we refer to the set\_quantity method which will read .pts and .csv files into \anuga using memory blocking allowing large files to be used. 3886 {data_points=None, 3887 attributes=None, 3888 geo_reference=None, 3889 default_attribute_name=None, 3890 file_name=None} 3891 Module: \code{geospatial\_data} 3892 3893 This class is used to store a set of data points and associated 3894 attributes, allowing these to be manipulated by methods defined for 3895 the class. 3896 3897 The data points are specified either by reading them from a NetCDF 3898 or CSV file, identified through the parameter \code{file\_name}, or 3899 by providing their \code{x}- and \code{y}-coordinates in metres, 3900 either as a sequence of 2-tuples of floats or as an $M \times 2$ 3901 numeric array of floats, where $M$ is the number of points. 3902 Coordinates are interpreted relative to the origin specified by the 3903 object \code{geo\_reference}, which contains data indicating the UTM 3904 zone, easting and northing. If \code{geo\_reference} is not 3905 specified, a default is used. 3906 3907 Attributes are specified through the parameter \code{attributes}, 3908 set either to a list or array of length $M$ or to a dictionary whose 3909 keys are the attribute names and whose values are lists or arrays of 3910 length $M$. One of the attributes may be specified as the default 3911 attribute, by assigning its name to \code{default\_attribute\_name}. 3912 If no value is specified, the default attribute is taken to be the 3913 first one. 3914 3915 Note that the Geospatial\_data object currently reads entire datasets 3916 into memory i.e.\ no memomry blocking takes place. 3917 For this we refer to the set\_quantity method which will read .pts and .csv 3918 files into \anuga using memory blocking allowing large files to be used. 4148 3919 \end{classdesc} 4149 3920 4150 4151 \begin{methoddesc}{import\_points\_file}{delimiter = None, verbose = False} 4152 4153 \end{methoddesc} 4154 3921 \begin{methoddesc}{import\_points\_file}{delimiter=None, verbose=False} 3922 3923 \end{methoddesc} 4155 3924 4156 3925 \begin{methoddesc}{export\_points\_file}{ofile, absolute=False} … … 4158 3927 \end{methoddesc} 4159 3928 4160 4161 \begin{methoddesc}{get\_data\_points}{absolute = True, as\_lat\_long = 4162 False} 3929 \begin{methoddesc}{get\_data\_points}{absolute=True, as\_lat\_long=False} 4163 3930 If \code{as\_lat\_long} is\code{True} the point information 4164 3931 returned will be in Latitudes and Longitudes. 4165 4166 \end{methoddesc} 4167 3932 \end{methoddesc} 4168 3933 4169 3934 \begin{methoddesc}{set\_attributes}{attributes} … … 4171 3936 \end{methoddesc} 4172 3937 4173 4174 \begin{methoddesc}{get\_attributes}{attribute_name = None} 4175 4176 \end{methoddesc} 4177 3938 \begin{methoddesc}{get\_attributes}{attribute_name=None} 3939 3940 \end{methoddesc} 4178 3941 4179 3942 \begin{methoddesc}{get\_all\_attributes}{} … … 4181 3944 \end{methoddesc} 4182 3945 4183 4184 3946 \begin{methoddesc}{set\_default\_attribute\_name}{default_attribute_name} 4185 3947 4186 3948 \end{methoddesc} 4187 3949 4188 4189 3950 \begin{methoddesc}{set\_geo\_reference}{geo_reference} 4190 3951 4191 3952 \end{methoddesc} 4192 3953 4193 4194 3954 \begin{methoddesc}{add}{} 4195 3955 4196 3956 \end{methoddesc} 4197 3957 4198 4199 3958 \begin{methoddesc}{clip}{} 4200 Clip geospatial data by a polygon 4201 4202 Inputs are \code{polygon} which is either a list of points, an Nx2 array or 4203 a Geospatial data object and \code{closed}(optional) which determines 4204 whether points on boundary should be regarded as belonging to the polygon 4205 (\code{closed=True}) or not (\code{closed=False}). 4206 Default is \code{closed=True}. 4207 4208 Returns new Geospatial data object representing points 4209 inside specified polygon. 4210 \end{methoddesc} 4211 3959 Clip geospatial data by a polygon 3960 3961 Inputs are \code{polygon} which is either a list of points, an Nx2 array or 3962 a Geospatial data object and \code{closed}(optional) which determines 3963 whether points on boundary should be regarded as belonging to the polygon 3964 (\code{closed=True}) or not (\code{closed=False}). 3965 Default is \code{closed=True}. 3966 3967 Returns new Geospatial data object representing points inside specified polygon. 3968 \end{methoddesc} 4212 3969 4213 3970 \begin{methoddesc}{clip_outside}{} 4214 Clip geospatial data by a polygon 4215 4216 Inputs are \code{polygon} which is either a list of points, an Nx2 array or 4217 a Geospatial data object and \code{closed}(optional) which determines 4218 whether points on boundary should be regarded as belonging to the polygon 4219 (\code{closed=True}) or not (\code{closed=False}). 4220 Default is \code{closed=True}. 4221 4222 Returns new Geospatial data object representing points 4223 \emph{out}side specified polygon. 3971 Clip geospatial data by a polygon 3972 3973 Inputs are \code{polygon} which is either a list of points, an Nx2 array or 3974 a Geospatial data object and \code{closed}(optional) which determines 3975 whether points on boundary should be regarded as belonging to the polygon 3976 (\code{closed=True}) or not (\code{closed=False}). 3977 Default is \code{closed=True}. 3978 3979 Returns new Geospatial data object representing points \emph{out}side specified polygon. 4224 3980 \end{methoddesc} 4225 3981 4226 3982 \begin{methoddesc}{split}{factor=0.5, seed_num=None, verbose=False} 4227 Returns two geospatial_data object, first is the size of the 'factor' 4228 smaller the original and the second is the remainder. The two 4229 new object are disjoin set of each other. 4230 4231 Points of the two new geospatial_data object are selected RANDOMLY. 4232 4233 Input - the (\code{factor}) which to split the object, if 0.1 then 10% of the 4234 together object will be returned 4235 4236 Output - two geospatial_data objects that are disjoint sets of the original 4237 \end{methoddesc} 4238 4239 \begin{methoddesc}{find_optimal_smoothing_parameter}{data_file, alpha_list=None, mesh_file=None, boundary_poly=None, mesh_resolution=100000, 4240 north_boundary=None, south_boundary=None, east_boundary=None, west_boundary=None, plot_name='all_alphas', split_factor=0.1, seed_num=None, cache=False, verbose=False} 4241 4242 Removes a small random sample of points from 'data_file'. Creates 4243 models from resulting points in 'data_file' with different alpha values from 'alpha_list' and cross validates 4244 the predicted value to the previously removed point data. Returns the 4245 alpha value which has the smallest covariance. 4246 4247 data_file: must not contain points outside the boundaries defined 4248 and it either a pts, txt or csv file. 4249 4250 alpha_list: the alpha values to test in a single list 4251 4252 mesh_file: name of the created mesh file or if passed in will read it. 4253 NOTE, if there is a mesh file mesh_resolution, north_boundary, south... etc will be ignored. 4254 4255 mesh_resolution: the maximum area size for a triangle 4256 4257 north_boundary... west_boundary: the value of the boundary 4258 4259 plot_name: the name for the plot contain the results 4260 4261 seed_num: the seed to the random number generator 4262 4263 USAGE: 4264 convariance_value, alpha = find_optimal_smoothing_parameter(data_file=fileName, 4265 alpha_list=[0.0001, 0.01, 1], 4266 mesh_file=None, 4267 mesh_resolution=3, 4268 north_boundary=5, 4269 south_boundary=-5, 4270 east_boundary=5, 4271 west_boundary=-5, 4272 plot_name='all_alphas', 4273 seed_num=100000, 4274 verbose=False) 4275 4276 OUTPUT: returns the minumum normalised covalance calculate AND the 4277 alpha that created it. PLUS writes a plot of the results 4278 4279 NOTE: code will not work if the data_file extent is greater than the 4280 boundary_polygon or any of the boundaries, eg north_boundary...west_boundary 4281 \end{methoddesc} 4282 3983 Returns two geospatial_data object, first is the size of the 'factor' 3984 smaller the original and the second is the remainder. The two 3985 new object are disjoin set of each other. 3986 3987 Points of the two new geospatial_data object are selected RANDOMLY. 3988 3989 Input -- the (\code{factor}) which to split the object, if 0.1 then 10% of the 3990 together object will be returned 3991 3992 Output -- two geospatial_data objects that are disjoint sets of the original 3993 \end{methoddesc} 3994 3995 \begin{methoddesc}{find_optimal_smoothing_parameter}{data_file, alpha_list=None, 3996 mesh_file=None, boundary_poly=None, mesh_resolution=100000, 3997 north_boundary=None, south_boundary=None, east_boundary=None, 3998 west_boundary=None, plot_name='all_alphas', split_factor=0.1, 3999 seed_num=None, cache=False, verbose=False} 4000 Removes a small random sample of points from 'data_file'. Creates 4001 models from resulting points in 'data_file' with different alpha values from 'alpha_list' and cross validates 4002 the predicted value to the previously removed point data. Returns the 4003 alpha value which has the smallest covariance. 4004 4005 data_file: must not contain points outside the boundaries defined 4006 and it either a pts, txt or csv file. 4007 4008 alpha_list: the alpha values to test in a single list 4009 4010 mesh_file: name of the created mesh file or if passed in will read it. 4011 NOTE, if there is a mesh file mesh_resolution, north_boundary, south... etc will be ignored. 4012 4013 mesh_resolution: the maximum area size for a triangle 4014 4015 north_boundary... west_boundary: the value of the boundary 4016 4017 plot_name: the name for the plot contain the results 4018 4019 seed_num: the seed to the random number generator 4020 4021 USAGE: 4022 convariance_value, alpha = find_optimal_smoothing_parameter(data_file=fileName, 4023 alpha_list=[0.0001, 0.01, 1], 4024 mesh_file=None, 4025 mesh_resolution=3, 4026 north_boundary=5, 4027 south_boundary=-5, 4028 east_boundary=5, 4029 west_boundary=-5, 4030 plot_name='all_alphas', 4031 seed_num=100000, 4032 verbose=False) 4033 4034 OUTPUT: returns the minumum normalised covalance calculate AND the 4035 alpha that created it. PLUS writes a plot of the results 4036 4037 NOTE: code will not work if the data_file extent is greater than the 4038 boundary_polygon or any of the boundaries, eg north_boundary...west_boundary 4039 \end{methoddesc} 4283 4040 4284 4041 4285 4042 \section{Graphical Mesh Generator GUI} 4286 The program \code{graphical \_mesh\_generator.py} in the pmesh module4043 The program \code{graphical_mesh_generator.py} in the pmesh module 4287 4044 allows the user to set up the mesh of the problem interactively. 4288 4045 It can be used to build the outline of a mesh or to visualise a mesh … … 4299 4056 by pressing the the middle mouse button (scroll bar). 4300 4057 4058 4301 4059 \section{alpha\_shape} 4302 4060 \emph{Alpha shapes} are used to generate close-fitting boundaries 4303 4061 around sets of points. The alpha shape algorithm produces a shape 4304 that approximates to the `shape formed by the points'---or the shape4062 that approximates to the 'shape formed by the points' -- or the shape 4305 4063 that would be seen by viewing the points from a coarse enough 4306 4064 resolution. For the simplest types of point sets, the alpha shape … … 4321 4079 with instances of this class. 4322 4080 4323 \begin{classdesc}{Alpha\_Shape}{points, alpha =None}4324 Module: \code{alpha\_shape}4325 4326 To instantiate this class the user supplies the points from which4327 the alpha shape is to be created (in the form of a list of 2-tuples4328 \code{[[x1, y1],[x2, y2]}\ldots\code{]}, assigned to the parameter4329 \code{points}) and, optionally, a value for the parameter4330 \code{alpha}. The alpha shape is then computed and the user can then4331 retrieve details of the boundary through the attributes defined for4332 the class.4081 \begin{classdesc}{Alpha\_Shape}{points, alpha=None} 4082 Module: \code{alpha\_shape} 4083 4084 To instantiate this class the user supplies the points from which 4085 the alpha shape is to be created (in the form of a list of 2-tuples 4086 \code{[[x1, y1],[x2, y2]}\ldots\code{]}, assigned to the parameter 4087 \code{points}) and, optionally, a value for the parameter 4088 \code{alpha}. The alpha shape is then computed and the user can then 4089 retrieve details of the boundary through the attributes defined for 4090 the class. 4333 4091 \end{classdesc} 4334 4092 4335 4336 \begin{funcdesc}{alpha\_shape\_via\_files}{point_file, boundary_file, alpha= None} 4337 Module: \code{alpha\_shape} 4338 4339 This function reads points from the specified point file 4340 \code{point\_file}, computes the associated alpha shape (either 4341 using the specified value for \code{alpha} or, if no value is 4342 specified, automatically setting it to an optimal value) and outputs 4343 the boundary to a file named \code{boundary\_file}. This output file 4344 lists the coordinates \code{x, y} of each point in the boundary, 4345 using one line per point. 4093 \begin{funcdesc}{alpha\_shape\_via\_files}{point_file, boundary_file, alpha=None} 4094 Module: \code{alpha\_shape} 4095 4096 This function reads points from the specified point file 4097 \code{point\_file}, computes the associated alpha shape (either 4098 using the specified value for \code{alpha} or, if no value is 4099 specified, automatically setting it to an optimal value) and outputs 4100 the boundary to a file named \code{boundary\_file}. This output file 4101 lists the coordinates \code{x, y} of each point in the boundary, 4102 using one line per point. 4346 4103 \end{funcdesc} 4347 4348 4104 4349 4105 \begin{methoddesc}{set\_boundary\_type}{self,raw_boundary=True, … … 4352 4108 expand_pinch=False, 4353 4109 boundary_points_fraction=0.2} 4354 Module: \code{alpha\_shape}, Class: \class{Alpha\_Shape} 4355 4356 This function sets flags that govern the operation of the algorithm 4357 that computes the boundary, as follows: 4358 4359 \code{raw\_boundary = True} returns raw boundary, i.e. the regular edges of the 4360 alpha shape.\\ 4361 \code{remove\_holes = True} removes small holes (`small' is defined by 4362 \code{boundary\_points\_fraction})\\ 4363 \code{smooth\_indents = True} removes sharp triangular indents in 4364 boundary\\ 4365 \code{expand\_pinch = True} tests for pinch-off and 4366 corrects---preventing a boundary vertex from having more than two edges. 4367 \end{methoddesc} 4368 4110 Module: \code{alpha\_shape}, Class: \class{Alpha\_Shape} 4111 4112 This function sets flags that govern the operation of the algorithm 4113 that computes the boundary, as follows: 4114 4115 \code{raw\_boundary = True} returns raw boundary, i.e. the regular edges of the 4116 alpha shape.\\ 4117 \code{remove\_holes = True} removes small holes ('small' is defined by 4118 \code{boundary\_points\_fraction})\\ 4119 \code{smooth\_indents = True} removes sharp triangular indents in 4120 boundary\\ 4121 \code{expand\_pinch = True} tests for pinch-off and 4122 corrects -- preventing a boundary vertex from having more than two edges. 4123 \end{methoddesc} 4369 4124 4370 4125 \begin{methoddesc}{get\_boundary}{} 4371 Module: \code{alpha\_shape}, Class: \class{Alpha\_Shape} 4372 4373 Returns a list of tuples representing the boundary of the alpha 4374 shape. Each tuple represents a segment in the boundary by providing 4375 the indices of its two endpoints. 4376 \end{methoddesc} 4377 4126 Module: \code{alpha\_shape}, Class: \class{Alpha\_Shape} 4127 4128 Returns a list of tuples representing the boundary of the alpha 4129 shape. Each tuple represents a segment in the boundary by providing 4130 the indices of its two endpoints. 4131 \end{methoddesc} 4378 4132 4379 4133 \begin{methoddesc}{write\_boundary}{file_name} 4380 Module: \code{alpha\_shape}, Class: \class{Alpha\_Shape} 4381 4382 Writes the list of 2-tuples returned by \code{get\_boundary} to the 4383 file \code{file\_name}, using one line per tuple. 4384 \end{methoddesc} 4385 4134 Module: \code{alpha\_shape}, Class: \class{Alpha\_Shape} 4135 4136 Writes the list of 2-tuples returned by \code{get\_boundary} to the 4137 file \code{file\_name}, using one line per tuple. 4138 \end{methoddesc} 4139 4140 4141 \pagebreak 4386 4142 \section{Numerical Tools} 4387 4143 … … 4389 4145 may be found in the module \module{utilities.numerical\_tools}: 4390 4146 4391 \begin{tabular}{|p{8cm} p{8cm}|} \hline 4392 \code{angle(v1, v2=None)} & Angle between two-dimensional vectors 4393 \code{v1} and \code{v2}, or between \code{v1} and the $x$-axis if 4394 \code{v2} is \code{None}. Value is in range $0$ to $2\pi$. \\ 4395 4396 \code{normal\_vector(v)} & Normal vector to \code{v}.\\ 4397 4398 \code{mean(x)} & Mean value of a vector \code{x}.\\ 4399 4400 \code{cov(x, y=None)} & Covariance of vectors \code{x} and \code{y}. 4401 If \code{y} is \code{None}, returns \code{cov(x, x)}.\\ 4402 4403 \code{err(x, y=0, n=2, relative=True)} & Relative error of 4404 $\parallel$\code{x}$-$\code{y}$\parallel$ to 4405 $\parallel$\code{y}$\parallel$ (2-norm if \code{n} = 2 or Max norm 4406 if \code{n} = \code{None}). If denominator evaluates to zero or if 4407 \code{y} 4408 is omitted or if \code{relative = False}, absolute error is returned.\\ 4409 4410 \code{norm(x)} & 2-norm of \code{x}.\\ 4411 4412 \code{corr(x, y=None)} & Correlation of \code{x} and \code{y}. If 4413 \code{y} is \code{None} returns autocorrelation of \code{x}.\\ 4414 4415 \code{ensure\_numeric(A, typecode = None)} & Returns a Numeric array 4416 for any sequence \code{A}. If \code{A} is already a Numeric array it 4417 will be returned unaltered. Otherwise, an attempt is made to convert 4418 it to a Numeric array. (Needed because \code{array(A)} can 4419 cause memory overflow.)\\ 4420 4421 \code{histogram(a, bins, relative=False)} & Standard histogram. If 4422 \code{relative} is \code{True}, values will be normalised against 4423 the total and thus represent frequencies rather than counts.\\ 4424 4425 \code{create\_bins(data, number\_of\_bins = None)} & Safely create 4426 bins for use with histogram. If \code{data} contains only one point 4427 or is constant, one bin will be created. If \code{number\_of\_bins} 4428 is omitted, 10 bins will be created.\\ \hline 4147 \begin{tabular}{|p{7.4cm} p{8.6cm}|} 4148 \hline 4149 \code{angle(v1, v2=None)} & Angle between two-dimensional vectors 4150 \code{v1} and \code{v2}, or between \code{v1} and the $x$-axis if 4151 \code{v2} is \code{None}. Value is in range $0$ to $2\pi$. \\ 4152 & \\ 4153 \code{normal\_vector(v)} & Normal vector to \code{v}.\\ 4154 & \\ 4155 \code{mean(x)} & Mean value of a vector \code{x}.\\ 4156 & \\ 4157 \code{cov(x, y=None)} & Covariance of vectors \code{x} and \code{y}. 4158 If \code{y} is \code{None}, returns \code{cov(x, x)}.\\ 4159 & \\ 4160 \code{err(x, y=0, n=2, relative=True)} & Relative error of $\parallel$\code{x}$-$\code{y}$\parallel$ 4161 to $\parallel$\code{y}$\parallel$ (2-norm if \code{n} = 2 or 4162 Max norm if \code{n} = \code{None}). If denominator evaluates 4163 to zero or if \code{y} is omitted or if \code{relative=False}, 4164 absolute error is returned.\\ 4165 & \\ 4166 \code{norm(x)} & 2-norm of \code{x}.\\ 4167 & \\ 4168 \code{corr(x, y=None)} & Correlation of \code{x} and \code{y}. If 4169 \code{y} is \code{None} returns autocorrelation of \code{x}.\\ 4170 & \\ 4171 \code{ensure\_numeric(A, typecode=None)} & Returns a numeric array for any sequence \code{A}. If 4172 \code{A} is already a numeric array it will be returned 4173 unaltered. Otherwise, an attempt is made to convert 4174 it to a numeric array. (Needed because \code{array(A)} can 4175 cause memory overflow.)\\ 4176 & \\ 4177 \code{histogram(a, bins, relative=False)} & Standard histogram. If \code{relative} is \code{True}, 4178 values will be normalised against the total and thus 4179 represent frequencies rather than counts.\\ 4180 & \\ 4181 \code{create\_bins(data, number\_of\_bins=None)} & Safely create bins for use with histogram. 4182 If \code{data} contains only one point 4183 or is constant, one bin will be created. 4184 If \code{number\_of\_bins} is omitted, 4185 10 bins will be created.\\ 4186 \hline 4187 \end{tabular} 4188 4429 4189 4430 4190 \section{Finding the Optimal Alpha Value} … … 4433 4193 more to come very soon 4434 4194 4435 \end{tabular} 4436 4195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4437 4196 4438 4197 \chapter{Modules available in \anuga} … … 4443 4202 \label{mod:generalmesh} 4444 4203 4204 4445 4205 \section{\module{abstract\_2d\_finite\_volumes.neighbour\_mesh} } 4446 4206 \declaremodule[neighbourmesh]{}{neighbour\_mesh} 4447 4207 \label{mod:neighbourmesh} 4208 4448 4209 4449 4210 \section{\module{abstract\_2d\_finite\_volumes.domain}} … … 4472 4233 Otherwise check that it is compatible with dimenions of domain. 4473 4234 Otherwise raise an exception 4474 4475 4235 \end{verbatim} 4476 4236 4477 4237 4478 4479 4480 4238 \section{\module{shallow\_water}} 4239 4481 4240 2D triangular domains for finite-volume 4482 4241 computations of the shallow water wave equation. 4483 4242 This module contains a specialisation of class Domain from module domain.py consisting of methods specific to the Shallow Water 4484 4243 Wave Equation 4244 4485 4245 \declaremodule[shallowwater]{}{shallow\_water} 4486 4246 \label{mod:shallowwater} 4487 4247 4488 4489 4490 4491 4248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4492 4249 4493 4250 \chapter{ANUGA Full-scale Validations} 4494 4251 4252 4495 4253 \section{Overview} 4496 There are some long-running validations that are not included in the small-scale validations that run when you execute the \module{validate_all.py} 4497 script in the \module{anuga_validation/automated_validation_test} directory. These validations are not run automatically 4498 since they can take a large amount of time and require an internet connection and user input. 4254 4255 There are some long-running validations that are not included in the small-scale 4256 validations that run when you execute the \module{validate_all.py} 4257 script in the \module{anuga_validation/automated_validation_test} directory. 4258 These validations are not run automatically since they can take a large amount 4259 of time and require an internet connection and user input. 4260 4499 4261 4500 4262 \section{Patong Beach} 4263 4501 4264 The Patong Beach validation is run from the \module{automated_validation_tests/patong_beach_validation} 4502 directory. Just execute the \module{validate_patong.py} script in that directory. This will run a Patong Beach 4503 simulation and compare the generated SWW file with a known good copy of that file. 4504 4505 The script attempts to refresh the validation data files from master copies held on the Sourceforge 4506 project site. If you don't have an internet connection you may still run the validation, as long as you have 4507 the required files. 4508 4509 You may download the validation data files by hand and then run the validation. Just go to the ANUGA Sourceforge 4510 project download page at \module{http://sourceforge.net/project/showfiles.php?group_id=172848} and select the 4511 \module{validation_data} package, \module{patong-1.0} release. You need the \module{data.tgz} file and one or more 4512 of the \module{patong.sww.\{BASIC|TRIAL|FINAL\}.tgz} files. 4513 4514 The BASIC validation is the quickest and the FINAL validation is the slowest. The \module{validate.py} script 4515 will use whatever files you have, BASIC first and FINAL last. 4265 directory. Just execute the \module{validate_patong.py} script in that directory. 4266 This will run a Patong Beach simulation and compare the generated SWW file with a 4267 known good copy of that file. 4268 4269 The script attempts to refresh the validation data files from master copies held 4270 on the Sourceforge project site. If you don't have an internet connection you 4271 may still run the validation, as long as you have the required files. 4272 4273 You may download the validation data files by hand and then run the validation. 4274 Just go to the ANUGA Sourceforge project download page at 4275 \module{http://sourceforge.net/project/showfiles.php?group_id=172848} and select 4276 the \module{validation_data} package, \module{patong-1.0} release. You need the 4277 \module{data.tgz} file and one or more of the \module{patong.sww.\{BASIC|TRIAL|FINAL\}.tgz} 4278 files. 4279 4280 The BASIC validation is the quickest and the FINAL validation is the slowest. 4281 The \module{validate.py} script will use whatever files you have, BASIC first and 4282 FINAL last. 4516 4283 4517 4284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 4519 4286 \chapter{Frequently Asked Questions} 4520 4287 4521 The Frequently Asked Questions have been move to the online FAQ at: 4522 4288 The Frequently Asked Questions have been move to the online FAQ at: \\ 4523 4289 \url{https://datamining.anu.edu.au/anuga/wiki/FrequentlyAskedQuestions} 4524 4290 … … 4528 4294 4529 4295 \begin{tabular}{|lp{10cm}|c|} \hline 4530 %\begin{tabular}{|llll|} \hline 4531 \emph{Term} & \emph{Definition} & \emph{Page}\\ \hline 4532 4533 \indexedbold{\anuga} & Name of software (joint development between ANU and 4534 GA) & \pageref{def:anuga}\\ 4535 4536 \indexedbold{bathymetry} & offshore elevation &\\ 4537 4538 \indexedbold{conserved quantity} & conserved (stage, x and y 4539 momentum) & \\ 4540 4541 % \indexedbold{domain} & The domain of a function is the set of all input values to the 4542 % function.&\\ 4543 4544 \indexedbold{Digital Elevation Model (DEM)} & DEMs are digital files consisting of points of elevations, 4545 sampled systematically at equally spaced intervals.& \\ 4546 4547 \indexedbold{Dirichlet boundary} & A boundary condition imposed on a differential equation 4548 that specifies the values the solution is to take on the boundary of the 4549 domain. & \pageref{def:dirichlet boundary}\\ 4550 4551 \indexedbold{edge} & A triangular cell within the computational mesh can be depicted 4552 as a set of vertices joined by lines (the edges). & \\ 4553 4554 \indexedbold{elevation} & refers to bathymetry and topography &\\ 4555 4556 \indexedbold{evolution} & integration of the shallow water wave equations 4557 over time &\\ 4558 4559 \indexedbold{finite volume method} & The method evaluates the terms in the shallow water 4560 wave equation as fluxes at the surfaces of each finite volume. Because the 4561 flux entering a given volume is identical to that leaving the adjacent volume, 4562 these methods are conservative. Another advantage of the finite volume method is 4563 that it is easily formulated to allow for unstructured meshes. The method is used 4564 in many computational fluid dynamics packages. & \\ 4565 4566 \indexedbold{forcing term} & &\\ 4567 4568 \indexedbold{flux} & the amount of flow through the volume per unit 4569 time & \\ 4570 4571 \indexedbold{grid} & Evenly spaced mesh & \\ 4572 4573 \indexedbold{latitude} & The angular distance on a mericlear north and south of the 4574 equator, expressed in degrees and minutes. & \\ 4575 4576 \indexedbold{longitude} & The angular distance east or west, between the meridian 4577 of a particular place on Earth and that of the Prime Meridian (located in Greenwich, 4578 England) expressed in degrees or time.& \\ 4579 4580 \indexedbold{Manning friction coefficient} & &\\ 4581 4582 \indexedbold{mesh} & Triangulation of domain &\\ 4583 4584 \indexedbold{mesh file} & A TSH or MSH file & \pageref{def:mesh file}\\ 4585 4586 \indexedbold{NetCDF} & &\\ 4587 4588 \indexedbold{node} & A point at which edges meet & \\ 4589 4590 \indexedbold{northing} & A rectangular (x,y) coordinate measurement of distance 4591 north from a north-south reference line, usually a meridian used as the axis of 4592 origin within a map zone or projection. Northing is a UTM (Universal Transverse 4593 Mercator) coordinate. & \\ 4594 4595 4596 \indexedbold{points file} & A PTS or CSV file & \\ \hline 4597 4598 \end{tabular} 4599 4600 \begin{tabular}{|lp{10cm}|c|} \hline 4601 4602 \indexedbold{polygon} & A sequence of points in the plane. \anuga represents a polygon 4603 either as a list consisting of Python tuples or lists of length 2 or as an $N \times 2$ 4604 Numeric array, where $N$ is the number of points. 4605 4606 The unit square, for example, would be represented either as 4607 \code{[ [0,0], [1,0], [1,1], [0,1] ]} or as \code{array( [0,0], [1,0], [1,1], 4608 [0,1] )}. 4609 4610 NOTE: For details refer to the module \module{utilities/polygon.py}. & 4611 \\ \indexedbold{resolution} & The maximal area of a triangular cell in a 4612 mesh & \\ 4613 4614 4615 \indexedbold{reflective boundary} & Models a solid wall. Returns same conserved 4616 quantities as those present in the neighbouring volume but reflected. Specific to the 4617 shallow water equation as it works with the momentum quantities assumed to be the 4618 second and third conserved quantities. & \pageref{def:reflective boundary}\\ 4619 4620 \indexedbold{stage} & &\\ 4621 4622 % \indexedbold{try this} 4623 4624 \indexedbold{animate} & visualisation tool used with \anuga & 4625 \pageref{sec:animate}\\ 4626 4627 \indexedbold{time boundary} & Returns values for the conserved 4628 quantities as a function of time. The user must specify 4629 the domain to get access to the model time. & \pageref{def:time boundary}\\ 4630 4631 \indexedbold{topography} & onshore elevation &\\ 4632 4633 \indexedbold{transmissive boundary} & & \pageref{def:transmissive boundary}\\ 4634 4635 \indexedbold{vertex} & A point at which edges meet. & \\ 4636 4637 \indexedbold{xmomentum} & conserved quantity (note, two-dimensional SWW equations say 4638 only \code{x} and \code{y} and NOT \code{z}) &\\ 4639 4640 \indexedbold{ymomentum} & conserved quantity & \\ \hline 4641 4642 \end{tabular} 4643 4296 \emph{Term} & \emph{Definition} & \emph{Page}\\ 4297 \hline 4298 \indexedbold{\anuga} & Name of software (joint development between ANU and GA) & \pageref{def:anuga}\\ 4299 \indexedbold{bathymetry} & offshore elevation & \\ 4300 \indexedbold{conserved quantity} & conserved (stage, x and y momentum) & \\ 4301 % \indexedbold{domain} & The domain of a function is the set of all input values to the function.& \\ 4302 \indexedbold{Digital Elevation Model (DEM)} & DEMs are digital files consisting of points of elevations, 4303 sampled systematically at equally spaced intervals.& \\ 4304 \indexedbold{Dirichlet boundary} & A boundary condition imposed on a differential equation that specifies 4305 the values the solution is to take on the boundary of the domain. 4306 & \pageref{def:dirichlet boundary}\\ 4307 \indexedbold{edge} & A triangular cell within the computational mesh can be depicted 4308 as a set of vertices joined by lines (the edges). & \\ 4309 \indexedbold{elevation} & refers to bathymetry and topography & \\ 4310 \indexedbold{evolution} & integration of the shallow water wave equations over time & \\ 4311 \indexedbold{finite volume method} & The method evaluates the terms in the shallow water wave equation as 4312 fluxes at the surfaces of each finite volume. Because the flux entering 4313 a given volume is identical to that leaving the adjacent volume, these 4314 methods are conservative. Another advantage of the finite volume method is 4315 that it is easily formulated to allow for unstructured meshes. The method 4316 is used in many computational fluid dynamics packages. & \\ 4317 \indexedbold{forcing term} & &\\ 4318 \indexedbold{flux} & the amount of flow through the volume per unit time & \\ 4319 \indexedbold{grid} & Evenly spaced mesh & \\ 4320 \indexedbold{latitude} & The angular distance on a mericlear north and south of the equator, expressed in degrees and minutes. & \\ 4321 \indexedbold{longitude} & The angular distance east or west, between the meridian of a particular place on Earth 4322 and that of the Prime Meridian (located in Greenwich, England) expressed in degrees or time.& \\ 4323 \indexedbold{Manning friction coefficient} & &\\ 4324 \indexedbold{mesh} & Triangulation of domain &\\ 4325 \indexedbold{mesh file} & A TSH or MSH file & \pageref{def:mesh file}\\ 4326 \indexedbold{NetCDF} & &\\ 4327 \indexedbold{node} & A point at which edges meet & \\ 4328 \indexedbold{northing} & A rectangular (x,y) coordinate measurement of distance north from a north-south 4329 reference line, usually a meridian used as the axis of origin within a map zone 4330 or projection. Northing is a UTM (Universal Transverse Mercator) coordinate. & \\ 4331 \indexedbold{points file} & A PTS or CSV file & \\ 4332 \hline 4333 \end{tabular} 4334 4335 \begin{tabular}{|lp{10cm}|c|} 4336 \hline 4337 \indexedbold{polygon} & A sequence of points in the plane. \anuga represents a polygon either as a list 4338 consisting of Python tuples or lists of length 2 or as an $N \times 2$ numeric array, 4339 where $N$ is the number of points. 4340 4341 The unit square, for example, would be represented either as \code{[ [0,0], [1,0], [1,1], [0,1] ]} 4342 or as \code{array( [0,0], [1,0], [1,1], [0,1] )}. 4343 4344 NOTE: For details refer to the module \module{utilities/polygon.py}. & \\ 4345 \indexedbold{resolution} & The maximal area of a triangular cell in a mesh & \\ 4346 \indexedbold{reflective boundary} & Models a solid wall. Returns same conserved quantities as those present in the 4347 neighbouring volume but reflected. Specific to the shallow water equation as 4348 it works with the momentum quantities assumed to be the second and third 4349 conserved quantities. & \pageref{def:reflective boundary}\\ 4350 \indexedbold{stage} & &\\ 4351 % \indexedbold{try this} 4352 \indexedbold{animate} & visualisation tool used with \anuga & \pageref{sec:animate}\\ 4353 \indexedbold{time boundary} & Returns values for the conserved quantities as a function of time. 4354 The user must specify the domain to get access to the model time. 4355 & \pageref{def:time boundary}\\ 4356 \indexedbold{topography} & onshore elevation &\\ 4357 \indexedbold{transmissive boundary} & & \pageref{def:transmissive boundary}\\ 4358 \indexedbold{vertex} & A point at which edges meet. & \\ 4359 \indexedbold{xmomentum} & conserved quantity (note, two-dimensional SWW equations say only 4360 \code{x} and \code{y} and NOT \code{z}) &\\ 4361 \indexedbold{ymomentum} & conserved quantity & \\ 4362 \hline 4363 \end{tabular} 4644 4364 4645 4365 %The \code{\e appendix} markup need not be repeated for additional 4646 4366 %appendices. 4647 4648 4367 4649 4368 % … … 4667 4386 4668 4387 4669 4670 4388 \begin{thebibliography}{99} 4389 %\begin{thebibliography} 4671 4390 \bibitem[nielsen2005]{nielsen2005} 4672 4391 {\it Hydrodynamic modelling of coastal inundation}. … … 4700 4419 \newblock A.~Kurganov, S.~Noelle, and G.~Petrova. 4701 4420 \newblock {\em SIAM Journal of Scientific Computing}, 23(3):707--740, 2001. 4702 \end{thebibliography}{99} 4421 \end{thebibliography} 4422 % \end{thebibliography}{99} 4703 4423 4704 4424 \end{document} -
anuga_core/documentation/user_manual/copyright.tex
r5566 r7064 21 21 Copyright \copyright 2004, 2005, 2006 Australian National University and Geoscience Australia. All rights reserved. 22 22 23 24 23 Permission to use, copy, modify, and distribute this software for any 25 24 purpose without fee is hereby granted under the terms of the GNU … … 41 40 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 42 41 43 44 45 42 This work was produced at Geoscience Australia and the Australian 46 43 National University funded by the Commonwealth of Australia. Neither … … 61 58 endorsement purposes. 62 59 63 64 60 This document does not convey a warranty, express or implied, 65 61 of merchantability or fitness for a particular purpose. 66 62 67 68 63 \begin{center} 69 70 64 %\vspace{0.5in} 71 65 \anuga 72 66 73 67 Manual typeset with \LaTeX 74 75 68 \end{center} 76 69 77 70 \vspace{0.5in} 78 71 79 72 \textbf{Credits}: … … 84 77 \end{itemize} 85 78 86 87 88 79 \textbf{License}: 89 80 \begin{itemize} … … 91 82 \end{itemize} 92 83 93 94 84 \pagebreak 95 85 \textbf{Acknowledgments}: 96 86 \begin{itemize} 97 \item John Jakeman, Rudy van Drie, Ted Rigby, Joaquim Luis, Nils Goseberg, William Power, Petar Milevski, Trevor Dhu, Linda Stals, Matt Hardy, Jack Kelly and Christopher Zoppou who contributed to this project at various times. 87 \item John Jakeman, Rudy van Drie, Ted Rigby, Joaquim Luis, Nils Goseberg, William Power, 88 Petar Milevski, Trevor Dhu, Linda Stals, Matt Hardy, Jack Kelly and Christopher 89 Zoppou who contributed to this project at various times. 98 90 \item A stand alone visualiser (anuga\_viewer) based on Open-scene-graph was developed by Darran Edmundson. 99 \item The mesh generator engine was written by Jonathan Richard Shewchuk and made freely available under the following license. 100 See source code \code{triangle.c} for more details on the origins of this code. The license reads 91 \item The mesh generator engine was written by Jonathan Richard Shewchuk and made freely 92 available under the following license. See source code \code{triangle.c} for more 93 details on the origins of this code. The license reads 101 94 102 {\tiny\begin{verbatim}95 \begin{verbatim} 103 96 /*****************************************************************************/ 104 97 /* */ … … 137 130 /* free, then you are not required to make any arrangement with me.) */ 138 131 /*****************************************************************************/ 139 \end{verbatim} }132 \end{verbatim} 140 133 134 \pagebreak 141 135 \item Pmw is a toolkit for building high-level compound widgets in 142 136 Python using the Tkinter module. Parts of Pmw have been encorpoated 143 137 into the graphical mesh generator. The license for Pmw reads 144 138 145 {\tiny\begin{verbatim}139 \begin{verbatim} 146 140 """ 147 141 Pmw copyright … … 170 164 171 165 """ 172 \end{verbatim} }166 \end{verbatim} 173 167 \end{itemize} -
anuga_core/documentation/user_manual/demos/cairns/ExportResults.py
r5408 r7064 1 import project,os1 import os 2 2 import sys 3 import project 3 4 4 5 from anuga.shallow_water.data_manager import sww2dem … … 7 8 8 9 scenario = 'slide' 9 #scenario = 'fixed_wave'10 10 11 11 name = scenario + sep + scenario + 'source' … … 13 13 print 'output dir:', name 14 14 which_var = 4 15 if which_var == 0: # Stage 15 16 if which_var == 0: # Stage 16 17 outname = name + '_stage' 17 18 quantityname = 'stage' 18 19 19 if which_var == 1: # Absolute Momentum20 if which_var == 1: # Absolute Momentum 20 21 outname = name + '_momentum' 21 quantityname = '(xmomentum**2 + ymomentum**2)**0.5' #Absolute momentum22 quantityname = '(xmomentum**2 + ymomentum**2)**0.5' #Absolute momentum 22 23 23 if which_var == 2: # Depth24 if which_var == 2: # Depth 24 25 outname = name + '_depth' 25 26 quantityname = 'stage-elevation' #Depth 26 27 27 if which_var == 3: # Speed28 if which_var == 3: # Speed 28 29 outname = name + '_speed' 29 30 quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-30)' #Speed 30 31 31 if which_var == 4: # Elevation32 if which_var == 4: # Elevation 32 33 outname = name + '_elevation' 33 34 quantityname = 'elevation' #Elevation … … 35 36 print 'start sww2dem' 36 37 37 sww2dem(name, basename_out = outname,38 quantity = quantityname,39 cellsize = 100,40 easting_min = project.eastingmin,41 easting_max = project.eastingmax,42 northing_min = project.northingmin,43 northing_max = project.northingmax,44 reduction = max,45 verbose = True,46 format = 'ers')47 38 sww2dem(name, 39 basename_out=outname, 40 quantity=quantityname, 41 cellsize=100, 42 easting_min=project.eastingmin, 43 easting_max=project.eastingmax, 44 northing_min=project.northingmin, 45 northing_max=project.northingmax, 46 reduction=max, 47 verbose=True, 48 format='ers') -
anuga_core/documentation/user_manual/demos/cairns/GetTimeseries.py
r4966 r7064 7 7 8 8 Note, this script will only work if pylab is installed on the platform 9 10 9 """ 11 10 … … 16 15 sww2csv_gauges('slide'+sep+'slidesource.sww', 17 16 project.gauge_filename, 18 quantities =['stage','speed','depth','elevation'],17 quantities=['stage','speed','depth','elevation'], 19 18 verbose=True) 20 19 21 20 sww2csv_gauges('fixed_wave'+sep+'fixed_wavesource.sww', 22 21 project.gauge_filename, 23 quantities =['stage', 'speed','depth','elevation'],22 quantities=['stage', 'speed','depth','elevation'], 24 23 verbose=True) 25 24 26 25 try: 27 26 import pylab 28 csv2timeseries_graphs(directories_dic={'slide'+sep: ['Slide',0, 0],29 'fixed_wave'+sep: ['Fixed Wave',0,0]},30 31 32 33 34 35 36 37 27 csv2timeseries_graphs(directories_dic={'slide'+sep: ['Slide',0, 0], 28 'fixed_wave'+sep: ['Fixed Wave',0,0]}, 29 output_dir='fixed_wave'+sep, 30 base_name='gauge_', 31 plot_numbers='', 32 quantities=['stage','speed','depth'], 33 extra_plot_name='', 34 assess_all_csv_files=True, 35 create_latex=False, 36 verbose=True) 38 37 except ImportError: 39 38 #ANUGA does not rely on pylab to work 40 39 print 'must have pylab installed to generate plots' 41 42 -
anuga_core/documentation/user_manual/demos/cairns/project.py
r6889 r7064 1 """Common filenames and locations for topographic data, meshes and outputs. 2 """ 1 """Common filenames and locations for topographic data, meshes and outputs.""" 3 2 4 3 from anuga.utilities.polygon import read_polygon, plot_polygons, \ 5 4 polygon_area, is_inside_polygon 6 5 7 8 6 #------------------------------------------------------------------------------ 9 7 # Define scenario as either slide or fixed_wave. 10 8 #------------------------------------------------------------------------------ 11 #scenario = 'slide'12 9 scenario = 'fixed_wave' 13 14 10 #scenario = 'slide' 11 15 12 #------------------------------------------------------------------------------ 16 13 # Filenames 17 14 #------------------------------------------------------------------------------ 18 demname = 'cairns' 15 demname = 'cairns' 19 16 meshname = demname + '.msh' 20 17 21 18 # Filename for locations where timeseries are to be produced 22 19 gauge_filename = 'gauges.csv' 23 24 20 25 21 #------------------------------------------------------------------------------ 26 22 # Domain definitions 27 23 #------------------------------------------------------------------------------ 28 29 24 # bounding polygon for study area 30 25 bounding_polygon = read_polygon('extent.csv') 31 26 32 A = polygon_area(bounding_polygon) /1000000.027 A = polygon_area(bounding_polygon) / 1000000.0 33 28 print 'Area of bounding polygon = %.2f km^2' % A 34 35 29 36 30 #------------------------------------------------------------------------------ 37 31 # Interior region definitions 38 32 #------------------------------------------------------------------------------ 39 40 33 # Read interior polygons 41 34 poly_cairns = read_polygon('cairns.csv') … … 47 40 48 41 # Optionally plot points making up these polygons 49 #plot_polygons([bounding_polygon,poly_cairns,poly_island0,poly_island1,\ 50 # poly_island2,poly_island3,poly_shallow],\ 51 # style='boundingpoly',verbose=False) 52 53 42 #plot_polygons([bounding_polygon, poly_cairns, poly_island0, poly_island1, 43 # poly_island2, poly_island3, poly_shallow], 44 # style='boundingpoly', verbose=False) 54 45 55 46 # Define resolutions (max area per triangle) for each polygon 56 default_res = 10000000 # Background resolution47 default_res = 10000000 # Background resolution 57 48 islands_res = 100000 58 49 cairns_res = 100000 … … 60 51 61 52 # Define list of interior regions with associated resolutions 62 interior_regions = [[poly_cairns, cairns_res],53 interior_regions = [[poly_cairns, cairns_res], 63 54 [poly_island0, islands_res], 64 55 [poly_island1, islands_res], … … 66 57 [poly_island3, islands_res], 67 58 [poly_shallow, shallow_res]] 68 69 70 59 71 60 #------------------------------------------------------------------------------ … … 80 69 # Data for landslide 81 70 #------------------------------------------------------------------------------ 82 slide_origin = [451871, 8128376] # Assume to be on continental shelf71 slide_origin = [451871, 8128376] # Assume to be on continental shelf 83 72 slide_depth = 500. 84 85 86 87 88 -
anuga_core/documentation/user_manual/demos/cairns/runcairns.py
r6889 r7064 15 15 # Import necessary modules 16 16 #------------------------------------------------------------------------------ 17 18 17 # Standard modules 19 18 import os … … 37 36 import project # Definition of file names and polygons 38 37 39 40 38 #------------------------------------------------------------------------------ 41 39 # Preparation of topographic data 42 40 # Convert ASC 2 DEM 2 PTS using source data and store result in source data 43 41 #------------------------------------------------------------------------------ 44 45 42 # Create DEM from asc data 46 43 convert_dem_from_ascii2netcdf(project.demname, use_cache=True, verbose=True) … … 49 46 dem2pts(project.demname, use_cache=True, verbose=True) 50 47 51 52 48 #------------------------------------------------------------------------------ 53 49 # Create the triangular mesh and domain based on … … 55 51 # boundary and interior regions as defined in project.py 56 52 #------------------------------------------------------------------------------ 57 58 53 domain = create_domain_from_regions(project.bounding_polygon, 59 54 boundary_tags={'top': [0], … … 67 62 verbose=True) 68 63 69 70 64 # Print some stats about mesh and domain 71 65 print 'Number of triangles = ', len(domain) … … 76 70 # Setup parameters of computational domain 77 71 #------------------------------------------------------------------------------ 78 79 80 72 domain.set_name('cairns_' + project.scenario) # Name of sww file 81 73 domain.set_datadir('.') # Store sww output here 82 74 domain.set_minimum_storable_height(0.01) # Store only depth > 1cm 83 75 84 85 76 #------------------------------------------------------------------------------ 86 77 # Setup initial conditions 87 78 #------------------------------------------------------------------------------ 88 89 79 tide = 0.0 90 80 domain.set_quantity('stage', tide) … … 96 86 alpha=0.1) 97 87 98 99 88 #------------------------------------------------------------------------------ 100 89 # Setup information for slide scenario (to be applied 1 min into simulation 101 90 #------------------------------------------------------------------------------ 102 103 91 if project.scenario == 'slide': 104 92 # Function for submarine slide … … 113 101 verbose=True) 114 102 115 116 103 #------------------------------------------------------------------------------ 117 104 # Setup boundary conditions 118 105 #------------------------------------------------------------------------------ 119 120 106 print 'Available boundary tags', domain.get_boundary_tags() 121 122 107 123 108 Bd = Dirichlet_boundary([tide,0,0]) # Mean water level 124 109 Bs = Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary 125 126 110 127 111 if project.scenario == 'fixed_wave': … … 129 113 Bw = Time_boundary(domain=domain, 130 114 function=lambda t: [(60<t<3660)*50, 0, 0]) 131 132 115 domain.set_boundary({'ocean_east': Bw, 133 116 'bottom': Bs, … … 141 124 'onshore': Bd, 142 125 'top': Bd}) 143 144 126 145 127 #------------------------------------------------------------------------------ 146 128 # Evolve system through time 147 129 #------------------------------------------------------------------------------ 148 149 130 import time 150 131 t0 = time.time() … … 154 135 155 136 if project.scenario == 'slide': 156 157 137 for t in domain.evolve(yieldstep=10, finaltime=60): 158 138 print domain.timestepping_statistics() … … 171 151 print domain.boundary_statistics(tags='ocean_east') 172 152 173 174 153 if project.scenario == 'fixed_wave': 175 176 154 # Save every two mins leading up to wave approaching land 177 155 for t in domain.evolve(yieldstep=120, finaltime=5000): -
anuga_core/documentation/user_manual/demos/channel1.py
r5173 r7064 12 12 from anuga.shallow_water import Dirichlet_boundary 13 13 14 15 14 #------------------------------------------------------------------------------ 16 15 # Setup computational domain … … 21 20 domain = Domain(points, vertices, boundary) # Create domain 22 21 domain.set_name('channel1') # Output name 23 24 22 25 23 #------------------------------------------------------------------------------ … … 34 32 expression='elevation + 0.0') 35 33 36 37 34 #------------------------------------------------------------------------------ 38 35 # Setup boundary conditions … … 43 40 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 44 41 45 46 42 #------------------------------------------------------------------------------ 47 43 # Evolve system through time 48 44 #------------------------------------------------------------------------------ 49 for t in domain.evolve(yieldstep = 0.2, finaltime =40.0):45 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 50 46 print domain.timestepping_statistics() 51 52 -
anuga_core/documentation/user_manual/demos/channel2.py
r6889 r7064 13 13 from anuga.shallow_water import Time_boundary 14 14 15 16 15 #------------------------------------------------------------------------------ 17 16 # Setup computational domain … … 26 25 domain.set_name('channel2') # Output name 27 26 28 29 27 #------------------------------------------------------------------------------ 30 28 # Setup initial conditions