"""Simple water flow example using ANUGA """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ from anuga.abstract_2d_finite_volumes.mesh_factory import * from anuga.shallow_water import * from anuga.shallow_water.shallow_water_domain import * from math import * from numpy import * import numpy from matplotlib import * from pylab import * import csv #Parameters filename = "WORKING-RIP-LAB_Expt-Geometry_Triangular_Mesh" location_of_shore = 140 #the position along the y axis of the shorefront sandbar = 1.2 #height of sandbar sealevel = 0 #height of coast above sea level steepness = 8000 #period of sandbar - larger number gives smoother slope - longer period halfchannelwidth = 5 bank_slope = 0.1 simulation_length = 1 timestep = 1 #------------------------------------------------------------------------------ # Setup computational domain #------------------------------------------------------------------------------ length = 120 width = 170 seafloor_resolution = 60.0 # Resolution: Max area of triangles in the mesh for seafloor feature_resolution = 1.0 beach_resolution = 10.0 sea_boundary_polygon = [[0,0],[length,0],[length,width],[0,width]] feature_boundary_polygon = [[0,100],[length,100],[length,150],[0,150]] beach_interior_polygon = [[0,150],[length,150],[length,width],[0,width]] meshname = str(filename)+'.msh' #interior regions feature_regions = [[feature_boundary_polygon, feature_resolution], [beach_interior_polygon, beach_resolution]] create_mesh_from_regions(sea_boundary_polygon, boundary_tags={'bottom': [0], 'right' : [1], 'top' : [2], 'left': [3]}, maximum_triangle_area = seafloor_resolution, filename = meshname, interior_regions = feature_regions, use_cache = False, verbose = False) domain = Domain(meshname, use_cache=True, verbose=True) domain.set_name(filename) # Output name print domain.statistics() #------------------------------------------------------------------------------ # Setup initial conditions #------------------------------------------------------------------------------ def topography(x,y): """Complex topography defined by a function of vectors x and y.""" #general slope and buildings z=0.05*(y-(location_of_shore)) N = len(x) for i in range(N): if y[i] < 25: z[i] = (0.2*(y[i]-25)) + 0.05*(y[i]-(location_of_shore)) for i in range(N): if y[i]>150: z[i] = (0.1*(y[i]-150)) + 0.05*(y[i] - (location_of_shore)) return z def topography3(x,y): z=0*x N = len(x) for i in range(N): if -1*(bank_slope)*x[i] + 112 < y[i] < -1*(bank_slope)*x[i] + 124 and 0> x_output, " " print >> y_output, " " print >> x_output, u_average print >> y_output, v_average X = [x[0] for x in csv.reader(open('New_gauges.csv','r'),dialect='excel',delimiter=",") ] Y = [x[1] for x in csv.reader(open('New_gauges.csv','r'),dialect='excel',delimiter=",") ] U = u_average.tolist() V = v_average.tolist() print "U = ", U print "U has type", type(U) from matplotlib import * from pylab import * figure() quiver(X,Y,U,V) show()