source: inundation/parallel/run_parallel_sw_rectangle.py @ 2198

Last change on this file since 2198 was 2198, checked in by jack, 18 years ago

Update visualisation calling on rectangle and meriumbula(metis) cases.
Reset final time on merimbula(metis) for running on the LC.

File size: 2.8 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.qcolor['stage'] = (0.0, 0.0, 0.8)
69    domain.visualiser.scale_z['stage'] = 1.0
70    domain.visualiser.scale_z['elevation'] = 0.05
71except:
72    print 'No visualiser'
73
74
75
76
77domain.default_order = 2
78
79#Boundaries
80from parallel_shallow_water import Transmissive_boundary, Reflective_boundary
81
82T = Transmissive_boundary(domain)
83R = Reflective_boundary(domain)
84
85
86domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
87domain.check_integrity()
88
89class Set_Stage:
90    """Set an initial condition with constant water height, for x<x0
91    """
92
93    def __init__(self, x0=0.25, x1=0.5, y0=0.0, y1=1.0, h=1.0):
94        self.x0 = x0
95        self.x1 = x1
96        self.y0 = y0
97        self.y1 = y1
98        self.= h
99
100    def __call__(self, x, y):
101        return self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
102
103domain.set_quantity('stage', Set_Stage(0.2,0.4,0.25, 0.75, 1.0))
104
105if myid == 0:
106    import time
107    t0 = time.time()
108
109yieldstep = 0.005
110finaltime = 1.0
111
112#Check that the boundary value gets propagated to all elements
113for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
114    if myid == 0:
115        domain.write_time()
116
117if myid == 0:
118    print 'That took %.2f seconds' %(time.time()-t0)
119    print 'Communication time %.2f seconds'%domain.communication_time
120    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
121    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
122
123
124pypar.finalize()
Note: See TracBrowser for help on using the repository browser.