Changeset 2566
- Timestamp:
- Mar 21, 2006, 2:25:40 PM (19 years ago)
- Location:
- inundation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/config.py
r2528 r2566 33 33 34 34 35 v_max = 100 #For use in domain_ext.c35 #v_max = 100 #For use in domain_ext.c 36 36 sound_speed = 500 37 37 … … 106 106 #Specific to shallow water W.E. 107 107 minimum_allowed_height = 1.0e-3 #Water depth below which it is considered to be 0 108 maximum_allowed_speed = 100.0 #Maximal particle speed of water -
inundation/pyvolution/shallow_water.py
r2516 r2566 79 79 tagged_elements, geo_reference, use_inscribed_circle) 80 80 81 from config import minimum_allowed_height, g81 from config import minimum_allowed_height, maximum_allowed_speed, g 82 82 self.minimum_allowed_height = minimum_allowed_height 83 self.maximum_allowed_speed = maximum_allowed_speed 83 84 self.g = g 84 85 … … 667 668 hc = wc - zc #Water depths at centroids 668 669 669 #Update 670 #Update 671 #FIXME: Modify accroditg to c-version - or discard altogether. 670 672 for k in range(domain.number_of_elements): 671 673 … … 691 693 from shallow_water_ext import protect 692 694 693 protect(domain.minimum_allowed_height, domain. epsilon,694 wc, zc, xmomc, ymomc)695 protect(domain.minimum_allowed_height, domain.maximum_allowed_speed, 696 domain.epsilon, wc, zc, xmomc, ymomc) 695 697 696 698 -
inundation/pyvolution/shallow_water_ext.c
r2561 r2566 356 356 int _protect(int N, 357 357 double minimum_allowed_height, 358 double maximum_allowed_speed, 358 359 double epsilon, 359 360 double* wc, … … 364 365 int k; 365 366 double hc; 366 double vx, vy; 367 double maximum_allowed_speed = 100.0; //FIXME (Ole): Pass in 367 double u, v, tmp_speed; 368 368 369 369 //Protect against initesimal and negative heights … … 373 373 374 374 if (hc < minimum_allowed_height) { 375 if (hc < epsilon) { 375 //if (1) { 376 //if (hc < epsilon) { 377 if (hc <= 0.0) { 376 378 wc[k] = zc[k]; //Contain 'lost mass' error 377 379 xmomc[k] = 0.0; … … 380 382 //Try to see if calculated speeds would blow up 381 383 //FIXME (Ole): This has not been written in Python 382 vx= xmomc[k]/hc;383 vy = ymomc[k]/hc; 384 if (fabs(vx) > maximum_allowed_speed) {385 printf("WARNING: Speed has %.3f has been reducedto %.3f\n",386 vx, maximum_allowed_speed);387 xmomc[k] = maximum_allowed_speed * hc * vx/fabs(vx);384 u = xmomc[k]/hc; 385 if (fabs(u) > maximum_allowed_speed) { 386 tmp_speed = maximum_allowed_speed * u/fabs(u); 387 //printf("WARNING: Speed (u) has been reduced from %.3f to %.3f\n", 388 // u, tmp_speed); 389 xmomc[k] = tmp_speed * hc; 388 390 } 389 391 390 if (fabs(vy) > maximum_allowed_speed) { 391 printf("WARNING: Speed has %.3f has been reduced to %.3f\n", 392 vy, maximum_allowed_speed); 393 ymomc[k] = maximum_allowed_speed * hc * vy/fabs(vy); 392 v = ymomc[k]/hc; 393 if (fabs(v) > maximum_allowed_speed) { 394 tmp_speed = maximum_allowed_speed * v/fabs(v); 395 //printf("WARNING: Speed (v) has been reduced from %.3f to %.3f\n", 396 // v, maximum_allowed_speed); 397 ymomc[k] = tmp_speed * hc; 394 398 } 395 399 … … 1043 1047 PyObject *protect(PyObject *self, PyObject *args) { 1044 1048 // 1045 // protect(minimum_allowed_height, wc, zc, xmomc, ymomc)1049 // protect(minimum_allowed_height, maximum_allowed_speed, wc, zc, xmomc, ymomc) 1046 1050 1047 1051 … … 1054 1058 1055 1059 int N; 1056 double minimum_allowed_height, epsilon;1060 double minimum_allowed_height, maximum_allowed_speed, epsilon; 1057 1061 1058 1062 // Convert Python arguments to C 1059 if (!PyArg_ParseTuple(args, "dd OOOO",1063 if (!PyArg_ParseTuple(args, "dddOOOO", 1060 1064 &minimum_allowed_height, 1065 &maximum_allowed_speed, 1061 1066 &epsilon, 1062 1067 &wc, &zc, &xmomc, &ymomc)) … … 1067 1072 _protect(N, 1068 1073 minimum_allowed_height, 1074 maximum_allowed_speed, 1069 1075 epsilon, 1070 1076 (double*) wc -> data, -
inundation/pyvolution/test_shallow_water.py
r2565 r2566 2174 2174 os.remove(domain.filename + '.sww') 2175 2175 2176 2177 def test_flatbed_second_order_vmax_0(self): 2178 from mesh_factory import rectangular 2179 from shallow_water import Domain,\ 2180 Reflective_boundary, Dirichlet_boundary 2181 2182 from Numeric import array 2183 2184 #Create basic mesh 2185 N = 8 2186 points, vertices, boundary = rectangular(N, N) 2187 2188 #Create shallow water domain 2189 domain = Domain(points, vertices, boundary) 2190 domain.smooth = False 2191 domain.visualise = False 2192 domain.default_order=2 2193 domain.maximum_allowed_speed = 0.0 #Makes it like the 'oldstyle' 2194 2195 # Boundary conditions 2196 Br = Reflective_boundary(domain) 2197 Bd = Dirichlet_boundary([0.2,0.,0.]) 2198 2199 domain.set_boundary({'left': Bd, 'right': Br, 'top': Br, 'bottom': Br}) 2200 domain.check_integrity() 2201 2202 #Evolution 2203 for t in domain.evolve(yieldstep = 0.01, finaltime = 0.03): 2204 pass 2205 2206 2207 assert allclose(domain.min_timestep, 0.0210448446782) 2208 assert allclose(domain.max_timestep, 0.0210448446782) 2209 2210 #FIXME: These numbers were from version before 21/3/6 - 2211 #could be recreated by setting maximum_allowed_speed to 0 maybe 2212 assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 2213 [ 0.00064835, 0.03685719, 0.00085073, 0.03687313]) 2214 2215 2216 assert allclose(domain.quantities['ymomentum'].vertex_values[:4,0], 2217 [-0.00139463,0.0006156,-0.00060364,0.00061827]) 2218 2219 2220 os.remove(domain.filename + '.sww') 2221 2222 2176 2223 2177 2224 def test_flatbed_second_order_distribute(self): -
inundation/test_all.py
r2563 r2566 23 23 exclude_dirs = ['pypar_dist', #Special requirements 24 24 'props', 'wcprops', 'prop-base', 'text-base', '.svn', #Svn 25 'tmp' ]26 #'pmesh'] #Name conflict on my home machine (Ole)25 'tmp', 26 'pmesh'] #Name conflict on my home machine (Ole) 27 27 28 28
Note: See TracChangeset
for help on using the changeset viewer.