Changeset 1742 for inundation/validation/LWRU2/lwru2.py
- Timestamp:
- Aug 23, 2005, 2:56:21 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/validation/LWRU2/lwru2.py
r1736 r1742 77 77 from Numeric import array, zeros, Float, allclose 78 78 import filenames 79 from caching import cache 79 80 80 picklefile = 'domain.pck' 81 from cPickle import dump, load 81 #Preparing time boundary 82 prepare_timeboundary(filenames.boundary_filename) 82 83 83 N = 100 84 85 try: 86 #raise Exception 87 fid = open(picklefile) 88 print 'Read pickled domain' 89 domain = load(fid) 90 91 except: 92 93 #Preparing time boundary 94 prepare_timeboundary(filenames.boundary_filename) 95 96 #Preparing points 97 from pyvolution.data_manager import xya2pts 98 xya2pts(filenames.bathymetry_filename, verbose = True, 99 z_func = lambda z: -z) 84 #Preparing points 85 from pyvolution.data_manager import xya2pts 86 xya2pts(filenames.bathymetry_filename, verbose = True, 87 z_func = lambda z: -z) 100 88 101 89 102 103 90 ####################### 91 # Domain 104 92 105 if read_mesh is True: 106 print 'Creating domain from', filenames.mesh_filename 107 domain = pmesh_to_domain_instance(filenames.mesh_filename, Domain) 108 else: 109 print 'Creating regular domain' 110 points, vertices, boundary = rectangular(N, N/5*3, 111 len1=5.448, len2=3.402) 112 domain = Domain(points, vertices, boundary) 93 if read_mesh is True: 94 print 'Creating domain from', filenames.mesh_filename 95 domain = pmesh_to_domain_instance(filenames.mesh_filename, Domain) 96 else: 97 print 'Creating regular mesh' 98 N = 100 99 points, vertices, boundary = rectangular(N, N/5*3, 100 len1=5.448, len2=3.402) 101 print 'Creating domain' 102 103 #domain = Domain(points, vertices, boundary) 104 domain = cache(Domain, (points, vertices, boundary)) 113 105 114 106 115 107 116 117 108 print "Number of triangles = ", len(domain) 109 print 'The extent is ', domain.get_extent() 118 110 119 111 120 121 112 #domain.check_integrity() 113 domain.default_order = 2 122 114 123 124 115 print "Number of triangles = ", len(domain) 116 domain.store = True #Store for visualisation purposes 125 117 126 127 128 118 import sys, os 119 base = os.path.basename(sys.argv[0]) 120 domain.filename, _ = os.path.splitext(base) 129 121 130 #LS code to be included in set_quantity 131 from pyvolution import util, least_squares 132 points, attributes = util.read_xya(filenames.bathymetry_filename[:-4] + '.pts') 122 #LS code to be included in set_quantity 123 print 'Reading points' 124 from pyvolution import util, least_squares 125 points, attributes = util.read_xya(filenames.bathymetry_filename[:-4] + '.pts') 126 elevation = attributes['elevation'] 133 127 134 135 136 137 138 139 140 128 #Fit attributes to mesh 129 #vertex_attributes = least_squares.fit_to_mesh(domain.coordinates, 130 # domain.triangles, 131 # points, 132 # attributes['elevation'], 133 # alpha = 0.0001, 134 # verbose=True) 141 135 142 print 'Initial values' 143 domain.set_quantity('elevation', vertex_attributes) 144 domain.set_quantity('friction', 0.0) 145 domain.set_quantity('stage', 0.0)136 #vertex_attributes = cache(least_squares.fit_to_mesh, 137 # (domain.coordinates, domain.triangles, 138 # points, elevation) , 139 # {'alpha': 0.0001, 'verbose': True}) 146 140 141 print 'Initial values' 142 #domain.set_quantity('elevation', vertex_attributes) 143 domain.set_quantity('elevation', points=points, attributes=attributes['elevation'], alpha=0.0001) 144 domain.set_quantity('friction', 0.0) 145 domain.set_quantity('stage', 0.0) 147 146 148 fid = open('domain.pck', 'w')149 dump(domain, fid)150 fid.close()151 147 152 148 … … 166 162 167 163 #Set boundary conditions 168 169 164 if read_mesh is True: 170 165 domain.set_boundary({'wave': Bts, 'wall': Br})
Note: See TracChangeset
for help on using the changeset viewer.