""" Main meribula script using new interface """ #------------------------------- # Module imports #------------------------------- import sys, os from pyvolution.shallow_water import Domain, Reflective_boundary,\ File_boundary, Transmissive_Momentum_Set_Stage_boundary from pyvolution.mesh_factory import rectangular_cross from pyvolution.pmesh2domain import pmesh_to_domain_instance from Numeric import array, zeros, Float, allclose import project from caching import cache #------------------------------- # Domain #------------------------------- print 'Creating domain from', project.mesh_filename domain = cache(pmesh_to_domain_instance, (project.mesh_filename, Domain), dependencies = [project.mesh_filename]) #domain = pmesh_to_domain_instance(project.mesh_filename, Domain) domain.check_integrity() print 'Number of triangles = ', len(domain) print 'The extent is ', domain.get_extent() #------------------------------- # Initial Conditions #------------------------------- print 'Initial values' domain.set_quantity('elevation', filename = project.bathymetry_filename[:-4] + '.xya', alpha = 10.0, verbose = True, use_cache = True) domain.set_quantity('friction', 0.03) domain.set_quantity('stage', 0.0) #------------------------------- # Boundary conditions #------------------------------- print 'Boundaries' # Tidal cycle recorded at Eden as open print 'Open sea boundary condition from ',project.boundary_filename from pyvolution.util import file_function tide_function = file_function(project.boundary_filename[:-4] + '.tms', domain, verbose = True) Bts = Transmissive_Momentum_Set_Stage_boundary(domain, tide_function) # All other boundaries are reflective Br = Reflective_boundary(domain) domain.set_boundary({'exterior': Br, 'open': Bts}) #------------------------------- # Setup domain runtime parameters #------------------------------- domain.visualise = True domain.visualise_color_stage = True base = os.path.basename(sys.argv[0]) domain.filename, _ = os.path.splitext(base) domain.default_order = 2 domain.store = True #Store for visualisation purposes #------------------------------- # Evolve #------------------------------- import time t0 = time.time() yieldstep = 60 finaltime = 3600*24 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): domain.write_time() print 'That took %.2f seconds' %(time.time()-t0)