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

Last change on this file since 8283 was 8283, checked in by steve, 8 years ago

This working on sww_merge

File size: 4.4 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, barrier
38
39
40#--------------------------------------------------------------------------
41# Setup parameters
42#--------------------------------------------------------------------------
43
44#mesh_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
47mesh_filename = "test-20.tsh" ; x0 = 0.25 ; x1 = 0.5
48yieldstep = 20
49finaltime = 40
50verbose = True
51
52#--------------------------------------------------------------------------
53# Setup procedures
54#--------------------------------------------------------------------------
55class Set_Stage:
56    """Set an initial condition with constant water height, for x0<x<x1
57    """
58
59    def __init__(self, x0=0.25, x1=0.5, h=1.0):
60        self.x0 = x0
61        self.x1 = x1
62        self.= h
63
64    def __call__(self, x, y):
65        return self.h*((x>self.x0)&(x<self.x1))
66
67#--------------------------------------------------------------------------
68# Setup Domain only on processor 0
69#--------------------------------------------------------------------------
70if myid == 0:
71    domain = create_domain_from_file(mesh_filename)
72    domain.set_quantity('stage', Set_Stage(x0, x1, 2.0))
73
74    print domain.statistics()
75    print domain.get_extent()
76    print domain.get_extent(absolute=True)
77    print domain.geo_reference
78else:
79    domain = None
80
81#--------------------------------------------------------------------------
82# Distribute sequential domain on processor 0 to other processors
83#--------------------------------------------------------------------------
84
85if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
86domain = distribute(domain)
87
88#domain.smooth = False
89
90domain.set_default_order(2)
91domain.set_timestepping_method('rk2')
92#domain.set_CFL(0.7)
93#domain.set_beta(1.5)
94domain.set_name('merimbula')
95
96for p in range(numprocs):
97    if myid == p:
98        print 'P%d'%p
99        print domain.get_extent()
100        print domain.get_extent(absolute=True)
101        print domain.geo_reference
102        #print domain.tri_map
103        #print domain.inv_tri_map
104        print domain.tri_l2g
105        print domain.node_l2g
106    else:
107        pass
108   
109    barrier()
110
111
112#------------------------------------------------------------------------------
113# Setup boundary conditions
114# This must currently happen *after* domain has been distributed
115#------------------------------------------------------------------------------
116Br = Reflective_boundary(domain)      # Solid reflective wall
117
118domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br})
119
120#------------------------------------------------------------------------------
121# Evolution
122#------------------------------------------------------------------------------
123if myid == 0 and verbose: print 'EVOLVE'
124
125t0 = time.time()
126
127for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
128    if myid == 0:
129        domain.write_time()
130
131
132if myid == 0:
133    print 'Number of processors %g ' %numprocs
134    print 'That took %.2f seconds' %(time.time()-t0)
135    print 'Communication time %.2f seconds'%domain.communication_time
136    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
137    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
138
139
140#--------------------------------------------------
141# Merge the individual sww files into one file
142#--------------------------------------------------
143domain.sww_merge()
144
145finalize()
146
147
148
149
Note: See TracBrowser for help on using the repository browser.