source: trunk/anuga_core/source/anuga_parallel/run_parallel_sw_merimbula.py @ 8115

Last change on this file since 8115 was 8115, checked in by steve, 13 years ago

Updating a few parallel test

File size: 3.7 KB
Line 
1
2"""Run parallel shallow water domain.
3
4   run using command like:
5
6   mpirun -np m python run_parallel_sw_merimbula.py
7
8   where m is the number of processors to be used.
9   
10   Will produce sww files with names domain_Pn_m.sww where m is number of processors and
11   n in [0, m-1] refers to specific processor that owned this part of the partitioned mesh.
12"""
13
14#------------------------------------------------------------------------------
15# Import necessary modules
16#------------------------------------------------------------------------------
17
18import os
19import sys
20import time
21import numpy as num
22
23#------------------------
24# ANUGA Modules
25#------------------------
26       
27from anuga import Domain
28from anuga import Reflective_boundary
29from anuga import Dirichlet_boundary
30from anuga import Time_boundary
31from anuga import Transmissive_boundary
32
33from anuga import rectangular_cross
34from anuga import create_domain_from_file
35
36
37from anuga_parallel import distribute, myid, numprocs, finalize
38
39
40#--------------------------------------------------------------------------
41# Setup parameters
42#--------------------------------------------------------------------------
43
44mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0
45#mesh_filename = "merimbula_43200.tsh"   ; x0 = 756000.0 ; x1 = 756500.0
46#mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5
47yieldstep = 5
48finaltime = 200
49verbose = True
50
51#--------------------------------------------------------------------------
52# Setup procedures
53#--------------------------------------------------------------------------
54class Set_Stage:
55    """Set an initial condition with constant water height, for x0<x<x1
56    """
57
58    def __init__(self, x0=0.25, x1=0.5, h=1.0):
59        self.x0 = x0
60        self.x1 = x1
61        self.= h
62
63    def __call__(self, x, y):
64        return self.h*((x>self.x0)&(x<self.x1))
65
66#--------------------------------------------------------------------------
67# Setup Domain only on processor 0
68#--------------------------------------------------------------------------
69if myid == 0:
70    domain = create_domain_from_file(mesh_filename)
71    domain.set_quantity('stage', Set_Stage(x0, x1, 2.0))
72else:
73    domain = None
74
75#--------------------------------------------------------------------------
76# Distribute sequential domain on processor 0 to other processors
77#--------------------------------------------------------------------------
78
79if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
80domain = distribute(domain)
81
82#domain.smooth = False
83
84domain.set_default_order(2)
85domain.set_timestepping_method('rk2')
86domain.set_CFL(0.7)
87domain.set_beta(1.5)
88domain.set_name('meribula')
89
90#------------------------------------------------------------------------------
91# Setup boundary conditions
92# This must currently happen *after* domain has been distributed
93#------------------------------------------------------------------------------
94Br = Reflective_boundary(domain)      # Solid reflective wall
95
96domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br})
97
98#------------------------------------------------------------------------------
99# Evolution
100#------------------------------------------------------------------------------
101if myid == 0 and verbose: print 'EVOLVE'
102
103t0 = time.time()
104
105for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
106    if myid == 0:
107        domain.write_time()
108
109
110if myid == 0:
111    print 'Number of processors %g ' %numprocs
112    print 'That took %.2f seconds' %(time.time()-t0)
113    print 'Communication time %.2f seconds'%domain.communication_time
114    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
115    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
116
117
118finalize()
119
120
121
122
Note: See TracBrowser for help on using the repository browser.