Changeset 212 for inundation/ga/storm_surge/pyvolution/test_quantity.py
- Timestamp:
- Aug 24, 2004, 4:11:25 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_quantity.py
r209 r212 217 217 218 218 219 # def test_second_order_extrapolation2(self): 220 221 # initialise_consecutive_datastructure(points=6+4, elements=4) 222 223 # a = Point (0.0, 0.0) 224 # b = Point (0.0, 2.0) 225 # c = Point (2.0, 0.0) 226 # d = Point (0.0, 4.0) 227 # e = Point (2.0, 2.0) 228 # f = Point (4.0, 0.0) 229 230 # #Set up for a gradient of (3,1), f(x) = 3x+y 231 # v1 = Volume(b,a,c,array([2.0+2.0/3,0,0])) 232 # v2 = Volume(b,c,e,array([4.0+4.0/3,0,0])) 233 # v3 = Volume(e,c,f,array([8.0+2.0/3,0,0])) 234 # v4 = Volume(d,b,e,array([2.0+8.0/3,0,0])) 235 236 # #Setup neighbour structure 237 # domain = Domain([v1,v2,v3,v4]) 238 # domain.precompute() 239 # domain.check_integrity() 240 241 # #Lets's check first order first, hey 242 # domain.order = 1 243 # domain.limiter = dummy_limiter 244 # distribute_to_vertices_and_edges(domain) 245 246 # assert allclose(v2.conserved_quantities_vertex0, 247 # v2.conserved_quantities_centroid) 248 # assert allclose(v2.conserved_quantities_vertex1, 249 # v2.conserved_quantities_centroid) 250 # assert allclose(v2.conserved_quantities_vertex2, 251 # v2.conserved_quantities_centroid) 252 253 254 # #Flux across right edge of volume 1 255 # #Outward pointing normal vector 256 # from shallow_water import flux_using_stage as flux_function 257 # normals = Volume.normals 258 259 # normal = Vector.coordinates[normals[1][2]] 260 # ql = Volume.conserved_quantities_face2[1] 261 # qr = Volume.conserved_quantities_face1[0] 262 # fl = array([0.,0.]) 263 # fr = array([0.,0.]) 264 # flux0, max_speed = flux_function(normal, ql, qr, fl, fr) 265 266 # #print flux0, max_speed 267 268 # #print 269 # #print v1.conserved_quantities_face0,\ 270 # # v2.conserved_quantities_face0,\ 271 # # v3.conserved_quantities_face0,\ 272 # # v4.conserved_quantities_face0 273 # #print 274 # #edgelengths = Volume.geometric[:,2:] 275 # #print 276 # #print 277 278 # from python_versions import compute_flux 279 # compute_flux(domain, 100) 280 # F1 = Volume.explicit_update 281 282 # from domain import compute_flux 283 # compute_flux(domain, 100) 284 # F2 = Volume.explicit_update 285 286 # assert allclose(F1, F2) 287 288 # #print F1 289 # #print F2 290 291 292 293 # #Gradient of fitted pwl surface 294 # a, b = compute_gradient(v2.id) 295 296 # assert abs(a[0] - 3.0) < epsilon 297 # assert abs(b[0] - 1.0) < epsilon 298 # #assert qmin[0] == 2.0 + 2.0/3 299 # #assert qmax[0] == 8.0 + 2.0/3 300 301 # #And now for the second order stuff 302 # # - the full second order extrapolation 303 # domain.order = 2 304 # domain.limiter = dummy_limiter 305 # distribute_to_vertices_and_edges(domain) 306 307 # assert allclose(v2.conserved_quantities_vertex0[0], 2.0) 308 # assert allclose(v2.conserved_quantities_vertex1[0], 6.0) 309 # assert allclose(v2.conserved_quantities_vertex2[0], 8.0) 310 219 def test_second_order_extrapolation2(self): 220 quantity = Quantity(self.mesh4) 221 222 #Set up for a gradient of (3,1), f(x) = 3x+y 223 quantity.set_values([2.0+2.0/3, 4.0+4.0/3, 8.0+2.0/3, 2.0+8.0/3], 224 location = 'centroids') 225 226 #Gradients 227 a, b = quantity.compute_gradients() 228 229 #gradient bewteen t0 and t1 is undefined as det==0 230 assert a[0] == 0.0 231 assert b[0] == 0.0 232 #The others are OK 233 for i in range(1,4): 234 assert allclose(a[i], 3.0) 235 assert allclose(b[i], 1.0) 236 237 238 quantity.extrapolate_second_order() 239 240 assert allclose(quantity.vertex_values[1,0], 2.0) 241 assert allclose(quantity.vertex_values[1,1], 6.0) 242 assert allclose(quantity.vertex_values[1,2], 8.0) 311 243 312 244
Note: See TracChangeset
for help on using the changeset viewer.