1 | """Validation of the AnuGA implementation of the shallow water wave equation. |
---|
2 | |
---|
3 | This script sets up LWRU2 benchmark with initial condition stated |
---|
4 | |
---|
5 | See also |
---|
6 | |
---|
7 | http://www.cee.cornell.edu/longwave/index.cfm?page=benchmark&problem=2 |
---|
8 | |
---|
9 | Depth at western boundary is d = 13.5 cm |
---|
10 | |
---|
11 | This a parallel version. |
---|
12 | """ |
---|
13 | |
---|
14 | # Module imports |
---|
15 | from Numeric import array, zeros, Float, allclose |
---|
16 | |
---|
17 | from anuga.shallow_water import Domain |
---|
18 | from anuga.shallow_water import Reflective_boundary |
---|
19 | from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary |
---|
20 | from anuga.abstract_2d_finite_volumes.util import file_function |
---|
21 | |
---|
22 | from anuga_parallel.parallel_api import myid, numprocs, distribute |
---|
23 | |
---|
24 | import project |
---|
25 | |
---|
26 | |
---|
27 | #------------------------- |
---|
28 | # Create Domain |
---|
29 | #------------------------- |
---|
30 | domain = Domain(project.mesh_filename, use_cache=True, verbose=True) |
---|
31 | |
---|
32 | #------------------------- |
---|
33 | # Initial Conditions |
---|
34 | #------------------------- |
---|
35 | domain.set_quantity('friction', 0.0) |
---|
36 | domain.set_quantity('stage', 0.0) |
---|
37 | domain.set_quantity('elevation', |
---|
38 | filename = project.bathymetry_filename[:-4] + '.pts', |
---|
39 | alpha = 0.02, |
---|
40 | verbose = True, |
---|
41 | use_cache = True) |
---|
42 | |
---|
43 | |
---|
44 | #------------------------- |
---|
45 | # Distribute domain |
---|
46 | #------------------------- |
---|
47 | domain = distribute(domain) |
---|
48 | |
---|
49 | # Parameters |
---|
50 | domain.set_name('okushiri_parallel') |
---|
51 | domain.set_minimum_storable_height(0.001) |
---|
52 | domain.set_default_order(2) |
---|
53 | domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK) |
---|
54 | |
---|
55 | # Set old (pre Sep 2006) defaults for limiters |
---|
56 | domain.beta_w = 0.9 |
---|
57 | domain.beta_w_dry = 0.9 |
---|
58 | domain.beta_uh = 0.9 |
---|
59 | domain.beta_uh_dry = 0.9 |
---|
60 | domain.beta_vh = 0.9 |
---|
61 | domain.beta_vh_dry = 0.9 |
---|
62 | |
---|
63 | |
---|
64 | #------------------------------------------------------------------------------ |
---|
65 | # Setup boundary conditions |
---|
66 | # (MUST currently happen after domain has been distributed) |
---|
67 | #------------------------------------------------------------------------------ |
---|
68 | |
---|
69 | Br = Reflective_boundary(domain) # Solid reflective wall |
---|
70 | |
---|
71 | function = file_function(project.boundary_filename[:-4] + '.tms', |
---|
72 | domain, |
---|
73 | verbose=True) |
---|
74 | |
---|
75 | Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
76 | |
---|
77 | domain.set_boundary({'wave': Bts, # Bind this one later |
---|
78 | 'wall': Br}) |
---|
79 | |
---|
80 | |
---|
81 | #------------------------- |
---|
82 | # Evolve through time |
---|
83 | #------------------------- |
---|
84 | import time |
---|
85 | t0 = time.time() |
---|
86 | |
---|
87 | for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): |
---|
88 | domain.write_time() |
---|
89 | |
---|
90 | if myid == 0: |
---|
91 | print 'That took %.2f seconds' %(time.time()-t0) |
---|