source: anuga_core/source/anuga_parallel/run_parallel_advection_prof.py @ 3739

Last change on this file since 3739 was 3579, checked in by ole, 17 years ago

Removed all references to pyvolution in parallel code

  • Property svn:executable set to *
File size: 3.1 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 = 80
53M = 80
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
65print "Myid = ", myid, "no points = ", len(points), \
66      "no vertices = ", len(vertices), "no boundaries = ", len(boundary)
67
68###########################################
69# Start the computations on each subpartion
70###########################################
71
72# Create advection domain with direction (1,-1)
73# Initial condition is zero by default
74
75domain = Parallel_Domain(points, vertices, boundary,
76                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
77
78# Turn on the visualisation
79
80# rect = [0.0, 0.0, 1.0, 1.0]
81# domain.initialise_visualiser(rect=rect)
82
83# Boundaries
84
85T = Transmissive_boundary(domain)
86domain.default_order = 2
87domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, \
88                      'ghost': None} )
89
90# Ensure that the domain definitions make sense
91
92domain.check_integrity()
93
94# Set the inititial conditions
95
96domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
97
98# Let processor 0 output some timing information
99
100if myid == 0:
101    import time
102    t0 = time.time()
103
104# Start the evolve computions
105import hotshot
106profiler = hotshot.Profile("hotshot." + str(numprocs) + "." + str(myid) + ".prof")
107s = '''for t in domain.evolve(yieldstep = 0.1, finaltime = 2.0):
108  if myid == 0:
109    domain.write_time()
110'''
111   
112
113result = profiler.runctx(s, globals(), locals())
114profiler.close()
115
116# for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
117#     if myid == 0:
118#         domain.write_time()
119
120# Output some computation statistics
121
122if myid == 0:
123    print 'That took %.2f seconds' %(time.time()-t0)
124    print 'Communication time %.2f seconds'\
125          %domain.communication_time
126    print 'Reduction Communication time %.2f seconds'\
127          %domain.communication_reduce_time
Note: See TracBrowser for help on using the repository browser.