Changeset 244


Ignore:
Timestamp:
Aug 30, 2004, 5:38:16 PM (20 years ago)
Author:
ole
Message:
 
Location:
inundation/ga/storm_surge/pyvolution
Files:
2 edited

Legend:

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

    r239 r244  
    3131#domain.visualise = True
    3232domain.newstyle = False  #For comparison
     33
    3334
    3435print 'Field values'
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r243 r244  
    410410    if not domain.newstyle:
    411411        #Protect against infinitesimal heights and high speeds at_centroid
    412         #FIXME: Try without when using the second balance function
     412        #FIXME: To be phased out
    413413       
    414414        for k in range(domain.number_of_elements):
     
    468468        Q.limit()       
    469469
    470 
    471470    balance_deep_and_shallow(domain)
    472471
    473472
    474473def balance_deep_and_shallow(domain):
    475     #FIXME: Grap math comments from old_first_order_balance....(below)
     474    """Compute linear combination between stage as computed by gradient-limiters and
     475    stage computed as constant height above bed.
     476    The former takes precedence when heights are large compared to the bed slope while the latter
     477    takes precedence when heights are relatively small.
     478    Anything in between is computed as a balanced linear combination in order to avoid numerical
     479    disturbances which would otherwise appear as a result of hard switching between modes.
     480    """
    476481   
    477482    #Shortcuts
     
    484489    hv = wv-zv
    485490
     491
    486492    #Computed linear combination between constant levels and and
    487493    #levels parallel to the bed elevation.     
    488     for k in range(domain.number_of_elements):               
    489                
     494    for k in range(domain.number_of_elements):
    490495        #Compute maximal variation in bed elevation
    491496        #  This quantitiy is
     
    494499        #  In the 1d case zc = (z0+z1)/2
    495500        #  In the 2d case zc = (z0+z1+z2)/3
    496         # 
    497        
    498         z_range = max(abs(zv[k,0]-zc[k]),
    499                       abs(zv[k,1]-zc[k]),
    500                       abs(zv[k,2]-zc[k]))
    501 
    502 
    503         hmin = min( hv[k, :] )
     501
     502        dz = max(abs(zv[k,0]-zc[k]),
     503                 abs(zv[k,1]-zc[k]),
     504                 abs(zv[k,2]-zc[k]))
     505
     506       
     507        hmin = min( hv[k,:] )
    504508
    505509        #Create alpha in [0,1], where alpha==0 means using shallow
    506         #first order scheme and alpha==1 means using the limited
    507         #second order scheme for the stage w
    508         #If hmin < 0 then alpha=0 reverting to first order.
     510        #first order scheme and alpha==1 means using the stage w as
     511        #computed by the gradient limiter (1st or 2nd order)
     512        #
     513        #If hmin > dz/2 then alpha = 1 and the bed will have no effect
     514        #If hmin < 0 then alpha = 0 reverting to constant height above bed.
    509515     
    510         if z_range > 0.0:
    511             alpha = max( min( 2*hmin/z_range, 1.0), 0.0)
    512         else:
     516        if dz > 0.0:
     517            alpha = max( min( 2*hmin/dz, 1.0), 0.0 )
     518        else:
     519            #Flat bed
    513520            alpha = 1.0
    514    
    515         #Update water levels
    516         #  (1-alpha)*(zvi+hc) + alpha*(zvi+hvi) =
    517         #   zvi + hc + alpha*(hvi - hc)
     521
     522
     523        #Weighted balance between stage parallel to bed elevation
     524        #(wvi = zvi + hc) and stage as computed by 1st or 2nd order gradient limiter
     525        #(wvi = zvi + hvi) where i=0,1,2 denotes the vertex ids
     526        #
     527        #It follows that the updated wvi is
     528        #  wvi := (1-alpha)*(zvi+hc) + alpha*(zvi+hvi) =
     529        #  zvi + hc + alpha*(hvi - hc)
     530        #
     531        #Note that hvi = zc+hc-zvi in the first order case (constant).
     532
    518533        if alpha < 1:         
    519534            for i in range(3):
Note: See TracChangeset for help on using the changeset viewer.