# Changeset 2637

Ignore:
Timestamp:
Mar 30, 2006, 8:20:39 PM (17 years ago)
Message:

File:
1 edited

### Legend:

Unmodified
 r2631 The present example represents a simple scenario and does not include any forcing terms, nor is the data taken from a file as it would be in many typical cases. would be in many typical cases. The conserved quantities involved in the problem are water depth, $x$-momentum and $y$-momentum. Other quantities involved in the computation are the friction, stage (absolute height of water surface) involved in the computation are the friction, stage (absolute height of water surface) and elevation, the last two being related to the depth through the equation \begin{tabular}{rcrcl} \begin{tabular}{rcrcl} \code{stage} &=& \code{elevation} &+& \code{depth} \end{tabular} \end{tabular} The stage (the height of the water surface) is related to the elevation and the depth at any time by the equation elevation and the depth at any time by the equation {\small \begin{verbatim} stage = elevation + depth \end{verbatim}} \end{verbatim}} For this example, we simply assign a constant value to \code{stage}, \end{verbatim}} which specifies that the surface level is set to a height of $-0.4$, i.e. 0.4 units which specifies that the surface level is set to a height of $-0.4$, i.e. 0.4 units below the zero level. involving other quantities. Suppose, instead of setting a constant value for the stage, we wished to specify a constant value for the \emph{depth}. For such a case we to specify a constant value for the \emph{depth}. For such a case we need to specify that \code{stage} is everywhere obtained by adding that value to the value already \end{verbatim}} That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus the That is, the value of \code{stage} is set to $\code{h} = 0.05$ plus the value of \code{elevation} already defined. The reader will probably appreciate that this capability to incorporate The reader will probably appreciate that this capability to incorporate expressions into statements using \code{set\_quantity} greatly expands its power.) \item[Dirichlet boundary]Specifies a fixed value at the boundary and assigns initial values to the $x$-momentum and $y$-momentum. boundary and assigns initial values to the $x$-momentum and $y$-momentum. \item[Time boundary.]A Dirichlet boundary whose behaviour varies with time. The reader may wish to experiment by varying the choice of boundary types for one or more of the boundaries. In the case of \code{Bd} and \code{Bw}, the three arguments in each case represent the for one or more of the boundaries. In the case of \code{Bd} and \code{Bw}, the three arguments in each case represent the {\small \begin{verbatim} \begin{figure}[hbt] \begin{figure}[hbt] %  \centerline{ \includegraphics[width=75mm, height=75mm]{examples/bedslopestart.eps}} \caption{Bedslope example viewed with Swollen} \label{fig:bedslopestart} \end{figure} \begin{figure}[hbt] \centerline{ \end{figure} \begin{figure}[hbt] \centerline{ %    \includegraphics[width=75mm, height=75mm]{examples/bedslopeduring.eps} %    \includegraphics[width=75mm, height=75mm]{examples/bedslopeend.eps} } } \caption{Bedslope example viewed with Swollen} \label{fig:bedslope2} \end{figure} \end{figure} scenario, rather than the artificial illustrative one used in \code{bedslopephysical.py}. The domain of interest surrounds the Sydney region, and predominantly covers Sydney Harbour. A hypothetical tsunami wave is and predominantly covers Sydney Harbour. A hypothetical tsunami wave is generated by a submarine mass failure situated on the edge of the continental shelf. area of a triangle used for triangulation---and mesh points are created inside the polygon through a random process. Figure \ref{fig:pentagon} shows a simple example of this, in which \ref{fig:pentagon} shows a simple example of this, in which the triangulation is carried out within a pentagon. \begin{figure}[hbt] \begin{figure}[hbt] \caption{Mesh points are created inside the polygon} \label{fig:pentagon} \end{figure} \label{fig:pentagon} \end{figure} Boundary tags are not restricted to \code{left'}, \code{right'}, resolution. See Figure \ref{fig:interior meshes}. \begin{figure}[hbt] \begin{figure}[hbt] \caption{Interior meshes with individual resolution} \label{fig:interior meshes} \end{figure} \label{fig:interior meshes} \end{figure} In its general form, \code{pmesh} takes for its input a bounding \code{meshname}. The statements The statements {\small \begin{verbatim} are used to read in the specific polygons \code{project.harbour\_polygon\_2} and \code{botanybay\_polygon\_2} from \code{project.py} and assign a common resolution of 5000 to each. The statement common resolution of 5000 to each. The statement {\small \begin{verbatim} create_mesh_from_regions(project.diffpolygonall,% boundary_tags= {'bottom': [0],% boundary_tags= {'bottom': [0],% 'right1': [1],% 'right0': [2],% 'left3': [7]},% maximum_triangle_area=100000,% filename=meshname,% filename=meshname,% interior_regions=interior_regions) \end{verbatim}} is then used to create the mesh, taking the bounding polygon to be the polygon \code{diffpolygonall} specified in \code{project.py}. The argument \code{boundary\_tags} assigns a dictionary, whose keys are the names of the boundary tags used for the bounding polygon---\code{bottom'}, right0', right1', right2', top', left1', left2' and left3'--- \code{diffpolygonall} specified in \code{project.py}. The argument \code{boundary\_tags} assigns a dictionary, whose keys are the names of the boundary tags used for the bounding polygon---\code{bottom'}, right0', right1', right2', top', left1', left2' and left3'--- and whose values identify the indices of the segments associated with each of these tags. (The value associated with each boundary tag is a one-element list.) taken from \code{project.py}. {\small \begin{verbatim} {\small \begin{verbatim} domain.set_name(project.basename)% domain.set_datadir(project.outputdir)% \code{slump\_tsunami}. This is similar to how we set elevation in \code{bedslopephysical.py} using a function---however, in this case the function is both more complex and more interesting. The function returns the water displacement for all \code{x} and \code{y} in the domain. The water displacement is a ?? function that depends function is both more complex and more interesting. The function returns the water displacement for all \code{x} and \code{y} in the domain. The water displacement is a ?? function that depends on the characteristics of the slump (length, thickness, slope, etc), its location (origin) and the depth at that location. location (origin) and the depth at that location. The elevation is specified by reading data from a file: {\small \begin{verbatim}% domain.set_quantity('elevation',% filename = project.combineddemname + '.pts',% use_cache = True,% verbose = True)% {\small \begin{verbatim} domain.set_quantity('elevation', filename = project.combineddemname + '.pts', use_cache = True, verbose = True) \end{verbatim}} \subsection{Boundary Conditions} Setting boundaries follows a similar pattern to the one used for \code{bedslopephysical.py}, except that in this case we need to associate a Setting boundaries follows a similar pattern to the one used for \code{bedslopephysical.py}, except that in this case we need to associate a boundary type with each of the boundary tag names introduced when we established the mesh. In place of the four boundary types introduced for \code{bedslopephysical.py}, we use the reflective boundary tag names introduced when we established the mesh. In place of the four boundary types introduced for \code{bedslopephysical.py}, we use the reflective boundary for each of the eight tagged segments: {\small \begin{verbatim} import time t0 = time.time() for t in domain.evolve(yieldstep = 120, duration = 18000): print domain.timestepping_statistics() print domain.boundary_statistics(tags = 'bottom') print 'That took %.2f seconds' %(time.time() \end{verbatim}} % Translate following into layman's language This function is used to create a triangular mesh suitable for use with \anuga, within a specified region. The region is specified as the interior of a polygon (the \emph{bounding polygon}). The user specifies the bounding polygon and the \emph{resolution}---that is, maximal area of any triangle in the mesh. There is This function is used to create a triangular mesh suitable for use with \anuga, within a specified region. The region is specified as the interior of a polygon (the \emph{bounding polygon}). The user specifies the bounding polygon and the \emph{resolution}---that is, maximal area of any triangle in the mesh. There is also an option to specify a number of internal polygons within each of which a separate mesh is created, generally with a smaller resolution. Additionally, the user specifies a list of boundary tags, one for each edge of the bounding polygon. the user specifies a list of boundary tags, one for each edge of the bounding polygon. \end{funcdesc} Module: \code{pyvolution.pmesh2domain} Once the initial mesh file has been created, this function is applied Once the initial mesh file has been created, this function is applied to convert it to a domain object---that is, to a member of the special Python class Domain (or a subclass of Domain), which provides access to properties and \begin{funcdesc} {set\_name}{name} Module: \code{pyvolution.domain} Assigns the name \code{name} to the domain \end{funcdesc} \begin{funcdesc} {get\_name}{} Module: \code{pyvolution.domain} Returns the name assigned to the domain by \code{set_name}. If no name has been assigned, returns domain'. \begin{funcdesc} {set\_datadir}{name} Module: \code{pyvolution.domain} Sets the directory used for data to the value \code{name}. The default value, before \code{set\_datadir} is run, is the value \code{default_datadir} \code{set\_datadir} is run, is the value \code{default_datadir} specified in \code{config.py}. \end{funcdesc} \begin{funcdesc} {get_datadir}{} Module: \code{pyvolution.domain} Returns the data directory set by \code{set\_datadir} or, if \code{set\_datadir} has not been run, returns the value \code{default_datadir} specified in been run, returns the value \code{default_datadir} specified in \code{config.py}. \end{funcdesc} \section{Setting Quantities} \begin{funcdesc}{set\_quantity}{name, numeric = None, quantity = None, function = None, geospatial_data = None, \begin{funcdesc}{set\_quantity}{name, numeric = None, quantity = None, function = None, geospatial_data = None, filename = None, attribute_name = None, alpha = None, location = 'vertices', indices = None, attribute_name = None, alpha = None, location = 'vertices', indices = None, verbose = False, use_cache = False} use_cache = False} Module: \code{pyvolution.domain} (see also \code{pyvolution.quantity.set_values}) the quantity in question. \item a list of numbers or a Numeric array ordered the same way as the mesh vertices. \item a function (e.g.\ see the samples introduced in Chapter 2) \item a function (e.g.\ see the samples introduced in Chapter 2) \item an expression composed of other quantities and numbers, arrays, lists (for example, a linear combination of quantities) \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. \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. \item a geospatial dataset (See ?????). Optional argument attribute_name applies here as with files. \end{itemize} Set quantity will look at the type of the second argument (\code{numeric}) and determine what action to take. Set quantity will look at the type of the second argument (\code{numeric}) and determine what action to take. Values can also be set using the appropriate keyword arguments. 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)} are all equivalent. 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)} are all equivalent. \item \code{indices} which is a list of ids of triangles to which set_quantity should apply its assignment of values. \item \code{location} determines which part of the triangles to assign to. Options are 'vertices' (default), 'edges', and 'centroids'. \end{itemize} \end{itemize} with \code{set_quantity}. \begin{funcdesc}{tsunami_slump}{length, depth, slope, width=None, thickness=None, \ x0=0.0, y0=0.0, alpha=0.0, \ gravity=9.8, gamma=1.85, \ massco=1, dragco=1, frictionco=0, psi=0, \ dx=None, kappa=3.0, kappad=0.8, zsmall=0.01, \ \begin{funcdesc}{tsunami_slump}{length, depth, slope, width=None, thickness=None, x0=0.0, y0=0.0, alpha=0.0, gravity=9.8, gamma=1.85, massco=1, dragco=1, frictionco=0, psi=0, dx=None, kappa=3.0, kappad=0.8, zsmall=0.01, domain=None, verbose=False} Module: \code{pyvolution.least\_squares} Given a time series, either as a sequence of numbers or Given a time series, either as a sequence of numbers or defined at the vertices of a triangular mesh (such as those stored in \code{sww} files), \code{Interpolation\_function} is used to create a callable object that interpolates a value for an arbitrary time \code{t} within the model limits and possibly a point \code{(x, y)} within a mesh region. The actual time series at which data is available is specified by means an arbitrary time \code{t} within the model limits and possibly a point \code{(x, y)} within a mesh region. The actual time series at which data is available is specified by means of an array \code{time} of monotonically increasing times. The quantities containing the values to be interpolated are specified in an array---or dictionary of arrays (used in conjunction with the optional argument The quantities containing the values to be interpolated are specified in an array---or dictionary of arrays (used in conjunction with the optional argument \code{quantitity\_names}) --- called \code{quantities}. The optional arguments \code{vertex_coordinates} and \code{triangles} represent The optional arguments \code{vertex_coordinates} and \code{triangles} represent the spatial mesh associated with the quantity arrays. If omitted the function created by \code{Interpolation\_function} will be a function of \code{t} only. Since, in practice, values need to be computed at specified Since, in practice, values need to be computed at specified points, the syntax allows the user to specify, once and for all, a list \code{interpolation\_points} of points at which values are required. In this case, This function allows you to assign a boundary object (corresponding to a pre-defined or user-specified boundary condition) to every boundary segment that has been assigned a particular tag. has been assigned a particular tag. This is done by specifying a dictionary \code{boundary\_map}, whose values are the boundary objects \begin{funcdesc}{evolve}{yieldstep = None, finaltime = None, duration = None, skip_initial_step = False} Module: pyvolution.domain This function (a method of \code{domain}) is invoked once all the preliminaries have been completed, and causes the model to progress through successive steps in its evolution, storing results and This function (a method of \code{domain}) is invoked once all the preliminaries have been completed, and causes the model to progress through successive steps in its evolution, storing results and outputting statistics whenever a user-specified period \code{yieldstep} is completed (generally during this period the model will evolve through several steps internally). The user specifies the total time period over which the evolution is to take place, by specifying values (in seconds) for either \code{duration} or \code{finaltime}, as well as the interval in seconds after which results are to be stored and statistics output. \code{duration} or \code{finaltime}, as well as the interval in seconds after which results are to be stored and statistics output. You can include \code{evolve} in a statement of the type: {\small \begin{verbatim} for t in domain.evolve(yieldstep, finaltime): \end{funcdesc} \begin{funcdesc}{get_quantity}{???} Module: \code{pyvolution.domain} Module: \code{pyvolution.domain} Allow access to individual quantities and their methods \end{funcdesc} \end{funcdesc} \begin{funcdesc}{get_values}{???} Module: \code{pyvolution.quantity} Module: \code{pyvolution.quantity} Extract values for quantity as an array \end{funcdesc} \end{funcdesc} \begin{funcdesc}{get_integral}{???} Module: \code{pyvolution.quantity} Module: \code{pyvolution.quantity} Return computed integral over entire domain for this quantity \end{funcdesc} \section{Other} \begin{funcdesc}{domain.create_quantity_from_expression}{???} Handy for creating derived quantities on-the-fly. \end{funcdesc} \section{Other} \begin{funcdesc}{domain.create_quantity_from_expression}{???} Handy for creating derived quantities on-the-fly. See \code{Analytical\_solution\_circular\_hydraulic\_jump.py} for an example of use. \end{funcdesc} \end{funcdesc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{funcdesc}{sww2dem}{???} Module: \code{pyvolution.data\_manager} \end{funcdesc} Module: \code{pyvolution.data\_manager} \end{funcdesc} \begin{funcdesc}{dem2pts}{???} Module: \code{pyvolution.data_manager} \end{funcdesc} Module: \code{pyvolution.data_manager} \end{funcdesc} %\[ func_defualts, co_argcount)} and the function will be recomputed. Options are set by means of the function \code{set_option(key, value)}, Options are set by means of the function \code{set_option(key, value)}, where \code{key} is a key associated with a Python dictionary \code{options}. This dictionary stores settings such as the name of Python dictionary \code{options}. This dictionary stores settings such as the name of the directory used, the maximum number of cached files allowed, and so on. \end{verbatim}} \section{swollen} The output generated by \anuga may be viewed by means of the visualisation tool \code{swollen}, which takes the \code{sww} file output by \anuga and creates a visual representation of the data. Examples may be seen in Figures \ref{fig:bedslopestart} and \ref{fig:bedslope2}. To view an \code{sww} file with \code{swollen} in the Windows environment, you can simply drag the icon representing the file over an icon on the desktop The output generated by \anuga may be viewed by means of the visualisation tool \code{swollen}, which takes the \code{sww} file output by \anuga and creates a visual representation of the data. Examples may be seen in Figures \ref{fig:bedslopestart} and \ref{fig:bedslope2}. To view an \code{sww} file with \code{swollen} in the Windows environment, you can simply drag the icon representing the file over an icon on the desktop for the \code{swollen} executable file (or a shortcut to it). Alternatively, you can operate \code{swollen} from the command line, in both Windows and Linux environments. On successful operation, you will see an interactive moving-picture display. You can use keys and the mouse to slow down, speed up or stop the display, change the viewing position or carry out a number of other to slow down, speed up or stop the display, change the viewing position or carry out a number of other simple operations. The main keys operating the interactive screen are:\\ \begin{classdesc}{Polygon_function}{regions, default = 0.0, geo_reference = None} Module: \code{utilities.polygon} Module: \code{utilities.polygon} \end{classdesc} \begin{funcdesc}{read_polygon}{filename} Module: \code{utilities.polygon} Module: \code{utilities.polygon} Reads the specified file and returns a polygon. Each line of the file must contain exactly two numbers, separated by a comma, which are interpreted as coordinates of one vertex of the polygon. \end{funcdesc} \begin{funcdesc}{populate_polygon}{polygon, number_of_points, seed = None, exclude = None} Module: \code{utilities.polygon} Module: \code{utilities.polygon} Populates the interior of the specified polygon with the specified number of points, selected by means of a uniform distribution function. \end{funcdesc} \begin{funcdesc}{point_in_polygon}{polygon, delta=1e-8} Module: \code{utilities.polygon} Module: \code{utilities.polygon} Returns a point inside the specified polygon and close to the edge. The distance between the returned point and the nearest point of the polygon is less than $\sqrt{2}$ times the second argument \code{delta}, which is taken as $10^{-8}$ by default. \end{funcdesc} \begin{funcdesc}{inside_polygon}{points, polygon, closed = True, verbose = False} Module: \code{utilities.polygon} Module: \code{utilities.polygon} Used to test whether a single point---or the members of a list of points--- are inside the specified polygon. If the first argument is a single point, array comprising the indices of the points in the list that lie inside the polygon. (If none of the points are inside, returns \code{zeros((0,), 'l')}.) Points on the edges of the polygon are regarded as inside if Points on the edges of the polygon are regarded as inside if \code{closed} is set to \code{True} or omitted; otherwise they are regarded as outside. \end{funcdesc} \begin{funcdesc}{outside_polygon}{points, polygon, closed = True, verbose = False} Module: \code{utilities.polygon} Module: \code{utilities.polygon} Exactly like \code{inside_polygon}, but with the words inside' and `outside' interchanged. \end{funcdesc} \begin{funcdesc}{point_on_line}{x, y, x0, y0, x1, y1} Module: \code{utilities.polygon} Returns \code{True} or \code{False}, depending on whether the point with coordinates \code{x, y} is on the line passing through the points with coordinates \code{x0, y0} \code{x, y} is on the line passing through the points with coordinates \code{x0, y0} and \code{x1, y1} (extended if necessary at either end). \end{funcdesc} \begin{funcdesc}{separate_points_by_polygon}{points, polygon, closed = True, verbose = False}\indexedcode{separate_points_by_polygon} Module: \code{utilities.polygon} Module: \code{utilities.polygon} \end{funcdesc} \section{geo_spatial_data} This describes a class that represents arbitrary point data in UTM This describes a class that represents arbitrary point data in UTM coordinates along with named attribute values.