1 | """Validation of the AnuGA implementation of the shallow water wave equation. |
---|
2 | |
---|
3 | This script sets up Okushiri Island benchmark as published at the |
---|
4 | |
---|
5 | THE THIRD INTERNATIONAL WORKSHOP ON LONG-WAVE RUNUP MODELS |
---|
6 | June 17-18 2004 |
---|
7 | Wrigley Marine Science Center |
---|
8 | Catalina Island, California |
---|
9 | http://www.cee.cornell.edu/longwave/ |
---|
10 | |
---|
11 | |
---|
12 | The validation data was downloaded and made available in this directory |
---|
13 | for convenience but the original data is available at |
---|
14 | http://www.cee.cornell.edu/longwave/index.cfm?page=benchmark&problem=2 |
---|
15 | where a detailed description of the problem is also available. |
---|
16 | |
---|
17 | |
---|
18 | Run create_okushiri.py to process the boundary condition and build a the |
---|
19 | mesh before running this script. |
---|
20 | |
---|
21 | To run on e.g. 8 processors |
---|
22 | mpirun -machinefile ~/.machines_tornado -np 8 python run_okushiri_parallel.py |
---|
23 | |
---|
24 | where the machine file has the format |
---|
25 | |
---|
26 | compute-0-19 cpu=4 |
---|
27 | compute-0-18 cpu=4 |
---|
28 | compute-0-17 cpu=4 |
---|
29 | compute-0-16 cpu=4 |
---|
30 | compute-0-15 cpu=4 |
---|
31 | compute-0-14 cpu=4 |
---|
32 | compute-0-13 cpu=4 |
---|
33 | compute-0-12 cpu=4 |
---|
34 | compute-0-11 cpu=4 |
---|
35 | compute-0-10 cpu=4 |
---|
36 | compute-0-9 cpu=4 |
---|
37 | compute-0-8 cpu=4 |
---|
38 | compute-0-7 cpu=4 |
---|
39 | compute-0-6 cpu=4 |
---|
40 | compute-0-5 cpu=4 |
---|
41 | compute-0-4 cpu=4 |
---|
42 | compute-0-3 cpu=4 |
---|
43 | compute-0-2 cpu=4 |
---|
44 | compute-0-1 cpu=4 |
---|
45 | compute-0-0 cpu=4 |
---|
46 | tornado cpu=4 |
---|
47 | |
---|
48 | See mpirun manual for more details |
---|
49 | """ |
---|
50 | |
---|
51 | # To know quickly if pypar can be imported |
---|
52 | import imp |
---|
53 | print " imp.find_module('pypar')", imp.find_module('pypar') |
---|
54 | import pypar |
---|
55 | |
---|
56 | # Module imports |
---|
57 | from anuga.shallow_water import Domain |
---|
58 | from anuga.shallow_water import Reflective_boundary |
---|
59 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
60 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
61 | |
---|
62 | from anuga_parallel.parallel_api import myid, numprocs, distribute, processor_name |
---|
63 | |
---|
64 | import project |
---|
65 | |
---|
66 | print 'Pypar running process %d of %d on node "%s"' % (myid, numprocs, processor_name) |
---|
67 | |
---|
68 | use_cache = True |
---|
69 | #------------------------- |
---|
70 | # Create Domain from mesh |
---|
71 | # on processor 0 |
---|
72 | #------------------------- |
---|
73 | if myid == 0 : |
---|
74 | domain = Domain(project.mesh_filename, use_cache=use_cache, verbose=True) |
---|
75 | print domain.statistics() |
---|
76 | |
---|
77 | #------------------------- |
---|
78 | # Initial Conditions |
---|
79 | # At present need to do the |
---|
80 | # fitting of the bathymetry |
---|
81 | # on a global domain, ie before |
---|
82 | # distributing the domain |
---|
83 | #------------------------- |
---|
84 | domain.set_quantity('friction', 0.0) |
---|
85 | domain.set_quantity('stage', 0.0) |
---|
86 | domain.set_quantity('elevation', |
---|
87 | filename=project.bathymetry_filename, |
---|
88 | alpha=0.02, |
---|
89 | verbose=True, |
---|
90 | use_cache=use_cache) |
---|
91 | else: |
---|
92 | domain = None |
---|
93 | |
---|
94 | #------------------------- |
---|
95 | # Distribute domain if run in parallel |
---|
96 | #------------------------- |
---|
97 | if numprocs > 1: |
---|
98 | domain = distribute(domain) |
---|
99 | |
---|
100 | |
---|
101 | #------------------------- |
---|
102 | # Set simulation parameters |
---|
103 | #------------------------- |
---|
104 | domain.set_name(project.output_filename) # Name of output sww file |
---|
105 | domain.set_default_order(2) # Apply second order scheme |
---|
106 | domain.set_all_limiters(0.9) # Max second order scheme (old lim) |
---|
107 | domain.set_minimum_storable_height(0.001) # Don't store w < 0.001m |
---|
108 | domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK) |
---|
109 | |
---|
110 | |
---|
111 | #------------------------- |
---|
112 | # Boundary Conditions |
---|
113 | #------------------------- |
---|
114 | |
---|
115 | # Create boundary function from timeseries provided in file |
---|
116 | function = file_function(project.boundary_filename, |
---|
117 | domain, verbose=True) |
---|
118 | |
---|
119 | # Create and assign boundary objects |
---|
120 | Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
121 | Br = Reflective_boundary(domain) |
---|
122 | domain.set_boundary({'wave': Bts, 'wall': Br}) |
---|
123 | |
---|
124 | #------------------------- |
---|
125 | # Evolve through time |
---|
126 | #------------------------- |
---|
127 | import time |
---|
128 | t0 = time.time() |
---|
129 | |
---|
130 | for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): |
---|
131 | if myid == 0 : |
---|
132 | domain.write_time() |
---|
133 | |
---|
134 | |
---|
135 | print 'That took %.2f seconds' %(time.time()-t0) |
---|