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

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

Concentrating code

File size: 3.5 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 pypar    # The Python-MPI interface
17import time
18
19#from Numeric import array
20# pmesh
21import numpy as num
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.1
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.