Changeset 8195
- Timestamp:
- Aug 10, 2011, 8:05:33 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/2010-projects/anuga_1d/channel/channel_domain.py
r8194 r8195 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 … … 164 165 165 166 #----------------------------------------------------------------------- 166 # Distribute to verticies with stage reconstructed and then extrapolated 167 # Distribute to verticies with stage, velocity and channel geometry 168 # reconstructed and then extrapolated. 167 169 #----------------------------------------------------------------------- 168 def distribute_to_vertices_and_edges_limit_a_d(domain): 169 170 #Remove very thin layers of water 171 #protect_against_infinitesimal_and_negative_heights(domain) 172 173 174 170 def distribute_to_vertices_and_edges_limit_s_v(domain): 175 171 import sys 176 172 from anuga_1d.config import epsilon, h0 177 173 178 179 174 N = domain.number_of_elements 180 175 … … 197 192 w_C = stage.centroid_values 198 193 199 #if domain.setstageflag: 200 # a_C[:,] = (w_C-z_C)*b_C 201 # domain.setstageflag = False 202 203 #if domain.discontinousb: 204 # width.extrapolate_second_order() 205 206 207 h0 = 1.0e-10 208 #Calculate height (and fix negatives)better be non-negative! 209 h_C[:] = numpy.where(a_C > 0.0, a_C/b_C, 0.0) 210 u_C[:] = numpy.where(a_C > 0.0, d_C/a_C, 0.0) 194 # Calculate height, velocity and stage. 195 # Here we assume the conserved quantities and the channel geometry 196 # (i.e. bed and width) have been accurately computed in the previous 197 # timestep. 198 h_C[:] = numpy.where(a_C > 0.0, a_C/(b_C + h0/b_C), 0.0) 199 u_C[:] = numpy.where(a_C > 0.0, d_C/(a_C + h0/a_C), 0.0) 211 200 212 201 w_C[:] = h_C + z_C 213 214 215 bed.extrapolate_second_order() 216 217 for name in ['velocity', 'stage', 'width']: 202 203 # Extrapolate velocity and stage as well as channel geometry. 204 for name in ['velocity', 'stage', 'elevation', 'width']: 218 205 Q = domain.quantities[name] 219 206 if domain.order == 1: … … 234 221 h_V = height.vertex_values 235 222 d_V = discharge.vertex_values 236 237 238 223 224 # Calculate height and fix up negatives. The main idea here is 225 # fix up the wet/dry interface. 239 226 h_V[:,:] = w_V - z_V 240 227 … … 253 240 254 241 242 # Protect against negative and small heights. If we set h to zero 243 # we better do the same with velocity (i.e. no water, no velocity). 255 244 h_V[:,:] = numpy.where (h_V <= h0, 0.0, h_V) 256 245 u_V[:,:] = numpy.where (h_V <= h0, 0.0, u_V) 257 246 258 247 259 # Clean up conserved quantities edge values 260 w_V[:] = z_V+h_V 248 # Clean up conserved quantities 249 w_V[:] = z_V + h_V 250 a_V[:] = b_V * h_V 251 d_V[:] = u_V * a_V 252 253 254 return 255 256 #----------------------------------------------------------------------- 257 # Distribute to verticies with stage, height and velocity reconstructed 258 # and then extrapolated. 259 # In this method, we extrapolate the stage and height out to the vertices. 260 # The bed, although given as initial data to the problem, is reconstructed 261 # from the stage and height. This ensures consistency of the reconstructed 262 # quantities (i.e. w = z + h) as well as protecting against negative 263 # heights. 264 #----------------------------------------------------------------------- 265 def distribute_to_vertices_and_edges_limit_s_v_h(domain): 266 import sys 267 from anuga_1d.config import epsilon, h0 268 269 N = domain.number_of_elements 270 271 #Shortcuts 272 area = domain.quantities['area'] 273 discharge = domain.quantities['discharge'] 274 bed = domain.quantities['elevation'] 275 height = domain.quantities['height'] 276 velocity = domain.quantities['velocity'] 277 width = domain.quantities['width'] 278 stage = domain.quantities['stage'] 279 280 #Arrays 281 a_C = area.centroid_values 282 d_C = discharge.centroid_values 283 z_C = bed.centroid_values 284 h_C = height.centroid_values 285 u_C = velocity.centroid_values 286 b_C = width.centroid_values 287 w_C = stage.centroid_values 288 289 # Construct h,u,w from the conserved quantities after protecting 290 # conserved quantities from becoming too small. 291 a_C[:] = numpy.where( (a_C>h0), a_C, 0.0 ) 292 d_C[:] = numpy.where( (a_C>h0), d_C, 0.0 ) 293 h_C[:] = numpy.where( (b_C>h0), a_C/(b_C + h0/b_C), 0.0 ) 294 u_C[:] = numpy.where( (a_C>h0), d_C/(a_C + h0/a_C), 0.0 ) 295 296 # Set the stage 297 w_C[:] = h_C + z_C 298 299 # Extrapolate "fundamental" quantities. 300 # All other quantities will be reconstructed from these. 301 for name in ['velocity', 'stage', 'height', 'width']: 302 Q = domain.quantities[name] 303 if domain.order == 1: 304 Q.extrapolate_first_order() 305 elif domain.order == 2: 306 Q.extrapolate_second_order() 307 else: 308 raise 'Unknown order' 309 310 # These quantities have been extrapolated. 311 u_V = velocity.vertex_values 312 w_V = stage.vertex_values 313 h_V = height.vertex_values 314 b_V = width.vertex_values 315 316 # These need to be reconstructed 317 a_V = area.vertex_values 318 d_V = discharge.vertex_values 319 z_V = bed.vertex_values 320 321 # Reconstruct bed from stage and height. 322 z_V[:] = w_V-h_V 323 324 # Now reconstruct our conserved quantities from the above 325 # reconstructed quantities. 261 326 a_V[:] = b_V*h_V 262 327 d_V[:] = u_V*a_V 263 328 264 265 print [ h_V, u_V ]266 329 return 267 330
Note: See TracChangeset
for help on using the changeset viewer.