1 | |
---|
2 | """Run parallel shallow water domain. |
---|
3 | |
---|
4 | run using command like: |
---|
5 | |
---|
6 | python run_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 | |
---|
18 | import os |
---|
19 | import sys |
---|
20 | import time |
---|
21 | import numpy as num |
---|
22 | |
---|
23 | #------------------------ |
---|
24 | # ANUGA Modules |
---|
25 | #------------------------ |
---|
26 | |
---|
27 | #from swb_domain import Domain |
---|
28 | |
---|
29 | # Gareth's well balance code |
---|
30 | #from balanced_basic import Domain |
---|
31 | |
---|
32 | from anuga import Domain |
---|
33 | from anuga import Reflective_boundary |
---|
34 | from anuga import Dirichlet_boundary |
---|
35 | from anuga import Time_boundary |
---|
36 | #from swb_domain import Transmissive_boundary |
---|
37 | |
---|
38 | from anuga import rectangular_cross |
---|
39 | from anuga import create_domain_from_file |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | #-------------------------------------------------------------------------- |
---|
44 | # Setup parameters |
---|
45 | #-------------------------------------------------------------------------- |
---|
46 | |
---|
47 | mesh_filename = "merimbula_10785_1.tsh" ; x0 = 756000.0 ; x1 = 756500.0 |
---|
48 | #mesh_filename = "merimbula_43200.tsh" ; x0 = 756000.0 ; x1 = 756500.0 |
---|
49 | #mesh_filename = "test-100.tsh" ; x0 = 0.25 ; x1 = 0.5 |
---|
50 | #mesh_filename = "test-20.tsh" ; x0 = 250.0 ; x1 = 350.0 |
---|
51 | yieldstep = 1 #20 |
---|
52 | finaltime = 10 #200 |
---|
53 | verbose = True |
---|
54 | |
---|
55 | #-------------------------------------------------------------------------- |
---|
56 | # Setup procedures |
---|
57 | #-------------------------------------------------------------------------- |
---|
58 | class 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 = h |
---|
66 | |
---|
67 | def __call__(self, x, y): |
---|
68 | return self.h*((x>self.x0)&(x<self.x1)) |
---|
69 | |
---|
70 | |
---|
71 | class Set_Elevation: |
---|
72 | """Set an elevation |
---|
73 | """ |
---|
74 | |
---|
75 | def __init__(self, h=1.0): |
---|
76 | self.x0 = x0 |
---|
77 | self.x1 = x1 |
---|
78 | self.h = h |
---|
79 | |
---|
80 | def __call__(self, x, y): |
---|
81 | return x/self.h |
---|
82 | |
---|
83 | |
---|
84 | #-------------------------------------------------------------------------- |
---|
85 | # Setup Domain |
---|
86 | #-------------------------------------------------------------------------- |
---|
87 | domain = create_domain_from_file(mesh_filename, DomainClass=Domain) |
---|
88 | |
---|
89 | domain.set_quantity('stage', Set_Stage(x0, x1, 2.0)) |
---|
90 | |
---|
91 | |
---|
92 | #-------------------------------------------------------------------------- |
---|
93 | # Setup Domain |
---|
94 | #-------------------------------------------------------------------------- |
---|
95 | domain.set_default_order(2) |
---|
96 | domain.set_timestepping_method('rk2') |
---|
97 | #domain.set_CFL(0.7) |
---|
98 | #domain.set_beta(1.5) |
---|
99 | domain.set_name('merimbula') |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | #------------------------------------------------------------------------------ |
---|
104 | # Setup boundary conditions |
---|
105 | # This must currently happen *after* domain has been distributed |
---|
106 | #------------------------------------------------------------------------------ |
---|
107 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
108 | |
---|
109 | domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br}) |
---|
110 | |
---|
111 | #------------------------------------------------------------------------------ |
---|
112 | # Evolution |
---|
113 | #------------------------------------------------------------------------------ |
---|
114 | if verbose: print 'EVOLVE' |
---|
115 | |
---|
116 | t0 = time.time() |
---|
117 | |
---|
118 | for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): |
---|
119 | domain.write_time() |
---|
120 | |
---|
121 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
122 | |
---|
123 | |
---|
124 | |
---|