[4578] | 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 | # Module imports |
---|
| 24 | from anuga.shallow_water import Domain |
---|
| 25 | from anuga.shallow_water import Reflective_boundary |
---|
| 26 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
| 27 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
| 28 | |
---|
| 29 | import project |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | #------------------------- |
---|
| 33 | # Create Domain from mesh |
---|
| 34 | #------------------------- |
---|
| 35 | domain = Domain(project.mesh_filename, use_cache=True, verbose=True) |
---|
| 36 | print domain.statistics() |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | #------------------------- |
---|
| 40 | # Initial Conditions |
---|
| 41 | #------------------------- |
---|
| 42 | domain.set_quantity('friction', 0.0) |
---|
| 43 | domain.set_quantity('stage', 0.0) |
---|
| 44 | domain.set_quantity('elevation', |
---|
| 45 | filename=project.bathymetry_filename, |
---|
| 46 | alpha=0.02, |
---|
| 47 | verbose=True, |
---|
| 48 | use_cache=True) |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | #------------------------- |
---|
| 52 | # Set simulation parameters |
---|
| 53 | #------------------------- |
---|
| 54 | domain.set_name(project.output_filename) # Name of output sww file |
---|
| 55 | domain.set_default_order(2) # Apply second order scheme |
---|
| 56 | domain.set_all_limiters(0.9) # Max second order scheme (old lim) |
---|
| 57 | domain.set_minimum_storable_height(0.001) # Don't store w < 0.001m |
---|
[4732] | 58 | domain.set_maximum_allowed_speed(0.0) # No runoff (0.1 is OK) |
---|
[4578] | 59 | domain.set_store_vertices_uniquely(False) |
---|
| 60 | #domain.set_quantities_to_be_stored(None) |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | #------------------------- |
---|
| 64 | # Boundary Conditions |
---|
| 65 | #------------------------- |
---|
| 66 | |
---|
| 67 | # Create boundary function from timeseries provided in file |
---|
| 68 | function = file_function(project.boundary_filename, |
---|
| 69 | domain, verbose=True) |
---|
| 70 | |
---|
| 71 | # Create and assign boundary objects |
---|
| 72 | Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
| 73 | Br = Reflective_boundary(domain) |
---|
| 74 | domain.set_boundary({'wave': Bts, 'wall': Br}) |
---|
| 75 | |
---|
[4685] | 76 | # Select optimisation |
---|
| 77 | domain.optimise_dry_cells = True |
---|
[4578] | 78 | |
---|
| 79 | #------------------------- |
---|
| 80 | # Evolve through time |
---|
| 81 | #------------------------- |
---|
| 82 | import time |
---|
| 83 | t0 = time.time() |
---|
| 84 | |
---|
[6766] | 85 | s = 'for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): domain.write_time()' |
---|
[4578] | 86 | |
---|
| 87 | import profile, pstats |
---|
| 88 | FN = 'profile.dat' |
---|
| 89 | |
---|
| 90 | profile.run(s, FN) |
---|
| 91 | |
---|
| 92 | print 'That took %.2f seconds' %(time.time()-t0) |
---|
| 93 | |
---|
| 94 | S = pstats.Stats(FN) |
---|
[6766] | 95 | s = S.sort_stats('time').print_stats(20) |
---|
[4724] | 96 | #s = S.sort_stats('cumulative').print_stats(30) |
---|
[4578] | 97 | |
---|
[6766] | 98 | #s.print_callers() |
---|
[6779] | 99 | print s |
---|
[4578] | 100 | |
---|