source: inundation/parallel/run_parallel_sw_rectangle.py @ 1740

Last change on this file since 1740 was 1697, checked in by steve, 20 years ago

Found problem with File_Boundary as used in validation test LWRU2. Have setup new BC Transmissive_Momentum_Set _Stage

File size: 4.2 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 = 20
81N = M*numprocs
82
83#N = M = 250
84
85if myid == 0:
86    print 'N == %d' %N
87
88points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
89    parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g=1.0)
90
91
92
93domain = Parallel_Domain(points, vertices, boundary,
94                         full_send_dict  = full_send_dict,
95                         ghost_recv_dict = ghost_recv_dict)
96
97print 'number of triangles = ', domain.number_of_elements
98
99
100rect = [ 0.0, 0.0, 1.0*numprocs, 1.0]
101try:
102    domain.initialise_visualiser(rect=rect)
103    domain.visualiser.coloring['stage'] = True
104    domain.visualiser.scale_z['stage'] = 1.0
105    domain.visualiser.scale_z['elevation'] = 0.05
106except:
107    print 'No visualiser'
108
109
110
111
112domain.default_order = 2
113
114#Boundaries
115from parallel_shallow_water import Transmissive_boundary, Reflective_boundary
116
117T = Transmissive_boundary(domain)
118R = Reflective_boundary(domain)
119
120
121domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
122domain.check_integrity()
123
124class Set_Stage:
125    """Set an initial condition with constant water height, for x<x0
126    """
127
128    def __init__(self, x0=0.25, x1=0.5, y0=0.0, y1=1.0, h=1.0):
129        self.x0 = x0
130        self.x1 = x1
131        self.y0 = y0
132        self.y1 = y1
133        self.= h
134
135    def __call__(self, x, y):
136        return self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
137
138domain.set_quantity('stage', Set_Stage(0.2,0.4,0.25, 0.75, 1.0))
139
140if myid == 0:
141    import time
142    t0 = time.time()
143
144yieldstep = 0.005
145finaltime = 1.0
146
147#Check that the boundary value gets propagated to all elements
148for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
149    if myid == 0:
150        domain.write_time()
151
152if myid == 0:
153    print 'That took %.2f seconds' %(time.time()-t0)
154    print 'Communication time %.2f seconds'%domain.communication_time
155    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
156    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
157
158
159pypar.finalize()
Note: See TracBrowser for help on using the repository browser.