Changeset 3846
- Timestamp:
- Oct 24, 2006, 12:59:08 PM (19 years ago)
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py
r3829 r3846 196 196 from anuga.config import default_datadir 197 197 self.datadir = default_datadir 198 self. filename = 'domain'198 self.simulation_name = 'domain' 199 199 self.checkpoint = False 200 200 … … 633 633 634 634 def get_name(self): 635 return self. filename635 return self.simulation_name 636 636 637 637 def set_name(self, name): 638 self.filename = name 638 """Assign a name to this simulation. 639 This will be used to identify the output sww file. 640 641 """ 642 if name.endswith('.sww'): 643 name = name[-4:] 644 645 self.simulation_name = name 639 646 640 647 def get_datadir(self): -
anuga_core/source/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py
r3655 r3846 39 39 #domain.visualise = True 40 40 domain.default_order = 2 41 domain. filename = 'show_balanced_limiters'41 domain.set_name('show_balanced_limiters') 42 42 domain.store = True 43 43 domain.format = 'sww' #Native netcdf visualisation format -
anuga_core/source/anuga/damage_modelling/test_inundation_damage.py
r3807 r3846 115 115 116 116 #sww_file = tempfile.mktemp("") 117 self.domain.filename = 'datatest' + str(time.time()) 118 #self.domain.filename = sww_file 119 #print "self.domain.filename",self.domain.filename 117 self.domain.set_name('datatest' + str(time.time())) 120 118 self.domain.format = 'sww' 121 119 self.domain.smooth = True … … 158 156 # Note, this isn't testing the results, 159 157 # just that is all runs 160 sww_file = self.domain. filename+ "." + self.domain.format158 sww_file = self.domain.get_name() + "." + self.domain.format 161 159 #print "sww_file",sww_file 162 160 inundation_damage(sww_file, self.csv_file, verbose=False) … … 197 195 198 196 #sww_file = tempfile.mktemp("") 199 domain.filename = 'datatest' + str(time.time()) 200 #domain.filename = sww_file 201 #print "domain.filename",domain.filename 197 domain.set_name('datatest' + str(time.time())) 202 198 domain.format = 'sww' 203 199 domain.smooth = True … … 222 218 fd.close() 223 219 224 sww_file = domain. filename+ "." + domain.format220 sww_file = domain.get_name() + "." + domain.format 225 221 #print "sww_file",sww_file 226 222 inundation_damage(sww_file, csv_file, verbose=False) … … 239 235 240 236 def ztest_add_depth_and_momentum2csv(self): 241 sww_file = self.domain. filename+ "." + self.domain.format237 sww_file = self.domain.get_name() + "." + self.domain.format 242 238 #print "sww_file",sww_file 243 239 -
anuga_core/source/anuga/examples/beach.py
r3656 r3846 37 37 domain.default_order = 2 38 38 print "Output being written to " + domain.get_datadir() + sep + \ 39 domain. filename+ domain.format39 domain.get_name() + domain.format 40 40 41 41 -
anuga_core/source/anuga/examples/cornell_room.py
r3565 r3846 73 73 else: 74 74 s = 'nonsmooth' 75 domain. filename = root + '_' + s75 domain.set_name(root + '_' + s) 76 76 77 77 #Set bed-slope and friction -
anuga_core/source/anuga/examples/flatbed.py
r3565 r3846 25 25 domain.set_name('polygons') 26 26 print "Output being written to " + domain.get_datadir() + sep + \ 27 domain. filename+ "_size%d." %len(domain) + domain.format27 domain.get_name() + "_size%d." %len(domain) + domain.format 28 28 29 29 -
anuga_core/source/anuga/examples/netherlands.py
r3842 r3846 126 126 #FIXME: This was os.path.splitext but caused weird filenames based on root 127 127 base = os.path.basename(sys.argv[0]) 128 domain.filename, _ = os.path.splitext(base) 128 basename, _ = os.path.splitext(base) 129 domain.set_name(basename) 129 130 else: 130 131 #domain.initialise_visualiser(rect=[0.0,0.0,1.0,1.0]) -
anuga_core/source/anuga/examples/pressure_force.py
r3565 r3846 24 24 25 25 domain.store = True 26 domain. filename = 'pressure'26 domain.set_name('pressure') 27 27 28 28 ####################### -
anuga_core/source/anuga/examples/run_gong.py
r3535 r3846 63 63 file_path, filename = path.split(filename) 64 64 filename, ext = path.splitext(filename) 65 domain. filename =filename + '_' + '_ys'+ str(yieldstep) + \66 '_ft' + str(finaltime)65 domain.set_name(filename + '_' + '_ys'+ str(yieldstep) + \ 66 '_ft' + str(finaltime)) 67 67 print "Output being written to " + domain.get_datadir() + sep + \ 68 domain. filename+ "." + domain.format68 domain.get_name() + "." + domain.format 69 69 70 70 -
anuga_core/source/anuga/examples/run_tsh.py
r3535 r3846 76 76 else: 77 77 s = 'nonsmooth' 78 domain. filename =filename + '_' + s + '_ys'+ str(yieldstep) + \79 '_ft' + str(finaltime)78 domain.set_name(filename + '_' + s + '_ys'+ str(yieldstep) + \ 79 '_ft' + str(finaltime)) 80 80 print "Output being written to " + domain.get_datadir() + sep + \ 81 domain. filename+ "." + domain.format81 domain.get_name() + "." + domain.format 82 82 83 83 -
anuga_core/source/anuga/examples/run_tsh_weir.py
r3565 r3846 41 41 domain.store = False #True 42 42 domain.format = 'sww' 43 domain. filename = 'weir'43 domain.set_name('weir') 44 44 domain.checkpoint = False #True 45 45 domain.visualise = True #False -
anuga_core/source/anuga/examples/twolevels.py
r3567 r3846 25 25 domain.set_name('two_levels') 26 26 print "Output being written to " + domain.get_datadir() + sep + \ 27 domain. filename+ "_size%d." %len(domain) + domain.format27 domain.get_name() + "_size%d." %len(domain) + domain.format 28 28 29 29 -
anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r3689 r3846 1493 1493 domain.set_quantity('stage', 1.0) 1494 1494 1495 #sww_file = tempfile.mktemp("") 1496 domain.filename = 'datatest' + str(time.time()) 1497 #domain.filename = sww_file 1498 #print "domain.filename",domain.filename 1495 1496 domain.set_name('datatest' + str(time.time())) 1499 1497 domain.format = 'sww' 1500 1498 domain.smooth = True -
anuga_core/source/anuga/shallow_water/data_manager.py
r3830 r3846 212 212 213 213 #Create filename 214 #self.filename = create_filename(domain.get_datadir(),215 #domain.get_name(), extension, len(domain))216 217 218 214 self.filename = create_filename(domain.get_datadir(), 219 215 domain.get_name(), extension) … … 429 425 #remember the old filename, then give domain a 430 426 #name with the extension 431 old_domain_filename = self.domain. filename427 old_domain_filename = self.domain.get_name() 432 428 if not self.recursion: 433 self.domain.filename = self.domain.filename+filename_ext 429 self.domain.set_name(old_domain_filename+filename_ext) 430 434 431 435 432 #change the domain starttime to the current time … … 456 453 #restore the old starttime and filename 457 454 self.domain.starttime = old_domain_starttime 458 self.domain. filename = old_domain_filename455 self.domain.set_name(old_domain_filename) 459 456 else: 460 457 self.recursion = False … … 3563 3560 file_path, filename = path.split(filename) 3564 3561 filename, ext = path.splitext(filename) 3565 domain. filename = filename3562 domain.set_name(filename) 3566 3563 domain.reduction = mean 3567 3564 if verbose == True:print "file_path",file_path … … 3571 3568 if verbose == True: 3572 3569 print "Output written to " + domain.get_datadir() + sep + \ 3573 domain. filename+ "." + domain.format3570 domain.get_name() + "." + domain.format 3574 3571 sww = get_dataobject(domain) 3575 3572 sww.store_connectivity() -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r3820 r3846 162 162 from Scientific.IO.NetCDF import NetCDFFile 163 163 164 self.domain. filename = 'datatest' + str(id(self))165 self.domain.format = 'sww' 164 self.domain.set_name('datatest' + str(id(self))) 165 self.domain.format = 'sww' #Remove?? 166 166 self.domain.smooth = False 167 167 … … 209 209 from Scientific.IO.NetCDF import NetCDFFile 210 210 211 self.domain. filename = 'datatest' + str(id(self))211 self.domain.set_name('datatest' + str(id(self))) 212 212 self.domain.format = 'sww' 213 213 self.domain.smooth = True … … 266 266 from Scientific.IO.NetCDF import NetCDFFile 267 267 268 self.domain. filename = 'datatest' + str(id(self))268 self.domain.set_name('datatest' + str(id(self))) 269 269 self.domain.format = 'sww' 270 270 self.domain.smooth = True … … 321 321 from Scientific.IO.NetCDF import NetCDFFile 322 322 323 self.domain. filename = 'datatest' + str(id(self))323 self.domain.set_name('datatest' + str(id(self))) 324 324 self.domain.format = 'sww' 325 325 self.domain.smooth = True … … 376 376 from Scientific.IO.NetCDF import NetCDFFile 377 377 378 self.domain. filename = 'datatest' + str(id(self))378 self.domain.set_name('datatest' + str(id(self))) 379 379 self.domain.format = 'sww' 380 380 self.domain.smooth = True … … 432 432 from Scientific.IO.NetCDF import NetCDFFile 433 433 434 self.domain. filename = 'synctest'434 self.domain.set_name('synctest') 435 435 self.domain.format = 'sww' 436 436 self.domain.smooth = False … … 467 467 from Scientific.IO.NetCDF import NetCDFFile 468 468 469 self.domain. filename = 'datatest' + str(id(self))469 self.domain.set_name('datatest' + str(id(self))) 470 470 self.domain.format = 'sww' 471 471 self.domain.smooth = True … … 515 515 from Scientific.IO.NetCDF import NetCDFFile 516 516 517 self.domain. filename = 'datatest' + str(id(self))517 self.domain.set_name('datatest' + str(id(self))) 518 518 self.domain.format = 'sww' 519 519 self.domain.smooth = True … … 1136 1136 1137 1137 #Setup 1138 self.domain. filename = 'datatest'1139 1140 prjfile = self.domain. filename+ '_elevation.prj'1141 ascfile = self.domain. filename+ '_elevation.asc'1142 swwfile = self.domain. filename+ '.sww'1138 self.domain.set_name('datatest') 1139 1140 prjfile = self.domain.get_name() + '_elevation.prj' 1141 ascfile = self.domain.get_name() + '_elevation.asc' 1142 swwfile = self.domain.get_name() + '.sww' 1143 1143 1144 1144 self.domain.set_datadir('.') … … 1171 1171 1172 1172 #Export to ascii/prj files 1173 sww2dem(self.domain. filename,1173 sww2dem(self.domain.get_name(), 1174 1174 quantity = 'elevation', 1175 1175 cellsize = cellsize, … … 1303 1303 domain.default_order = 2 1304 1304 1305 domain. filename = 'datatest'1306 1307 prjfile = domain. filename+ '_elevation.prj'1308 ascfile = domain. filename+ '_elevation.asc'1309 swwfile = domain. filename+ '.sww'1305 domain.set_name('datatest') 1306 1307 prjfile = domain.get_name() + '_elevation.prj' 1308 ascfile = domain.get_name() + '_elevation.asc' 1309 swwfile = domain.get_name() + '.sww' 1310 1310 1311 1311 domain.set_datadir('.') … … 1347 1347 1348 1348 #Export to ascii/prj files 1349 sww2dem(domain. filename,1349 sww2dem(domain.get_name(), 1350 1350 quantity = 'elevation', 1351 1351 cellsize = cellsize, … … 1487 1487 domain.default_order = 2 1488 1488 1489 domain. filename = 'datatest'1490 1491 prjfile = domain. filename+ '_elevation.prj'1492 ascfile = domain. filename+ '_elevation.asc'1493 swwfile = domain. filename+ '.sww'1489 domain.set_name('datatest') 1490 1491 prjfile = domain.get_name() + '_elevation.prj' 1492 ascfile = domain.get_name() + '_elevation.asc' 1493 swwfile = domain.get_name() + '.sww' 1494 1494 1495 1495 domain.set_datadir('.') … … 1531 1531 1532 1532 #Export to ascii/prj files 1533 sww2dem(domain. filename,1533 sww2dem(domain.get_name(), 1534 1534 quantity = 'elevation', 1535 1535 cellsize = cellsize, … … 1641 1641 1642 1642 #Setup 1643 self.domain. filename = 'datatest'1644 1645 prjfile = self.domain. filename+ '_stage.prj'1646 ascfile = self.domain. filename+ '_stage.asc'1647 swwfile = self.domain. filename+ '.sww'1643 self.domain.set_name('datatest') 1644 1645 prjfile = self.domain.get_name() + '_stage.prj' 1646 ascfile = self.domain.get_name() + '_stage.asc' 1647 swwfile = self.domain.get_name() + '.sww' 1648 1648 1649 1649 self.domain.set_datadir('.') … … 1677 1677 1678 1678 #Export to ascii/prj files 1679 sww2dem(self.domain. filename,1679 sww2dem(self.domain.get_name(), 1680 1680 quantity = 'stage', 1681 1681 cellsize = cellsize, 1682 1682 reduction = min, 1683 1683 format = 'asc') 1684 1684 1685 1685 … … 1750 1750 1751 1751 #Setup 1752 self.domain. filename = 'datatest'1753 1754 prjfile = self.domain. filename+ '_depth.prj'1755 ascfile = self.domain. filename+ '_depth.asc'1756 swwfile = self.domain. filename+ '.sww'1752 self.domain.set_name('datatest') 1753 1754 prjfile = self.domain.get_name() + '_depth.prj' 1755 ascfile = self.domain.get_name() + '_depth.asc' 1756 swwfile = self.domain.get_name() + '.sww' 1757 1757 1758 1758 self.domain.set_datadir('.') … … 1787 1787 1788 1788 #Export to ascii/prj files 1789 sww2dem(self.domain. filename,1789 sww2dem(self.domain.get_name(), 1790 1790 basename_out = 'datatest_depth', 1791 1791 quantity = 'stage - elevation', 1792 1792 cellsize = cellsize, 1793 1793 reduction = min, 1794 1794 format = 'asc', 1795 1795 verbose = False) 1796 1796 … … 1905 1905 domain.distribute_to_vertices_and_edges() 1906 1906 1907 domain. filename = 'datatest'1908 1909 prjfile = domain. filename+ '_elevation.prj'1910 ascfile = domain. filename+ '_elevation.asc'1911 swwfile = domain. filename+ '.sww'1907 domain.set_name('datatest') 1908 1909 prjfile = domain.get_name() + '_elevation.prj' 1910 ascfile = domain.get_name() + '_elevation.asc' 1911 swwfile = domain.get_name() + '.sww' 1912 1912 1913 1913 domain.set_datadir('.') … … 1939 1939 1940 1940 #Export to ascii/prj files 1941 sww2dem(domain. filename,1941 sww2dem(domain.get_name(), 1942 1942 quantity = 'elevation', 1943 1943 cellsize = cellsize, 1944 1944 verbose = False, 1945 1945 format = 'asc') 1946 1946 1947 1947 … … 2011 2011 2012 2012 #Setup 2013 self.domain. filename = 'datatest'2014 2015 headerfile = self.domain. filename+ '.ers'2016 swwfile = self.domain. filename+ '.sww'2013 self.domain.set_name('datatest') 2014 2015 headerfile = self.domain.get_name() + '.ers' 2016 swwfile = self.domain.get_name() + '.sww' 2017 2017 2018 2018 self.domain.set_datadir('.') … … 2045 2045 2046 2046 #Export to ers files 2047 sww2dem(self.domain. filename,2047 sww2dem(self.domain.get_name(), 2048 2048 quantity = 'elevation', 2049 2049 cellsize = cellsize, 2050 2050 NODATA_value = NODATA_value, 2051 2051 verbose = False, 2052 2052 format = 'ers') 2053 2053 2054 2054 #Check header data 2055 2056 2057 header = read_ermapper_header(self.domain.filename+ '_elevation.ers')2055 from ermapper_grids import read_ermapper_header, read_ermapper_data 2056 2057 header = read_ermapper_header(self.domain.get_name() + '_elevation.ers') 2058 2058 #print header 2059 2059 assert header['projection'].lower() == '"utm-56"' … … 2068 2068 assert int(header['nrofcellsperline']) == 5 2069 2069 assert int(header['nullcellvalue']) == NODATA_value 2070 2070 #FIXME - there is more in the header 2071 2071 2072 2072 2073 2073 #Check grid data 2074 grid = read_ermapper_data(self.domain. filename+ '_elevation')2075 2076 2077 2078 2079 2080 2081 2074 grid = read_ermapper_data(self.domain.get_name() + '_elevation') 2075 2076 #FIXME (Ole): Why is this the desired reference grid for -x-y? 2077 ref_grid = [NODATA_value, NODATA_value, NODATA_value, NODATA_value, NODATA_value, 2078 -1, -1.25, -1.5, -1.75, -2.0, 2079 -0.75, -1.0, -1.25, -1.5, -1.75, 2080 -0.5, -0.75, -1.0, -1.25, -1.5, 2081 -0.25, -0.5, -0.75, -1.0, -1.25] 2082 2082 2083 2083 2084 2084 #print grid 2085 2085 assert allclose(grid, ref_grid) 2086 2086 2087 2087 fid.close() … … 2091 2091 #Done (Ole) - it was because sww2ers didn't close it's sww file 2092 2092 os.remove(sww.filename) 2093 os.remove(self.domain. filename+ '_elevation')2094 os.remove(self.domain. filename+ '_elevation.ers')2093 os.remove(self.domain.get_name() + '_elevation') 2094 os.remove(self.domain.get_name() + '_elevation.ers') 2095 2095 2096 2096 … … 2110 2110 2111 2111 # Setup 2112 self.domain. filename = 'datatest'2113 2114 ptsfile = self.domain. filename+ '_elevation.pts'2115 swwfile = self.domain. filename+ '.sww'2112 self.domain.set_name('datatest') 2113 2114 ptsfile = self.domain.get_name() + '_elevation.pts' 2115 swwfile = self.domain.get_name() + '.sww' 2116 2116 2117 2117 self.domain.set_datadir('.') … … 2144 2144 # Invoke interpolation for vertex points 2145 2145 points = concatenate( (x[:,NewAxis],y[:,NewAxis]), axis=1 ) 2146 sww2pts(self.domain. filename,2146 sww2pts(self.domain.get_name(), 2147 2147 quantity = 'elevation', 2148 2148 data_points = points, … … 2153 2153 #print 'P', point_values 2154 2154 #print 'Ref', ref_point_values 2155 2155 assert allclose(point_values, ref_point_values) 2156 2156 2157 2157 … … 2160 2160 points = self.domain.get_centroid_coordinates() 2161 2161 #print points 2162 sww2pts(self.domain. filename,2162 sww2pts(self.domain.get_name(), 2163 2163 quantity = 'elevation', 2164 2164 data_points = points, … … 2171 2171 #print 'P', point_values 2172 2172 #print 'Ref', ref_point_values 2173 2173 assert allclose(point_values, ref_point_values) 2174 2174 2175 2175 … … 2233 2233 #Check first value 2234 2234 stage = fid.variables['stage'][:] 2235 2236 2237 2238 2235 xmomentum = fid.variables['xmomentum'][:] 2236 ymomentum = fid.variables['ymomentum'][:] 2237 2238 #print ymomentum 2239 2239 2240 2240 assert allclose(stage[0,0], first_value/100) #Meters … … 2351 2351 2352 2352 for fid in [fid1,fid2,fid3]: 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2353 fid.createDimension(long_name,nx) 2354 fid.createVariable(long_name,'d',(long_name,)) 2355 fid.variables[long_name].point_spacing='uneven' 2356 fid.variables[long_name].units='degrees_east' 2357 fid.variables[long_name].assignValue(h1_list) 2358 2359 fid.createDimension(lat_name,ny) 2360 fid.createVariable(lat_name,'d',(lat_name,)) 2361 fid.variables[lat_name].point_spacing='uneven' 2362 fid.variables[lat_name].units='degrees_north' 2363 fid.variables[lat_name].assignValue(h2_list) 2364 2365 fid.createDimension(time_name,2) 2366 fid.createVariable(time_name,'d',(time_name,)) 2367 fid.variables[time_name].point_spacing='uneven' 2368 fid.variables[time_name].units='seconds' 2369 fid.variables[time_name].assignValue([0.,1.]) 2370 if fid == fid3: break 2371 2371 2372 2372 2373 2373 for fid in [fid4]: 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2374 fid.createDimension(long_name,nx) 2375 fid.createVariable(long_name,'d',(long_name,)) 2376 fid.variables[long_name].point_spacing='uneven' 2377 fid.variables[long_name].units='degrees_east' 2378 fid.variables[long_name].assignValue(h1_list) 2379 2380 fid.createDimension(lat_name,ny) 2381 fid.createVariable(lat_name,'d',(lat_name,)) 2382 fid.variables[lat_name].point_spacing='uneven' 2383 fid.variables[lat_name].units='degrees_north' 2384 fid.variables[lat_name].assignValue(h2_list) 2385 2385 2386 2386 name = {} … … 2515 2515 2516 2516 for fid in [fid1,fid2,fid3]: 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2517 fid.createDimension(long_name,nx) 2518 fid.createVariable(long_name,'d',(long_name,)) 2519 fid.variables[long_name].point_spacing='uneven' 2520 fid.variables[long_name].units='degrees_east' 2521 fid.variables[long_name].assignValue(h1_list) 2522 2523 fid.createDimension(lat_name,ny) 2524 fid.createVariable(lat_name,'d',(lat_name,)) 2525 fid.variables[lat_name].point_spacing='uneven' 2526 fid.variables[lat_name].units='degrees_north' 2527 fid.variables[lat_name].assignValue(h2_list) 2528 2529 fid.createDimension(time_name,2) 2530 fid.createVariable(time_name,'d',(time_name,)) 2531 fid.variables[time_name].point_spacing='uneven' 2532 fid.variables[time_name].units='seconds' 2533 fid.variables[time_name].assignValue([0.,1.]) 2534 if fid == fid3: break 2535 2535 2536 2536 2537 2537 for fid in [fid4]: 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2538 fid.createDimension(long_name,nx) 2539 fid.createVariable(long_name,'d',(long_name,)) 2540 fid.variables[long_name].point_spacing='uneven' 2541 fid.variables[long_name].units='degrees_east' 2542 fid.variables[long_name].assignValue(h1_list) 2543 2544 fid.createDimension(lat_name,ny) 2545 fid.createVariable(lat_name,'d',(lat_name,)) 2546 fid.variables[lat_name].point_spacing='uneven' 2547 fid.variables[lat_name].units='degrees_north' 2548 fid.variables[lat_name].assignValue(h2_list) 2549 2549 2550 2550 name = {} … … 2575 2575 2576 2576 for fid in [fid4]: 2577 2577 fid.createVariable(name[fid],'d',(lat_name,long_name)) 2578 2578 fid.variables[name[fid]].point_spacing='uneven' 2579 2579 fid.variables[name[fid]].units=units[fid] … … 2677 2677 from Scientific.IO.NetCDF import NetCDFFile 2678 2678 2679 self.domain. filename = 'datatest' + str(id(self))2679 self.domain.set_name('datatest' + str(id(self))) 2680 2680 self.domain.format = 'sww' 2681 2681 self.domain.smooth = True … … 2695 2695 sww.store_timestep('stage') 2696 2696 2697 file_and_extension_name = self.domain. filename+ ".sww"2697 file_and_extension_name = self.domain.get_name() + ".sww" 2698 2698 #print "file_and_extension_name",file_and_extension_name 2699 2699 [xmin, xmax, ymin, ymax, stagemin, stagemax] = \ … … 2731 2731 domain.visualise = False 2732 2732 domain.store = True 2733 domain. filename = 'bedslope'2733 domain.set_name('bedslope') 2734 2734 domain.default_order=2 2735 2735 #Bed-slope and friction … … 2766 2766 import os 2767 2767 2768 filename = domain.datadir +os.sep+domain.filename+'.sww'2768 filename = domain.datadir + os.sep + domain.get_name() + '.sww' 2769 2769 domain2 = sww2domain(filename,None,fail_if_NaN=False,verbose = False) 2770 2770 #points, vertices, boundary = rectangular(15,15) … … 2774 2774 ################### 2775 2775 2776 #os.remove(domain. filename+ '.sww')2776 #os.remove(domain.get_name() + '.sww') 2777 2777 os.remove(filename) 2778 2778 … … 2856 2856 2857 2857 def test_sww2domain2(self): 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2858 ################################################################## 2859 #Same as previous test, but this checks how NaNs are handled. 2860 ################################################################## 2861 2862 2863 from mesh_factory import rectangular 2864 from Numeric import array 2865 2866 #Create basic mesh 2867 points, vertices, boundary = rectangular(2,2) 2868 2869 #Create shallow water domain 2870 domain = Domain(points, vertices, boundary) 2871 domain.smooth = False 2872 domain.visualise = False 2873 domain.store = True 2874 domain.set_name('test_file') 2875 2875 domain.set_datadir('.') 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2876 domain.default_order=2 2877 domain.quantities_to_be_stored=['stage'] 2878 2879 domain.set_quantity('elevation', lambda x,y: -x/3) 2880 domain.set_quantity('friction', 0.1) 2881 2882 from math import sin, pi 2883 Br = Reflective_boundary(domain) 2884 Bt = Transmissive_boundary(domain) 2885 Bd = Dirichlet_boundary([0.2,0.,0.]) 2886 Bw = Time_boundary(domain=domain, 2887 f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) 2888 2889 domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) 2890 2891 h = 0.05 2892 elevation = domain.quantities['elevation'].vertex_values 2893 domain.set_quantity('stage', elevation + h) 2894 2895 domain.check_integrity() 2896 2897 for t in domain.evolve(yieldstep = 1, finaltime = 2.0): 2898 pass 2899 #domain.write_time() 2900 2900 2901 2901 2902 2902 2903 2903 ################################## 2904 2904 #Import the file as a new domain 2905 2905 ################################## 2906 2907 2906 from data_manager import sww2domain 2907 from Numeric import allclose 2908 2908 import os 2909 2909 2910 filename = domain.datadir+os.sep+domain.filename+'.sww'2911 2912 2913 2914 2915 2916 2917 2918 2910 filename = domain.datadir + os.sep + domain.get_name() + '.sww' 2911 2912 #Fail because NaNs are present 2913 try: 2914 domain2 = sww2domain(filename,boundary,fail_if_NaN=True,verbose=False) 2915 except: 2916 #Now import it, filling NaNs to be 0 2917 filler = 0 2918 domain2 = sww2domain(filename,None,fail_if_NaN=False,NaN_filler = filler,verbose=False) 2919 2919 2920 2920 #Clean up … … 2926 2926 'vertex_coordinates'] 2927 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2928 for quantity in ['elevation']+domain.quantities_to_be_stored: 2929 bits.append('get_quantity("%s").get_integral()' %quantity) 2930 bits.append('get_quantity("%s").get_values()' %quantity) 2931 2932 for bit in bits: 2933 # print 'testing that domain.'+bit+' has been restored' 2934 assert allclose(eval('domain.'+bit),eval('domain2.'+bit)) 2935 2936 assert max(max(domain2.get_quantity('xmomentum').get_values()))==filler 2937 assert min(min(domain2.get_quantity('xmomentum').get_values()))==filler 2938 assert max(max(domain2.get_quantity('ymomentum').get_values()))==filler 2939 assert min(min(domain2.get_quantity('ymomentum').get_values()))==filler 2940 2940 2941 2941 2942 2942 2943 2943 #def test_weed(self): 2944 2944 from data_manager import weed 2945 2945 2946 2946 coordinates1 = [[0.,0.],[1.,0.],[1.,1.],[1.,0.],[2.,0.],[1.,1.]] … … 2965 2965 #FIXME This fails - smooth makes the comparism too hard for allclose 2966 2966 def ztest_sww2domain3(self): 2967 2968 2969 2970 2971 2972 2967 ################################################ 2968 #DOMAIN.SMOOTH = TRUE !!!!!!!!!!!!!!!!!!!!!!!!!! 2969 ################################################ 2970 from mesh_factory import rectangular 2971 from Numeric import array 2972 #Create basic mesh 2973 2973 2974 2974 yiel=0.01 2975 2976 2977 2978 2975 points, vertices, boundary = rectangular(10,10) 2976 2977 #Create shallow water domain 2978 domain = Domain(points, vertices, boundary) 2979 2979 domain.geo_reference = Geo_reference(56,11,11) 2980 2981 2982 2983 domain.filename = 'bedslope' 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 2980 domain.smooth = True 2981 domain.visualise = False 2982 domain.store = True 2983 domain.set_name('bedslope') 2984 domain.default_order=2 2985 #Bed-slope and friction 2986 domain.set_quantity('elevation', lambda x,y: -x/3) 2987 domain.set_quantity('friction', 0.1) 2988 # Boundary conditions 2989 from math import sin, pi 2990 Br = Reflective_boundary(domain) 2991 Bt = Transmissive_boundary(domain) 2992 Bd = Dirichlet_boundary([0.2,0.,0.]) 2993 Bw = Time_boundary(domain=domain, 2994 f=lambda t: [(0.1*sin(t*2*pi)), 0.0, 0.0]) 2995 2996 domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd}) 2997 2998 domain.quantities_to_be_stored.extend(['xmomentum','ymomentum']) 2999 #Initial condition 3000 h = 0.05 3001 elevation = domain.quantities['elevation'].vertex_values 3002 domain.set_quantity('stage', elevation + h) 3003 3004 3005 domain.check_integrity() 3006 #Evolution 3007 for t in domain.evolve(yieldstep = yiel, finaltime = 0.05): 3008 # domain.write_time() 3009 pass 3010 3011 3012 ########################################## 3013 #Import the example's file as a new domain 3014 ########################################## 3015 from data_manager import sww2domain 3016 from Numeric import allclose 3017 3017 import os 3018 3018 3019 filename = domain.datadir+os.sep+domain.filename+'.sww'3020 3021 3019 filename = domain.datadir + os.sep + domain.get_name() + '.sww' 3020 domain2 = sww2domain(filename,None,fail_if_NaN=False,verbose = False) 3021 #points, vertices, boundary = rectangular(15,15) 3022 3022 #domain2.boundary = boundary 3023 3023 ################### 3024 3024 ##NOW TEST IT!!! 3025 3025 ################### 3026 3026 3027 os.remove(domain. filename+ '.sww')3027 os.remove(domain.get_name() + '.sww') 3028 3028 3029 3029 #FIXME smooth domain so that they can be compared 3030 3030 3031 3031 3032 3033 3034 3035 3036 3037 3038 3032 bits = []#'vertex_coordinates'] 3033 for quantity in ['elevation']+domain.quantities_to_be_stored: 3034 bits.append('quantities["%s"].get_integral()'%quantity) 3035 3036 3037 for bit in bits: 3038 #print 'testing that domain.'+bit+' has been restored' 3039 3039 #print bit 3040 3040 #print 'done' 3041 3041 #print ('domain.'+bit), eval('domain.'+bit) 3042 3042 #print ('domain2.'+bit), eval('domain2.'+bit) 3043 3043 assert allclose(eval('domain.'+bit),eval('domain2.'+bit),rtol=1.0e-1,atol=1.e-3) 3044 3044 pass 3045 3045 … … 3049 3049 visualise = False 3050 3050 visualise = True 3051 3051 domain.visualise = visualise 3052 3052 domain.time = 0. 3053 3053 from time import sleep … … 3055 3055 final = .5 3056 3056 domain.set_quantity('friction', 0.1) 3057 3058 3059 3060 3057 domain.store = False 3058 domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Br}) 3059 3060 for t in domain.evolve(yieldstep = yiel, finaltime = final): 3061 3061 if visualise: sleep(.03) 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3062 #domain.write_time() 3063 pass 3064 3065 domain2.smooth = True 3066 domain2.visualise = visualise 3067 domain2.store = False 3068 domain2.default_order=2 3069 domain2.set_quantity('friction', 0.1) 3070 #Bed-slope and friction 3071 # Boundary conditions 3072 3072 Bd2=Dirichlet_boundary([0.2,0.,0.]) 3073 3073 Br2 = Reflective_boundary(domain2) 3074 3074 domain2.boundary = domain.boundary 3075 3075 #print 'domain2.boundary' 3076 3076 #print domain2.boundary 3077 3077 domain2.set_boundary({'left': Bd2, 'right': Bd2, 'top': Bd2, 'bottom': Br2}) 3078 3078 #domain2.boundary = domain.boundary 3079 3080 3081 3082 3083 3079 #domain2.set_boundary({'exterior': Bd}) 3080 3081 domain2.check_integrity() 3082 3083 for t in domain2.evolve(yieldstep = yiel, finaltime = final): 3084 3084 if visualise: sleep(.03) 3085 3086 3085 #domain2.write_time() 3086 pass 3087 3087 3088 3088 ################### 3089 3089 ##NOW TEST IT!!! 3090 3090 ################## 3091 3091 3092 3092 print '><><><><>>' 3093 3094 3095 3096 3097 3098 3099 3093 bits = [ 'vertex_coordinates'] 3094 3095 for quantity in ['elevation','xmomentum','ymomentum']:#+domain.quantities_to_be_stored: 3096 #bits.append('quantities["%s"].get_integral()'%quantity) 3097 bits.append('get_quantity("%s").get_values()' %quantity) 3098 3099 for bit in bits: 3100 3100 print bit 3101 3101 assert allclose(eval('domain.'+bit),eval('domain2.'+bit)) 3102 3102 3103 3103 … … 3289 3289 from Scientific.IO.NetCDF import NetCDFFile 3290 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3291 # the memory optimised least squares 3292 # cellsize = 20, # this one seems to hang 3293 # cellsize = 200000, # Ran 1 test in 269.703s 3294 #Ran 1 test in 267.344s 3295 # cellsize = 20000, # Ran 1 test in 460.922s 3296 # cellsize = 2000 #Ran 1 test in 5340.250s 3297 # cellsize = 200 #this one seems to hang, building matirx A 3298 3299 # not optimised 3300 # seems to hang 3301 # cellsize = 2000 # Ran 1 test in 5334.563s 3302 3302 #Export to ascii/prj files 3303 3303 sww2dem('karratha_100m', … … 4675 4675 #Check first value 4676 4676 stage = fid.variables['stage'][:] 4677 4678 4679 4680 4677 xmomentum = fid.variables['xmomentum'][:] 4678 ymomentum = fid.variables['ymomentum'][:] 4679 4680 #print ymomentum 4681 4681 assert allclose(stage[0,0], e +tide) #Meters 4682 4682 -
anuga_core/source/anuga/shallow_water/test_interpolate_sww.py
r3564 r3846 80 80 from Scientific.IO.NetCDF import NetCDFFile 81 81 82 self.domain.filename = 'datatest' + str(time.time()) 82 #FIXME (Ole): This test still passes if commented out 83 #self.domain.set_name('datatest' + str(time.time())) 84 85 83 86 self.domain.format = 'sww' 84 87 self.domain.smooth = True … … 148 151 concatinate_attributelist 149 152 150 self.domain. filename = 'datatest' + str(time.time())153 self.domain.set_name('datatest' + str(time.time())) 151 154 self.domain.format = 'sww' 152 155 self.domain.smooth = True … … 159 162 sww.store_timestep('stage') 160 163 161 #print "self.domain.filename",self.domain.filename162 164 interp = Interpolate_sww(sww.filename, 'depth') 163 165 … … 267 269 concatinate_attributelist 268 270 269 self.domain. filename = 'datatest' + str(time.time())271 self.domain.set_name('datatest' + str(time.time())) 270 272 self.domain.format = 'sww' 271 273 self.domain.smooth = True … … 279 281 280 282 try: 281 interpolate_sww2xya(self.domain. filename,283 interpolate_sww2xya(self.domain.get_name(), 282 284 'stage','yeah','yeah.x', 283 285 verbose = False) -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r3829 r3846 1106 1106 assert not allclose(stage, initial_stage) 1107 1107 1108 os.remove(domain. filename+ '.sww')1108 os.remove(domain.get_name() + '.sww') 1109 1109 1110 1110 … … 1626 1626 L = domain.quantities['stage'].vertex_values 1627 1627 1628 1628 #First order 1629 1629 domain._order_ = 1 1630 1630 domain.distribute_to_vertices_and_edges() 1631 1632 1633 1631 assert allclose(L[1], val1) 1632 1633 #Second order 1634 1634 domain._order_ = 2 1635 1635 domain.beta_w = 0.9 … … 1640 1640 domain.beta_vh_dry = 0.9 1641 1641 domain.distribute_to_vertices_and_edges() 1642 1642 assert allclose(L[1], [2.2, 4.9, 4.9]) 1643 1643 1644 1644 … … 1662 1662 L = domain.quantities['stage'].vertex_values 1663 1663 1664 1664 def stage(x,y): 1665 1665 return x**2 1666 1666 1667 1667 domain.set_quantity('stage', stage, location='centroids') 1668 1668 1669 1669 a, b = domain.quantities['stage'].compute_gradients() 1670 1671 1670 assert allclose(a[1], 3.33333334) 1671 assert allclose(b[1], 0.0) 1672 1672 1673 1673 domain._order_ = 1 … … 1705 1705 L = domain.quantities['stage'].vertex_values 1706 1706 1707 1707 def stage(x,y): 1708 1708 return x**4+y**2 1709 1709 1710 1710 domain.set_quantity('stage', stage, location='centroids') 1711 1711 #print domain.quantities['stage'].centroid_values 1712 1712 1713 1713 a, b = domain.quantities['stage'].compute_gradients() 1714 1715 1714 assert allclose(a[1], 25.18518519) 1715 assert allclose(b[1], 3.33333333) 1716 1716 1717 1717 domain._order_ = 1 … … 1769 1769 domain._order_ = 1 1770 1770 domain.distribute_to_vertices_and_edges() 1771 1772 1771 ##assert allclose(L[1], [0.19999999, 20.05, 20.05]) 1772 assert allclose(L[1], [0.1, 20.1, 20.1]) 1773 1773 1774 1774 domain._order_ = 2 1775 1775 domain.distribute_to_vertices_and_edges() 1776 1776 assert allclose(L[1], [0.1, 20.1, 20.1]) 1777 1777 1778 1778 def test_distribute_near_bed1(self): … … 1814 1814 domain._order_ = 1 1815 1815 domain.distribute_to_vertices_and_edges() 1816 1817 1816 ##assert allclose(L[1], [4.19999999, 16.07142857, 20.02857143]) 1817 assert allclose(L[1], [4.1, 16.1, 20.1]) 1818 1818 1819 1819 domain._order_ = 2 1820 1820 domain.distribute_to_vertices_and_edges() 1821 1821 assert allclose(L[1], [4.1, 16.1, 20.1]) 1822 1822 1823 1823 … … 1832 1832 d = [1.0/5, 0.0] 1833 1833 e = [1.0/5, 1.0/5] 1834 1834 f = [1.0/5, 2.0/5] 1835 1835 g = [2.0/5, 2.0/5] 1836 1836 … … 1846 1846 domain.set_quantity('elevation', slope) 1847 1847 domain.set_quantity('stage', 1848 1848 [0.01298164, 0.00365611, 1849 1849 0.01440365, -0.0381856437096], 1850 1850 location='centroids') 1851 1851 domain.set_quantity('xmomentum', 1852 1852 [0.00670439, 0.01263789, 1853 1853 0.00647805, 0.0178180740668], 1854 1854 location='centroids') 1855 1855 domain.set_quantity('ymomentum', 1856 1856 [-7.23510980e-004, -6.30413883e-005, 1857 1857 6.30413883e-005, 0.000200907255866], 1858 1858 location='centroids') 1859 1859 1860 1860 E = domain.quantities['elevation'].vertex_values … … 1875 1875 1876 1876 #print L[1,:] 1877 1878 1877 #print X[1,:] 1878 #print Y[1,:] 1879 1879 1880 1880 assert allclose(L[1,:], [-0.00825735775384, 1881 1881 -0.00801881482869, 1882 1882 0.0272445025825]) 1883 1883 assert allclose(X[1,:], [0.0143507718962, 1884 1884 0.0142502147066, 1885 1885 0.00931268339717]) 1886 1886 assert allclose(Y[1,:], [-0.000117062180693, 1887 1887 7.94434448109e-005, 1888 1888 -0.000151505429018]) … … 1892 1892 def test_balance_deep_and_shallow(self): 1893 1893 """Test that balanced limiters preserve conserved quantites. 1894 1894 """ 1895 1895 import copy 1896 1896 … … 1913 1913 mesh.set_quantity('stage', [[3,0,3], [2,2,6], [5,3,8], [8,3,5]]) 1914 1914 mesh.set_quantity('elevation', 0) #Flat bed 1915 1916 1917 1915 stage = mesh.quantities['stage'] 1916 1917 ref_centroid_values = copy.copy(stage.centroid_values[:]) #Copy 1918 1918 1919 1919 #Limit 1920 1920 mesh.distribute_to_vertices_and_edges() 1921 1921 1922 1922 #Assert that quantities are conserved … … 1928 1928 1929 1929 #Now try with a non-flat bed - closely hugging initial stage in places 1930 1930 #This will create alphas in the range [0, 0.478260, 1] 1931 1931 mesh.set_quantity('stage', [[3,0,3], [2,2,6], [5,3,8], [8,3,5]]) 1932 1932 mesh.set_quantity('elevation', [[0,0,0], 1933 1934 1935 1936 1937 1938 1939 1933 [1.8,1.9,5.9], 1934 [4.6,0,0], 1935 [0,2,4]]) 1936 stage = mesh.quantities['stage'] 1937 1938 ref_centroid_values = copy.copy(stage.centroid_values[:]) #Copy 1939 ref_vertex_values = copy.copy(stage.vertex_values[:]) #Copy 1940 1940 1941 1941 #Limit 1942 1942 mesh.distribute_to_vertices_and_edges() 1943 1943 1944 1944 1945 1945 #Assert that all vertex quantities have changed 1946 1946 for k in range(mesh.number_of_elements): 1947 1947 #print ref_vertex_values[k,:], stage.vertex_values[k,:] 1948 1948 assert not allclose (ref_vertex_values[k,:], stage.vertex_values[k,:]) 1949 1949 #and assert that quantities are still conserved … … 1956 1956 #Also check that Python and C version produce the same 1957 1957 assert allclose (stage.vertex_values, 1958 1959 1960 1961 1958 [[2,2,2], 1959 [1.93333333, 2.03333333, 6.03333333], 1960 [6.93333333, 4.53333333, 4.53333333], 1961 [5.33333333, 5.33333333, 5.33333333]]) 1962 1962 1963 1963 … … 1967 1967 """Test that stage is conserved globally 1968 1968 1969 1970 1971 1969 This one uses a flat bed, reflective bdries and a suitable 1970 initial condition 1971 """ 1972 1972 from mesh_factory import rectangular 1973 1973 from Numeric import array … … 1981 1981 domain.default_order=2 1982 1982 1983 1983 #IC 1984 1984 def x_slope(x, y): 1985 1985 return x/3 … … 1995 1995 domain.check_integrity() 1996 1996 1997 1998 1999 2000 2001 2002 1997 #domain.visualise = True #If you want to take a sticky beak 1998 1999 initial_volume = domain.quantities['stage'].get_integral() 2000 initial_xmom = domain.quantities['xmomentum'].get_integral() 2001 2002 #print initial_xmom 2003 2003 2004 2004 #Evolution 2005 2005 for t in domain.evolve(yieldstep = 0.05, finaltime = 5.0): 2006 2006 volume = domain.quantities['stage'].get_integral() 2007 2007 assert allclose (volume, initial_volume) 2008 2008 2009 2009 #I don't believe that the total momentum should be the same 2010 2010 #It starts with zero and ends with zero though 2011 2011 #xmom = domain.quantities['xmomentum'].get_integral() 2012 2013 2014 2015 os.remove(domain. filename+ '.sww')2012 #print xmom 2013 #assert allclose (xmom, initial_xmom) 2014 2015 os.remove(domain.get_name() + '.sww') 2016 2016 2017 2017 … … 2019 2019 """Test that stage is conserved globally 2020 2020 2021 2022 2023 2021 This one uses a slopy bed, reflective bdries and a suitable 2022 initial condition 2023 """ 2024 2024 from mesh_factory import rectangular 2025 2025 from Numeric import array … … 2033 2033 domain.default_order=2 2034 2034 2035 2035 #IC 2036 2036 def x_slope(x, y): 2037 2037 return x/3 … … 2047 2047 domain.check_integrity() 2048 2048 2049 2050 2051 2052 2053 2054 2049 #domain.visualise = True #If you want to take a sticky beak 2050 2051 initial_volume = domain.quantities['stage'].get_integral() 2052 initial_xmom = domain.quantities['xmomentum'].get_integral() 2053 2054 #print initial_xmom 2055 2055 2056 2056 #Evolution 2057 2057 for t in domain.evolve(yieldstep = 0.05, finaltime = 5.0): 2058 2058 volume = domain.quantities['stage'].get_integral() 2059 2059 assert allclose (volume, initial_volume) 2060 2060 2061 2061 #FIXME: What would we expect from momentum 2062 2062 #xmom = domain.quantities['xmomentum'].get_integral() 2063 2064 2065 2066 os.remove(domain. filename+ '.sww')2063 #print xmom 2064 #assert allclose (xmom, initial_xmom) 2065 2066 os.remove(domain.get_name() + '.sww') 2067 2067 2068 2068 def test_conservation_3(self): 2069 2069 """Test that stage is conserved globally 2070 2070 2071 2072 2073 2071 This one uses a larger grid, convoluted bed, reflective bdries and a suitable 2072 initial condition 2073 """ 2074 2074 from mesh_factory import rectangular 2075 2075 from Numeric import array … … 2082 2082 domain.smooth = False 2083 2083 domain.default_order = 2 2084 2085 2086 2087 2084 domain.beta_h = 0.2 2085 domain.set_quantities_to_be_stored(['stage']) 2086 2087 #IC 2088 2088 def x_slope(x, y): 2089 2090 2089 z = 0*x 2090 for i in range(len(x)): 2091 2091 if x[i] < 0.3: 2092 2092 z[i] = x[i]/3 … … 2111 2111 domain.check_integrity() 2112 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2113 #domain.visualise = True #If you want to take a sticky beak 2114 2115 initial_volume = domain.quantities['stage'].get_integral() 2116 initial_xmom = domain.quantities['xmomentum'].get_integral() 2117 2118 import copy 2119 ref_centroid_values =\ 2120 copy.copy(domain.quantities['stage'].centroid_values) 2121 2122 #print 'ORG', domain.quantities['stage'].centroid_values 2123 domain.distribute_to_vertices_and_edges() 2124 2125 2126 #print domain.quantities['stage'].centroid_values 2127 assert allclose(domain.quantities['stage'].centroid_values, 2128 ref_centroid_values) 2129 2130 2131 #Check that initial limiter doesn't violate cons quan 2132 assert allclose (domain.quantities['stage'].get_integral(), 2133 initial_volume) 2134 2134 2135 2135 #Evolution … … 2137 2137 volume = domain.quantities['stage'].get_integral() 2138 2138 #print t, volume, initial_volume 2139 2140 2141 os.remove(domain. filename+ '.sww')2139 assert allclose (volume, initial_volume) 2140 2141 os.remove(domain.get_name() + '.sww') 2142 2142 2143 2143 def test_conservation_4(self): 2144 2144 """Test that stage is conserved globally 2145 2145 2146 2147 2148 2146 This one uses a larger grid, convoluted bed, reflective bdries and a suitable 2147 initial condition 2148 """ 2149 2149 from mesh_factory import rectangular 2150 2150 from Numeric import array … … 2157 2157 domain.smooth = False 2158 2158 domain.default_order=2 2159 2160 2161 2159 domain.beta_h = 0.0 2160 2161 #IC 2162 2162 def x_slope(x, y): 2163 2164 2163 z = 0*x 2164 for i in range(len(x)): 2165 2165 if x[i] < 0.3: 2166 2166 z[i] = x[i]/3 … … 2171 2171 z[i] = 0.34 #OK with beta == 0.0 2172 2172 #z[i] = 0.35#Fails after 80 timesteps with an error 2173 2173 #of the order 1.0e-5 2174 2174 if 0.7 <= x[i]: 2175 2175 z[i] = x[i]/3 … … 2188 2188 domain.check_integrity() 2189 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2190 #domain.visualise = True #If you want to take a sticky beak 2191 2192 initial_volume = domain.quantities['stage'].get_integral() 2193 initial_xmom = domain.quantities['xmomentum'].get_integral() 2194 2195 import copy 2196 ref_centroid_values =\ 2197 copy.copy(domain.quantities['stage'].centroid_values) 2198 2199 #Test limiter by itself 2200 domain.distribute_to_vertices_and_edges() 2201 2202 #Check that initial limiter doesn't violate cons quan 2203 assert allclose (domain.quantities['stage'].get_integral(), 2204 initial_volume) 2205 2205 #NOTE: This would fail if any initial stage was less than the 2206 2206 #corresponding bed elevation - but that is reasonable. 2207 2207 2208 2208 … … 2214 2214 2215 2215 2216 2217 2216 #if not allclose (volume, initial_volume): 2217 # print 't==4.05' 2218 2218 # for k in range(domain.number_of_elements): 2219 #pass2220 #print domain.quantities['stage'].centroid_values[k] -\2219 # pass 2220 # print domain.quantities['stage'].centroid_values[k] -\ 2221 2221 # ref_centroid_values[k] 2222 2222 2223 2224 2225 2226 os.remove(domain. filename+ '.sww')2223 assert allclose (volume, initial_volume) 2224 2225 2226 os.remove(domain.get_name() + '.sww') 2227 2227 2228 2228 2229 2229 def test_conservation_5(self): 2230 2230 """Test that momentum is conserved globally in 2231 2232 2233 2234 2231 steady state scenario 2232 2233 This one uses a slopy bed, dirichlet and reflective bdries 2234 """ 2235 2235 from mesh_factory import rectangular 2236 2236 from Numeric import array … … 2244 2244 domain.default_order=2 2245 2245 2246 2246 #IC 2247 2247 def x_slope(x, y): 2248 2248 return x/3 … … 2257 2257 Bright = Dirichlet_boundary([0.1,0,0]) 2258 2258 domain.set_boundary({'left': Bleft, 'right': Bright, 2259 2259 'top': Br, 'bottom': Br}) 2260 2260 2261 2261 domain.check_integrity() 2262 2262 2263 2264 2265 2266 2263 #domain.visualise = True #If you want to take a sticky beak 2264 2265 initial_volume = domain.quantities['stage'].get_integral() 2266 initial_xmom = domain.quantities['xmomentum'].get_integral() 2267 2267 2268 2268 … … 2273 2273 ymom = domain.quantities['ymomentum'].get_integral() 2274 2274 2275 2275 if allclose(t, 6): #Steady state reached 2276 2276 steady_xmom = domain.quantities['xmomentum'].get_integral() 2277 2277 steady_ymom = domain.quantities['ymomentum'].get_integral() 2278 2278 steady_stage = domain.quantities['stage'].get_integral() 2279 2279 2280 2280 if t > 6: 2281 2281 #print '%.2f %14.8f %14.8f' %(t, ymom, steady_ymom) 2282 2282 assert allclose(xmom, steady_xmom) … … 2285 2285 2286 2286 2287 os.remove(domain. filename+ '.sww')2287 os.remove(domain.get_name() + '.sww') 2288 2288 2289 2289 … … 2293 2293 def test_conservation_real(self): 2294 2294 """Test that momentum is conserved globally 2295 2295 2296 2296 Stephen finally made a test that revealed the problem. 2297 2297 This test failed with code prior to 25 July 2005 2298 2298 """ 2299 2299 2300 2300 yieldstep = 0.01 … … 2352 2352 assert allclose(ref, now), msg 2353 2353 2354 os.remove(domain. filename+ '.sww')2354 os.remove(domain.get_name() + '.sww') 2355 2355 2356 2356 def test_second_order_flat_bed_onestep(self): … … 2425 2425 -1.22721531e-004, -4.57969873e-005]) 2426 2426 2427 os.remove(domain. filename+ '.sww')2427 os.remove(domain.get_name() + '.sww') 2428 2428 2429 2429 … … 2457 2457 #print domain.quantities['stage'].centroid_values 2458 2458 2459 os.remove(domain. filename+ '.sww')2459 os.remove(domain.get_name() + '.sww') 2460 2460 2461 2461 … … 2502 2502 2503 2503 2504 os.remove(domain. filename+ '.sww')2504 os.remove(domain.get_name() + '.sww') 2505 2505 2506 2506 def test_flatbed_second_order(self): … … 2549 2549 2550 2550 #FIXME: These numbers were from version before 21/3/6 - 2551 #could be recreated by setting maximum_allowed_speed to 0 maybe 2551 #could be recreated by setting maximum_allowed_speed to 0 maybe 2552 2552 #assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 2553 2553 # [ 0.00064835, 0.03685719, 0.00085073, 0.03687313]) 2554 2554 2555 2555 assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 2556 2556 [ 0.00090581, 0.03685719, 0.00088303, 0.03687313]) 2557 2558 2557 2558 2559 2559 2560 2560 #assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], … … 2565 2565 2566 2566 2567 os.remove(domain. filename+ '.sww')2568 2569 2567 os.remove(domain.get_name() + '.sww') 2568 2569 2570 2570 def test_flatbed_second_order_vmax_0(self): 2571 2571 from mesh_factory import rectangular … … 2605 2605 2606 2606 #FIXME: These numbers were from version before 21/3/6 - 2607 #could be recreated by setting maximum_allowed_speed to 0 maybe 2607 #could be recreated by setting maximum_allowed_speed to 0 maybe 2608 2608 assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 2609 2609 [ 0.00064835, 0.03685719, 0.00085073, 0.03687313]) 2610 2610 2611 2611 2612 2612 assert allclose(domain.quantities['ymomentum'].vertex_values[:4,0], … … 2614 2614 2615 2615 2616 os.remove(domain. filename+ '.sww')2617 2618 2616 os.remove(domain.get_name() + '.sww') 2617 2618 2619 2619 2620 2620 def test_flatbed_second_order_distribute(self): … … 2724 2724 if not V: 2725 2725 #FIXME: These numbers were from version before 21/3/6 - 2726 #could be recreated by setting maximum_allowed_speed to 0 maybe2727 2728 #assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.0) 2729 assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.000286060839592) 2726 #could be recreated by setting maximum_allowed_speed to 0 maybe 2727 2728 #assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.0) 2729 assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.000286060839592) 2730 2730 2731 2731 else: … … 2742 2742 #assert allclose(domain.quantities['xmomentum'].centroid_values[17], 2743 2743 # 0.0) 2744 assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.000286060839592) 2744 assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.000286060839592) 2745 2745 2746 2746 … … 2768 2768 # [0.00090581,0.03685719,0.00088303,0.03687313]) 2769 2769 2770 os.remove(domain. filename+ '.sww')2770 os.remove(domain.get_name() + '.sww') 2771 2771 2772 2772 … … 2807 2807 2808 2808 2809 os.remove(domain. filename+ '.sww')2809 os.remove(domain.get_name() + '.sww') 2810 2810 2811 2811 def test_bedslope_problem_first_order_moresteps(self): … … 2870 2870 -0.14439383, -0.13924047, -0.14829043]) 2871 2871 2872 os.remove(domain. filename+ '.sww')2872 os.remove(domain.get_name() + '.sww') 2873 2873 2874 2874 def test_bedslope_problem_second_order_one_step(self): … … 2943 2943 2944 2944 #print domain.quantities['stage'].centroid_values 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 os.remove(domain. filename+ '.sww')2945 assert allclose(domain.quantities['stage'].centroid_values, 2946 [0.01290985, 0.02356019, 0.01619096, 0.02356019, 0.01619096, 2947 0.02356019, 0.01619096, 0.02356019, 0.01619096, 0.02356019, 2948 0.01619096, 0.0268413, -0.04411074, -0.0248011, -0.04186556, 2949 -0.0248011, -0.04186556, -0.0248011, -0.04186556, -0.0248011, 2950 -0.04186556, -0.0248011, -0.04186556, -0.02255593, 2951 -0.09966629, -0.08035666, -0.09742112, -0.08035666, 2952 -0.09742112, -0.08035666, -0.09742112, -0.08035666, 2953 -0.09742112, -0.08035666, -0.09742112, -0.07811149, 2954 -0.15522185, -0.13591222, -0.15297667, -0.13591222, 2955 -0.15297667, -0.13591222, -0.15297667, -0.13591222, 2956 -0.15297667, -0.13591222, -0.15297667, -0.13366704, 2957 -0.2107774, -0.19146777, -0.20853223, -0.19146777, 2958 -0.20853223, -0.19146777, -0.20853223, -0.19146777, 2959 -0.20853223, -0.19146777, -0.20853223, -0.1892226, 2960 -0.26120669, -0.24776246, -0.25865535, -0.24776246, 2961 -0.25865535, -0.24776246, -0.25865535, -0.24776246, 2962 -0.25865535, -0.24776246, -0.25865535, -0.24521113]) 2963 2964 os.remove(domain.get_name() + '.sww') 2965 2965 2966 2966 def test_bedslope_problem_second_order_two_steps(self): … … 3060 3060 3061 3061 3062 os.remove(domain. filename+ '.sww')3062 os.remove(domain.get_name() + '.sww') 3063 3063 3064 3064 def test_bedslope_problem_second_order_two_yieldsteps(self): … … 3134 3134 3135 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 os.remove(domain. filename+ '.sww')3136 assert allclose(domain.quantities['stage'].centroid_values, 3137 [0.00855788, 0.01575204, 0.00994606, 0.01717072, 0.01005985, 3138 0.01716362, 0.01005985, 0.01716299, 0.01007098, 0.01736248, 3139 0.01216452, 0.02026776, -0.04462374, -0.02479045, -0.04199789, 3140 -0.0229465, -0.04184033, -0.02295693, -0.04184013, 3141 -0.02295675, -0.04184486, -0.0228168, -0.04028876, 3142 -0.02036486, -0.10029444, -0.08170809, -0.09772846, 3143 -0.08021704, -0.09760006, -0.08022143, -0.09759984, 3144 -0.08022124, -0.09760261, -0.08008893, -0.09603914, 3145 -0.07758209, -0.15584152, -0.13723138, -0.15327266, 3146 -0.13572906, -0.15314427, -0.13573349, -0.15314405, 3147 -0.13573331, -0.15314679, -0.13560104, -0.15158523, 3148 -0.13310701, -0.21208605, -0.19283913, -0.20955631, 3149 -0.19134189, -0.20942821, -0.19134598, -0.20942799, 3150 -0.1913458, -0.20943005, -0.19120952, -0.20781177, 3151 -0.18869401, -0.25384082, -0.2463294, -0.25047649, 3152 -0.24464654, -0.25031159, -0.24464253, -0.25031112, 3153 -0.24464253, -0.25031463, -0.24454764, -0.24885323, 3154 -0.24286438]) 3155 3156 os.remove(domain.get_name() + '.sww') 3157 3157 3158 3158 def test_bedslope_problem_second_order_more_steps(self): … … 3275 3275 -4.50964850e-003, -3.06319963e-003, 6.08950810e-004, -4.79537921e-004]) 3276 3276 3277 os.remove(domain. filename+ '.sww')3277 os.remove(domain.get_name() + '.sww') 3278 3278 3279 3279 … … 3316 3316 pass 3317 3317 3318 3319 3318 assert allclose(domain.quantities['stage'].centroid_values[:4], 3319 [0.00206836, 0.01296714, 0.00363415, 0.01438924]) 3320 3320 #print domain.quantities['xmomentum'].centroid_values[:4] 3321 3322 3323 3324 3325 3326 3327 os.remove(domain. filename+ '.sww')3321 assert allclose(domain.quantities['xmomentum'].centroid_values[:4], 3322 [0.01360154, 0.00671133, 0.01264578, 0.00648503]) 3323 assert allclose(domain.quantities['ymomentum'].centroid_values[:4], 3324 [-1.19201077e-003, -7.23647546e-004, 3325 -6.39083123e-005, 6.29815168e-005]) 3326 3327 os.remove(domain.get_name() + '.sww') 3328 3328 3329 3329 def test_complex_bed(self): … … 3399 3399 # -5.48333333e-001, -5.31666667e-001, -5.48333333e-001, -5.31666667e-001]) 3400 3400 3401 os.remove(domain. filename+ '.sww')3401 os.remove(domain.get_name() + '.sww') 3402 3402 3403 3403 def test_spatio_temporal_boundary_1(self): … … 3472 3472 3473 3473 boundary = { (0,1):'bottom', (1,1):'bottom', (4,1): 'bottom', 3474 3475 3474 (4,2):'right', (6,2):'right', (8,2):'right', 3475 (0,0):'diagonal', (3,0):'diagonal', (8,0):'diagonal'} 3476 3476 3477 3477 domain2 = Domain(points, vertices, boundary) … … 3488 3488 # Boundary conditions 3489 3489 Br = Reflective_boundary(domain2) 3490 Bf = Spatio_temporal_boundary(domain1. filename + '.' + domain1.format,3491 3490 Bf = Spatio_temporal_boundary(domain1.get_name() + '.' +\ 3491 domain1.format, domain2) 3492 3492 domain2.set_boundary({'right':Br, 'bottom':Br, 'diagonal':Bf}) 3493 3493 domain2.check_integrity() … … 3517 3517 3518 3518 #Cleanup 3519 os.remove(domain1. filename+ '.' + domain1.format)3520 os.remove(domain2. filename+ '.' + domain2.format)3519 os.remove(domain1.get_name() + '.' + domain1.format) 3520 os.remove(domain2.get_name() + '.' + domain2.format) 3521 3521 3522 3522 … … 3582 3582 3583 3583 points = [ [0,0], [1.0/3,0], [1.0/3,1.0/3], 3584 3585 3584 [2.0/3,0], [2.0/3,1.0/3], [2.0/3,2.0/3], 3585 [1,0], [1,1.0/3], [1,2.0/3], [1,1]] 3586 3586 3587 3587 vertices = [ [1,2,0], 3588 3589 3588 [3,4,1], [2,1,4], [4,5,2], 3589 [6,7,3], [4,3,7], [7,8,4], [5,4,8], [8,9,5]] 3590 3590 3591 3591 boundary = { (0,1):'bottom', (1,1):'bottom', (4,1): 'bottom', 3592 3593 3592 (4,2):'right', (6,2):'right', (8,2):'right', 3593 (0,0):'diagonal', (3,0):'diagonal', (8,0):'diagonal'} 3594 3594 3595 3595 domain2 = Domain(points, vertices, boundary) … … 3607 3607 #Read results for specific timesteps t=1 and t=2 3608 3608 from Scientific.IO.NetCDF import NetCDFFile 3609 fid = NetCDFFile(domain1. filename+ '.' + domain1.format)3609 fid = NetCDFFile(domain1.get_name() + '.' + domain1.format) 3610 3610 3611 3611 x = fid.variables['x'][:] … … 3622 3622 #print points[0], points[5], points[10], points[15] 3623 3623 assert allclose( take(points, [0,5,10,15]), 3624 3624 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]) 3625 3625 3626 3626 3627 3627 # Boundary conditions 3628 3628 Br = Reflective_boundary(domain2) 3629 Bf = Spatio_temporal_boundary(domain1. filename+ '.' + domain1.format,3630 3629 Bf = Spatio_temporal_boundary(domain1.get_name() + '.' + domain1.format, 3630 domain2) 3631 3631 domain2.set_boundary({'right':Br, 'bottom':Br, 'diagonal':Bf}) 3632 3632 domain2.check_integrity() … … 3636 3636 3637 3637 boundary_midpoints = [[1.0/6, 0], [1.0/2, 0], [5.0/6,0], 3638 3639 3638 [1.0, 1.0/6], [1.0, 1.0/2], [1.0, 5.0/6], 3639 [1.0/6, 1.0/6], [0.5, 0.5], [5.0/6, 5.0/6]] 3640 3640 3641 3641 boundary_midpoints.sort() … … 3694 3694 3695 3695 #Cleanup 3696 os.remove(domain1. filename+ '.' + domain1.format)3696 os.remove(domain1.get_name() + '.' + domain1.format) 3697 3697 3698 3698 -
anuga_core/source/anuga/shallow_water/tsh2sww.py
r3564 r3846 36 36 file_path, filename = path.split(sww_file_name) 37 37 filename, ext = path.splitext(filename) 38 domain. filename = filename38 domain.set_name(filename) 39 39 40 40 domain.reduction = mean … … 45 45 if verbose == True: 46 46 print "Output written to " + domain.get_datadir() + sep + \ 47 domain. filename+ "." + domain.format47 domain.get_name() + "." + domain.format 48 48 sww = get_dataobject(domain) 49 49 sww.store_connectivity() -
anuga_core/source/anuga_parallel/run_parallel_sw_merimbula_test.py
r3579 r3846 196 196 197 197 domain.store = False 198 #domain.filename = 'merimbula-%d' %domain.processor199 198 200 199 #--------- -
anuga_core/source/anuga_parallel/run_sw_lost_mass.py
r3579 r3846 94 94 95 95 96 #domain.set_quantity('stage', quantities['stage'])97 #domain.set_quantity('elevation', quantities['elevation'])98 99 #domain.store = True100 #domain.filename = 'merimbula-%d' %domain.processor101 96 102 97 #--------- -
anuga_validation/analytical solutions/Analytical solution_oblique_shock.py
r2229 r3846 61 61 62 62 # Provide file name for storing output 63 domain. filename="oblique"63 domain.set_name('oblique') 64 64 65 65 # Visualization smoothing -
anuga_validation/analytical solutions/Analytical solution_oblique_shock_01.py
r3657 r3846 57 57 58 58 # Provide file name for storing output 59 domain. filename="oblique_cross_%g_%g_%g_%g_%g" % (n,m,theta,h_bc,p_bc)60 print domain. filename59 domain.set_name('oblique_cross_%g_%g_%g_%g_%g' % (n,m,theta,h_bc,p_bc)) 60 print domain.get_name() 61 61 62 62 # Output format -
anuga_validation/analytical solutions/Analytical solution_wave_runup.py
r3514 r3846 58 58 domain.store = True 59 59 domain.format = 'sww' 60 domain. filename = 'run-up_second_order_again'60 domain.set_name('run-up_second_order_again') 61 61 62 62 print "Number of triangles = ", len(domain) -
anuga_validation/analytical solutions/Analytical_solution_MacDonald_import_mesh.py
r3514 r3846 45 45 domain.store = True #Store for visualisation purposes 46 46 domain.format = 'sww' #Native netcdf visualisation format 47 domain. filename = 'MacDonald_77541'47 domain.set_name('MacDonald_77541') 48 48 49 49 #------------- -
anuga_validation/analytical solutions/Analytical_solution_MacDonald_import_mesh_wall.py
r3514 r3846 45 45 domain.store = True #Store for visualisation purposes 46 46 domain.format = 'sww' #Native netcdf visualisation format 47 domain. filename = 'MacDonald_first_order_wall'47 domain.set_name('MacDonald_first_order_wall') 48 48 49 49 #------------- -
anuga_validation/analytical solutions/Analytical_solution_MacDonald_import_mesh_wall0.py
r3514 r3846 41 41 domain.store = True #Store for visualisation purposes 42 42 domain.format = 'sww' #Native netcdf visualisation format 43 domain. filename = 'MacDonald_first_order_wall'43 domain.set_name('MacDonald_first_order_wall') 44 44 45 45 #-------------- -
anuga_validation/analytical solutions/Analytical_solution_Sampson_cross_mesh.py
r3514 r3846 61 61 domain.store = True 62 62 domain.format = 'sww' 63 domain. filename = 'sampson_first_order_cross'63 domain.set_name('sampson_first_order_cross') 64 64 65 65 print 'Number of triangles = ', len(domain) … … 140 140 tri = [domain.coordinates[t[0]],domain.coordinates[t[1]],domain.coordinates[t[2]]] 141 141 142 filename=domain. filename142 filename=domain.get_name() 143 143 file = open(filename,'w') 144 144 -
anuga_validation/analytical solutions/Analytical_solution_Sampson_import_mesh.py
r3514 r3846 53 53 domain.store = True 54 54 domain.format = 'sww' 55 domain. filename = 'sampson_strang_second_order'55 domain.set_name('sampson_strang_second_order') 56 56 57 57 print 'Number of triangles = ', len(domain) -
anuga_validation/analytical solutions/Analytical_solution_Yoon_cross_mesh.py
r3514 r3846 45 45 domain.store = False 46 46 domain.format = 'sww' 47 domain. filename = 'yoon_mesh_second_order_cross'47 domain.set_name('yoon_mesh_second_order_cross') 48 48 print 'Number of triangles = ', len(domain) 49 49 … … 120 120 tri = [domain.coordinates[t[0]],domain.coordinates[t[1]],domain.coordinates[t[2]]] 121 121 122 filename=domain. filename122 filename=domain.get_name() 123 123 file = open(filename,'w') 124 124 -
anuga_validation/analytical solutions/Analytical_solution_Yoon_import_mesh.py
r3514 r3846 42 42 domain.store = False 43 43 domain.format = 'sww' 44 domain. filename = 'yoon_mesh_second_order.2'44 domain.set_name('yoon_mesh_second_order.2') 45 45 print 'Number of triangles = ', len(domain) 46 46 … … 114 114 tri = [domain.coordinates[t[0]],domain.coordinates[t[1]],domain.coordinates[t[2]]] 115 115 116 filename=domain. filename116 filename=domain.get_name() 117 117 file = open(filename,'w') 118 118 -
anuga_validation/analytical solutions/Analytical_solution_circular_hydraulic_jump.py
r3678 r3846 59 59 domain.store = True 60 60 domain.format = 'sww' 61 domain. filename = 'circular_second_order'61 domain.set_name('circular_second_order') 62 62 63 63 #------------------------------------------ -
anuga_validation/analytical solutions/Analytical_solution_contracting_channel.py
r3651 r3846 60 60 domain.store = True #Store for visualisation purposes 61 61 domain.format = 'sww' #Native netcdf visualisation format 62 domain. filename = 'contracting_channel_second-order'62 domain.set_name('contracting_channel_second-order') 63 63 64 64 -
anuga_validation/analytical solutions/Analytical_solution_contracting_channel_import_mesh.py
r3514 r3846 45 45 domain.store = True #Store for visualisation purposes 46 46 domain.format = 'sww' #Native netcdf visualisation format 47 domain. filename = 'contracting_channel_second-order'47 domain.set_name('contracting_channel_second-order') 48 48 49 49 #---------------------------------------------------------- -
anuga_validation/analytical solutions/Analytical_solution_oblique_shock.py
r3653 r3846 47 47 domain.store = True 48 48 domain.format = "sww" #"sww" for NET.CDF binary format or "dat" for ASCII 49 domain. filename = "oblique_first_order"49 domain.set_name('oblique_first_order') 50 50 51 51 #------------------------ -
anuga_validation/analytical solutions/Malpasset_new.py
r2229 r3846 55 55 domain.store = True 56 56 domain.format = 'sww' 57 domain. filename = 'Malpasset_second_order'57 domain.set_name('Malpasset_second_order') 58 58 59 59 #---------------------------- -
anuga_validation/analytical solutions/Non_symmetrical_dam_break.py
r3514 r3846 140 140 domain.store = True 141 141 domain.format = 'sww' 142 domain. filename = 'Non_symetrical_Dam_Break_second_order'142 domain.set_name('Non_symetrical_Dam_Break_second_order') 143 143 144 144 -
anuga_validation/analytical solutions/Sydney.py
r3514 r3846 34 34 domain.store = True 35 35 domain.format = 'sww' 36 domain. filename = 'sydney_ubd_again'36 domain.set_name('sydney_ubd_again') 37 37 38 38 #Reduction operation for get_vertex_values -
anuga_work/development/LWRU1/lwru1.py
r3514 r3846 58 58 import sys, os 59 59 base = os.path.basename(sys.argv[0]) 60 domain.filename, _ = os.path.splitext(base) 61 60 61 basename, _ = os.path.splitext(base) 62 domain.set_name(basename) 62 63 63 64 #Set initial values -
anuga_work/development/cairns_2006/run_cairns.py
r3514 r3846 108 108 109 109 base = os.path.basename(sys.argv[0]) 110 domain.filename, _ = os.path.splitext(base) 110 basename, _ = os.path.splitext(base) 111 domain.set_name(basename) 111 112 domain.default_order = 2 112 113 domain.store = True #Store for visualisation purposes -
anuga_work/development/pyvolution-1d/data_manager.py
r3535 r3846 413 413 #remember the old filename, then give domain a 414 414 #name with the extension 415 old_domain_filename = self.domain. filename415 old_domain_filename = self.domain.get_name() 416 416 if not self.recursion: 417 self.domain. filename = self.domain.filename+filename_ext417 self.domain.set_name(old_domain_filename+filename_ext) 418 418 419 419 #change the domain starttime to the current time … … 440 440 #restore the old starttime and filename 441 441 self.domain.starttime = old_domain_starttime 442 self.domain. filename = old_domain_filename442 self.domain.set_name(old_domain_filename) 443 443 else: 444 444 self.recursion = False … … 3388 3388 file_path, filename = path.split(filename) 3389 3389 filename, ext = path.splitext(filename) 3390 domain. filename = filename3390 domain.set_name(filename) 3391 3391 domain.reduction = mean 3392 3392 if verbose == True:print "file_path",file_path … … 3396 3396 if verbose == True: 3397 3397 print "Output written to " + domain.get_datadir() + sep + \ 3398 domain. filename+ "." + domain.format3398 domain.get_name() + "." + domain.format 3399 3399 sww = get_dataobject(domain) 3400 3400 sww.store_connectivity() -
anuga_work/development/pyvolution-1d/test_shallow_water_1d.py
r3295 r3846 632 632 assert not allclose(stage, initial_stage) 633 633 634 os.remove(domain. filename+ '.sww')634 os.remove(domain.get_name() + '.sww') 635 635 636 636 ##################################################### -
anuga_work/development/stochastic_study/run_model.py
r3514 r3846 148 148 149 149 print 'P%d: Extracting time series for realisation %d from file %s'\ 150 %(myid, realisation, project.working_dir + domain.filename + '.sww') 151 f = file_function(project.working_dir + domain.filename + '.sww', 150 %(myid, realisation, project.working_dir +\ 151 domain.get_name() + '.sww') 152 f = file_function(project.working_dir +\ 153 domain.get_name() + '.sww', 152 154 quantities='stage', 153 155 interpolation_points=project.gauges, -
anuga_work/development/stochastic_study/run_simple_model.py
r3514 r3846 150 150 151 151 print 'P%d: Extracting time series for realisation %d from file %s'\ 152 %(myid, realisation, project.working_dir + domain.filename + '.sww') 153 f = file_function(project.working_dir + domain.filename + '.sww', 152 %(myid, realisation, project.working_dir +\ 153 domain.get_name() + '.sww') 154 f = file_function(project.working_dir +\ 155 domain.get_name() + '.sww', 154 156 quantities='stage', 155 157 interpolation_points=project.gauges,
Note: See TracChangeset
for help on using the changeset viewer.