"""Validation of the AnuGA implementation of the shallow water wave equation. This script sets up LWRU2 benchmark with initial condition stated See also http://www.cee.cornell.edu/longwave/index.cfm?page=benchmark&problem=2 Depth at western boundary is d = 13.5 cm This a parallel version. """ # Module imports from Numeric import array, zeros, Float, allclose from anuga.shallow_water import Domain from anuga.shallow_water import Reflective_boundary from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary from anuga.abstract_2d_finite_volumes.util import file_function from anuga_parallel.parallel_api import myid, numprocs, distribute import project #------------------------- # Create Domain #------------------------- domain = Domain(project.mesh_filename, use_cache=True, verbose=True) domain.set_name('okushiri') domain.set_default_order(2) print domain.statistics() #------------------------- # Initial Conditions #------------------------- domain.set_quantity('friction', 0.0) domain.set_quantity('stage', 0.0) domain.set_quantity('elevation', filename = project.bathymetry_filename[:-4] + '.pts', alpha = 0.02, verbose = True, use_cache = True) #------------------------- # Boundary Conditions #------------------------- Br = Reflective_boundary(domain) domain.set_boundary({'wave': None, # Bind this one later 'wall': Br}) #------------------------- # Distribute domain #------------------------- #if numprocs > 1: # domain = distribute(domain) domain = distribute(domain) # Bind boundary, that cannot be fully specified before distribution. function = file_function(project.boundary_filename[:-4] + '.tms', domain, verbose=True) Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) domain.modify_boundary({'wave': Bts}) #------------------------- # Evolve through time #------------------------- import time t0 = time.time() for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): domain.write_time() print 'That took %.2f seconds' %(time.time()-t0)