source: inundation/parallel/run_parallel_sw_rectangle.py @ 2754

Last change on this file since 2754 was 2654, checked in by linda, 19 years ago

Added routines to print domain stats in parallel

File size: 3.0 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
27from print_stats import print_test_stats, build_full_flag
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
48if myid == 0:
49    print 'N == %d' %N
50
51points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
52    parallel_rectangle(N, M, len1_g=1.0*numprocs, len2_g = 1.0)
53
54
55
56domain = Parallel_Domain(points, vertices, boundary,
57                         full_send_dict  = full_send_dict,
58                         ghost_recv_dict = ghost_recv_dict)
59
60# Make a notes of which triangles are full and which are ghost
61
62tri_full_flag = build_full_flag(domain, ghost_recv_dict)
63
64print 'number of triangles = ', domain.number_of_elements
65
66
67rect = [ 0.0, 0.0, 1.0*numprocs, 1.0]
68try:
69    domain.initialise_visualiser(rect=rect)
70    domain.visualiser.qcolor['stage'] = (0.0, 0.0, 0.8)
71    domain.visualiser.scale_z['stage'] = 1.0
72    domain.visualiser.scale_z['elevation'] = 0.05
73except:
74    print 'No visualiser'
75
76
77
78
79domain.default_order = 2
80
81#Boundaries
82from parallel_shallow_water import Transmissive_boundary, Reflective_boundary
83
84T = Transmissive_boundary(domain)
85R = Reflective_boundary(domain)
86
87
88domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R, 'ghost': None} )
89domain.check_integrity()
90
91class Set_Stage:
92    """Set an initial condition with constant water height, for x<x0
93    """
94
95    def __init__(self, x0=0.25, x1=0.5, y0=0.0, y1=1.0, h=1.0):
96        self.x0 = x0
97        self.x1 = x1
98        self.y0 = y0
99        self.y1 = y1
100        self.= h
101
102    def __call__(self, x, y):
103        return self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
104
105domain.set_quantity('stage', Set_Stage(0.2,0.4,0.25, 0.75, 1.0))
106
107if myid == 0:
108    import time
109    t0 = time.time()
110
111yieldstep = 0.005
112finaltime = 1.0
113
114#Check that the boundary value gets propagated to all elements
115for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
116    if myid == 0:
117        domain.write_time()
118    print_test_stats(domain, tri_full_flag)
119
120if myid == 0:
121    print 'That took %.2f seconds' %(time.time()-t0)
122    print 'Communication time %.2f seconds'%domain.communication_time
123    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
124    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
125
126
127pypar.finalize()
Note: See TracBrowser for help on using the repository browser.