source: anuga_core/source/anuga_parallel/test_parallel_sw_runup.py @ 3588

Last change on this file since 3588 was 3588, checked in by ole, 18 years ago

Work on simple parallel test

File size: 4.5 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water driven up a linear slope and time varying boundary,
4similar to a beach environment
5
6This is a very simple test of the parallel algorithm
7"""
8
9
10#------------------------------------------------------------------------------
11# Import necessary modules
12#------------------------------------------------------------------------------
13
14from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
15from anuga.shallow_water import Domain
16from anuga.shallow_water import Reflective_boundary
17from anuga.shallow_water import Dirichlet_boundary
18from anuga.shallow_water import Time_boundary
19from anuga.shallow_water import Transmissive_boundary
20
21from parallel_api import *
22
23
24#------------------------------------------------------------------------------
25# Initialise
26#------------------------------------------------------------------------------
27
28if myid == 0:
29    #--------------------------------------------------------------------------
30    # Setup computational domain
31    #--------------------------------------------------------------------------
32
33    points, vertices, boundary = rectangular_cross(20, 20) # Basic mesh
34
35    domain = Domain(points, vertices, boundary) # Create domain
36    domain.set_name('runup')                    # Set sww filename
37   
38
39    #------------ -------------------------------------------------------------
40    # Setup initial conditions
41    #--------------------------------------------------------------------------
42
43    def topography(x,y): 
44        return -x/2                              # linear bed slope
45
46    domain.set_quantity('elevation', topography) # Use function for elevation
47    domain.set_quantity('friction', 0.1)         # Constant friction
48    domain.set_quantity('stage', -.4)            # Constant initial stage
49
50
51    #--------------------------------------------------------------------------
52    # Setup boundary conditions
53    #--------------------------------------------------------------------------
54
55    Br = Reflective_boundary(domain)      # Solid reflective wall
56    Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
57
58    # Associate boundary tags with boundary objects
59    domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br})
60
61
62#------------------------------------------------------------------------------
63# Parallel stuff
64#------------------------------------------------------------------------------
65
66if myid == 0:
67    # Distribute the domain
68    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict,\
69            = distribute_mesh(domain)
70    print 'Communication done'       
71   
72else:
73    # Read in the mesh partition that belongs to this
74    # processor (note that the information is in the
75    # correct form for the GA data structure)
76
77    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict, \
78            = rec_submesh(0)
79
80
81
82#------------------------------------------------------------------------------
83# Start the computations on each subpartion
84#------------------------------------------------------------------------------
85
86# Build the domain for this processor
87domain = Parallel_Domain(points, vertices, boundary,
88                         full_send_dict  = full_send_dict,
89                         ghost_recv_dict = ghost_recv_dict)
90
91
92# Name and dir, etc currently has to be set here as they are not
93# transferred from the original domain
94domain.set_name('runup')                    # Set sww filename
95
96
97#------------------------------------------------------------------------------
98# Setup initial conditions
99#------------------------------------------------------------------------------
100for q in quantities:
101    domain.set_quantity(q, quantities[q]) # Distribute all quantities   
102
103
104#------------------------------------------------------------------------------
105# Setup parallel boundary conditions
106#------------------------------------------------------------------------------
107
108Br = Reflective_boundary(domain)      # Solid reflective wall
109Bd = Dirichlet_boundary([-0.2,0.,0.]) # Constant boundary values
110
111# Associate boundary tags with boundary objects
112domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br,
113                     'ghost': None, 'exterior': Bd})
114
115
116
117#------------------------------------------------------------------------------
118# Evolve system through time
119#------------------------------------------------------------------------------
120
121for t in domain.evolve(yieldstep = 0.1, finaltime = 10.0):
122    domain.write_time()
123   
124
125
Note: See TracBrowser for help on using the repository browser.