source: branches/Numeric_anuga_source/anuga_parallel/run_parallel_advection.py @ 7952

Last change on this file since 7952 was 6721, checked in by steve, 16 years ago

Debugging parallel test function

File size: 3.5 KB
Line 
1#!/usr/bin/env python
2#########################################################
3#
4#  Main file for parallel mesh testing. Runs an advection
5# flow simulation using a rectangular mesh
6#
7#
8#  Authors: Steve Roberts June 2005
9#  Modified by Linda Stals April 2006
10#
11#
12#########################################################
13
14
15
16# Parallel communication routines
17
18import pypar
19
20#  Mesh partition routines
21
22from parallel_meshes import parallel_rectangle
23
24# Parallel Domain
25 
26from parallel_advection import Parallel_Domain
27from parallel_advection import Transmissive_boundary
28
29############################
30# Set the initial conditions
31############################
32class Set_Stage:
33    """Set an initial condition with constant water height, for x<x0
34    """
35
36    def __init__(self, x0=0.25, x1=0.5, h=1.0):
37        self.x0 = x0
38        self.x1 = x1
39        self.= h
40
41    def __call__(self, x, y):
42        return self.h*((x>self.x0)&(x<self.x1))
43
44###############################
45# Read in processor information
46###############################
47
48numprocs = pypar.size()
49myid = pypar.rank()
50processor_name = pypar.Get_processor_name()
51
52N = 5
53M = 2
54
55#######################
56# Partition the mesh
57#######################
58
59# Build a unit mesh, subdivide it over numproces processors with each
60# submesh containing M*N nodes
61
62points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
63    parallel_rectangle(N, M, len1_g=1.0)
64
65#print 'ghost ',ghost_recv_dict
66#print 'full  ',full_send_dict
67
68
69
70print "Myid = ", myid, "no points = ", len(points), \
71      "no vertices = ", len(vertices), "no boundaries = ", len(boundary)
72
73###########################################
74# Start the computations on each subpartion
75###########################################
76
77# Create advection domain with direction (1,-1)
78# Initial condition is zero by default
79
80domain = Parallel_Domain(points, vertices, boundary,
81                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
82
83#print 'ghost ',ghost_recv_dict
84#print 'full  ',full_send_dict
85
86
87# Boundaries
88
89T = Transmissive_boundary(domain)
90
91
92
93
94domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, \
95                      'ghost': None} )
96
97
98# Set Evolve parameters
99domain.set_default_order(2)
100domain.set_timestepping_method('rk2')
101
102print domain.get_timestepping_method()
103
104#domain.use_edge_limiter = True
105#domain.tight_slope_limiters = True
106#domain.use_centroid_velocities = False
107
108domain.CFL = 1.0
109
110domain.set_beta(0.8)
111
112
113# Ensure that the domain definitions make sense
114
115domain.check_integrity()
116
117# Set the inititial conditions
118
119domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
120
121# Let processor 0 output some timing information
122
123visualise = True
124if visualise:
125    from anuga.visualiser import RealtimeVisualiser
126    vis = RealtimeVisualiser(domain)
127    vis.render_quantity_height("stage", zScale = 5.0, dynamic=True)
128    vis.colour_height_quantity('stage', (0.2, 0.2, 0.8))
129    vis.start()
130    import time
131    time.sleep(2.0)
132   
133
134
135if myid == 0:
136    import time
137    t0 = time.time()
138
139for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
140    if myid == 0:
141        domain.write_time()
142       
143    if visualise:
144        vis.update()                                           
145
146       
147
148if visualise: vis.evolveFinished()
149   
150
151# Output some computation statistics
152
153if myid == 0:
154    print 'That took %.2f seconds' %(time.time()-t0)
155    print 'Communication time %.2f seconds'\
156          %domain.communication_time
157    print 'Reduction Communication time %.2f seconds'\
158          %domain.communication_reduce_time
159       
160 
161if visualise: vis.join()
Note: See TracBrowser for help on using the repository browser.