"""Simple water flow example using ANUGA Will Powers example of a simple sinusoidal wave which showed diffusive effects of thefirst order and standard second order method. Problem resolved if "rk2" timestepping and higher beta = 2 limiter used. Also new edge limiter with rk2 resolves problem """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ import sys from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross from anuga.shallow_water import Domain from anuga.shallow_water import Reflective_boundary from anuga.shallow_water import Dirichlet_boundary from anuga.shallow_water import Time_boundary from anuga.shallow_water import Transmissive_boundary from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files from math import cos from Numeric import zeros, Float from time import localtime, strftime, gmtime from os import sep #------------------------------------------------------------------------------- # Copy scripts to time stamped output directory and capture screen # output to file #------------------------------------------------------------------------------- model_name = 'tilted' time = strftime('%Y%m%d_%H%M%S',localtime()) output_dir = model_name + '_'+time output_file = model_name copy_code_files(output_dir,__file__) #start_screen_catcher(output_dir+sep) #------------------------------------------------------------------------------ # Setup domain #------------------------------------------------------------------------------ dx = 6.0*0.01 dy = dx L = 600*0.01 W = 10*dx # structured mesh points, vertices, boundary = rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, -W/2)) domain = Domain(points, vertices, boundary) domain.set_name(output_file) domain.set_datadir(output_dir) #------------------------------------------------------------------------------ # Setup Algorithm #------------------------------------------------------------------------------ domain.set_timestepping_method('rk2') domain.set_default_order(2) print domain.get_timestepping_method() domain.use_edge_limiter = True domain.tight_slope_limiters = True domain.CFL = 1.0 domain.beta_w = 0.6 domain.beta_w_dry = 0.0 domain.beta_uh = 0.6 domain.beta_uh_dry = 0.0 domain.beta_vh = 0.6 domain.beta_vh_dry = 0.0 domain.beta_h = 0.0 interactive_visualisation = True #------------------------------------------------------------------------------ # Setup initial conditions #------------------------------------------------------------------------------ domain.set_quantity('elevation',0.0) domain.set_quantity('friction', 0.00) domain.set_quantity('stage', lambda x,y : 14.0*0.01 + x/(600.0*0.01)*14.0*0.01 ) #----------------------------------------------------------------------------- # Setup boundary conditions #------------------------------------------------------------------------------ from math import sin, pi, exp Br = Reflective_boundary(domain) # Solid reflective wall # Associate boundary tags with boundary objects domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) #=============================================================================== if interactive_visualisation: from anuga.visualiser import RealtimeVisualiser vis = RealtimeVisualiser(domain) vis.render_quantity_height("stage", zScale =1, dynamic=True) vis.colour_height_quantity('stage', (1.0, 0.5, 0.5)) vis.start() #=============================================================================== #------------------------------------------------------------------------------ # Evolve system through time #------------------------------------------------------------------------------ for t in domain.evolve(yieldstep = 0.5, finaltime = 60.0): domain.write_time() if interactive_visualisation: vis.update() if interactive_visualisation: vis.evolveFinished()