source: inundation/parallel/run_parallel_sw_rectangle.py @ 2920

Last change on this file since 2920 was 2814, checked in by steve, 19 years ago

Resolving conflicts between Ole's new cache argument and the ghost and full dictionary for domain

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