Ignore:
Timestamp:
Sep 6, 2004, 1:57:41 PM (20 years ago)
Author:
ole
Message:

Cleaned up distribute

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r273 r274  
    386386
    387387def distribute_to_vertices_and_edges(domain):
    388 
    389     protect_against_infintesimal_and_negative_heights(domain)   
    390     if domain.order == 1:
    391         extrapolate_first_order(domain)
    392     elif domain.order == 2:
    393         extrapolate_second_order(domain)
    394     else:
    395         raise 'Unknown order'
    396    
    397     #Compute edge values
     388    """Distribution from centroids to vertices specific to the
     389    shallow water wave
     390    equation.
     391
     392    It will ensure that h (w-z) is always non-negative even in the
     393    presence of steep bed-slopes by taking a weighted average between shallow
     394    and deep cases.
     395   
     396    In addition, all conserved quantities get distributed as per either a
     397    constant (order==1) or a piecewise linear function (order==2).
     398   
     399    FIXME: more explanation about removal of artificial variability etc
     400
     401    Precondition:
     402      All quantities defined at centroids and bed elevation defined at
     403      vertices.
     404
     405    Postcondition
     406      Conserved quantities defined at vertices
     407   
     408    """
     409
     410    #Remove very thin layers of water
     411    protect_against_infintesimal_and_negative_heights(domain)
     412
     413    #Extrapolate all conserved quantities
     414    for name in domain.conserved_quantities:
     415        Q = domain.quantities[name]
     416        if domain.order == 1:
     417            Q.extrapolate_first_order()
     418        elif domain.order == 2:
     419            Q.extrapolate_second_order()
     420            Q.limit()                               
     421        else:
     422            raise 'Unknown order'
     423
     424    #Take bed slevation into account when heights are small   
     425    balance_deep_and_shallow(domain)
     426   
     427    #Compute edge values by interpolation
    398428    for name in domain.conserved_quantities:
    399429        Q = domain.quantities[name]
    400430        Q.interpolate_from_vertices_to_edges()
    401431                   
    402     #domain.w.interpolate_from_vertices_to_edges()           
    403     #domain.uh.interpolate_from_vertices_to_edges()           
    404     #domain.vh.interpolate_from_vertices_to_edges()                   
    405432   
    406433
     
    443470    protect(domain.minimum_allowed_height, wc, zc, xmomc, ymomc)
    444471   
    445 
    446 
    447 def extrapolate_first_order(domain):
    448     """First order extrapolator function, specific
    449     to the shallow water wave equation.
    450    
    451     It will ensure that h (w-z) is always non-negative even in the
    452     presence of steep bed-slopes (see comment in code)
    453     In addition, momemtums get distributed as constant values.
    454 
    455     Precondition:
    456       All quantities defined at centroids and bed elevation defined at
    457       vertices.
    458 
    459     Postcondition
    460       Conserved quantities defined at vertices
    461     """
    462 
    463     #Shortcuts
    464     wc = domain.quantities['level'].centroid_values
    465     zc = domain.quantities['elevation'].centroid_values
    466     xmomc = domain.quantities['xmomentum'].centroid_values
    467     ymomc = domain.quantities['ymomentum'].centroid_values           
    468     hc = wc - zc   #Water depths at centroids
    469 
    470 
    471     #Update conserved quantities using straight first order
    472     for name in domain.conserved_quantities:
    473         Q = domain.quantities[name]
    474         Q.extrapolate_first_order()
    475 
    476 
    477 
    478 
    479     balance_deep_and_shallow(domain)
    480 
    481 
    482    
    483            
    484        
    485 def extrapolate_second_order(domain):
    486     """Second order limiter function, specific to the shallow water wave
    487     equation.
    488    
    489     It will ensure that h (w-z) is always non-negative even in the
    490     presence of steep bed-slopes (see comment in code)
    491 
    492     A weighted average between shallow
    493     and deep cases is as in the first order case.
    494    
    495     In addition, all conserved quantities get distributed as per a
    496     piecewise linear function.
    497     FIXME: more explanation about removal of artificial variability etc
    498 
    499     Precondition:
    500       All quantities defined at centroids and bed elevation defined at
    501       vertices.
    502 
    503     Postcondition
    504       Conserved quantities defined at vertices
    505    
    506     """
    507    
    508 
    509     #Update conserved quantities using straight second order with limiter
    510     for name in domain.conserved_quantities:
    511         Q = domain.quantities[name]
    512         Q.extrapolate_second_order()
    513         Q.limit()       
    514 
    515     balance_deep_and_shallow(domain)
    516 
    517472
    518473def balance_deep_and_shallow(domain):
Note: See TracChangeset for help on using the changeset viewer.