source: trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangle.py @ 8022

Last change on this file since 8022 was 8011, checked in by steve, 14 years ago

Tested parallel code with new anuga interface. Seems to be working

File size: 3.7 KB
Line 
1#########################################################
2#
3#  Main file for parallel mesh testing.
4#
5#  This is a modification of the run_parallel_advection.py
6# file.
7#
8#
9#  Authors: Linda Stals, Steve Roberts and Matthew Hardy,
10# June 2005
11#
12#
13#
14#########################################################
15
16import time
17
18import numpy as num
19
20from print_stats import print_test_stats, build_full_flag
21
22#----------------------------
23# Sequential interface
24#---------------------------
25from anuga import Domain
26from anuga import Transmissive_boundary, Reflective_boundary
27
28#----------------------------
29# Parallel interface
30#---------------------------
31from anuga_parallel.interface import Parallel_shallow_water_domain
32from anuga_parallel.interface import parallel_rectangle
33from anuga_parallel.interface import myid, numprocs, finalize, get_processor_name
34
35###############################
36# Read in processor information
37###############################
38#numprocs = numprocs()
39#myid     = myid()
40processor_name = get_processor_name()
41
42M = 50
43N = M*numprocs
44
45
46if myid == 0:
47    print 'N == %d' %N
48
49points, vertices, boundary, full_send_dict, ghost_recv_dict =\
50        parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g = 1.0)
51
52print "Myid = ", myid, "no points = ", len(points), \
53      "no vertices = ", len(vertices), "no boundaries = ", len(boundary)
54
55###########################################
56# Start the computations on each subpartion
57###########################################
58
59domain = Parallel_shallow_water_domain(points, vertices, boundary,
60                                       full_send_dict  = full_send_dict,
61                                       ghost_recv_dict = ghost_recv_dict)
62
63
64
65
66
67
68domain.set_name('sw_rectangle')
69
70#Boundaries
71T = Transmissive_boundary(domain)
72R = Reflective_boundary(domain)
73
74
75domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R, 'ghost': None} )
76
77
78
79
80domain.check_integrity()
81
82class Set_Stage:
83    """Set an initial condition with constant water height, for x<x0
84    """
85
86    def __init__(self, x0=0.25, x1=0.75, y0=0.0, y1=1.0, h=5.0, h0=0.0):
87        self.x0 = x0
88        self.x1 = x1
89        self.y0 = y0
90        self.y1 = y1
91        self.= h
92        self.h0 = h0
93
94    def __call__(self, x, y):
95        return self.h0 + self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
96
97domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
98
99
100# Set Evolve parameters
101domain.set_default_order(2)
102domain.set_timestepping_method('rk2')
103domain.set_CFL(0.7)
104domain.set_beta(1.5)
105
106#print domain.get_timestepping_method()
107#domain.use_edge_limiter = True
108#domain.tight_slope_limiters = True
109#domain.use_centroid_velocities = False
110
111
112
113
114
115if myid == 0:
116    import time
117    t0 = time.time()
118
119
120# Turn on the visualisation
121visualise = False
122if visualise:
123    from anuga.visualiser import RealtimeVisualiser
124    vis = RealtimeVisualiser(domain)
125    vis.render_quantity_height("elevation", offset=0.001, dynamic=False)
126    vis.render_quantity_height("stage", dynamic=True)
127    vis.colour_height_quantity('stage', (0.2, 0.2, 0.8))
128    vis.start()
129    import time
130    time.sleep(2.0)
131
132
133
134yieldstep = 0.05
135finaltime = 2.0
136
137#Check that the boundary value gets propagated to all elements
138for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
139    if myid == 0:
140        domain.write_time()
141    #print_test_stats(domain, tri_full_flag)
142    if visualise:
143        vis.update()                                           
144
145
146
147if visualise: vis.evolveFinished()
148
149if myid == 0:
150    print 'That took %.2f seconds' %(time.time()-t0)
151    print 'Communication time %.2f seconds'%domain.communication_time
152    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
153    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
154
155
156if visualise: vis.join()
157
158finalize()
Note: See TracBrowser for help on using the repository browser.