source: trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/ex1.py @ 8304

Last change on this file since 8304 was 8304, checked in by pittj, 12 years ago

adding more files from the resource experiments

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1"""Simple water flow example using ANUGA
2Water flowing down a channel
3"""
4#------------------------------------------------------------------------------
5# Import necessary modules
6#------------------------------------------------------------------------------
7# Import standard shallow water domain and standard boundaries.
8import anuga
9import time
10import random
11import os
12from anuga.abstract_2d_finite_volumes.util import add_directories
13
14home = os.getenv('INUNDATIONHOME')
15scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
16                                     "channelflow"])
17
18#------------------------------------------------------------------------------
19# Setup computational domain
20#------------------------------------------------------------------------------
21def runex(lower,length):
22   points, vertices, boundary = anuga.rectangular_cross(50,50,
23                                                     len1=length, len2=length) # Mesh
24
25#--------------------------------------------------------------------------
26# Setup Domain only on processor 0
27#--------------------------------------------------------------------------
28   domain = anuga.Domain(points, vertices, boundary) # Create domain
29   domain.set_datadir(scenariodir) 
30   domain.set_name('channel1.sww') # Output name
31
32   def topography(x, y):
33      z = -x/10
34      N = len(x)
35      for i in range(N):
36         if y[i] > lower:
37            z[i] += 1
38             
39      return  z
40
41   domain.set_quantity('elevation', topography) # Use function for elevation
42   domain.set_quantity('friction', 0.01) # Constant friction
43   domain.set_quantity('stage', -1000.0)
44
45
46#------------------------------------------------------------------------------
47# Setup boundary conditions
48#------------------------------------------------------------------------------
49   Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow
50   Bo = anuga.Dirichlet_boundary([-100,0,0]) 
51   Br = anuga.Reflective_boundary(domain) # Solid reflective wall
52   domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
53
54#------------------------------------------------------------------------------
55# Evolve system through time
56#------------------------------------------------------------------------------
57   for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
58     #if myid == 0:
59       domain.write_time()
60
61#domain.sww_merge()
62#finalize()
63
Note: See TracBrowser for help on using the repository browser.