Changeset 4117


Ignore:
Timestamp:
Dec 22, 2006, 1:39:34 PM (18 years ago)
Author:
ole
Message:

Added section on architecture

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/publications/linuxconf_2006/paper_ole_nielsen.tex

    r4116 r4117  
    308308observed CFL condition.
    309309
     310\section{Software Implementation}
     311
     312To set up a scenario the user specifies the geometry (derived from bathymetric and topographic data), the initial water level, boundary conditions (e.g. tide), outputs from other models (e.g. a deep water tsunami model), and forcing terms (e.g. frictional resistance, wind stress, atmospheric pressure gradients etc.).  The geometry could for example be a digital elevation model of an estuary and a boundary could be a collection of time series derived from tide gauges.
     313
     314To help with these tasks, a tool called pmesh has been developed which allows the user to set up the geometry of the problem interactively.  Pmesh produces a triangular mesh of the study area in which the user can specify the locations and types of boundary conditions that apply as well as identifying regions for either mesh refinement or for assignment of values at run time.  Figure 1 shows an example of a geometry generated by pmesh.
     315
     316 
     317Figure 1 Mesh generated by pmesh for a reservoir simulation.
     318
     319When the model is run, the mesh is converted into a domain object which represents the study area, the mesh, quantities, boundaries and forcing terms together with methods for time stepping, flux calculations, and all other numerical operations pertinent to the model.
     320
     321The (conserved) quantities updated by the numerical scheme are stage (water level) and horizontal momentum while bed elevation and friction are quantities that are not updated.  Setting initial values for quantities is done through the method
     322domain.set_quantity(name, X, location, region)
     323where name is the name of the quantity (e.g. 'stage', 'xmomentum', 'ymomentum', 'elevation' or 'friction').  The variable X represents the source data for populating the quantity and may take one of the following forms:
     324"       A constant value as in domain.set_quantity('stage', 1) which will set the initial water level to 1 m everywhere.
     325"       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 quantity accordingly.  One common application of this would be to assign the stage as a constant depth above the bed elevation.
     326"       An arbitrary function (or a callable object), f(x, y), where x and y are assumed to be vectors.  The quantity will take values for f at each location within the mesh.
     327"       An arbitrary set of points and associated values (wrapped into a point_set object).  The points need not coincide with triangle vertices or centroids and a penalised least squares technique is employed to populate the quantity in a smooth and stable way.
     328"       A filename containing points and attributes.
     329"       A Numerical Python array (or a list of numbers) ordered according to the internal data structure.
     330The parameter location determines whether the values should be assigned to triangle edge midpoints or vertices and region allows the operation to be restricted to a region specified by a symbolic tag or a set of indices.
     331
     332Since the least squares technique can be time consuming for large problems, set_quantity employs a caching technique which automatically decides whether to perform the computations or retrieve them from a cache.  This will typically speed up the build by several orders of magnitude after each computation has been performed once.
     333
     334Boundary conditions are bound to symbolic tags through the method domain.set_boundary which takes as input a lookup table (implemented as a Python dictionary) of the form {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 it is relatively straightforward to define problem-specific custom boundaries if needed.  The predefined boundary conditions include Dirichlet, Reflective, Transmissive, Temporal, and Spatio-Temporal boundaries.
     335
     336Forcing terms can be written according to a fixed protocol and added to the model using the idiom domain.forcing_terms.append(F) where F is assumed to be a user-defined callable object.
     337
     338When the simulation is running, the length of each time step is determined from the maximal speeds encountered and the sizes of triangles in order not to violate the CFL condition which specifies that no information should skip any triangles in one time step.  With 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:
     339For t in domain.evolve(yieldstep, duration):
     340   <do whatever>
     341
     342The parameter duration specifies the time period over which evolve operates, and control is passed to the body of the for-loop at each fixed yieldstep.  The internal time stepping is thus decoupled from the overall time stepping so that outputs may be stored, displayed or interrogated.  The evolve method has been implemented using a Python generator.
     343
     344Figure 2 shows a simulation of water flowing through a hypothetical breach in a levee, down onto a flat surface and past an obstacle.  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.
     345
     346 
     347Figure 2  Simulation of a levee breach.
     348
     349Most of the components of AnuGA are written in Python, an object-oriented programming language known for its clarity, elegance, efficiency and reliability.  It is often said that "Python lets you focus on the problem at hand".  This means that it is possible to develop complex pieces of software without undue distractions in dealing with idiosyncrasies of the software language syntax.  Consequently, software written in Python can be produced quickly and can be readily adapted to changing requirements throughout its lifetime.
     350
     351
    310352
    311353
Note: See TracChangeset for help on using the changeset viewer.