- Timestamp:
- Nov 24, 2004, 4:43:40 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_generic_boundary_conditions.py
r324 r623 144 144 t_string = time.strftime(time_format, time.gmtime(t)) 145 145 146 147 146 fid.write('%s,%f %f\n' %(t_string, 1.0*i, sin(i*2*pi/10))) 148 147 fid.close() 149 148 150 149 151 F = File_boundary( domain, filename)150 F = File_boundary(filename, domain) 152 151 153 152 from config import default_boundary_tag … … 164 163 165 164 os.remove(filename) 165 166 167 168 def test_fileboundary_exception(self): 169 """Test that boundary object complians if number of 170 conserved quantities are wrong 171 """ 172 173 from domain import Domain 174 from quantity import Quantity 175 import time, os 176 from math import sin, pi 177 from config import time_format 178 179 a = [0.0, 0.0] 180 b = [0.0, 2.0] 181 c = [2.0,0.0] 182 d = [0.0, 4.0] 183 e = [2.0, 2.0] 184 f = [4.0,0.0] 185 186 points = [a, b, c, d, e, f] 187 188 #bac, bce, ecf, dbe 189 elements = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ] 190 191 domain = Domain(points, elements) 192 domain.conserved_quantities = ['level', 'xmomentum', 'ymomentum'] 193 domain.quantities['level'] =\ 194 Quantity(domain, [[1,2,3], [5,5,5], 195 [0,0,9], [-6, 3, 3]]) 196 197 domain.quantities['xmomentum'] =\ 198 Quantity(domain, [[2,3,4], [5,5,5], 199 [0,0,9], [-6, 3, 3]]) 200 domain.quantities['ymomentum'] =\ 201 Quantity(domain, [[2,3,4], [5,5,5], 202 [0,0,9], [-6, 3, 3]]) 203 204 domain.check_integrity() 205 206 #Write file (with only two values) 207 filename = 'boundarytest' + str(time.time()) 208 fid = open(filename, 'w') 209 start = time.mktime(time.strptime('2000', '%Y')) 210 dt = 5*60 #Five minute intervals 211 for i in range(10): 212 t = start + i*dt 213 t_string = time.strftime(time_format, time.gmtime(t)) 214 215 fid.write('%s,%f %f\n' %(t_string, 1.0*i, sin(i*2*pi/10))) 216 fid.close() 217 218 219 try: 220 F = File_boundary(filename, domain) 221 except AssertionError: 222 pass 223 else: 224 raise 'Should have raised an exception' 225 226 os.remove(filename) 227 228 166 229 167 230 #-------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.