Changeset 8375
- Timestamp:
- Mar 31, 2012, 2:47:12 PM (13 years ago)
- Location:
- trunk/anuga_work/development/gareth
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain.py
r8356 r8375 144 144 # self.check_integrity() 145 145 146 #print 'Into Evolve' 147 146 148 msg = 'Attribute self.beta_w must be in the interval [0, 2]' 147 149 assert 0 <= self.beta_w <= 2.0, msg … … 155 157 if self.store is True and self.get_time() == self.get_starttime(): 156 158 self.initialise_storage() 157 159 #print 'Into Generic_Domain Evolve' 158 160 # Call basic machinery from parent class 159 161 for t in Generic_Domain.evolve(self, yieldstep=yieldstep, 160 162 finaltime=finaltime, duration=duration, 161 163 skip_initial_step=skip_initial_step): 164 #print 'Out of Generic_Domain Evolve' 162 165 # Store model data, e.g. for subsequent visualisation 163 166 if self.store is True: … … 208 211 from swb2_domain_ext import compute_fluxes_ext_central \ 209 212 as compute_fluxes_ext 213 214 #print "." 210 215 211 216 # Shortcuts … … 364 369 365 370 # Remove very thin layers of water 371 #print 'Before protect' 366 372 domain.protect_against_infinitesimal_and_negative_heights() 373 #print 'After protect' 367 374 368 375 #for name in domain.conserved_quantities: … … 378 385 # raise Exception('Unknown order') 379 386 387 #print 'Before extrapolate' 380 388 domain.extrapolate_second_order_edge_sw() 389 #print 'After extrapolate' 381 390 382 391 #balance_deep_and_shallow(domain) -
trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c
r8359 r8375 787 787 double dqv[3], qmin, qmax, hmin, hmax, bedmax, stagemin; 788 788 double hc, h0, h1, h2, beta_tmp, hfactor; 789 double xmom_centroid_store[number_of_elements], ymom_centroid_store[number_of_elements], dk, dv0, dv1, dv2, de[3]; 790 double stage_centroid_store[number_of_elements]; 791 789 double dk, dv0, dv1, dv2, de[3]; 790 //double xmom_centroid_store[number_of_elements], ymom_centroid_store[number_of_elements] 791 //double stage_centroid_store[number_of_elements]; 792 793 double *xmom_centroid_store, *ymom_centroid_store, *stage_centroid_store; 794 795 // Use malloc to avoid putting these variables on the stack, which can cause 796 // segfaults in large model runs 797 xmom_centroid_store = malloc(number_of_elements*sizeof(double)); 798 ymom_centroid_store = malloc(number_of_elements*sizeof(double)); 799 stage_centroid_store = malloc(number_of_elements*sizeof(double)); 800 792 801 if(extrapolate_velocity_second_order==1){ 793 802 // Replace momentum centroid with velocity centroid to allow velocity … … 819 828 820 829 if (number_of_boundaries[k]==3) 830 //if (0==0) 821 831 { 822 832 // No neighbours, set gradient on the triangle to zero … … 1366 1376 } 1367 1377 } 1378 1379 free(xmom_centroid_store); 1380 free(ymom_centroid_store); 1381 free(stage_centroid_store); 1368 1382 1369 1383 return 0; … … 1859 1873 number_of_elements = stage_centroid_values -> dimensions[0]; 1860 1874 1875 //printf("In C before Extrapolate"); 1876 //e=1; 1861 1877 // Call underlying computational routine 1862 1878 e = _extrapolate_second_order_edge_sw(number_of_elements, … … 1884 1900 extrapolate_velocity_second_order); 1885 1901 1902 //printf("In C before edges-to-vertices"); 1886 1903 1887 1904 //Extrapolate from edges to vertices … … 1896 1913 (double *) elevation_vertex_values -> data, 1897 1914 extrapolate_velocity_second_order); 1915 //printf("In C after edges-to-vertices"); 1898 1916 1899 1917 if (e == -1) { -
trunk/anuga_work/development/gareth/tests/channel_floodplain/plotme.py
r8359 r8375 4 4 5 5 # Time-index to plot outputs from 6 index= 756 index=900 7 7 8 8 #p2 = util.get_output('channel_floodplain1_bal_dev.sww', minimum_allowed_height=0.01) -
trunk/anuga_work/development/gareth/tests/util.py
r8353 r8375 73 73 ############## 74 74 75 def animate_1D(time, var, x, ylab=' '): #, x=range(var.shape[1]), vmin=var.min(), vmax=var.max()):76 # Input: time = one-dimensional time vector;77 # var = array with first dimension = len(time) ;78 # x = (optional) vector width dimension equal to var.shape[1];79 80 import pylab81 import numpy82 83 84 85 pylab.close()86 pylab.ion()87 88 # Initial plot89 vmin=var.min()90 vmax=var.max()91 line, = pylab.plot( (x.min(), x.max()), (vmin, vmax), 'o')92 93 # Lots of plots94 for i in range(len(time)):95 line.set_xdata(x)96 line.set_ydata(var[i,:])97 pylab.draw()98 pylab.xlabel('x')99 pylab.ylabel(ylab)100 pylab.title('time = ' + str(time[i]))101 102 return103 75 104 76 … … 198 170 #pylab.quiver(x,y,xvel[n,:],yvel[n,:]) 199 171 #pylab.savefig('Plot1.png') 172 173 def animate_1D(time, var, x, ylab=' '): #, x=range(var.shape[1]), vmin=var.min(), vmax=var.max()): 174 # Input: time = one-dimensional time vector; 175 # var = array with first dimension = len(time) ; 176 # x = (optional) vector width dimension equal to var.shape[1]; 177 178 import pylab 179 import numpy 180 181 182 183 pylab.close() 184 pylab.ion() 185 186 # Initial plot 187 vmin=var.min() 188 vmax=var.max() 189 line, = pylab.plot( (x.min(), x.max()), (vmin, vmax), 'o') 190 191 # Lots of plots 192 for i in range(len(time)): 193 line.set_xdata(x) 194 line.set_ydata(var[i,:]) 195 pylab.draw() 196 pylab.xlabel('x') 197 pylab.ylabel(ylab) 198 pylab.title('time = ' + str(time[i])) 199 200 return 201 202 def near_transect(p, point1, point2, tol=1.): 203 # Function to get the indices of points in p less than 'tol' from the line 204 # joining (x1,y1), and (x2,y2) 205 # p comes from util.get_output('mysww.sww') 206 # 207 # e.g. 208 # import util 209 # #import transect_interpolate 210 # from matplotlib import pyplot 211 # p=util.get_output('merewether_1m.sww',0.01) 212 # p2=util.get_centroids(p,velocity_extrapolation=True) 213 # #xxx=transect_interpolate.near_transect(p,[95., 85.], [120.,68.],tol=2.) 214 # xxx=util.near_transect(p,[95., 85.], [120.,68.],tol=2.) 215 # pyplot.scatter(xxx[1],p.vel[140,xxx[0]],color='red') 216 217 x1=point1[0] 218 y1=point1[1] 219 220 x2=point2[0] 221 y2=point2[1] 222 223 # Find line equation a*x + b*y + c = 0 224 # based on y=gradient*x +intercept 225 if x1!=x2: 226 gradient= (y2-y1)/(x2-x1) 227 intercept = y1 - gradient*x1 228 229 a = -gradient 230 b = 1. 231 c = -intercept 232 else: 233 #print 'FIXME: Still need to treat 0 and infinite gradients' 234 #assert 0==1 235 a=1. 236 b=0. 237 c=-x2 238 239 # Distance formula 240 inv_denom = 1./(a**2 + b**2)**0.5 241 distp = abs(p.x*a + p.y*b + c)*inv_denom 242 243 near_points = (distp<tol).nonzero()[0] 244 245 # Now find a 'local' coordinate for the point, projected onto the line 246 # g1 = unit vector parallel to the line 247 # g2 = vector joining (x1,y1) and (p.x,p.y) 248 g1x = x2-x1 249 g1y = y2-y1 250 g1_norm = (g1x**2 + g1y**2)**0.5 251 g1x=g1x/g1_norm 252 g1y=g1x/g1_norm 253 254 g2x = p.x[near_points] - x1 255 g2y = p.y[near_points] - y1 256 257 # Dot product = projected distance == a local coordinate 258 local_coord = g1x*g2x + g1y*g2y 259 260 return near_points, local_coord
Note: See TracChangeset
for help on using the changeset viewer.