# source:anuga_core/benchmarks/create_test_sww.py@7697

Last change on this file since 7697 was 7697, checked in by hudson, 13 years ago

Added benchmark for testing sww2dem speed.

File size: 2.0 KB
Line
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
5from anuga.shallow_water import Domain
6from anuga.shallow_water import Reflective_boundary
7from anuga.shallow_water import Dirichlet_boundary
8
9
10def create_test_sww(sww_name):
11
12        #------------------------------------------------------------------------------
13        # Setup computational domain
14        #------------------------------------------------------------------------------
15        points, vertices, boundary = rectangular_cross(50, 50,
16                                                                                                   len1=50.0, len2=50.0) # Mesh
17
18        domain = Domain(points, vertices, boundary)  # Create domain
19        domain.set_name(sww_name)                  # Output name
20
21        #------------------------------------------------------------------------------
22        # Setup initial conditions
23        #------------------------------------------------------------------------------
24        def topography(x, y):
25                return -x/20                             # linear bed slope
26
27        domain.set_quantity('elevation', topography) # Use function for elevation
28        domain.set_quantity('friction', 0.01)        # Constant friction
29        domain.set_quantity('stage',                 # Dry bed
30                                                expression='elevation')
31
32        #------------------------------------------------------------------------------
33        # Setup boundary conditions
34        #------------------------------------------------------------------------------
35        Bi = Dirichlet_boundary([0.4, 0, 0])         # Inflow
36        Br = Reflective_boundary(domain)             # Solid reflective wall
37
38        domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
39
40        #------------------------------------------------------------------------------
41        # Evolve system through time
42        #------------------------------------------------------------------------------
43        for t in domain.evolve(yieldstep=10.0, finaltime=100.0):
44                print domain.timestepping_statistics()
Note: See TracBrowser for help on using the repository browser.