Changeset 8196
- Timestamp:
- Aug 12, 2011, 1:30:07 PM (13 years ago)
- Location:
- trunk/anuga_work/development/2010-projects/anuga_1d/pipe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain.py
r8188 r8196 140 140 #Call correct module function 141 141 #(either from this module or C-extension) 142 distribute_to_vertices_and_edges_limit_a_d(self) 142 distribute_to_vertices_and_edges_limit_s_v_h(self) 143 #distribute_to_vertices_and_edges_limit_s_v(self) 143 144 144 145 … … 166 167 167 168 #----------------------------------------------------------------------- 168 # Distribute to verticies with stage reconstructed and then extrapolated 169 # Distribute to verticies with stage, velocity and pipe geometry 170 # reconstructed and then extrapolated. 169 171 #----------------------------------------------------------------------- 170 def distribute_to_vertices_and_edges_limit_a_d(domain): 171 172 #Remove very thin layers of water 173 #protect_against_infinitesimal_and_negative_heights(domain) 174 175 176 172 def distribute_to_vertices_and_edges_limit_s_v(domain): 177 173 import sys 178 174 from anuga_1d.config import epsilon, h0 179 175 180 181 176 N = domain.number_of_elements 182 177 … … 203 198 s_C = state.centroid_values 204 199 205 if domain.setstageflag: 206 a_C[:,] = (w_C-z_C)*b_C 207 domain.setstageflag = False 208 209 # Paul: Same for top? 210 if domain.discontinousb: 211 width.extrapolate_second_order() 212 213 214 h0 = 1.0e-12 215 216 # Paul: How does top (i.e. t_C) affect these? 217 h_C[:] = numpy.where( (a_C>h0) | (b_C>h0), a_C/(b_C+h0/b_C), 0.0 ) 218 u_C[:] = numpy.where( (a_C>h0) | (b_C>h0), d_C/(a_C+h0/a_C), 0.0 ) 219 220 a_C[:] = numpy.where( (a_C>h0) | (b_C>h0), a_C, 0.0 ) 221 b_C[:] = numpy.where( (a_C>h0) | (b_C>h0), b_C, 0.0 ) 222 t_C[:] = numpy.where( (a_C>h0) | (b_C>h0), t_C, 0.0 ) 223 d_C[:] = numpy.where( (a_C>h0) | (b_C>h0), d_C, 0.0 ) 224 225 w_C[:] = h_C + z_C 226 227 228 # Paul: same for top? 229 bed.extrapolate_second_order() 230 231 for name in ['velocity','stage']: 200 # Calculate height, velocity and stage. 201 # Here we assume the conserved quantities and the channel geometry 202 # (i.e. bed, top and width) have been accurately computed in the previous 203 # timestep. 204 h_C[:] = numpy.where(a_C > 0.0, a_C/(b_C + h0/b_C), 0.0) 205 u_C[:] = numpy.where(a_C > 0.0, d_C/(a_C + h0/a_C), 0.0) 206 207 w_C[:] = h_C + z_C 208 209 # Extrapolate velocity and stage as well as channel geometry. 210 for name in ['velocity', 'stage', 'elevation', 'width', 'top']: 232 211 Q = domain.quantities[name] 233 212 if domain.order == 1: … … 238 217 raise 'Unknown order' 239 218 240 241 a_V = area.vertex_values219 # Stage, bed, width, top and velocity have been extrapolated. 220 # We may need to ensure that top is never 0. 242 221 w_V = stage.vertex_values 222 u_V = velocity.vertex_values 243 223 z_V = bed.vertex_values 244 h_V = height.vertex_values245 u_V = velocity.vertex_values246 d_V = discharge.vertex_values247 224 b_V = width.vertex_values 248 225 t_V = top.vertex_values 226 227 # These quantites need to update vertex_values 228 a_V = area.vertex_values 229 h_V = height.vertex_values 230 d_V = discharge.vertex_values 231 232 # State is true of false so should not be extrapolated 249 233 s_V = state.vertex_values 250 234 251 235 252 h_V[:] = w_V-z_V 253 254 w_V[:] = numpy.where(h_V > h0, w_V, z_V) 255 h_V[:] = numpy.where(h_V > h0, h_V, 0.0) 236 # Calculate height and fix up negatives. The main idea here is 237 # fix up the wet/dry interface. 238 h_V[:,:] = w_V - z_V 239 240 h_0 = numpy.where(h_V[:,0] < 0.0, 0.0, h_V[:,0]) 241 h_1 = numpy.where(h_V[:,0] < 0.0, h_V[:,1]+h_V[:,0], h_V[:,1]) 242 243 h_V[:,0] = h_0 244 h_V[:,1] = h_1 245 246 247 h_0 = numpy.where(h_V[:,1] < 0.0, h_V[:,1]+h_V[:,0], h_V[:,0]) 248 h_1 = numpy.where(h_V[:,1] < 0.0, 0.0, h_V[:,1]) 249 250 h_V[:,0] = h_0 251 h_V[:,1] = h_1 252 253 254 # Protect against negative and small heights. If we set h to zero 255 # we better do the same with velocity (i.e. no water, no velocity). 256 h_V[:,:] = numpy.where (h_V <= h0, 0.0, h_V) 257 u_V[:,:] = numpy.where (h_V <= h0, 0.0, u_V) 258 259 260 # Clean up conserved quantities 261 w_V[:] = z_V + h_V 262 a_V[:] = b_V * h_V 263 d_V[:] = u_V * a_V 264 265 266 return 267 268 #----------------------------------------------------------------------- 269 # Distribute to verticies with stage, height and velocity reconstructed 270 # and then extrapolated. 271 # In this method, we extrapolate the stage and height out to the vertices. 272 # The bed, although given as initial data to the problem, is reconstructed 273 # from the stage and height. This ensures consistency of the reconstructed 274 # quantities (i.e. w = z + h) as well as protecting against negative 275 # heights. 276 #----------------------------------------------------------------------- 277 def distribute_to_vertices_and_edges_limit_s_v_h(domain): 278 import sys 279 from anuga_1d.config import epsilon, h0 280 281 N = domain.number_of_elements 282 283 #Shortcuts 284 area = domain.quantities['area'] 285 discharge = domain.quantities['discharge'] 286 bed = domain.quantities['elevation'] 287 height = domain.quantities['height'] 288 velocity = domain.quantities['velocity'] 289 width = domain.quantities['width'] 290 top = domain.quantities['top'] 291 stage = domain.quantities['stage'] 292 state = domain.quantities['state'] 293 294 #Arrays 295 a_C = area.centroid_values 296 d_C = discharge.centroid_values 297 z_C = bed.centroid_values 298 h_C = height.centroid_values 299 u_C = velocity.centroid_values 300 b_C = width.centroid_values 301 t_C = top.centroid_values 302 w_C = stage.centroid_values 303 s_C = state.centroid_values 304 305 # Construct h,u,w from the conserved quantities after protecting 306 # conserved quantities from becoming too small. 307 a_C[:] = numpy.where( (a_C>h0), a_C, 0.0 ) 308 d_C[:] = numpy.where( (a_C>h0), d_C, 0.0 ) 309 h_C[:] = numpy.where( (b_C>h0), a_C/(b_C + h0/b_C), 0.0 ) 310 u_C[:] = numpy.where( (a_C>h0), d_C/(a_C + h0/a_C), 0.0 ) 311 312 # Set the stage 313 w_C[:] = h_C + z_C 314 315 # Extrapolate "fundamental" quantities. 316 # All other quantities will be reconstructed from these. 317 for name in ['velocity', 'stage', 'height', 'width', 'top']: 318 Q = domain.quantities[name] 319 if domain.order == 1: 320 Q.extrapolate_first_order() 321 elif domain.order == 2: 322 Q.extrapolate_second_order() 323 else: 324 raise 'Unknown order' 325 326 # These quantities have been extrapolated. 327 # We may need to ensure top is never 0. 328 u_V = velocity.vertex_values 329 w_V = stage.vertex_values 330 h_V = height.vertex_values 331 b_V = width.vertex_values 332 t_V = top.vertex_values 333 334 # These need to be reconstructed 335 a_V = area.vertex_values 336 d_V = discharge.vertex_values 337 z_V = bed.vertex_values 338 339 # State is true or false so should never be extrapolated. 340 s_V = state.vertex_values 341 342 # Reconstruct bed from stage and height. 343 z_V[:] = w_V-h_V 344 345 # Now reconstruct our conserved quantities from the above 346 # reconstructed quantities. 256 347 a_V[:] = b_V*h_V 257 348 d_V[:] = u_V*a_V 258 349 259 260 350 return 261 351 -
trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain_ext.c
r8188 r8196 21 21 22 22 // Hard coded choices of computational methods 23 #define flux_formula0 flux_formula_press0 24 #define flux_formula1 flux_formula_press1 23 //#define flux_formula0 flux_formula_press0 24 //#define flux_formula1 flux_formula_press1 25 #define flux_formula0 flux_formula_fs0 26 #define flux_formula1 flux_formula_fs1 25 27 #define compute_flux compute_flux_godunov 26 28 #define forcingterm_formula_press forcingterm_formula_press_naive 27 29 #define forcingterm_formula_fs forcingterm_formula_fs_naive 28 #define compute_forcingterm compute_forcingterm_press 30 //#define compute_forcingterm compute_forcingterm_press 31 #define compute_forcingterm compute_forcingterm_fs 29 32 30 33 // Some formulae … … 91 94 92 95 edgeflux[1] = smax*flux_formula1(q_m, g) - smin*flux_formula1(q_p, g); 93 edgeflux[1] += smax*smin * (q_p[4]*a_p - q_m[4]*a_m); 96 //edgeflux[1] += smax*smin * (q_p[4]*a_p - q_m[4]*a_m); 97 edgeflux[1] += smax*smin * (q_p[1] - q_m[1]); 94 98 edgeflux[1] /= denom; 95 99 } -
trunk/anuga_work/development/2010-projects/anuga_1d/pipe/test_pipe.py
r8188 r8196 12 12 print "Pipe Variable Width Only Test" 13 13 14 z_infty = 10.0 ## max equilibrium water depth at lowest point. 15 L_x = 2500.0 ## width of channel 16 A0 = 0.5*L_x ## determines amplitudes of oscillations 17 omega = sqrt(2*g*z_infty)/L_x ## angular frequency of osccilation 18 14 19 # Define functions for initial quantities 15 20 def initial_stage(x): 16 z_infty = 10.0 ## max equilibrium water depth at lowest point.17 L_x = 2500.0 ## width of channel18 A0 = 0.5*L_x ## determines amplitudes of oscillations19 omega = sqrt(2*g*z_infty)/L_x ## angular frequency of osccilation20 21 t=0.0 21 22 y = numpy.zeros(len(x),numpy.float) 22 23 for i in range(len(x)): 23 #y[i] = z_infty+2*A0*z_infty/L_x*cos(omega*t)*(x[i]/L_x-0.5*A0/(L_x)*cos(omega*t))24 y[i] = 12.024 y[i] = z_infty+2*A0*z_infty/L_x*cos(omega*t)*(x[i]/L_x-0.5*A0/(L_x)*cos(omega*t)) 25 #y[i] = 12.0 25 26 return y 26 27 27 28 def bed(x): 28 N = len(x) 29 z_infty = 10.0 30 z = numpy.zeros(N,numpy.float) 31 L_x = 2500.0 32 A0 = 0.5*L_x 33 omega = sqrt(2*g*z_infty)/L_x 34 for i in range(N): 29 z = numpy.zeros(len(x),numpy.float) 30 for i in range(len(x)): 35 31 z[i] = z_infty*(x[i]**2/L_x**2) 36 32 return z 33 34 def width(x): 35 return 1.0 36 37 def top(x): 38 return 4.0 37 39 38 40 def initial_area(x): … … 40 42 for i in range(len(x)): 41 43 y[i]=initial_stage([x[i]])-bed([x[i]]) 42 43 44 return y 44 45 def width(x):46 return 147 48 def top(x):49 return 450 45 51 46 def initial_state(x): … … 57 52 58 53 # Set final time and yield time for simulation 59 finaltime = 10.060 yieldstep = 1 .054 finaltime = 500.0 55 yieldstep = 10.0 61 56 62 57 # Length of channel (m)
Note: See TracChangeset
for help on using the changeset viewer.