Ignore:
Timestamp:
Aug 24, 2004, 6:11:26 PM (21 years ago)
Author:
ole
Message:

More testing of gravity, forcing terms, distributors

File:
1 edited

Legend:

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

    r212 r215  
    586586    for k in range(domain.number_of_elements):   
    587587        avg_h = sum( h[k,:] )/3
    588 
     588       
    589589        #Compute bed slope
    590590        x0, y0, x1, y1, x2, y2 = V[k,:]   
    591591        z0, z1, z2 = Elevation.vertex_values[k,:]
     592
    592593        zx, zy = gradient(x0, y0, x1, y1, x2, y2, z0, z1, z2)
    593594
     
    595596        Xmom.explicit_update[k] += -g*zx*avg_h
    596597        Ymom.explicit_update[k] += -g*zy*avg_h       
    597    
     598
    598599
    599600def manning_friction(domain):
     
    627628
    628629###########################
     630###########################
     631#Geometries
     632
     633
     634#FIXME: Rethink this way of creating values.
     635
     636
     637class Weir:
     638    """Set a bathymetry for weir with a hole and a downstream gutter
     639    x,y are assumed to be in the unit square
     640    """
     641   
     642    def __init__(self, stage):
     643        self.inflow_stage = stage
     644
     645    def __call__(self, x, y):   
     646        from Numeric import zeros, Float
     647        from math import sqrt
     648   
     649        N = len(x)
     650        assert N == len(y)   
     651
     652        z = zeros(N, Float)
     653        for i in range(N):
     654            z[i] = -x[i]/2  #General slope
     655
     656            #Flattish bit to the left
     657            if x[i] < 0.3:
     658                z[i] = -x[i]/10
     659           
     660            #Weir
     661            if x[i] >= 0.3 and x[i] < 0.4:
     662                z[i] = -x[i]+0.9
     663
     664            #Dip
     665            x0 = 0.6
     666            #depth = -1.3
     667            depth = -1.0
     668            #plateaux = -0.9
     669            plateaux = -0.6           
     670            if y[i] < 0.7:
     671                if x[i] > x0 and x[i] < 0.9:
     672                    z[i] = depth
     673
     674                #RHS plateaux
     675                if x[i] >= 0.9:
     676                    z[i] = plateaux
     677                   
     678                   
     679            elif y[i] >= 0.7 and y[i] < 1.5:
     680                #Restrict and deepen
     681                if x[i] >= x0 and x[i] < 0.8:
     682                    z[i] = depth-(y[i]/3-0.3)
     683                    #z[i] = depth-y[i]/5
     684                    #z[i] = depth
     685                elif x[i] >= 0.8:   
     686                    #RHS plateaux
     687                    z[i] = plateaux
     688                   
     689            elif y[i] >= 1.5:
     690                if x[i] >= x0 and x[i] < 0.8 + (y[i]-1.5)/1.2:
     691                    #Widen up and stay at constant depth
     692                    z[i] = depth-1.5/5
     693                elif x[i] >= 0.8 + (y[i]-1.5)/1.2:                       
     694                    #RHS plateaux
     695                    z[i] = plateaux                                   
     696                   
     697
     698            #Hole in weir (slightly higher than inflow condition)
     699            if x[i] >= 0.3 and x[i] < 0.4 and y[i] > 0.2 and y[i] < 0.4:
     700                z[i] = -x[i]+self.inflow_stage + 0.02
     701
     702            #Channel behind weir
     703            x0 = 0.5
     704            if x[i] >= 0.4 and x[i] < x0 and y[i] > 0.2 and y[i] < 0.4:
     705                z[i] = -x[i]+self.inflow_stage + 0.02
     706               
     707            if x[i] >= x0 and x[i] < 0.6 and y[i] > 0.2 and y[i] < 0.4:
     708                #Flatten it out towards the end
     709                z[i] = -x0+self.inflow_stage + 0.02 + (x0-x[i])/5
     710
     711            #Hole to the east
     712            x0 = 1.1; y0 = 0.35
     713            #if x[i] < -0.2 and y < 0.5:
     714            if sqrt((2*(x[i]-x0))**2 + (2*(y[i]-y0))**2) < 0.2:
     715                z[i] = sqrt(((x[i]-x0))**2 + ((y[i]-y0))**2)-1.0
     716
     717            #Tiny channel draining hole
     718            if x[i] >= 1.14 and x[i] < 1.2 and y[i] >= 0.4 and y[i] < 0.6:
     719                z[i] = -0.9 #North south
     720               
     721            if x[i] >= 0.9 and x[i] < 1.18 and y[i] >= 0.58 and y[i] < 0.65:
     722                z[i] = -1.0 + (x[i]-0.9)/3 #East west
     723           
     724           
     725
     726            #Stuff not in use
     727           
     728            #Upward slope at inlet to the north west
     729            #if x[i] < 0.0: # and y[i] > 0.5:
     730            #    #z[i] = -y[i]+0.5  #-x[i]/2
     731            #    z[i] = x[i]/4 - y[i]**2 + 0.5
     732
     733            #Hole to the west
     734            #x0 = -0.4; y0 = 0.35 # center
     735            #if sqrt((2*(x[i]-x0))**2 + (2*(y[i]-y0))**2) < 0.2:
     736            #    z[i] = sqrt(((x[i]-x0))**2 + ((y[i]-y0))**2)-0.2
     737
     738
     739
     740
     741
     742        return z/2
     743
     744class Weir_simple:
     745    """Set a bathymetry for weir with a hole and a downstream gutter
     746    x,y are assumed to be in the unit square
     747    """
     748   
     749    def __init__(self, stage):
     750        self.inflow_stage = stage
     751
     752    def __call__(self, x, y):   
     753        from Numeric import zeros, Float
     754   
     755        N = len(x)
     756        assert N == len(y)   
     757
     758        z = zeros(N, Float)
     759        for i in range(N):
     760            z[i] = -x[i]  #General slope
     761
     762            #Flat bit to the left
     763            if x[i] < 0.3:
     764                z[i] = -x[i]/10  #General slope
     765           
     766            #Weir
     767            if x[i] > 0.3 and x[i] < 0.4:
     768                z[i] = -x[i]+0.9
     769
     770            #Dip
     771            if x[i] > 0.6 and x[i] < 0.9:
     772                z[i] = -x[i]-0.5  #-y[i]/5
     773
     774            #Hole in weir (slightly higher than inflow condition)
     775            if x[i] > 0.3 and x[i] < 0.4 and y[i] > 0.2 and y[i] < 0.4:
     776                z[i] = -x[i]+self.inflow_stage + 0.05       
     777           
     778
     779        return z/2
     780       
     781
     782           
    629783class Constant_height:
    630784    """Set an initial condition with constant water height, e.g
    631785    stage s = z+h
    632786    """
    633 
    634     #FIXME: Rethink this way of creating values.
    635 
    636787    def __init__(self, W, h):
    637788        self.W = W
Note: See TracChangeset for help on using the changeset viewer.