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 | domain.set_name('okushiri') |
---|
32 | domain.set_default_order(2) |
---|
33 | print domain.statistics() |
---|
34 | |
---|
35 | |
---|
36 | #------------------------- |
---|
37 | # Initial Conditions |
---|
38 | #------------------------- |
---|
39 | domain.set_quantity('friction', 0.0) |
---|
40 | domain.set_quantity('stage', 0.0) |
---|
41 | domain.set_quantity('elevation', |
---|
42 | filename = project.bathymetry_filename[:-4] + '.pts', |
---|
43 | alpha = 0.02, |
---|
44 | verbose = True, |
---|
45 | use_cache = True) |
---|
46 | |
---|
47 | #------------------------- |
---|
48 | # Boundary Conditions |
---|
49 | #------------------------- |
---|
50 | Br = Reflective_boundary(domain) |
---|
51 | |
---|
52 | # Note this boundary cannot be fully specified here and |
---|
53 | # distributed without problem. |
---|
54 | #Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
55 | |
---|
56 | domain.set_boundary({'wave': None, # Bind this one later |
---|
57 | 'wall': Br}) |
---|
58 | |
---|
59 | |
---|
60 | #------------------------- |
---|
61 | # Distribute domain |
---|
62 | #------------------------- |
---|
63 | if numprocs > 1: |
---|
64 | domain = distribute(domain) |
---|
65 | |
---|
66 | function = file_function(project.boundary_filename[:-4] + '.tms', |
---|
67 | domain, |
---|
68 | verbose=True) |
---|
69 | |
---|
70 | Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) |
---|
71 | domain.modify_boundary({'wave': Bts}) |
---|
72 | |
---|
73 | #------------------------- |
---|
74 | # Evolve through time |
---|
75 | #------------------------- |
---|
76 | import time |
---|
77 | t0 = time.time() |
---|
78 | |
---|
79 | for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): |
---|
80 | domain.write_time() |
---|
81 | |
---|
82 | print 'That took %.2f seconds' %(time.time()-t0) |
---|