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

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

added in some parallel data to allow sww_merge to create a merged sww file

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
46mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5
47yieldstep = 20
48finaltime = 500
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))
72
73    print domain.statistics()
74    print domain.get_extent()
75    print domain.get_extent(absolute=True)
76    print domain.geo_reference
77else:
78    domain = None
79
80#--------------------------------------------------------------------------
81# Distribute sequential domain on processor 0 to other processors
82#--------------------------------------------------------------------------
83
84if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
85domain = distribute(domain)
86
87#domain.smooth = False
88
89domain.set_default_order(2)
90domain.set_timestepping_method('rk2')
91#domain.set_CFL(0.7)
92#domain.set_beta(1.5)
93domain.set_name('merimbula')
94
95for p in range(numprocs):
96    if myid == p:
97        print 'P%d'%p
98        print domain.get_extent()
99        print domain.get_extent(absolute=True)
100        print domain.geo_reference
101        #print domain.tri_map
102        #print domain.inv_tri_map
103        print domain.tri_l2g
104        print domain.node_l2g
105    else:
106        pass
107   
108    barrier()
109
110
111#------------------------------------------------------------------------------
112# Setup boundary conditions
113# This must currently happen *after* domain has been distributed
114#------------------------------------------------------------------------------
115Br = Reflective_boundary(domain)      # Solid reflective wall
116
117domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br})
118
119#------------------------------------------------------------------------------
120# Evolution
121#------------------------------------------------------------------------------
122if myid == 0 and verbose: print 'EVOLVE'
123
124t0 = time.time()
125
126for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
127    if myid == 0:
128        domain.write_time()
129
130
131if myid == 0:
132    print 'Number of processors %g ' %numprocs
133    print 'That took %.2f seconds' %(time.time()-t0)
134    print 'Communication time %.2f seconds'%domain.communication_time
135    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
136    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
137
138
139#--------------------------------------------------
140# Merge the individual sww files into one file
141#--------------------------------------------------
142domain.sww_merge()
143
144finalize()
145
146
147
148
Note: See TracBrowser for help on using the repository browser.