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

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

Testing unit tests

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.interface import Domain
26from anuga.interface 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, get_processor_name
34
35###############################
36# Read in processor information
37###############################
38numprocs = numprocs()
39myid     = 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#Boundaries
65
66
67T = Transmissive_boundary(domain)
68R = Reflective_boundary(domain)
69
70
71domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R, 'ghost': None} )
72
73
74
75
76domain.check_integrity()
77
78class Set_Stage:
79    """Set an initial condition with constant water height, for x<x0
80    """
81
82    def __init__(self, x0=0.25, x1=0.75, y0=0.0, y1=1.0, h=5.0, h0=0.0):
83        self.x0 = x0
84        self.x1 = x1
85        self.y0 = y0
86        self.y1 = y1
87        self.= h
88        self.h0 = h0
89
90    def __call__(self, x, y):
91        return self.h0 + self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
92
93domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
94
95
96# Set Evolve parameters
97domain.set_default_order(2)
98domain.set_timestepping_method('rk2')
99
100print domain.get_timestepping_method()
101
102#domain.use_edge_limiter = True
103#domain.tight_slope_limiters = True
104#domain.use_centroid_velocities = False
105
106domain.CFL = 1.0
107
108domain.set_beta(0.8)
109
110
111
112if myid == 0:
113    import time
114    t0 = time.time()
115
116
117# Turn on the visualisation
118visualise = False
119if visualise:
120    from anuga.visualiser import RealtimeVisualiser
121    vis = RealtimeVisualiser(domain)
122    vis.render_quantity_height("elevation", offset=0.001, dynamic=False)
123    vis.render_quantity_height("stage", dynamic=True)
124    vis.colour_height_quantity('stage', (0.2, 0.2, 0.8))
125    vis.start()
126    import time
127    time.sleep(2.0)
128
129
130
131yieldstep = 0.1
132finaltime = 1.0
133
134#Check that the boundary value gets propagated to all elements
135for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
136    if myid == 0:
137        domain.write_time()
138    #print_test_stats(domain, tri_full_flag)
139    if visualise:
140        vis.update()                                           
141
142
143
144if visualise: vis.evolveFinished()
145
146if myid == 0:
147    print 'That took %.2f seconds' %(time.time()-t0)
148    print 'Communication time %.2f seconds'%domain.communication_time
149    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
150    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
151
152
153if visualise: vis.join()
154pypar.finalize()
Note: See TracBrowser for help on using the repository browser.