source: inundation/parallel/run_parallel_sw_rectangle.py @ 2197

Last change on this file since 2197 was 2193, checked in by jack, 19 years ago

Corrected potential error in pmesh_divide when examining pmesh_divide_metis
run_parallel_sw_rectangle was asking the visualiser to colour the stage, but was not specifying a colour. It now colours the stage at (0.0, 0.0, 0.8)

File size: 2.9 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#
10#  Authors: Linda Stals, Steve Roberts and Matthew Hardy,
11# June 2005
12#
13#
14#
15#########################################################
16import sys
17import pypar    # The Python-MPI interface
18import time
19
20
21from os import sep
22sys.path.append('..'+sep+'pyvolution')
23
24from Numeric import array
25# pmesh
26
27#from shallow_water import Domain
28
29from shallow_water import Domain
30from parallel_shallow_water import Parallel_Domain
31
32
33# mesh partition routines
34from parallel_meshes import parallel_rectangle
35
36
37from pmesh_divide import pmesh_divide, pmesh_divide_steve
38
39# read in the processor information
40
41numprocs = pypar.size()
42myid = pypar.rank()
43processor_name = pypar.Get_processor_name()
44
45M = 20
46N = M*numprocs
47
48#N = M = 250
49
50if myid == 0:
51    print 'N == %d' %N
52
53points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
54    parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g=1.0)
55
56
57
58domain = Parallel_Domain(points, vertices, boundary,
59                         full_send_dict  = full_send_dict,
60                         ghost_recv_dict = ghost_recv_dict)
61
62print 'number of triangles = ', domain.number_of_elements
63
64
65rect = [ 0.0, 0.0, 1.0*numprocs, 1.0]
66try:
67    domain.initialise_visualiser(rect=rect)
68    domain.visualiser.coloring['stage'] = True
69    domain.visualiser.qcolor['stage'] = (0.0, 0.0, 0.8)
70    domain.visualiser.scale_z['stage'] = 1.0
71    domain.visualiser.scale_z['elevation'] = 0.05
72except:
73    print 'No visualiser'
74
75
76
77
78domain.default_order = 2
79
80#Boundaries
81from parallel_shallow_water import Transmissive_boundary, Reflective_boundary
82
83T = Transmissive_boundary(domain)
84R = Reflective_boundary(domain)
85
86
87domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
88domain.check_integrity()
89
90class Set_Stage:
91    """Set an initial condition with constant water height, for x<x0
92    """
93
94    def __init__(self, x0=0.25, x1=0.5, y0=0.0, y1=1.0, h=1.0):
95        self.x0 = x0
96        self.x1 = x1
97        self.y0 = y0
98        self.y1 = y1
99        self.= h
100
101    def __call__(self, x, y):
102        return self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
103
104domain.set_quantity('stage', Set_Stage(0.2,0.4,0.25, 0.75, 1.0))
105
106if myid == 0:
107    import time
108    t0 = time.time()
109
110yieldstep = 0.005
111finaltime = 1.0
112
113#Check that the boundary value gets propagated to all elements
114for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
115    if myid == 0:
116        domain.write_time()
117
118if myid == 0:
119    print 'That took %.2f seconds' %(time.time()-t0)
120    print 'Communication time %.2f seconds'%domain.communication_time
121    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
122    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
123
124
125pypar.finalize()
Note: See TracBrowser for help on using the repository browser.