# Changeset 2277

Ignore:
Timestamp:
Jan 25, 2006, 12:20:23 PM (17 years ago)
Message:

Updated program example format

Location:
documentation
Files:
3 edited

Unmodified
Added
Removed
• ## documentation/AnuGA_user_manual.tex

 r2274 %\newcommand{\code}[1]{{\small \tt #1}} %For use with one-line code snippets \documentclass{report} \title{AnuGA User Manual} \verb+\\+\emph{s at the ends of lines!]} \begin{verbatim} from pyvolution.mesh_factory import rectangular \\ {\scriptsize \begin{verbatim} from pyvolution.mesh_factory import rectangular from pyvolution.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary, Time_boundary, Transmissive_boundary points, vertices, boundary = rectangular(10,10) #Create shallow water domain \\ domain = Domain(points, vertices,boundary) \\ #Create shallow water domain domain = Domain(points, vertices,boundary) domain.smooth = False domain.visualise = False domain.store = True domain.filename = 'bedslope' # Boundary conditions \\ from math import sin, pi \\ Br = Reflective_boundary(domain)\\ Bt = Transmissive_boundary(domain) \\ Bd = Dirichlet_boundary([0.2,0.,0.])\\ # Boundary conditions from math import sin, pi Br = Reflective_boundary(domain) Bt = Transmissive_boundary(domain) Bd = Dirichlet_boundary([0.2,0.,0.]) Bw = Time_boundary(domain=domain, domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) \\ #domain.set_boundary({'left': Bw, 'right': Br, 'top': Br, 'bottom': Br}) ###################### \\ domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) ###################### #Evolution \end{verbatim} \end{verbatim}} scenario. This is carried out through the statement: \begin{verbatim} {\small \begin{verbatim} points, vertices, boundary = rectangular(10, 10) . \end{verbatim} \end{verbatim}} The function \texttt{rectangular} is imported from a module specific way. In general, the assignment \begin{verbatim} {\small \begin{verbatim} points, vertices, boundary = rectangular(m, n) \end{verbatim} \end{verbatim}} returns: \texttt{domain}, through the assignment: \begin{verbatim} {\small \begin{verbatim} domain = Domain(points, vertices, boundary) \end{verbatim} \end{verbatim}} This uses a Python class \texttt{Domain}, imported from of what these do]} \begin{verbatim} {\scriptsize \begin{verbatim} domain.smooth = False domain.visualise = False domain.filename = 'bedslope' domain.default_order = 2 \end{verbatim} \end{verbatim}} purposes: \begin{verbatim} {\small \begin{verbatim} \# Initial conditions def f(x,y): return -x/2 \end{verbatim} \end{verbatim}} This simply associates an elevation with each point $(x, y)$ of \texttt{elevation} is assigned through the simple statement: {\small \begin{verbatim} \begin{verbatim} domain.set_quantity('elevation', f) \end{verbatim} \end{verbatim}} assign them to a constant numerical value: \begin{verbatim} {\small \begin{verbatim} domain.set_quantity('friction', 0.1) \end{verbatim} \end{verbatim}} This just specifies that the Manning friction coefficient is set quantities: \begin{verbatim} {\small \begin{verbatim} h = 0.05 \# Constant depth domain.set_quantity('stage', expression = 'elevation + %f' %h) \end{verbatim} \end{verbatim}} Here the quantity \texttt{stage} is defined by taking the quantity The boundary conditions are specified as follows: \begin{verbatim} {\small \begin{verbatim} Br = Reflective_boundary(domain) Bw = Time_boundary(domain=domain, f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) \end{verbatim} \end{verbatim}} The effect of these statements is to set up four alternative form \begin{verbatim} domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) \end{verbatim} {\small \begin{verbatim} domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) \end{verbatim}} This statement stipulates that, in the current example, the left The final statement \nopagebreak[3] \begin{verbatim} {\small \begin{verbatim} for t in domain.evolve(yieldstep = 0.1, finaltime = 4.0): domain.write_time() \end{verbatim} \end{verbatim}} is the key step that causes the configuration of the domain to
Note: See TracChangeset for help on using the changeset viewer.