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

Last change on this file since 8012 was 8012, checked in by steve, 14 years ago

Larger file in example

File size: 3.9 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 pypar
22import numpy as num
23
24#------------------------
25# ANUGA Modules
26#------------------------
27from anuga.utilities.numerical_tools import ensure_numeric
28from anuga.utilities.util_ext        import double_precision
29from anuga.utilities.norms           import l1_norm, l2_norm, linf_norm
30       
31from anuga import Domain
32from anuga import Reflective_boundary
33from anuga import Dirichlet_boundary
34from anuga import Time_boundary
35from anuga import Transmissive_boundary
36
37from anuga import rectangular_cross
38from anuga import create_domain_from_file
39
40
41from anuga_parallel.interface import distribute, myid, numprocs, finalize
42
43
44#--------------------------------------------------------------------------
45# Setup parameters
46#--------------------------------------------------------------------------
47
48#mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0
49mesh_filename = "merimbula_43200.tsh"   ; x0 = 756000.0 ; x1 = 756500.0
50#mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5
51yieldstep = 5
52finaltime = 200
53verbose = True
54
55#--------------------------------------------------------------------------
56# Setup procedures
57#--------------------------------------------------------------------------
58class Set_Stage:
59    """Set an initial condition with constant water height, for x0<x<x1
60    """
61
62    def __init__(self, x0=0.25, x1=0.5, h=1.0):
63        self.x0 = x0
64        self.x1 = x1
65        self.= h
66
67    def __call__(self, x, y):
68        return self.h*((x>self.x0)&(x<self.x1))
69
70#--------------------------------------------------------------------------
71# Setup Domain only on processor 0
72#--------------------------------------------------------------------------
73if myid == 0:
74    domain = create_domain_from_file(mesh_filename)
75    domain.set_quantity('stage', Set_Stage(x0, x1, 2.0))
76else:
77    domain = None
78
79#--------------------------------------------------------------------------
80# Distribute sequential domain on processor 0 to other processors
81#--------------------------------------------------------------------------
82
83if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
84domain = distribute(domain)
85
86#domain.smooth = False
87
88domain.set_default_order(2)
89domain.set_timestepping_method('rk2')
90domain.set_CFL(0.7)
91domain.set_beta(1.5)
92domain.set_name('meribula')
93
94#------------------------------------------------------------------------------
95# Setup boundary conditions
96# This must currently happen *after* domain has been distributed
97#------------------------------------------------------------------------------
98Br = Reflective_boundary(domain)      # Solid reflective wall
99
100domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br})
101
102#------------------------------------------------------------------------------
103# Evolution
104#------------------------------------------------------------------------------
105if myid == 0 and verbose: print 'EVOLVE'
106
107t0 = time.time()
108
109for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
110    if myid == 0:
111        domain.write_time()
112
113
114if myid == 0:
115    print 'That took %.2f seconds' %(time.time()-t0)
116    print 'Communication time %.2f seconds'%domain.communication_time
117    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
118    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
119
120
121finalize()
122
123
124
125
Note: See TracBrowser for help on using the repository browser.