Changeset 5370 for anuga_work
- Timestamp:
- May 27, 2008, 5:39:41 PM (17 years ago)
- Location:
- anuga_work/development
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/Hinwood_2008/create_mesh.py
r5092 r5370 1 """Create mesh for University of Queensland dam breakflume1 """Create mesh for Jon Hinwoods wave flume 2 2 """ 3 3 … … 6 6 from anuga.coordinate_transforms.geo_reference import Geo_reference 7 7 8 xslope = 5.0 # Distance between the boundary and ethe start of the slope8 xslope = 5.0 # Distance between the boundary and the start of the slope 9 9 10 10 11 def generate(mesh_filename, maximum_triangle_area=0.01):11 def generate(mesh_filename, slope, maximum_triangle_area=0.01): 12 12 """ 13 Generate mesh for University of Aberbeen dam break flume. 14 The gate position is the distance from the right wall of the wave tank 15 to the gate. 13 Generate mesh for Monash University wave generation flume. 14 15 Origin of x coordinate is the toe of the beach, x measured 16 positive shorewards. 16 17 17 18 """ … … 19 20 global xslope 20 21 21 xright = 19.0 22 xleft = slope['xleft'][0] 23 xtoe = slope['xtoe'][0] 24 xbeach = slope['xbeach'][0] 25 xright = slope['xright'][0] 22 26 ybottom = 0 23 27 ytop = 1.00 24 xleft = 0.025 28 ###xslope = slope 26 29 … … 32 35 33 36 34 # slope seperation (middle)35 point_ slope_top = [xslope, ytop]36 point_ slope_bottom = [xslope, ybottom]37 # 1st slope seperation (middle) 38 point_toe_top = [xtoe, ytop] 39 point_toe_bottom = [xtoe, ybottom] 37 40 41 # 2nd slope seperation (middle) 42 point_beach_top = [xbeach, ytop] 43 point_beach_bottom = [xbeach, ybottom] 44 38 45 m = Mesh() 39 46 … … 41 48 points = [point_sw, #se 42 49 point_nw, 43 point_slope_top, 50 point_toe_top, # 2 51 point_beach_top, # 3 44 52 point_ne, 45 53 point_se, 46 point_slope_bottom 54 point_beach_bottom, # 6 55 point_toe_bottom # 7 47 56 ] 48 57 … … 53 62 [3,4], 54 63 [4,5], 55 [5,0], #The outer border 56 [2,5] # slope separator 64 [5,6], 65 [6,7], 66 [7,0], #The outer border 67 [2,7], # toe separator 68 [3,6] # _beach separator 57 69 ] 58 70 59 segment_tags = {'wall':[1,2,3,4,5 ],71 segment_tags = {'wall':[1,2,3,4,5,6,7], 60 72 'wave':[0]} # '':[6] 61 73 62 74 m.add_points_and_segments(points, segments, segment_tags) 63 75 64 dam = m.add_region(xslope - 0.0000001,(ytop - ybottom)/2)65 # this is the location of the reservoir region.66 dam.setTag("flat")76 # dam = m.add_region(xslope - 0.0000001,(ytop - ybottom)/2) 77 # # this is the location of the reservoir region. 78 # dam.setTag("flat") 67 79 68 slope = m.add_region(xslope + 0.0000001,(ytop - ybottom)/2)69 # this is the location of the slope region.70 slope.setTag("slope")80 # slope = m.add_region(xslope + 0.0000001,(ytop - ybottom)/2) 81 # # this is the location of the slope region. 82 # slope.setTag("slope") 71 83 72 84 m.generate_mesh(maximum_triangle_area=maximum_triangle_area) -
anuga_work/development/Hinwood_2008/prepare_time_boundary.py
r5350 r5370 25 25 def prepare_time_boundary(filename): 26 26 """Convert benchmark 2 time series to NetCDF tms file. 27 This is a 'throw-away' code taylor made for files like 28 'Benchmark_2_input.txt' from the LWRU2 benchmark 27 29 28 """ 30 29 … … 35 34 # Read the ascii (.csv) version of this file 36 35 fid = open(filename[:-4] + '.csv') 37 38 # Skip first line39 line = fid.readline()40 36 41 37 # Read remaining lines … … 62 58 63 59 60 64 61 # Create tms NetCDF file 65 66 62 fid = NetCDFFile(filename, 'w') 67 63 fid.institution = 'Geoscience Australia' … … 87 83 """ 88 84 89 Convert the raw ishvelocity and depth values, which have values at85 Convert the raw velocity and depth values, which have values at 90 86 different times to a csv file, with values at the same time, with 91 87 SI units. 88 89 Set the depth values to be at the same times as the velocity values. 92 90 93 91 The format for the velocity file is; … … 98 96 [time, sec], [mm above SWL for sensor A], many other sensors... 99 97 """ 100 98 missing = 1e+20 99 101 100 # Read velocity file 102 101 vfid = open(velocity_file) … … 107 106 n_velocity = len(lines) 108 107 vtimes = zeros(n_velocity, Float) #Time 109 velocities = zeros(n_velocity, Float) # 108 x_velocities = zeros(n_velocity, Float) # 109 y_velocities = zeros(n_velocity, Float) # 110 110 111 111 for i, line in enumerate(lines): 112 fields = line.split( ',')112 fields = line.split() #(',') 113 113 114 114 vtimes[i] = float(fields[0]) 115 velocities[i] = float(fields[1]) 115 x_velocities[i] = float(fields[1]) 116 y_velocities[i] = float(fields[2]) 116 117 117 118 # Read the depth file … … 120 121 dfid.close() 121 122 122 123 123 124 n_depth = len(lines) 125 n_sensors = len(lines[0].split()) 124 126 dtimes = zeros(n_depth, Float) #Time 125 127 depths = zeros(n_depth, Float) # 128 sensors = zeros((n_depth,n_sensors), Float) 126 129 127 130 for i, line in enumerate(lines): 128 fields = line.split(',') 129 130 dtimes[i] = float(fields[0]) 131 depths[i] = float(fields[1]) 132 133 depths_at_vtimes = interp(dtimes, depths, vtimes, missing=1e+20) 131 fields = line.split() #(',') 132 fields = [float(j) for j in fields] 133 dtimes[i] = fields[0] 134 depths[i] = fields[1] 135 sensors[i] = fields 136 #print "dtimes", dtimes 137 #print "depths", depths 138 #print "vtimes", vtimes 139 depths_at_vtimes = interp( depths, dtimes, 140 vtimes, missing=missing) 134 141 depths_at_vtimes = ensure_numeric(depths_at_vtimes) 142 143 #print "len(dtimes)", len(vtimes) 144 #print "len(depths_at_vtimes)", len(depths_at_vtimes) 145 # for i in range(len(depths_at_vtimes)): 146 # print "i", i 147 # print "vtimes[i]", vtimes[i] 148 # print "depths_at_vtimes[i]", depths_at_vtimes[i] 149 # print "depths_at_vtimes", depths_at_vtimes 135 150 depths_at_vtimes = depths_at_vtimes/1000.00 # convert from mm to m 136 velocities = ensure_numeric(velocities) 137 velocities = velocities * -1.0 # Swap axis around 151 missing=missing/1000.00 # Do to missing what is done to depths_at_vtimes 152 x_velocities = ensure_numeric(x_velocities) 153 x_velocities = x_velocities * -1.0 # Swap axis around 154 y_velocities = ensure_numeric(y_velocities) 155 y_velocities = y_velocities * -1.0 # Swap axis around 138 156 139 157 fid = open(out_file,'w') 140 158 141 159 assert len(depths_at_vtimes) == len(vtimes) 142 160 start_time = None 161 #start_time = 0.0 143 162 #for vtime, depth_at_vtime, velocity in map(vtimes, depths_at_vtimes, 144 163 # velocities): 145 164 for i in xrange(len(vtimes)): 146 fid.write(str(vtimes[i]) + ',' + str(depths_at_vtimes[i]) \ 147 + ',' + str(velocities[i])+'\n') 148 149 fid.close() 165 if not depths_at_vtimes[i] == missing: 166 # Make the times start at zero. 167 if start_time is None: 168 start_time = vtimes[i] 169 fid.write(str(vtimes[i]-start_time) \ 170 + ',' + str(depths_at_vtimes[i]) \ 171 + ',' + str(x_velocities[i]) \ 172 + ',' + str(y_velocities[i])+'\n') 173 174 fid.close() 175 176 # Since there is a new time reference save the depth info using this 177 # new reference. 178 fid = open(depth_file[:-4] + '_new_time'+depth_file[-4:],'w') 179 sensors[:,0] -= start_time 180 #print "depth_file", depth_file 181 #print "start_time", start_time 182 for i in xrange(len(dtimes)): 183 fid.write(str(sensors[i,0])) 184 for j in xrange(1,len(sensors[0])): 185 fid.write(' ' + str(sensors[i,j])) 186 fid.write('\n') 187 fid.close() 188 150 189 151 190 152 191 #------------------------------------------------------------------- 153 192 if __name__ == "__main__": 154 combine_velocity_depth('T2R7velfilt.csv','T2R7pressfilt.csv', 'cyeah.csv') 155 193 from os import getenv 194 from os.path import join 195 home = getenv('INUNDATIONHOME') 196 Hinwood_dir = join(home,'data','flumes','Hinwood_2008') 197 raw_data_dir = join(Hinwood_dir, 'raw_data') 198 199 # Test 1 Run 5 200 combine_velocity_depth(join(raw_data_dir,'T1R5velfilt.txt'), 201 join(raw_data_dir,'T1R5pressfilt.txt'), 202 join(Hinwood_dir, 'T1R5_boundary.csv')) 203 # Create the tsm file 204 prepare_time_boundary(join(Hinwood_dir, 'T1R5_boundary.tsm')) 205 206 # Test 2 Run 7 207 combine_velocity_depth(join(raw_data_dir,'T2R7velfilt.txt'), 208 join(raw_data_dir,'T2R7pressfilt.txt'), 209 join(Hinwood_dir, 'T2R7_boundary.csv')) 210 # Create the tsm file 211 prepare_time_boundary(join(Hinwood_dir, 'T2R7_boundary.tsm')) -
anuga_work/development/Hinwood_2008/project.py
r5350 r5370 38 38 self.meshdir = scenariodir+sep+'meshes'+sep 39 39 self.scenariodir = scenariodir+sep 40 self.boundary _file = self.scenariodir + 'boundary.tsm'40 self.boundarydir = self.scenariodir 41 41 42 42 # creates copy of output dir structure, if it doesn't exist -
anuga_work/development/Hinwood_2008/run_dam.py
r5350 r5370 22 22 from shutil import copy 23 23 from os import path, sep 24 from os.path import dirname #, basename25 24 from os.path import dirname, join #, basename 25 from Numeric import zeros, size, Float 26 26 27 27 # Related major packages … … 40 40 import create_mesh 41 41 from prepare_time_boundary import prepare_time_boundary 42 43 44 45 def elevation_function(x,y): 46 from Numeric import zeros, size, Float 47 48 xslope = create_mesh.xslope #4 ## Bit of a magic Number 49 print "xslope",xslope 50 z = zeros(size(x), Float) 51 for i in range(len(x)): 52 if x[i] < xslope: 53 z[i] = 0.0 #WARNING: the code in prepare_time_boundary 54 # that calc's momentum assumes this is 0.0 55 else: 56 z[i] = (x[i]-xslope)*(1./16.) 57 return z 58 59 def main(friction=0.01, outputdir_name=None, is_trial_run=False): 42 from interp import interp 43 44 45 class Elevation_function: 46 def __init__(self, slope): 47 self.xslope_position = [slope['xleft'][0],slope['xtoe'][0], 48 slope['xbeach'][0],slope['xright'][0]] 49 self.yslope_height = [slope['xleft'][1],slope['xtoe'][1], 50 slope['xbeach'][1],slope['xright'][1]] 51 52 def __call__(self, x,y): 53 54 z = interp(self.yslope_height, self.xslope_position, x) 55 return z 56 57 def main(boundary_file, 58 boundary_location, 59 slope, 60 boundary_path=None, 61 friction=0.01, 62 outputdir_name=None, 63 is_trial_run=False): 60 64 61 65 … … 84 88 pro_instance.outputdir + 'create_mesh.py') 85 89 86 90 # Boundary file manipulation 91 if boundary_path is None: 92 boundary_path = pro_instance.boundarydir 93 boundary_file_path = join(boundary_path, boundary_file) 87 94 # Convert the boundary file, .csv to .tsm 88 95 try: 89 temp = open( pro_instance.boundary_file)96 temp = open(boundary_file_path) 90 97 temp.close() 91 98 except IOError: 92 prepare_time_boundary( pro_instance.boundary_file)99 prepare_time_boundary(boundary_file_path) 93 100 94 101 mesh_filename = pro_instance.meshdir + basename + '.msh' … … 110 117 # this creates the mesh 111 118 #gate_position = 12.0 112 create_mesh.generate(mesh_filename, 119 create_mesh.generate(mesh_filename, slope, 113 120 maximum_triangle_area=maximum_triangle_area) 114 121 … … 138 145 139 146 domain.set_quantity('stage', 0.4) 140 domain.set_quantity('friction', friction) 147 domain.set_quantity('friction', friction) 148 elevation_function = Elevation_function(slope) 141 149 domain.set_quantity('elevation', elevation_function) 142 150 … … 148 156 #Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) 149 157 try: 150 function = file_function( pro_instance.boundary_file, domain,158 function = file_function(boundary_file_path, domain, 151 159 verbose=True) 152 160 except IOError: … … 156 164 157 165 Br = Reflective_boundary(domain) 158 #Bd = Dirichlet_boundary([0.3,0,0])166 Bd = Dirichlet_boundary([0.3,0,0]) 159 167 Bts = Time_boundary(domain, function) 160 168 domain.set_boundary( {'wall': Br, 'wave': Bts} ) 169 domain.set_boundary( {'wall': Br, 'wave': Bd} ) 161 170 162 171 #------------------------------------------------------------------------- … … 165 174 t0 = time.time() 166 175 176 # It seems that ANUGA can't handle a starttime that is >0. 177 domain.starttime = 1.0 167 178 for t in domain.evolve(yieldstep, finaltime): 168 179 domain.write_time() … … 196 207 #------------------------------------------------------------- 197 208 if __name__ == "__main__": 198 main( is_trial_run = True, 209 #slopes = [[-4.5,0.0],[0.0,0.0],[1.285,0.090],[16.1,.960]] 210 slope = {'xleft':[-4.5,0.0], 211 'xtoe':[0.0,0.0], 212 'xbeach':[1.285,0.090], 213 'xright':[16.1,.960]} 214 main( 'T1R5_boundary.tsm', 8, slope, 215 is_trial_run = True, 199 216 outputdir_name='Hinwood_low_stage_low_velocity_draft') -
anuga_work/development/friction_UA_flume_2006/parallel_run_dam.py
r4443 r5370 9 9 10 10 e.g. 11 miprun -c 4 python parallel_run_dam.py 12 13 or 14 e.g. 15 miprun c4-8 python parallel_run_dam.py 11 mpirun -c 4 python parallel_run_dam.py 12 16 13 17 14
Note: See TracChangeset
for help on using the changeset viewer.