source: anuga_core/source/anuga_parallel/run_parallel_sw_rectangle.py @ 3696

Last change on this file since 3696 was 3696, checked in by steve, 18 years ago

Added run_sw_rectangle in examples to show improvement in dealing with wet/dry interface. Controlled by beta's for cell near interface

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