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 | """ |
---|
22 | |
---|
23 | # To know quickly if pypar can be imported |
---|
24 | import imp |
---|
25 | print " imp.find_module('pypar')", imp.find_module('pypar') |
---|
26 | import pypar |
---|
27 | |
---|
28 | # Module imports |
---|
29 | from anuga.shallow_water import Domain |
---|
30 | from anuga.shallow_water import Reflective_boundary |
---|
31 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
32 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
33 | |
---|
34 | from anuga_parallel.parallel_api import myid, numprocs, distribute |
---|
35 | |
---|
36 | import project |
---|
37 | |
---|
38 | use_cache = True |
---|
39 | #------------------------- |
---|
40 | # Create Domain from mesh |
---|
41 | #------------------------- |
---|
42 | domain = Domain(project.mesh_filename, use_cache=use_cache, verbose=True) |
---|
43 | print domain.statistics() |
---|
44 | |
---|
45 | |
---|
46 | #------------------------- |
---|
47 | # Initial Conditions |
---|
48 | #------------------------- |
---|
49 | domain.set_quantity('friction', 0.0) |
---|
50 | domain.set_quantity('stage', 0.0) |
---|
51 | domain.set_quantity('elevation', |
---|
52 | filename=project.bathymetry_filename, |
---|
53 | alpha=0.02, |
---|
54 | verbose=True, |
---|
55 | use_cache=use_cache) |
---|
56 | |
---|
57 | |
---|
58 | #------------------------- |
---|
59 | # Distribute domain if run in parallel |
---|
60 | #------------------------- |
---|
61 | if numprocs > 1: |
---|
62 | domain = distribute(domain) |
---|
63 | |
---|
64 | |
---|
65 | #------------------------- |
---|
66 | # Set simulation parameters |
---|
67 | #------------------------- |
---|
68 | domain.set_name(project.output_filename) # Name of output sww file |
---|
69 | domain.set_default_order(2) # Apply second order scheme |
---|
70 | domain.set_all_limiters(0.9) # Max second order scheme (old lim) |
---|
71 | domain.set_minimum_storable_height(0.001) # Don't store w < 0.001m |
---|
72 | domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK) |
---|
73 | |
---|
74 | |
---|
75 | #------------------------- |
---|
76 | # Boundary Conditions |
---|
77 | #------------------------- |
---|
78 | |
---|
79 | # Create boundary function from timeseries provided in file |
---|
80 | function = file_function(project.boundary_filename, |
---|
81 | domain, verbose=True) |
---|
82 | |
---|
83 | # Create and assign boundary objects |
---|
84 | Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
85 | Br = Reflective_boundary(domain) |
---|
86 | domain.set_boundary({'wave': Bts, 'wall': Br}) |
---|
87 | |
---|
88 | |
---|
89 | #------------------------- |
---|
90 | # Evolve through time |
---|
91 | #------------------------- |
---|
92 | import time |
---|
93 | t0 = time.time() |
---|
94 | |
---|
95 | for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): |
---|
96 | domain.write_time() |
---|
97 | |
---|
98 | print 'That took %.2f seconds' %(time.time()-t0) |
---|