Changeset 8881
- Timestamp:
- Jun 5, 2013, 4:08:23 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_validation_tests/Analytical_exact/lake_at_rest_varying_width/numerical_varying_width.py
r8878 r8881 12 12 from anuga import Domain as Domain 13 13 from math import cos 14 from numpy import zeros, ones, array, interp, polyval 14 from numpy import zeros, ones, array, interp, polyval, ones_like, zeros_like 15 from numpy import where, logical_and 15 16 from time import localtime, strftime, gmtime 16 17 from scipy.interpolate import interp1d … … 71 72 45.,40.,40.,30.,40.,40.,5.,40.,35.,25.,40.,40.])/2. 72 73 73 print "Start here" 74 75 depth = interp1d(XX, ZZ) 76 width = interp1d(XX, WW) 77 74 78 def bed_elevation(x,y): 75 z = 25.*ones(len(x), float) 76 for i in range(len(XX)-1): 77 for j in range(len(x)): 78 if XX[i] <= x[j] <= XX[i+1]: 79 v1 = [XX[i+1]-XX[i], WW[i+1]-WW[i]] 80 v2 = [XX[i+1]-x[j], WW[i+1]-abs(y[j])] 81 xp = v1[0]*v2[1] - v1[1]*v2[0] 82 #if 0.0 <= abs(y[j]) <= interp1d([XX[i],XX[i+1]], [WW[i],WW[i+1]])(y[j]): 83 if xp >= 0: 84 z[j] = interp1d([XX[i],XX[i+1]], [ZZ[i],ZZ[i+1]])(x[j]) 79 80 z = 25.0*ones_like(x) 81 82 wid = width(x) 83 dep = depth(x) 84 85 z = where( logical_and(y < wid, y>-wid), dep, z) 86 85 87 return z 88 86 89 domain.set_quantity('elevation', bed_elevation) 87 print "Start now" 90 88 91 89 92 #-----------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.