source: anuga_core/source/anuga_parallel/run_parallel_sw_merimbula.py @ 7676

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