Changeset 2455


Ignore:
Timestamp:
Feb 27, 2006, 4:52:42 PM (19 years ago)
Author:
howard
Message:

Further work on second example. Also reorganised section and subsection levels to give a more consistent logical structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentation/user_manual/anuga_user_manual.tex

    r2450 r2455  
    146146many of the ideas, and the second is a real-life example.
    147147
    148 \section{First Example: Overview}
     148\section{A Simple Example}
     149
     150\subsection{Overview}
    149151
    150152What follows
     
    181183%\emph{[More details of the problem background]}
    182184
    183 \section{Outline of the Program}
     185\subsection{Outline of the Program}
    184186
    185187In outline, \code{bedslope.py} performs the following steps:
     
    203205\end{enumerate}
    204206
    205 \section{The Code}
     207\subsection{The Code}
    206208
    207209%FIXME: we are using the \code function here.
     
    257259for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0):
    258260    domain.write_time()
    259 
    260 
    261 \end{verbatim}}
    262 
    263 
    264 \section{Establishing the Mesh}
     261\end{verbatim}}
     262
     263
     264\subsection{Establishing the Mesh}
    265265
    266266The first task is to set up the triangular mesh to be used for the
     
    302302
    303303
    304 \section{Initialising the Domain}
     304\subsection{Initialising the Domain}
    305305
    306306These variables are then used to set up a data structure
     
    323323
    324324
    325 \section{Specifying the Quantities}
     325\subsection{Specifying the Quantities}
    326326
    327327The next task is to specify a number of quantities that we wish to set
     
    340340
    341341
    342 \subsection{Elevation}
     342\subsubsection{Elevation}
    343343
    344344The elevation is set using a function, defined through the
     
    365365
    366366
    367 \subsection{Friction}
     367\subsubsection{Friction}
    368368
    369369The assignment of the friction quantity demonstrates another way
     
    378378to 0.1 at every mesh point.
    379379
    380 \subsection{Depth}
     380\subsubsection{Depth}
    381381
    382382Assigning depth illustrates a more complex way to use
     
    395395elevation of the bed.
    396396
    397 \subsection{Boundary Conditions}
     397\subsubsection{Boundary Conditions}
    398398
    399399The boundary conditions are specified as follows:
     
    446446
    447447
    448 \section{Evolution}
     448\subsection{Evolution}
    449449
    450450The final statement \nopagebreak[3]
     
    462462
    463463
    464 \section{Output}
     464\subsection{Output}
    465465
    466466%Give details here of the form of the output and explain how it can
     
    493493\code{run_sydney_smf.py}, that follows the same basic outline, but
    494494incorporates many more complex features.
     495
     496\subsection{Overview}
     497As in the case of \code{bedslope.py}, the actions carried out by the
     498program can be organised according to this outline:
     499
     500\begin{enumerate}
     501
     502   \item Set up a triangular mesh.
     503
     504   \item Set certain parameters governing the mode of
     505operation of the model-specifying, for instance, where to store the
     506model output.
     507
     508   \item Input various quantities describing physical measurements, such
     509as the elevation, to be specified at each mesh point (vertex).
     510
     511   \item Set up the boundary conditions.
     512
     513   \item Carry out the evolution of the model through a series of time
     514steps and outputs the results, providing a results file that can be
     515visualised.
     516
     517\end{enumerate}
     518
     519
     520
     521\subsection{The Code}
    495522
    496523Here is the code for \code{run_sydney_smf.py}:
     
    535562from smf import slump_tsunami
    536563# Function for submarine mudslide
    537 
    538 
    539 #-------------------------------------------------------------------------------
    540 # Preparation of topographic data #
    541 # Convert ASC 2 DEM 2 PTS using
    542 source data and store result in source data
    543 # Do for coarse and fine
     564\end{verbatim}}
     565
     566
     567{\scriptsize \begin{verbatim}
     568#-------------------------------------------------------------------------------
     569# Preparation of topographic data # # Convert ASC 2 DEM 2 PTS using
     570source data and store result in source data # Do for coarse and fine
    544571data
    545572
     
    590617
    591618from pmesh.create_mesh import create_mesh_from_regions
    592 
    593 num_polygons = 1 filelist = [] fileext = '.csv' filename =
    594 project.polygonptsfile interior_res = 50000
     619\end{verbatim}}
     620
     621
     622{\scriptsize \begin{verbatim}
     623 num_polygons = 1 filelist = [] fileext
     624= '.csv' filename = project.polygonptsfile interior_res = 50000
    595625
    596626for p in range(1, num_polygons+1):
     
    599629    interior_regions.append([interior_polygon, interior_res])
    600630
    601 # test #interior_regions = [[project.poly1, interior_res], #
    602 [project.poly2, interior_res]] # original #interior_regions =
    603 [[project.harbour_polygon_2, interior_res], #
     631# test
     632#interior_regions = [[project.poly1, interior_res],
     633#
     634[project.poly2, interior_res]]
     635# original
     636#interior_regions =
     637[[project.harbour_polygon_2, interior_res],
     638#
    604639[project.botanybay_polygon_2, interior_res]]
    605640
    606641#FIXME: Fix caching of this one once the mesh_interface is ready
    607 from caching import cache _ = cache(create_mesh_from_regions,
     642from caching import cache
     643_ = cache(create_mesh_from_regions,
    608644          project.diffpolygonall,
    609645          {'boundary_tags': {'bottom': [0],
     
    620656
    621657#-------------------------------------------------------------------------------
    622 # Setup computational domain
     658# Set up computational domain
    623659#-------------------------------------------------------------------------------
    624660
     
    694730high-level perspective of the various tasks it undertakes.
    695731
    696 If we compare this example with \code{bedslope.py}, the most
    697 noticeable difference is that data is taken from a file. This is to
    698 be expected, since the example now represents an actual physical
    699 scenario rather than an illustrative example.
    700 
    701 However, another important difference is that this example uses a
    702 different method to create the mesh---one more suited to use for a
    703 physical scenario. Instead of imposing a mesh structure on a
     732\subsection{Establishing the Mesh}
     733
     734Comparing the present example with \code{bedslope.py}, we note that
     735one important difference is the use of a more complex method to
     736create the mesh. Instead of imposing a mesh structure on a
    704737rectangular grid, the technique used for this example involves
    705738building mesh structures inside polygons specified by the user.
    706739
    707 In its simplest form, this technique creates the mesh within a
    708 single polygon whose vertices are at geographical locations
    709 specified by the user. A triangular mesh is created using points
    710 inside the polygon selected through a random process, the user
    711 specifying the \emph{resolution}---that is, the maximal area of a
    712 triangle used for triangulation.
    713 
    714 Figure XXX shows a simple example, in which the triangulation is
    715 carried out within a pentagon. Instead of using the four tags
    716 \code{`left'}, \code{`right'}, \code{`bottom'} and
    717 \code{`top'} to distinguish boundary elements, the user can define
    718 tags appropriate to the configuration being modelled.
    719 
    720 While this offers more flexibility than the rectangular grid, it
    721 doesn't provide a way to adapt to geographic or other features in the
    722 landscape, for which we may require to vary the resolution. We achieve
    723 more flexibility by extending this method, allowing the user to
    724 specify a number of interior polygons which are triangulated
    725 separately, possibly using different resolutions.  See Figure XXX.
    726 
    727 As before, we start by including
    728 
    729 
    730 
    731 
    732 
    733 
     740The following remarks may help the reader understand the basic ideas
     741behind the mesh-creation technique used in this program.
     742
     743In its simplest form, the technique creates the mesh within a single
     744polygon whose vertices are at geographical locations specified by
     745the user. A triangular mesh is created using points inside the
     746polygon selected through a random process, the user specifying the
     747\emph{resolution}---that is, the maximal area of a triangle used for
     748triangulation.
     749
     750Figure XXX shows a simple example of this, in which the
     751triangulation is carried out within a pentagon. Instead of using the
     752four tags \code{`left'}, \code{`right'}, \code{`bottom'} and
     753\code{`top'} that we used in the case of \code{bedslope.py} to
     754distinguish boundary elements, the user can define tags appropriate
     755to the configuration being modelled.
     756
     757While this simple version of the technique offers more flexibility
     758than the rectangular grid, it doesn't provide a way to adapt to
     759geographic or other features in the landscape, whose presence may
     760require us to vary the resolution in the neighbourhood of the
     761features. To achieve more flexibility we therefore extend the
     762technique, allowing the user to specify a number of interior
     763polygons to be triangulated separately, possibly using different
     764resolutions. See Figure XXX.
     765
     766The upshot is a general method that takes for its input a bounding
     767polygon and (optionally) a list of interior polygons. It creates a
     768triangular mesh inside the bounding polygon, using a specified
     769resolution, but initially leaves the regions inside the interior
     770polygons alone. It then triangulates each of these regions
     771separately, using a separately specified resolution.
     772
     773The function used to implement this process is the function
     774\code{create_mesh_from_regions}. Its arguments include the bounding
     775polygon and its resolution, a list of boundary tags, and a list of
     776pairs \code{[polygon, resolution]}, specifying the interior polygons
     777and their resolutions.
     778
     779In practice, the details of the polygons used are read from a
     780separate file \code{project.py}.
     781
     782
     783\subsection{Initialising the Domain}
     784
     785As with \code{bedslope.py}, once we have created the mesh, the next
     786step is to create the data structure \code{domain}.
     787
     788{\scriptsize \begin{verbatim}
     789domain =
     790pmesh_to_domain_instance(meshname, Domain,
     791                                  use_cache = True,
     792                                  verbose = True)
     793\end{verbatim}}
     794
     795\subsection{Specifying the Quantities}
     796
     797{\scriptsize \begin{verbatim}
     798domain.set_name(project.basename)
     799domain.set_datadir(project.outputdir)
     800domain.set_quantities_to_be_stored(['stage', 'xmomentum',
     801'ymomentum'])
     802
     803
     804#-------------------------------------------------------------------------------
     805# Set up scenario (tsunami_source is a callable object used with
     806set_quantity)
     807#-------------------------------------------------------------------------------
     808
     809tsunami_source = slump_tsunami(length=30000.0,
     810                               depth=400.0,
     811                               slope=6.0,
     812                               thickness=176.0,
     813                               radius=3330,
     814                               dphi=0.23,
     815                               x0=project.slump_origin[0],
     816                               y0=project.slump_origin[1],
     817                               alpha=0.0,
     818                               domain=domain)
     819
     820
     821#-------------------------------------------------------------------------------
     822# Setup initial conditions
     823#-------------------------------------------------------------------------------
     824
     825domain.set_quantity('stage', tsunami_source)
     826domain.set_quantity('friction', 0.03) # supplied by Benfield
     827domain.set_quantity('elevation',
     828                    filename = project.combineddemname + '.pts',
     829                    use_cache = True,
     830                    verbose = True)
     831\end{verbatim}}
     832
     833\subsection{Boundary Conditions}
     834
     835{\scriptsize \begin{verbatim}
     836Br = Reflective_boundary(domain)
     837domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
     838                      'right2': Br, 'top': Br, 'left1': Br,
     839                      'left2': Br, 'left3': Br} )
     840\end{verbatim}}
    734841
    735842\chapter{\anuga Public Interface}
Note: See TracChangeset for help on using the changeset viewer.