source: trunk/anuga_core/source/anuga_parallel/run_parallel_advection_prof.py @ 8283

Last change on this file since 8283 was 5242, checked in by steve, 16 years ago
  • Property svn:executable set to *
File size: 3.0 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# Boundaries
79
80T = Transmissive_boundary(domain)
81domain.default_order = 2
82domain.set_boundary( {'left': T, 'right': T, 'bottom': T, 'top': T, \
83                      'ghost': None} )
84
85# Ensure that the domain definitions make sense
86
87domain.check_integrity()
88
89# Set the inititial conditions
90
91domain.set_quantity('stage', Set_Stage(0.2,0.4,1.0))
92
93# Let processor 0 output some timing information
94
95if myid == 0:
96    import time
97    t0 = time.time()
98
99# Start the evolve computions
100import hotshot
101profiler = hotshot.Profile("hotshot." + str(numprocs) + "." + str(myid) + ".prof")
102s = '''for t in domain.evolve(yieldstep = 0.1, finaltime = 2.0):
103  if myid == 0:
104    domain.write_time()
105'''
106   
107
108result = profiler.runctx(s, globals(), locals())
109profiler.close()
110
111# for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
112#     if myid == 0:
113#         domain.write_time()
114
115# Output some computation statistics
116
117if myid == 0:
118    print 'That took %.2f seconds' %(time.time()-t0)
119    print 'Communication time %.2f seconds'\
120          %domain.communication_time
121    print 'Reduction Communication time %.2f seconds'\
122          %domain.communication_reduce_time
Note: See TracBrowser for help on using the repository browser.