# Changeset 700

Ignore:
Timestamp:
Dec 13, 2004, 5:45:14 PM (19 years ago)
Message:

Added error message if indices is not a list, array or None. Also fixed up Hobart examples.

Location:
inundation/ga/storm_surge
Files:
4 edited

Unmodified
Removed
• ## inundation/ga/storm_surge/analytical solutions/Hobart.py

 r699 print 'Creating domain from', filename domain = pmesh_to_domain_instance(filename, Domain) print "Number of triangles = ", len(domain) print 'Number of triangles = ', len(domain) print 'Extent = ', domain.get_extent() domain.default_order = 1 domain.smooth = True #------------------------------ X = domain.get_centroid_coordinates() #        Find triangle indices which are within polygon boundary only indicies = inside_polygon(X,p0) indices = inside_polygon(X, p0) #        Get the bed elevation at the centroid of every triangle in polygon region zp = domain.get_quantity('elevation',location='centroids',indexes='indicies') #        Set the level to bed elevation plus depth for all triangle centroids in the polygon region domain.set_quantity('level',zp+depth,location='centroids',indexes='indicies') zp = domain.get_quantity('elevation', location='centroids', indexes=indices) #        Set the level to bed elevation plus depth for all triangle vertices in the polygon region domain.set_quantity('level', zp+depth, location='centroids', indexes=indices) #Alternative way which also works (I used it for testing - OMN) # #z = domain.get_quantity('elevation') #from copy import copy #w = copy(z) #for i in indices: #    w[i, :] = z[i, :] + depth #domain.set_quantity('level', w) #-------------------------------------
• ## inundation/ga/storm_surge/pyvolution/quantity.py

 r659 msg = 'Given values are None' raise msg import types import types, Numeric assert type(indexes) in [types.ListType, types.NoneType, Numeric.ArrayType],\ 'Indices must be a list or None' if callable(X): raise msg import types, Numeric assert type(indexes) in [types.ListType, types.NoneType, Numeric.ArrayType],\ 'Indices must be a list or None' if (indexes ==  None): indexes = range(len(self)) if location == 'centroids':
• ## inundation/ga/storm_surge/pyvolution/test_domain.py

 r648 domain.set_region([set_bottom_friction, set_top_friction]) #print domain.quantities['friction'].get_values() assert allclose(domain.quantities['friction'].get_values(), [[ 0.09,  0.09,  0.09], [ 0.09,  0.09,  0.09], [ 0.07,  0.07,  0.07], [ 0.07,  0.07,  0.07], [ 1.0,  1.0,  1.0], [ 1.0,  1.0,  1.0]]) assert allclose(domain.quantities['friction'].get_values(),\ [[ 0.09,  0.09,  0.09], [ 0.09,  0.09,  0.09], [ 0.07,  0.07,  0.07], [ 0.07,  0.07,  0.07], [ 1.0,  1.0,  1.0], [ 1.0,  1.0,  1.0]]) domain.set_region([set_all_friction])
• ## inundation/ga/storm_surge/pyvolution/test_region.py

 r592 domain.set_region([a, b]) #print domain.quantities['friction'].get_values() assert allclose(domain.quantities['friction'].get_values(), [[ 0.09,  0.09,  0.09], [ 0.09,  0.09,  0.09], [ 0.07,  0.07,  0.07], [ 0.07,  0.07,  0.07], [ 1.0,  1.0,  1.0], [ 1.0,  1.0,  1.0]]) assert allclose(domain.quantities['friction'].get_values(),\ [[ 0.09,  0.09,  0.09], [ 0.09,  0.09,  0.09], [ 0.07,  0.07,  0.07], [ 0.07,  0.07,  0.07], [ 1.0,  1.0,  1.0], [ 1.0,  1.0,  1.0]]) #c = Add_Value_To_Region('all', 'friction', 10.0)
Note: See TracChangeset for help on using the changeset viewer.