source: anuga_core/source/anuga_parallel/run_parallel_sw_rectangle.py @ 5822

Last change on this file since 5822 was 5822, checked in by steve, 15 years ago

Now test_parallel_sw_runup seems to be producing correct results (at
least on two processors)

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