Changeset 335
- Timestamp:
- Sep 21, 2004, 5:43:03 PM (20 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution-1d/domain.py
r279 r335 17 17 18 18 from Numeric import array, zeros, Float, Int 19 19 20 self.beta = 1.0 20 21 #Store Points 21 22 self.coordinates = array(coordinates) -
inundation/ga/storm_surge/pyvolution-1d/quantity.py
r296 r335 200 200 self.explicit_update = zeros(N, Float ) 201 201 self.semi_implicit_update = zeros(N, Float ) 202 203 self.gradients = zeros(N, Float) 204 self.qmax = zeros(self.centroid_values.shape, Float) 205 self.qmin = zeros(self.centroid_values.shape, Float) 202 206 203 207 … … 226 230 227 231 def compute_gradients(self): 228 """Compute gradients of triangle surfacesdefined by centroids of232 """Compute gradients of piecewise linear function defined by centroids of 229 233 neighbouring volumes. 230 If one face is on the boundary, use own centroid as neighbour centroid.231 If two or more are on the boundary, fall back to first order scheme.232 233 Also return minimum and maximum of conserved quantities234 234 """ 235 235 236 236 237 237 from Numeric import array, zeros, Float 238 from util import gradient239 238 240 239 N = self.centroid_values.shape[0] 241 240 242 a = zeros(N, Float) 241 242 G = self.gradients 243 Q = self.centroid_values 244 X = self.domain.centroids 243 245 244 246 for k in range(N): … … 246 248 # first and last elements have boundaries 247 249 248 if k == 1:250 if k == 0: 249 251 250 252 #Get data … … 252 254 k1 = k+1 253 255 254 q0 = self.centroid_values[k0]255 q1 = self.centroid_values[k1]256 257 x0 = self.domain.centroids[k0] #V0 centroid258 x1 = self.domain.centroids[k1] #V1 centroid256 q0 = Q[k0] 257 q1 = Q[k1] 258 259 x0 = X[k0] #V0 centroid 260 x1 = X[k1] #V1 centroid 259 261 260 262 #Gradient 261 a[k] = (q1 - q0)/(x1 - x0)263 G[k] = (q1 - q0)/(x1 - x0) 262 264 263 265 elif k == N-1: … … 267 269 k1 = k-1 268 270 269 q0 = self.centroid_values[k0]270 q1 = self.centroid_values[k1]271 272 x0 = self.domain.centroids[k0] #V0 centroid273 x1 = self.domain.centroids[k1] #V1 centroid271 q0 = Q[k0] 272 q1 = Q[k1] 273 274 x0 = X[k0] #V0 centroid 275 x1 = X[k1] #V1 centroid 274 276 275 277 #Gradient 276 a[k] = (q1 - q0)/(x1 - x0)278 G[k] = (q1 - q0)/(x1 - x0) 277 279 278 else 280 else: 279 281 #Interior Volume (2 neighbours) 280 282 281 283 #Get data 282 k0 = self.domain.neighbours[k,0]283 k2 = self.domain.neighbours[k,1]284 285 q0 = self.centroid_values[k0]286 q1 = self.centroid_values[k]287 q2 = self.centroid_values[k2]288 289 x0 = self.domain.centroids[k0] #V0 centroid290 x1 = self.domain.centroids[k1] #V1 centroid (Self)291 x2 = self.domain.centroids[k2] #V2 centroid284 k0 = k-1 285 k2 = k+1 286 287 q0 = Q[k0] 288 q1 = Q[k] 289 q2 = Q[k2] 290 291 x0 = X[k0] #V0 centroid 292 x1 = X[k] #V1 centroid (Self) 293 x2 = X[k2] #V2 centroid 292 294 293 295 #Gradient 294 a[k] = ((q0-q1)/(x0-x1)*(x2-x1) - (q2-q1)/(x2-x1)*(x0-x1))/(x2-x0) 295 296 return a 297 298 299 ## def limit(self): 300 ## #Call correct module function 301 ## #(either from this module or C-extension) 302 ## limit(self) 303 304 305 ## def extrapolate_first_order(self): 306 ## """Extrapolate conserved quantities from centroid to 307 ## vertices for each volume using 308 ## first order scheme. 309 ## """ 310 311 ## qc = self.centroid_values 312 ## qv = self.vertex_values 313 314 ## for i in range(3): 315 ## qv[:,i] = qc 316 317 318 ## def extrapolate_second_order(self): 319 ## """Extrapolate conserved quantities from centroid to 320 ## vertices for each volume using 321 ## second order scheme. 322 ## """ 323 324 ## a, b = self.compute_gradients() 325 326 ## V = self.domain.get_vertex_coordinates() 327 ## qc = self.centroid_values 328 ## qv = self.vertex_values 329 330 ## #Check each triangle 331 ## for k in range(self.domain.number_of_elements): 332 ## #Centroid coordinates 333 ## x, y = self.domain.centroids[k] 334 335 ## #vertex coordinates 336 ## x0, y0, x1, y1, x2, y2 = V[k,:] 337 338 ## #Extrapolate 339 ## qv[k,0] = qc[k] + a[k]*(x0-x) + b[k]*(y0-y) 340 ## qv[k,1] = qc[k] + a[k]*(x1-x) + b[k]*(y1-y) 341 ## qv[k,2] = qc[k] + a[k]*(x2-x) + b[k]*(y2-y) 342 343 344 345 ## def limit(quantity): 346 ## """Limit slopes for each volume to eliminate artificial variance 347 ## introduced by e.g. second order extrapolator 348 349 ## This is an unsophisticated limiter as it does not take into 350 ## account dependencies among quantities. 351 352 ## precondition: 353 ## vertex values are estimated from gradient 354 ## postcondition: 355 ## vertex values are updated 356 ## """ 357 358 ## from Numeric import zeros, Float 359 360 ## N = quantity.domain.number_of_elements 361 362 ## beta = quantity.domain.beta 363 364 ## qc = quantity.centroid_values 365 ## qv = quantity.vertex_values 366 367 ## #Find min and max of this and neighbour's centroid values 368 ## qmax = zeros(qc.shape, Float) 369 ## qmin = zeros(qc.shape, Float) 370 371 ## for k in range(N): 372 ## qmax[k] = qmin[k] = qc[k] 373 ## for i in range(3): 374 ## n = quantity.domain.neighbours[k,i] 375 ## if n >= 0: 376 ## qn = qc[n] #Neighbour's centroid value 377 378 ## qmin[k] = min(qmin[k], qn) 379 ## qmax[k] = max(qmax[k], qn) 380 381 382 ## #Diffences between centroids and maxima/minima 383 ## dqmax = qmax - qc 384 ## dqmin = qmin - qc 385 386 ## #Deltas between vertex and centroid values 387 ## dq = zeros(qv.shape, Float) 388 ## for i in range(3): 389 ## dq[:,i] = qv[:,i] - qc 390 391 ## #Phi limiter 392 ## for k in range(N): 393 394 ## #Find the gradient limiter (phi) across vertices 395 ## phi = 1.0 396 ## for i in range(3): 397 ## r = 1.0 398 ## if (dq[k,i] > 0): r = dqmax[k]/dq[k,i] 399 ## if (dq[k,i] < 0): r = dqmin[k]/dq[k,i] 400 401 ## phi = min( min(r*beta, 1), phi ) 402 403 ## #Then update using phi limiter 404 ## for i in range(3): 405 ## qv[k,i] = qc[k] + phi*dq[k,i] 296 G[k] = ((q0-q1)/(x0-x1)*(x2-x1) - (q2-q1)/(x2-x1)*(x0-x1))/(x2-x0) 297 298 return 299 300 def extrapolate_first_order(self): 301 """Extrapolate conserved quantities from centroid to 302 vertices for each volume using 303 first order scheme. 304 """ 305 306 qc = self.centroid_values 307 qv = self.vertex_values 308 309 for i in range(2): 310 qv[:,i] = qc 311 312 313 def extrapolate_second_order(self): 314 """Extrapolate conserved quantities from centroid to 315 vertices for each volume using 316 second order scheme. 317 """ 318 319 self.compute_gradients() 320 321 G = self.gradients 322 V = self.domain.vertices 323 Qc = self.centroid_values 324 Qv = self.vertex_values 325 326 #Check each triangle 327 for k in range(self.domain.number_of_elements): 328 #Centroid coordinates 329 x = self.domain.centroids[k] 330 331 #vertex coordinates 332 x0, x1 = V[k,:] 333 334 #Extrapolate 335 Qv[k,0] = Qc[k] + G[k]*(x0-x) 336 Qv[k,1] = Qc[k] + G[k]*(x1-x) 337 338 339 340 341 def limit(self): 342 """Limit slopes for each volume to eliminate artificial variance 343 introduced by e.g. second order extrapolator 344 345 This is an unsophisticated limiter as it does not take into 346 account dependencies among quantities. 347 348 precondition: 349 vertex values are estimated from gradient 350 postcondition: 351 vertex values are updated 352 """ 353 354 from Numeric import zeros, Float 355 356 N = self.domain.number_of_elements 357 beta = self.domain.beta 358 359 qc = self.centroid_values 360 qv = self.vertex_values 361 362 #Find min and max of this and neighbour's centroid values 363 qmax = self.qmax 364 qmin = self.qmin 365 366 for k in range(N): 367 qmax[k] = qmin[k] = qc[k] 368 369 for i in [-1,1]: 370 n = k+i 371 if (n >= 0) & (n <= N-1): 372 qn = qc[n] #Neighbour's centroid value 373 374 qmin[k] = min(qmin[k], qn) 375 qmax[k] = max(qmax[k], qn) 376 377 #Phi limiter 378 for k in range(N): 379 380 #Diffences between centroids and maxima/minima 381 dqmax = qmax[k] - qc[k] 382 dqmin = qmin[k] - qc[k] 383 384 #Deltas between vertex and centroid values 385 dq = [0.0, 0.0] 386 for i in range(2): 387 dq[i] = qv[k,i] - qc[k] 388 389 #Find the gradient limiter (phi) across vertices 390 phi = 1.0 391 for i in range(2): 392 r = 1.0 393 if (dq[i] > 0): r = dqmax/dq[i] 394 if (dq[i] < 0): r = dqmin/dq[i] 395 396 phi = min( min(r*beta, 1), phi ) 397 398 #Then update using phi limiter 399 for i in range(2): 400 qv[k,i] = qc[k] + phi*dq[i] 406 401 407 402 … … 442 437 print Q1.vertex_values 443 438 print Q1.centroid_values 444 445 446 447 439 Xc = Q1.domain.vertices 440 Qc = Q1.vertex_values 441 print Xc 442 print Qc 443 444 Qc[1,0] = 3 445 from matplotlib.matlab import * 446 plot(Xc,Qc) 447 448 449 450 451 452 453 454 455 -
inundation/ga/storm_surge/pyvolution-1d/test_quantity.py
r296 r335 7 7 from quantity import * 8 8 #from config import epsilon 9 from Numeric import allclose, array 9 from Numeric import allclose, array, zeros, Float 10 10 11 11 … … 97 97 assert allclose(quantity.centroid_values, [1., 2., 3., 4., 5.]) #Centroid 98 98 99 #Test exceptions 99 #Test exceptionsdatamining.anu.edu.au/svn/ 100 100 try: 101 101 quantity.set_values([[1,2], [5,5], [0,0], [-6, 3], [-2,4]], … … 112 112 raise 'should have raised AssertionError' 113 113 114 115 116 114 def test_set_values_const(self): 117 115 quantity = Quantity(self.domain5) … … 144 142 145 143 146 ## def test_gradient(self): 147 ## quantity = Conserved_quantity(self.mesh4) 148 149 ## #Set up for a gradient of (3,0) at mid triangle 150 ## quantity.set_values([2.0, 4.0, 8.0, 2.0], 151 ## location = 'centroids') 152 153 ## #Gradients 154 ## a, b = quantity.compute_gradients() 155 156 157 ## #gradient bewteen t0 and t1 is undefined as det==0 158 ## assert a[0] == 0.0 159 ## assert b[0] == 0.0 160 ## #The others are OK 161 ## for i in range(1,4): 162 ## assert a[i] == 3.0 163 ## assert b[i] == 0.0 164 165 166 ## quantity.extrapolate_second_order() 167 168 ## assert allclose(quantity.vertex_values, [[2., 2., 2.], 169 ## [0., 6., 6.], 170 ## [6., 6., 12.], 171 ## [0., 0., 6.]]) 172 173 174 175 ## def test_second_order_extrapolation2(self): 176 ## quantity = Conserved_quantity(self.mesh4) 177 178 ## #Set up for a gradient of (3,1), f(x) = 3x+y 179 ## quantity.set_values([2.0+2.0/3, 4.0+4.0/3, 8.0+2.0/3, 2.0+8.0/3], 180 ## location = 'centroids') 181 182 ## #Gradients 183 ## a, b = quantity.compute_gradients() 184 185 ## #gradient bewteen t0 and t1 is undefined as det==0 186 ## assert a[0] == 0.0 187 ## assert b[0] == 0.0 188 ## #The others are OK 189 ## 163.968025 for i in range(1,4): 190 ## assert allclose(a[i], 3.0) 191 ## assert allclose(b[i], 1.0) 192 193 194 ## quantity.extrapolate_second_order() 195 196 ## assert allclose(quantity.vertex_values[1,0], 2.0) 197 ## assert allclose(quantity.vertex_values[1,1], 6.0) 198 ## assert allclose(quantity.vertex_values[1,2], 8.0) 199 200 201 202 ## # def test_limiter(self): 203 204 ## # initialise_consecutive_datastructure(points=6+4, elements=4) 205 206 ## # a = Point (0.0, 0.0) 207 ## # b = Point (0.0, 2.0) 208 ## # c = Point (2.0, 0.0) 209 ## # d = Point (0.0, 4.0) 210 ## # e = Point (2.0, 2.0) 211 ## # f = Point (4.0, 0.0) 212 213 ## # #Set up for a gradient of (3,1), f(x) = 3x+y 214 ## # v1 = Volume(b,a,c,array([0.0,0,0])) 215 ## # v2 = Volume(b,c,e,array([1.0,0,0])) 216 ## # v3 = Volume(e,c,f,array([10.0,0,0])) 217 ## # v4 = Volume(d,b,e,array([0.0,0,0])) 218 219 ## # #Setup neighbour structure 220 ## # domain = Domain([v1,v2,v3,v4]) 221 ## # domain.precompute() 222 223 ## # #Lets's check first order first, hey 224 ## # domain.order = 1 225 ## # domain.limiter = None 226 ## # distribute_to_vertices_and_edges(domain) 227 ## # assert allclose(v2.conserved_quantities_vertex0, 228 ## # v2.conserved_quantities_centroid) 229 ## # assert allclose(v2.conserved_quantities_vertex1, 230 ## # v2.conserved_quantities_centroid) 231 ## # assert allclose(v2.conserved_quantities_vertex2, 232 ## # v2.conserved_quantities_centroid) 233 234 235 ## # #Gradient of fitted pwl surface 236 ## # a, b = compute_gradient(v2.id) 237 238 239 ## # assert abs(a[0] - 5.0) < epsilon 240 ## # assert abs(b[0]) < epsilon 241 ## # #assert qminr[0] == 0.0 242 ## # #assert qmaxr[0] == 10.0 243 244 ## # #And now for the second order stuff 245 ## # # - the full second order extrapolation 246 ## # domain.order = 2 247 ## # distribute_to_vertices_and_edges(domain) 248 249 250 ## # qmin = qmax = v2.conserved_quantities_centroid 251 252 ## # qmin = minimum(qmin, v1.conserved_quantities_centroid) 253 ## # qmax = maximum(qmax, v1.conserved_quantities_centroid) 254 255 ## # qmin = minimum(qmin, v3.conserved_quantities_centroid) 256 ## # qmax = maximum(qmax, v3.conserved_quantities_centroid) 257 258 ## # qmin = minimum(qmin, v4.conserved_quantities_centroid) 259 ## # qmax = maximum(qmax, v4.conserved_quantities_centroid) 260 ## # #assert qminr == qmin 261 ## # #assert qmaxr == qmax 262 263 ## # assert v2.conserved_quantities_vertex0 <= qmax 264 ## # assert v2.conserved_quantities_vertex0 >= qmin 265 ## # assert v2.conserved_quantities_vertex1 <= qmax 266 ## # assert v2.conserved_quantities_vertex1 >= qmin 267 ## # assert v2.conserved_quantities_vertex2 <= qmax 268 ## # assert v2.conserved_quantities_vertex2 >= qmin 269 270 271 ## # #Check that volume has been preserved 272 273 ## # q = v2.conserved_quantities_centroid[0] 274 ## # w = (v2.conserved_quantities_vertex0[0] + 275 ## # v2.conserved_quantities_vertex1[0] + 276 ## # v2.conserved_quantities_vertex2[0])/3 277 278 ## # assert allclose(q, w) 144 def test_gradient(self): 145 146 quantity = Conserved_quantity(self.domain5) 147 148 #Set up for a gradient of (3,0) at mid triangle 149 quantity.set_values([2.0, 4.0, 8.0, 2.0, 5.0], 150 location = 'centroids') 151 152 #Gradients 153 quantity.compute_gradients() 154 N = quantity.gradients.shape[0] 155 156 G = quantity.gradients 157 G0 = zeros(N, Float) 158 Q = quantity.centroid_values 159 X = quantity.domain.centroids 160 161 def grad0(x0,x1,x2,q0,q1,q2): 162 return ((q0-q1)/(x0-x1)*(x2-x1) - (q2-q1)/(x2-x1)*(x0-x1))/(x2-x0) 163 164 def grad1(x0,x1,q0,q1): 165 return (q1 - q0)/(x1 - x0) 166 167 #Check Gradients 168 G0[0] = grad1(X[0],X[1],Q[0],Q[1]) 169 for i in range(1,4): 170 G0[i] = grad0(X[i-1],X[i],X[i+1],Q[i-1],Q[i],Q[i+1]) 171 G0[4] = grad1(X[3],X[4],Q[3],Q[4]) 172 173 assert allclose(G,G0) 174 175 quantity.extrapolate_first_order() 176 177 assert allclose(quantity.vertex_values, [[2., 2.], 178 [4., 4.], 179 [8., 8.], 180 [2., 2.], 181 [5., 5.]]) 182 183 quantity.extrapolate_second_order() 184 185 V = quantity.domain.vertices 186 for k in range(quantity.domain.number_of_elements): 187 G0[k] = G0[k]*(V[k,1]-V[k,0])*0.5 188 189 assert allclose(quantity.vertex_values, [[2.-G0[0], 2.+G0[0]], 190 [4.-G0[1], 4.+G0[1]], 191 [8.-G0[2], 8.+G0[2]], 192 [2.-G0[3], 2.+G0[3]], 193 [5.-G0[4], 5.+G0[4]]]) 194 195 196 197 def test_second_order_extrapolation2(self): 198 quantity = Conserved_quantity(self.domain5) 199 200 #Set up for a gradient of (2), f(x) = 2x 201 quantity.set_values([1., 3., 4.5, 5.6, 7.1], 202 location = 'centroids') 203 204 #Gradients 205 quantity.compute_gradients() 206 G = quantity.gradients 207 208 allclose(G, 2.0) 209 210 quantity.extrapolate_second_order() 211 212 V = quantity.domain.vertices 213 Q = quantity.vertex_values 214 215 assert allclose(Q[:,0], 2.0*V[:,0]) 216 assert allclose(Q[:,1], 2.0*V[:,1]) 217 218 219 279 220 280 221 … … 297 238 298 239 299 ## def test_second_order_extrapolator(self): 300 ## quantity = Conserved_quantity(self.mesh4) 301 302 ## #Set up for a gradient of (3,0) at mid triangle 303 ## quantity.set_values([2.0, 4.0, 8.0, 2.0], 304 ## location = 'centroids') 305 306 307 308 ## quantity.extrapolate_second_order() 309 ## quantity.limit() 310 311 312 ## #Assert that central triangle is limited by neighbours 313 ## assert quantity.vertex_values[1,0] >= quantity.vertex_values[0,0] 314 ## assert quantity.vertex_values[1,0] >= quantity.vertex_values[3,1] 315 316 ## assert quantity.vertex_values[1,1] <= quantity.vertex_values[2,1] 317 ## assert quantity.vertex_values[1,1] >= quantity.vertex_values[0,2] 318 319 ## assert quantity.vertex_values[1,2] <= quantity.vertex_values[2,0] 320 ## assert quantity.vertex_values[1,2] >= quantity.vertex_values[3,1] 321 322 323 ## #Assert that quantities are conserved 324 ## from Numeric import sum 325 ## for k in range(quantity.centroid_values.shape[0]): 326 ## assert allclose (quantity.centroid_values[k], 327 ## sum(quantity.vertex_values[k,:])/3) 328 329 330 331 332 333 ## def test_limiter(self): 334 ## quantity = Conserved_quantity(self.mesh4) 335 336 ## #Create a deliberate overshoot (e.g. from gradient computation) 337 ## quantity.set_values([[3,0,3], [2,2,6], [5,3,8], [8,3,5]]) 338 339 340 ## #Limit 341 ## quantity.limit() 342 343 ## #Assert that central triangle is limited by neighbours 344 ## assert quantity.vertex_values[1,0] >= quantity.vertex_values[0,0] 345 ## assert quantity.vertex_values[1,0] <= quantity.vertex_values[3,1] 346 347 ## assert quantity.vertex_values[1,1] <= quantity.vertex_values[2,1] 348 ## assert quantity.vertex_values[1,1] >= quantity.vertex_values[0,2] 349 350 ## assert quantity.vertex_values[1,2] <= quantity.vertex_values[2,0] 351 ## assert quantity.vertex_values[1,2] <= quantity.vertex_values[3,1] 352 353 354 355 ## #Assert that quantities are conserved 356 ## from Numeric import sum 357 ## for k in range(quantity.centroid_values.shape[0]): 358 ## assert allclose (quantity.centroid_values[k], 359 ## sum(quantity.vertex_values[k,:])/3) 240 def test_second_order_limit_extrapolator(self): 241 quantity = Conserved_quantity(self.domain5) 242 243 #Set up for a gradient of (3,0) at mid triangle 244 quantity.set_values([2.0, 4.0, 8.0, 2.0, 0.0], 245 location = 'centroids') 246 247 248 249 quantity.extrapolate_second_order() 250 quantity.limit() 251 252 253 #Assert that central triangle is limited by neighbours 254 assert quantity.vertex_values[0,0] >= 2.0 255 assert quantity.vertex_values[0,0] <= 4.0 256 assert quantity.vertex_values[0,1] >= 2.0 257 assert quantity.vertex_values[0,1] <= 4.0 258 259 assert quantity.vertex_values[1,0] >= 2.0 260 assert quantity.vertex_values[1,0] <= 8.0 261 assert quantity.vertex_values[1,1] >= 2.0 262 assert quantity.vertex_values[1,1] <= 8.0 263 264 assert quantity.vertex_values[2,0] >= 2.0 265 assert quantity.vertex_values[2,0] <= 8.0 266 assert quantity.vertex_values[2,1] >= 2.0 267 assert quantity.vertex_values[2,1] <= 8.0 268 269 assert quantity.vertex_values[3,0] >= 0.0 270 assert quantity.vertex_values[3,0] <= 8.0 271 assert quantity.vertex_values[3,1] >= 0.0 272 assert quantity.vertex_values[3,1] <= 8.0 273 274 assert quantity.vertex_values[4,0] >= 0.0 275 assert quantity.vertex_values[4,0] <= 2.0 276 assert quantity.vertex_values[4,1] >= 0.0 277 assert quantity.vertex_values[4,1] <= 2.0 278 279 280 281 #Assert that quantities are conserved 282 from Numeric import sum 283 for k in range(quantity.centroid_values.shape[0]): 284 assert allclose (quantity.centroid_values[k], 285 sum(quantity.vertex_values[k,:])/2) 286 287 288 289 290 def test_limiter(self): 291 quantity = Conserved_quantity(self.domain5) 292 293 #Create a deliberate overshoot (e.g. from gradient computation) 294 quantity.set_values([[3,0,3], [2,2,6], [5,3,8], [8,3,5]]) 295 296 297 #Limit 298 quantity.limit() 299 300 #Assert that central triangle is limited by neighbours 301 assert quantity.vertex_values[1,0] >= quantity.vertex_values[0,0] 302 assert quantity.vertex_values[1,0] <= quantity.vertex_values[3,1] 303 304 assert quantity.vertex_values[1,1] <= quantity.vertex_values[2,1] 305 assert quantity.vertex_values[1,1] >= quantity.vertex_values[0,2] 306 307 assert quantity.vertex_values[1,2] <= quantity.vertex_values[2,0] 308 assert quantity.vertex_values[1,2] <= quantity.vertex_values[3,1] 309 310 311 312 #Assert that quantities are conserved 313 from Numeric import sum 314 for k in range(quantity.centroid_values.shape[0]): 315 assert allclose (quantity.centroid_values[k], 316 sum(quantity.vertex_values[k,:])/3) 360 317 361 318 -
inundation/ga/storm_surge/pyvolution/netherlands.py
r297 r335 92 92 93 93 N = 600 #Size = 720000 94 N = 2 2094 N = 20 95 95 N = 55 96 96 … … 172 172 t0 = time.time() 173 173 174 for t in domain.evolve(yieldstep = 0. 01, finaltime = 1.0):174 for t in domain.evolve(yieldstep = 0.1, finaltime = 2.0): 175 175 domain.write_time() 176 176
Note: See TracChangeset
for help on using the changeset viewer.