source: anuga_work/development/parallel/run_parallel_advection_prof.py @ 5151

Last change on this file since 5151 was 3460, checked in by jack, 18 years ago

Moved parallel to development from inundation

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/usr/bin/env python
2###
3#########################################################
4#
5#  Main file for parallel mesh testing. Runs an advection
6# flow simulation using a rectangular mesh
7#
8#
9#  Authors: Steve Roberts June 2005
10#  Modified by Linda Stals April 2006
11#
12#
13#########################################################
14
15
16import sys
17from os import sep
18sys.path.append('..'+sep+'pyvolution')
19sys.path.append('..'+sep+'parallel')
20
21# Parallel communication routines
22
23import pypar
24
25#  Mesh partition routines
26
27from parallel_meshes import parallel_rectangle
28
29# Parallel Domain
30 
31from parallel_advection import Parallel_Domain
32from parallel_advection import Transmissive_boundary
33
34############################
35# Set the initial conditions
36############################
37class Set_Stage:
38    """Set an initial condition with constant water height, for x<x0
39    """
40
41    def __init__(self, x0=0.25, x1=0.5, h=1.0):
42        self.x0 = x0
43        self.x1 = x1
44        self.= h
45
46    def __call__(self, x, y):
47        return self.h*((x>self.x0)&(x<self.x1))
48
49###############################
50# Read in processor information
51###############################
52
53numprocs = pypar.size()
54myid = pypar.rank()
55processor_name = pypar.Get_processor_name()
56
57N = 80
58M = 80
59
60#######################
61# Partition the mesh
62#######################
63
64# Build a unit mesh, subdivide it over numproces processors with each
65# submesh containing M*N nodes
66
67points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
68    parallel_rectangle(N, M, len1_g=1.0)
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# Turn on the visualisation
84
85# rect = [0.0, 0.0, 1.0, 1.0]
86# domain.initialise_visualiser(rect=rect)
87
88# Boundaries
89
90T = Transmissive_boundary(domain)
91domain.default_order = 2
92domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, \
93                      'ghost': None} )
94
95# Ensure that the domain definitions make sense
96
97domain.check_integrity()
98
99# Set the inititial conditions
100
101domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
102
103# Let processor 0 output some timing information
104
105if myid == 0:
106    import time
107    t0 = time.time()
108
109# Start the evolve computions
110import hotshot
111profiler = hotshot.Profile("hotshot." + str(numprocs) + "." + str(myid) + ".prof")
112s = '''for t in domain.evolve(yieldstep = 0.1, finaltime = 2.0):
113  if myid == 0:
114    domain.write_time()
115'''
116   
117
118result = profiler.runctx(s, globals(), locals())
119profiler.close()
120
121# for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
122#     if myid == 0:
123#         domain.write_time()
124
125# Output some computation statistics
126
127if myid == 0:
128    print 'That took %.2f seconds' %(time.time()-t0)
129    print 'Communication time %.2f seconds'\
130          %domain.communication_time
131    print 'Reduction Communication time %.2f seconds'\
132          %domain.communication_reduce_time
Note: See TracBrowser for help on using the repository browser.