source: inundation/ga/storm_surge/parallel/run_parallel_sw_rectangle.py @ 1607

Last change on this file since 1607 was 1607, checked in by steve, 20 years ago
File size: 4.1 KB
Line 
1#!/usr/bin/env/python
2#########################################################
3#
4#  Main file for parallel mesh testing.
5#
6#  This is a modification of the run_parallel_advection.py
7# file.
8#
9#  *) The test files currently avaliable are of the form
10# test*.out, eg test_5l_4c.out. The term infront of the l
11# corresponds to the number of levels of refinement
12# required to build the grid, i.e. a higher number
13# corresponds to a finer grid. The term infront of the c
14# corresponds to the number of processors.
15#
16# *) The (new) files that have been added to manage the
17# grid partitioning are
18#    +) mg2ga.py: read in the test files.
19#    +) pmesh_divide.py: subdivide a pmesh
20#    +) build_submesh.py: build the submeshes on the host
21# processor.
22#    +) build_local.py: build the GA mesh datastructure
23# on each processor.
24#    +) build_commun.py: handle the communication between
25# the host and processors
26#
27# *) Things still to do:
28#    +) Overlap the communication and computation: The
29# communication routines in build_commun.py should be
30# interdispersed in the build_submesh.py and build_local.py
31# files. This will overlap the communication and
32# computation and will be far more efficient. This should
33# be done after more testing and there more confidence in
34# the subpartioning.
35#    +) Much more testing especially with large numbers of
36# processors.
37#  Authors: Linda Stals, Steve Roberts and Matthew Hardy,
38# June 2005
39#
40#
41#
42#########################################################
43import sys
44import pypar    # The Python-MPI interface
45import time
46
47
48from os import sep
49sys.path.append('..'+sep+'pyvolution')
50
51from Numeric import array
52# pmesh
53
54#from shallow_water import Domain
55
56from shallow_water import Domain
57from parallel_shallow_water import Parallel_Domain
58
59
60# mesh partition routines
61from parallel_meshes import parallel_rectangle
62
63
64from pmesh_divide import pmesh_divide, pmesh_divide_steve
65from build_submesh import *
66from build_local import *
67from build_commun import *
68from pmesh2domain import pmesh_to_domain_instance
69
70# read in the processor information
71
72numprocs = pypar.size()
73myid = pypar.rank()
74processor_name = pypar.Get_processor_name()
75
76
77
78
79
80M = 50
81N = M*numprocs
82
83
84points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
85    parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g=1.0)
86
87
88
89domain = Parallel_Domain(points, vertices, boundary,
90                         full_send_dict  = full_send_dict,
91                         ghost_recv_dict = ghost_recv_dict)
92
93
94#rect = [ 0.0, 0.0, 1.0*numprocs, 1.0]
95#try:
96#    domain.initialise_visualiser(rect=rect)
97#    domain.visualiser.coloring['stage'] = True
98#    domain.visualiser.scale_z['stage'] = 1.0
99#    domain.visualiser.scale_z['elevation'] = 0.05
100#except:
101#    print 'No visualiser'
102
103
104
105
106domain.default_order = 1
107
108#Boundaries
109from parallel_shallow_water import Transmissive_boundary, Reflective_boundary
110
111T = Transmissive_boundary(domain)
112R = Reflective_boundary(domain)
113
114
115domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
116domain.check_integrity()
117
118class Set_Stage:
119    """Set an initial condition with constant water height, for x<x0
120    """
121
122    def __init__(self, x0=0.25, x1=0.5, y0=0.0, y1=1.0, h=1.0):
123        self.x0 = x0
124        self.x1 = x1
125        self.y0 = y0
126        self.y1 = y1
127        self.= h
128
129    def __call__(self, x, y):
130        return self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
131
132domain.set_quantity('stage', Set_Stage(0.2,0.4,0.25, 0.75, 1.0))
133
134if myid == 0:
135    import time
136    t0 = time.time()
137
138yieldstep = 0.1
139finaltime = 0.5
140
141#Check that the boundary value gets propagated to all elements
142for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
143    if myid == 0:
144        domain.write_time()
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
Note: See TracBrowser for help on using the repository browser.