alpha=0.0, domain=domain, verbose=project.verbose) #------------------------------------------------------------------------------ # Setup boundary condition #------------------------------------------------------------------------------ print 'Available boundary tags', domain.get_boundary_tags() Bd = anuga.Dirichlet_boundary([tide, 0, 0]) # Mean water level Bs = anuga.Transmissive_stage_zero_momentum_boundary( domain) # Neutral boundary if project.scenario == 'fixed_wave': # Huge 10.94m wave starting after 60 seconds and lasting 60 minutes. Bw = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( domain=domain, function=lambda t: [(60 < t < 3660) * 10.94, 0, 0]) Bt = anuga.Time_boundary(domain=domain, function=lambda t: [(60 < t < 3660) * 11, 0, 0], default_boundary=None, verbose=False) domain.set_boundary({ 'bottom_ocean': Bd, 'west': Bs, 'onshore': Bw, 'east': Bs }) if project.scenario == 'slide': # Boundary conditions for slide scenario
#----------------------------------------------------------------------------- # Setup boundary conditions #------------------------------------------------------------------------------ from math import sin, pi, exp Br = anuga.Reflective_boundary(domain) # Solid reflective wall #Bt = anuga.Transmissive_boundary(domain) # Continue all values on boundary amplitude = 1 wave_length = 300.0 # Incoming wave def waveform2(t): return amplitude*sin((1./wave_length)*t*2*pi) Bw2 = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, waveform2) # A radiation type condition on the other side def zero_fun(t): return 0.0 Bw5 = anuga.Flather_external_stage_zero_velocity_boundary(domain, zero_fun) # Associate boundary tags with boundary objects domain.set_boundary({'left': Bw2, 'right': Bw5, 'top': Br, 'bottom': Br}) #------------------------------------------------------------------------------ # Produce a documentation of parameters #------------------------------------------------------------------------------ if myid == 0:
domain.set_flow_algorithm(alg) else: domain = None domain = distribute(domain) #------------------------- # Boundary Conditions #------------------------- # Create boundary function from timeseries provided in file wave_function = anuga.file_function(boundary_filename, domain, verbose=verbose) # Create and assign boundary objects Bts = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( domain, wave_function) Br = anuga.Reflective_boundary(domain) domain.set_boundary({'wave': Bts, 'wall': Br}) #------------------------------------------------------------------------- # Produce a documentation of parameters #------------------------------------------------------------------------- from anuga.validation_utilities import save_parameters_tex save_parameters_tex(domain) #------------------------- # Evolve through time #------------------------- import time
def generate_cairns_domain(gpu=False): #----------------------------------------------------------------------- # Preparation of topographic data # Convert ASC 2 DEM 2 PTS using source data # and store result in source data #----------------------------------------------------------------------- # Create DEM from asc data anuga.asc2dem(project.name_stem + '.asc', use_cache=True, verbose=True) # Create pts file for onshore DEM anuga.dem2pts(project.name_stem + '.dem', use_cache=True, verbose=True) #----------------------------------------------------------------------- # Create the triangular mesh and domain based on # overall clipping polygon with a tagged # boundary and interior regions as defined in project.py #----------------------------------------------------------------------- domain = anuga.create_domain_from_regions( project.bounding_polygon, boundary_tags={ 'top': [0], 'ocean_east': [1], 'bottom': [2], 'onshore': [3] }, maximum_triangle_area=project.default_res, mesh_filename=project.meshname, interior_regions=project.interior_regions, use_cache=True, verbose=True) if gpu: #domain.__class__ = GPU_domain domain = GPU_domain(domain=domain) # Print some stats about mesh and domain print 'Number of triangles = ', len(domain) #print 'The extent is ', domain.get_extent() #print domain.statistics() #----------------------------------------------------------------------- # Setup parameters of computational domain #----------------------------------------------------------------------- domain.set_name('cairns_' + project.scenario) # Name of sww file domain.set_datadir('.') # Store sww output here domain.set_minimum_storable_height(0.01) # Store only depth > 1cm domain.set_flow_algorithm('tsunami') #----------------------------------------------------------------------- # Setup initial conditions #----------------------------------------------------------------------- tide = 0.0 domain.set_quantity('stage', tide) domain.set_quantity('friction', 0.0) domain.set_quantity('elevation', filename=project.name_stem + '.pts', use_cache=True, verbose=True, alpha=0.1) #----------------------------------------------------------------------- # Setup information for slide scenario # (to be applied 1 min into simulation #----------------------------------------------------------------------- if project.scenario == 'slide': # Function for submarine slide tsunami_source = anuga.slide_tsunami(length=35000.0, depth=project.slide_depth, slope=6.0, thickness=500.0, x0=project.slide_origin[0], y0=project.slide_origin[1], alpha=0.0, domain=domain, verbose=True) #----------------------------------------------------------------------- # Setup boundary conditions #----------------------------------------------------------------------- print 'Available boundary tags', domain.get_boundary_tags() Bd = anuga.Dirichlet_boundary([tide, 0, 0]) # Mean water level Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary if project.scenario == 'fixed_wave': # Huge 50m wave starting after 60 seconds and lasting 1 hour. Bw = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( domain=domain, function=lambda t: [(60 < t < 3660) * 50, 0, 0]) domain.set_boundary({ 'ocean_east': Bw, 'bottom': Bs, 'onshore': Bd, 'top': Bs }) if project.scenario == 'slide': # Boundary conditions for slide scenario domain.set_boundary({ 'ocean_east': Bd, 'bottom': Bd, 'onshore': Bd, 'top': Bd }) if gpu: if '-gpu' in sys.argv: domain.using_gpu = True print " --> Enable GPU version" return domain
#------------------------------------------------------------------------------ # # Setup boundary conditions # #------------------------------------------------------------------------------ Br = anuga.Reflective_boundary(domain) # Solid reflective wall def outflow_stage_boundary(t): return 0.7 + 0.3 * numpy.sin( 2. * numpy.pi * t / (30. * 60.)) - 1.0 # Note elevation datum differs in hecras and ANUGA Bout_tmss = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( domain, function=outflow_stage_boundary) domain.set_boundary({ 'left': Br, 'right': Br, 'top1': Br, 'top2': Br, 'bottom1': Br, 'bottom2': Br, 'chan_out': Bout_tmss, 'chan_in': Br }) #------------------------------------------------------------------------------ # Produce a documentation of parameters #------------------------------------------------------------------------------
domain.set_quantities_to_be_monitored(['stage', 'xmomentum', 'ymomentum']) if myid == 0: print('running project:', project.scenario) #------------------------------------------------------------------------------ # Setup boundary conditions #------------------------------------------------------------------------------ #print 'Available boundary tags', domain.get_boundary_tags() def tide_fun(t): return tide Bd = anuga.Dirichlet_boundary([tide, 0, 0]) # Mean water level #Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary Bs = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary( domain, tide_fun) Bf = anuga.Flather_external_stage_zero_velocity_boundary(domain, tide_fun) Bt = anuga.Transmissive_boundary(domain) # Neutral boundary Br = anuga.Reflective_boundary(domain) # Boundary conditions for slide scenario domain.set_boundary({'ocean_east': Bf, 'bottom': Bf, 'onshore': Br, 'top': Bf}) if myid == 0: print(domain.boundary_statistics(tags=['ocean_east', 'onshore'])) #------------------------------------------------------------------------------ # Evolve system through time #------------------------------------------------------------------------------ # initial time t0 = time.time() min = 60 hour = 3600