Changeset 6904 for branches/numpy/anuga
- Timestamp:
- Apr 25, 2009, 11:00:44 PM (16 years ago)
- Location:
- branches/numpy/anuga
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/abstract_2d_finite_volumes/domain.py
r6902 r6904 1758 1758 # We have a list with ghosts expecting updates 1759 1759 1760 from Numeric import take,put1761 1762 1763 1760 #Update of ghost cells 1764 1761 iproc = self.processor … … 1773 1770 for i, q in enumerate(self.conserved_quantities): 1774 1771 Q_cv = self.quantities[q].centroid_values 1775 put(Q_cv, Idg, take(Q_cv, Idf))1772 num.put(Q_cv, Idg, num.take(Q_cv, Idf, axis=0)) 1776 1773 1777 1774 -
branches/numpy/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r6902 r6904 98 98 # Transmissive_Momentum_Set_Stage_Boundary (cf posting by rrraman) 99 99 def __init__(self, domain=None, 100 f=None, 100 f=None, # Should be removed and replaced by function below 101 function=None, 101 102 default_boundary=None, 102 103 verbose=False): -
branches/numpy/anuga/abstract_2d_finite_volumes/mesh_factory.py
r6902 r6904 259 259 E = EIndex(n,m) 260 260 261 points = num.zeros( (Np,2), num. Float)261 points = num.zeros( (Np,2), num.float) 262 262 263 263 for i in range(m+1): … … 271 271 272 272 273 elements = num.zeros( (Nt,3), num. Int)273 elements = num.zeros( (Nt,3), num.int) 274 274 boundary = {} 275 275 Idgl = [] … … 339 339 Idgr.extend(Idgl) 340 340 341 Idfl = num.array(Idfl, num. Int)342 Idgr = num.array(Idgr, num. Int)341 Idfl = num.array(Idfl, num.int) 342 Idgr = num.array(Idgr, num.int) 343 343 344 344 full_send_dict[processor] = [Idfl, Idfl] -
branches/numpy/anuga/compile_all.py
r6553 r6904 28 28 29 29 if sys.platform == 'win32': 30 raw_input('Press anykey')30 raw_input('Press the RETURN key') -
branches/numpy/anuga/load_mesh/loadASCII.py
r6902 r6904 817 817 mesh['vertex_attributes'] = None 818 818 819 #mesh['vertex_attribute_titles'] = []819 mesh['vertex_attribute_titles'] = [] 820 820 try: 821 821 titles = fid.variables['vertex_attribute_titles'][:] … … 829 829 mesh['segments'] = num.array([], num.int) #array default# 830 830 831 #mesh['segment_tags'] = []831 mesh['segment_tags'] = [] 832 832 try: 833 833 tags = fid.variables['segment_tags'][:] … … 844 844 mesh['triangle_neighbors'] = num.array([], num.int) #array default# 845 845 846 #mesh['triangle_tags'] = []846 mesh['triangle_tags'] = [] 847 847 try: 848 848 tags = fid.variables['triangle_tags'][:] -
branches/numpy/anuga/load_mesh/test_loadASCII.py
r6902 r6904 398 398 assert num.allclose(num.array(dict['segments']), 399 399 num.array(loaded_dict['segments'])) 400 401 self.failUnlessEqual(dict['triangle_tags'], loaded_dict['triangle_tags'])402 403 400 for ob, ldob in map(None, dict['triangle_tags'], 404 401 loaded_dict['triangle_tags']): … … 424 421 self.failUnless(seg == ldseg, fail_string + ' failed\n' + msg) 425 422 426 # dict_array = num.array(dict['vertex_attribute_titles']) 427 # loaded_dict_array = num.array(loaded_dict['vertex_attribute_titles']) 428 try: 429 assert num.allclose(dict_array, loaded_dict_array) 430 #except TypeError: #??# 423 try: 424 assert num.allclose(num.array(dict['vertex_attribute_titles']), 425 num.array(loaded_dict['vertex_attribute_titles'])) 431 426 except IndexError: 432 self.failUnless(num.alltrue(loaded_dict_array == dict_array), 427 self.failUnless(num.alltrue(num.array(loaded_dict['vertex_attribute_titles']) 428 == num.array(dict['vertex_attribute_titles'])), 433 429 fail_string + ' failed!! Test 8') 434 430 -
branches/numpy/anuga/test_all.py
r6553 r6904 217 217 218 218 if sys.platform == 'win32': 219 raw_input('Press anykey')219 raw_input('Press the RETURN key') -
branches/numpy/anuga/utilities/polygon_ext.c
r6553 r6904 330 330 331 331 int __separate_points_by_polygon(int M, // Number of points 332 int N, // Number of polygon vertices333 double* points,334 double* polygon,335 long* indices, // M-Array for storage indices336 int closed,337 int verbose) {332 int N, // Number of polygon vertices 333 double* points, 334 double* polygon, 335 long* indices, // M-Array for storage indices 336 int closed, 337 int verbose) { 338 338 339 339 double minpx, maxpx, minpy, maxpy, x, y, px_i, py_i, px_j, py_j, rtol=0.0, atol=0.0; 340 340 int i, j, k, outside_index, inside_index, inside; 341 341 342 // Find min and max of poly used for optimisation when points343 // are far away from polygon344 345 // FIXME(Ole): Pass in rtol and atol from Python342 // Find min and max of poly used for optimisation when points 343 // are far away from polygon 344 345 // FIXME(Ole): Pass in rtol and atol from Python 346 346 347 347 minpx = polygon[0]; maxpx = minpx; … … 358 358 } 359 359 360 // Begin main loop (for each point)361 inside_index = 0; // Keep track of points inside362 outside_index = M-1; // Keep track of points outside (starting from end)360 // Begin main loop (for each point) 361 inside_index = 0; // Keep track of points inside 362 outside_index = M-1; // Keep track of points outside (starting from end) 363 363 if (verbose){ 364 364 printf("Separating %d points\n", M); … … 374 374 inside = 0; 375 375 376 // Optimisation376 // Optimisation 377 377 if ((x > maxpx) || (x < minpx) || (y > maxpy) || (y < minpy)) { 378 // Nothing378 // Nothing 379 379 } else { 380 // Check polygon380 // Check polygon 381 381 for (i=0; i<N; i++) { 382 //printf("k,i=%d,%d\n", k, i);383 382 j = (i+1)%N; 384 383 … … 388 387 py_j = polygon[2*j+1]; 389 388 390 // Check for case where point is contained in line segment389 // Check for case where point is contained in line segment 391 390 if (__point_on_line(x, y, px_i, py_i, px_j, py_j, rtol, atol)) { 392 391 if (closed == 1) { -
branches/numpy/anuga/utilities/system_tools.py
r6825 r6904 50 50 51 51 def get_revision_number(): 52 """Get the version number of the SVN 52 """Get the version number of this repository copy. 53 54 Try getting data from stored_version_info.py first, otherwise 55 try using SubWCRev.exe (Windows) or svnversion (linux), otherwise 56 try reading file .svn/entries for version information, otherwise 57 throw an exception. 58 53 59 NOTE: This requires that the command svn is on the system PATH 54 60 (simply aliasing svn to the binary will not work) 55 61 """ 56 62 57 # FIXME (Ole): Change this so that svn info is attempted first. 58 # If that fails, try to read a stored file with that same info (this would 59 # be created by e.g. the release script). Failing that, throw an exception. 60 # FIXME (Ole): Move this and store_version_info to utilities 63 def get_revision_from_svn_entries(): 64 '''Get a subversion revision number from the .svn/entires file.''' 65 66 msg = ''' 67 No version info stored and command 'svn' is not recognised on the system PATH. 68 69 If ANUGA has been installed from a distribution e.g. as obtained from SourceForge, 70 the version info should be available in the automatically generated file 71 'stored_version_info.py' in the anuga root directory. 72 73 If run from a Subversion sandpit, ANUGA will try to obtain the version info by 74 using the command 'svn info'. In this case, make sure the command line client 75 'svn' is accessible on the system path. Simply aliasing 'svn' to the binary will 76 not work. 77 78 If you are using Windows, you have to install the file svn.exe which can be 79 obtained from http://www.collab.net/downloads/subversion. 80 81 Good luck! 82 ''' 83 84 try: 85 fd = open(os.path.join('.svn', 'entries')) 86 except: 87 raise Exception, msg 88 89 line = fd.readlines()[3] 90 fd.close() 91 try: 92 revision_number = int(line) 93 except: 94 msg = ".svn/entries, line 4 was '%s'?" % line.strip() 95 raise Exception, msg 96 97 return revision_number 98 99 def get_revision_from_svn_client(): 100 '''Get a subversion revision number from an svn client.''' 101 102 if sys.platform[0:3] == 'win': 103 try: 104 fid = os.popen(r'C:\Program Files\TortoiseSVN\bin\SubWCRev.exe') 105 except: 106 return get_revision_from_svn_entries() 107 else: 108 version_info = fid.read() 109 if version_info == '': 110 return get_revision_from_svn_entries() 111 112 # split revision number from data 113 for line in version_info.split('\n'): 114 if line.startswith('Updated to revision '): 115 break 116 117 fields = line.split(' ') 118 msg = 'Keyword "Revision" was not found anywhere in text: %s' % version_info 119 assert fields[0].startswith('Updated'), msg 120 121 try: 122 revision_number = int(fields[3]) 123 except: 124 msg = ("Revision number must be an integer. I got '%s' from " 125 "'SubWCRev.exe'." % fields[3]) 126 raise Exception, msg 127 else: # assume Linux 128 try: 129 fid = os.popen('svnversion -n . 2>/dev/null') 130 except: 131 return get_revision_from_svn_entries() 132 else: 133 version_info = fid.read() 134 if version_info == '': 135 return get_revision_from_svn_entries() 136 137 # split revision number from data 138 if ':' in version_info: 139 (_, revision_number) = version_info.split(':') 140 elif version_info.endswith('M'): 141 revision_number = version_info[:-1] 142 else: 143 revision_number = version_info 144 145 try: 146 revision_number = int(revision_number) 147 except: 148 msg = ("Revision number must be an integer. I got '%s' from " 149 "'svn'." % version_info) 150 raise Exception, msg 151 152 return revision_number 153 154 # try to get revision information from stored_version_info.py 61 155 try: 62 156 from anuga.stored_version_info import version_info 63 157 except: 64 msg = ''' 65 No version info stored and command 'svn' is not recognised on the system PATH. 66 67 If ANUGA has been installed from a distribution e.g. as obtained from 68 SourceForge, the version info should be available in the automatically 69 generated file 'stored_version_info.py' in the anuga root directory. 70 71 If run from a Subversion sandpit, ANUGA will try to obtain the version info 72 by using the command 'svn info'. In this case, make sure 'svn' is accessible 73 on the system PATH. Simply aliasing 'svn' to the binary will not work. 74 75 If you are using Windows, you have to install the file svn.exe which can be 76 obtained from http://www.collab.net/downloads/subversion. 77 78 Good luck! 79 ''' 80 81 # No file available - try using Subversion 82 try: 83 # The null stuff is so this section fails quitly. 84 # This could cause the svn info command to fail due to 85 # the redirection being bad on some platforms. 86 # If that occurs then change this code. 87 if sys.platform[0:3] == 'win': 88 fid = os.popen('svn info 2> null') 89 else: 90 fid = os.popen('svn info 2>/dev/null') 91 except: 92 raise Exception(msg) 93 else: 94 version_info = fid.read() 95 96 if version_info == '': 97 raise Exception, msg 98 else: 99 pass 100 #print 'Got version from file' 101 158 return get_revision_from_svn_client() 159 160 # split revision number from data 102 161 for line in version_info.split('\n'): 103 162 if line.startswith('Revision:'): … … 106 165 fields = line.split(':') 107 166 msg = 'Keyword "Revision" was not found anywhere in text: %s' % version_info 108 assert fields[0].startswith('Revision'), msg 167 assert fields[0].startswith('Revision'), msg 109 168 110 169 try: 111 170 revision_number = int(fields[1]) 112 171 except: 113 msg = 'Revision number must be an integer. I got %s' %fields[1] 114 msg += 'Check that the command svn is on the system path' 172 msg = ("Revision number must be an integer. I got '%s'.\n" 173 'Check that the command svn is on the system path.' 174 % fields[1]) 115 175 raise Exception, msg 116 176 … … 355 415 # @param auth Auth tuple (httpproxy, proxyuser, proxypass). 356 416 # @param blocksize Read file in this block size. 357 # @return 'auth' tuple for subsequent calls, if successful, else False.417 # @return (True, auth) if successful, else (False, auth). 358 418 # @note If 'auth' not supplied, will prompt user. 359 419 # @note Will try using environment variable HTTP_PROXY for proxy server. … … 379 439 try: 380 440 urllib.urlretrieve(file_url, file_name) 381 return None# no proxy, no auth required441 return (True, auth) # no proxy, no auth required 382 442 except IOError, e: 383 443 if e[1] == 407: # proxy error … … 385 445 elif e[1][0] == 113: # no route to host 386 446 print 'No route to host for %s' % file_url 387 return False# return False447 return (False, auth) # return False 388 448 else: 389 449 print 'Unknown connection error to %s' % file_url 390 return False450 return (False, auth) 391 451 392 452 # We get here if there was a proxy error, get file through the proxy … … 437 497 try: 438 498 webget = urllib2.urlopen(file_url) 439 except urllib2.HTTPError: 440 return False 499 except urllib2.HTTPError, e: 500 print 'Error received from proxy:\n%s' % str(e) 501 print 'Possibly the user/password is wrong.' 502 return (False, (httpproxy, proxyuser, proxypass)) 441 503 442 504 # transfer file to local filesystem … … 451 513 452 514 # return successful auth info 453 return ( httpproxy, proxyuser, proxypass)515 return (True, (httpproxy, proxyuser, proxypass)) 454 516 455 517 … … 483 545 484 546 ## 485 # @brief Return a hex digest string fora given file.547 # @brief Return a hex digest (MD5) of a given file. 486 548 # @param filename Path to the file of interest. 487 549 # @param blocksize Size of data blocks to read.
Note: See TracChangeset
for help on using the changeset viewer.