# Changeset 4128

Ignore:
Timestamp:
Dec 31, 2006, 1:50:19 PM (17 years ago)
Message:

Changed to code a few python commands

File:
1 edited

### Legend:

Unmodified
 r4124 communities.  Geoscience Australia and the Australian National University have developed a hydrodynamic inundation modelling tool called \AnuGA{} to help simulate the impact of these hazards. called \AnuGA{} to help simulate the impact of these hazards. The core of \AnuGA{} is a \Python{} implementation of a finite-volume method for solving the conservative form of the Shallow Water Wave equation. The flux $\HH_{ij}$ is evaluated using a numerical flux function $\HH(\cdot, \cdot ; \ \cdot)$ which is consistent with the shallow water flux in the sense that for all vectors $\UU$ and $\nn$ water flux in the sense that for all conservation vectors $\UU$ and normal vectors $\nn$ $$H(\UU,\UU;\ \nn) = \EE(\UU) n_1 + \GG(\UU) n_2 . Then$$ \HH_{ij}  = \HH(\overline{\UU}_i(m_{ij})), \overline{\UU}_i(m_{ij})), \mathbf{n}_{ij}) \HH_{ij}  = \HH(\UU_i(m_{ij}), \UU_j(m_{ij}); \mathbf{n}_{ij})  where $m_{ij}$ is the midpoint of the \textit{ij}th edge and $\mathbf{n}_{ij}$ is the outward pointing normal on the \textit{ij}th edge. The function $\overline{\UU}_i(x)$ for $x \in T_i$ is obtained from the average values, $\UU_i$, of the $i$th and $\mathbf{n}_{ij}$ is the outward pointing normal, with respect to the $i$th cell, on the \textit{ij}th edge. The function $\UU_i(x)$ for $x \in T_i$ is obtained from the vector $\UU_k$ of conserved average values for the $i$th and neighbouring  cells. \label{sec:software} \AnuGA{} is mostly written in the object-oriented programming language \Python{} with computationally intensive parts implemented as highly optimised shared objects written in C. \AnuGA{} is mostly written in the object-oriented programming language \Python{} with computationally intensive parts implemented as highly optimised shared objects written in C. \Python{} is known for its clarity, elegance, efficiency and changing requirements throughout its lifetime. The fundamental object in \AnuGA{} is the \code{Domain} which inherits functionality from a hierarchy of increasingly specialised classes starting with a basic structural Mesh to classes implementing the finite-volume scheme described in section \ref{sec:fvm}. Other classes are \code{Quantity} which represents values of one variable across the mesh along with their associated operations, \code{Geospatial_data} which represents georeferenced elevation data and a collection of \code{Boundary} classes which allows for a 'pluggable' way of driving the model. The conserved quantities updated automatically by the numerical scheme are stage (water level) $w$, $x$-momentum $uh$ and $y$-momentum $vh$. The quanitites elevation $z$ and friction $\eta$ are quantities that are not updated automaticall but can be changed explicitly during run-time if the user wishes to do so. To set up a scenario the user specifies the study area along with any internal regions where increased mesh resolution is required. External edges may be labelled using symbolic tags which are subsequently used to bind boundary condition objects to tagged segments of the mesh boundary. The mesh is then generated using \AnuGA{}'s built-in mesh generator and converted into the \code{Domain} object which provides all methods used to The fundamental object in \AnuGA{} is the \code{Domain} which inherits functionality from a hierarchy of increasingly specialised classes starting with a basic structural Mesh to classes implementing the finite-volume scheme described in section \ref{sec:fvm}. Other classes are \code{Quantity} which represents values of one variable across the mesh along with their associated operations, \code{Geospatial_data} which represents georeferenced elevation data and a collection of \code{Boundary} classes which allows for a 'pluggable' way of driving the model. The conserved quantities updated automatically by the numerical scheme are stage (water level) $w$, $x$-momentum $uh$ and $y$-momentum $vh$. The quanitites elevation $z$ and friction $\eta$ are quantities that are not updated automatically but can be changed explicitly during run-time if the user wishes to do so. To set up a scenario the user specifies the study area along with any internal regions where increased mesh resolution is required. External edges may be labelled using symbolic tags which are subsequently used to bind boundary condition objects to tagged segments of the mesh boundary. The mesh is then generated using \AnuGA{}'s built-in mesh generator and converted into the \code{Domain} object which provides all methods used to setup and run the flow simulation. Figure \ref{fig:anuga mesh} shows an example of a mesh generated by \AnuGA{}. \begin{figure} \includegraphics[width=4in,keepaspectratio=true]{tsunami-fig-1} \caption{Triangular mesh used in our finite volume method. Conserved quantities $h$, $uh$ and $vh$ are associated with each triangular cell.} quantities $h$, $uh$ and $vh$ are associated with each triangular cell.} \label{fig:anuga mesh} \end{center} one of the following forms: \begin{itemize} \item A constant value as in domain.set_quantity('stage', 1) which \begin{itemize} \item A constant value as in \code{domain.set_quantity('stage', 1)} which will set the initial water level to 1 m everywhere. \item Another quantity or a linear combination of quantities.  If q1 and q2 are two arbitrary quantities defined within the same domain, the expression set_quantity('stage', q1*(3*q2 + 5)) will set the stage \item Another quantity or a linear combination of quantities.  If \code{q1} and \code{q2} are two arbitrary quantities defined within the same domain, the expression \code{domain.set_quantity('stage', q1*(3*q2 + 5))} will set the stage quantity accordingly.  One common application of this would be to assign the stage as a constant depth above the bed elevation. \item An arbitrary function (or a callable object), f(x, y), where x and y are assumed to be vectors. The quantity will be assigned values by evaluating f at each location within the mesh. \item An arbitrary function (or a callable object), \code{f(x, y)}, where \code{x} and \code{y} are assumed to be vectors. The quantity will be assigned values by evaluating \code{f} at each location within the mesh. \item An arbitrary set of points and associated values (wrapped into a Geospatial_data object). The points need not coincide with triangle \item A Numerical Python array (or a list of numbers) ordered according to the internal data structure. \end{itemize} The parameter location determines whether the values should be assigned to triangle edge midpoints or vertices and region allows the \end{itemize} The parameter \code{location} determines whether the values should be assigned to triangle edge, midpoints or vertices and \code{region} allows the operation to be restricted to a region specified by a symbolic tag or a set of indices. a set of indices. Boundary conditions are bound to symbolic tags through the method \code{domain.set_boundary} which takes as input a lookup table (implemented as a Python dictionary) of the form \code{\{tag:~boundary_object\}}. as a Python dictionary) of the form \code{\{tag:~boundary_object\}}. The boundary objects are all assumed to be callable functions of vectors x and y.  Several predefined standard boundary objects are available and boundaries. Forcing terms can be written according to a fixed protocol and added to the model using the idiom \code{domain.forcing_terms.append(F)} where F is Forcing terms can be written according to a fixed protocol and added to the model using the idiom \code{domain.forcing_terms.append(F)} where \code{F} is assumed to be a user-defined callable object. large speeds and small triangles, time steps can become very small. In order to access the state of the simulation at regular time intervals, \AnuGA{} uses the method evolve: \begin{verbatim} For t in domain.evolve(yieldstep, duration): intervals, \AnuGA{} uses the method evolve: \begin{verbatim} For t in domain.evolve(yieldstep, duration): \end{verbatim} \end{verbatim} The parameter \code{duration} specifies the time period over which evolve operates, and control is passed to the body of the for-loop at Python generator hence the reference to 'yield' in the parameter name. Figure \ref{fig:beach runup} shows a simulation of water flowing onto a hypothetical beach with obstacles. Figure \ref{fig:beach runup} shows a simulation of water flowing onto a hypothetical beach with obstacles. A number of complex patterns are captured in this example including a shock where water reflected off the wall far (at the right hand side) meets the main flow. Other physical features are the standing waves and interference patterns. See the \AnuGA{} User Manual at \url{http://sourceforge.net/projects/anuga} for more details and examples. \section{Conclusions} \label{sec:6} \label{sec:6} \AnuGA{} is a flexible and robust modelling system that simulates hydrodynamics by solving the shallow water wave \AnuGA{} can take as input bathymetric and topographic datasets and simulate the behaviour of riverine flooding, storm surge, tsunami or even dam breaks. tsunami or even dam breaks. Initial validation using wave tank data supports \AnuGA{}'s ability to model complex scenarios. Further validation will be understand the potential impact from natural hazards in order to reduce their impact on Australian communities (see \cite{Nielsen2006}). The \AnuGA{} source code is available The \AnuGA{} source code is available at \url{http://sourceforge.net/projects/anuga}.