Changeset 9035


Ignore:
Timestamp:
Dec 4, 2013, 8:56:48 AM (11 years ago)
Author:
davies
Message:

Adding swDE1_domain_ext.c

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/utilities/plot_utils.py

    r9019 r9035  
    8888                p1.time = numpy.append(p1.time, p_tmp.time)
    8989                p1.stage = numpy.append(p1.stage, p_tmp.stage, axis=0)
     90                p1.height = numpy.append(p1.height, p_tmp.height, axis=0)
    9091                p1.xmom = numpy.append(p1.xmom, p_tmp.xmom, axis=0)
    9192                p1.ymom = numpy.append(p1.ymom, p_tmp.ymom, axis=0)
     
    138139    def __init__(self, filename, minimum_allowed_height=1.0e-03):
    139140        self.x, self.y, self.time, self.vols, self.stage, \
    140                 self.elev, self.xmom, self.ymom, \
     141                self.height, self.elev, self.xmom, self.ymom, \
    141142                self.xvel, self.yvel, self.vel, self.minimum_allowed_height = \
    142143                read_output(filename, minimum_allowed_height)
     144        self.filename=filename
    143145
    144146
     
    150152    #          we can then manipulate (e.g. plot, interrogate)
    151153    #
    152     # Output: x, y, time, stage, elev, xmom, ymom, xvel, yvel, vel
     154    # Output: x, y, time, stage, height, elev, xmom, ymom, xvel, yvel, vel
     155    #         x,y are only stored at one time
     156    #         elevation may be stored at one or multiple times
     157    #         everything else is stored every time step for vertices
    153158
    154159    # Import modules
     
    170175
    171176    elev=fid.variables['elevation'][:]
    172     #elev=elev.getValue()
     177
     178    if(fid.variables.has_key('height')):
     179        height=fid.variables['height'][:]
     180    else:
     181        # Back calculate height if it is not stored
     182        height=fid.variables['stage'][:]
     183        if(len(stage.shape)==len(elev.shape)):
     184            for i in range(stage.shape[0]):
     185                height[i,:]=stage[i,:]-elev[i,:]
     186        else:
     187            for i in range(stage.shape[0]):
     188                height[i,:]=stage[i,:]-elev
     189
    173190
    174191    xmom=fid.variables['xmomentum'][:]
     
    190207
    191208    for i in range(xmom.shape[0]):
    192         xvel[i,:]=xmom[i,:]/(stage[i,:]-elev+1.0e-06)*(stage[i,:]> elev+minimum_allowed_height)
    193         yvel[i,:]=ymom[i,:]/(stage[i,:]-elev+1.0e-06)*(stage[i,:]> elev+minimum_allowed_height)
     209        xvel[i,:]=xmom[i,:]/(height[i,:]+1.0e-06)*(height[i,:]>minimum_allowed_height)
     210        yvel[i,:]=ymom[i,:]/(height[i,:]+1.0e-06)*(height[i,:]>minimum_allowed_height)
    194211
    195212    vel = (xvel**2+yvel**2)**0.5
    196213
    197     return x, y, time, vols, stage, elev, xmom, ymom, xvel, yvel, vel, minimum_allowed_height
     214    return x, y, time, vols, stage, height, elev, xmom, ymom, xvel, yvel, vel, minimum_allowed_height
    198215
    199216##############
     
    207224        p = util.get_output('my_sww.sww', minimum_allowed_height=0.01) # vertex values
    208225        pc=util.get_centroids(p, velocity_extrapolation=True) # centroid values
     226
     227    NOTE: elevation is only stored once in the output, even if it was stored every timestep
     228         This is done because presently centroid elevations do not change over time.
    209229    """
    210230    def __init__(self,p, velocity_extrapolation=False):
    211231       
    212232        self.time, self.x, self.y, self.stage, self.xmom,\
    213              self.ymom, self.elev, self.xvel, \
     233             self.ymom, self.height, self.elev, self.xvel, \
    214234             self.yvel, self.vel= \
    215235             get_centroid_values(p, velocity_extrapolation)
     
    246266    x_cent=(p.x[vols0]+p.x[vols1]+p.x[vols2])/3.0
    247267    y_cent=(p.y[vols0]+p.y[vols1]+p.y[vols2])/3.0
    248 
    249     stage_cent=(p.stage[:,vols0]+p.stage[:,vols1]+p.stage[:,vols2])/3.0
    250     elev_cent=(p.elev[vols0]+p.elev[vols1]+p.elev[vols2])/3.0
    251 
    252     # Here, we need to treat differently the case of momentum extrapolation or
    253     # velocity extrapolation
    254     if velocity_extrapolation:
    255         xvel_cent=(p.xvel[:,vols0]+p.xvel[:,vols1]+p.xvel[:,vols2])/3.0
    256         yvel_cent=(p.yvel[:,vols0]+p.yvel[:,vols1]+p.yvel[:,vols2])/3.0
    257268       
    258         # Now compute momenta
    259         xmom_cent=stage_cent*0.0
    260         ymom_cent=stage_cent*0.0
    261 
    262         t=len(p.time)
    263 
    264         for i in range(t):
    265             xmom_cent[i,:]=xvel_cent[i,:]*(stage_cent[i,:]-elev_cent+1.0e-06)*\
    266                                             (stage_cent[i,:]>elev_cent+p.minimum_allowed_height)
    267             ymom_cent[i,:]=yvel_cent[i,:]*(stage_cent[i,:]-elev_cent+1.0e-06)*\
    268                                             (stage_cent[i,:]>elev_cent+p.minimum_allowed_height)
    269 
     269    fid=NetCDFFile(p.filename)
     270    if(fid.variables.has_key('stage_c')==False):
     271
     272        stage_cent=(p.stage[:,vols0]+p.stage[:,vols1]+p.stage[:,vols2])/3.0
     273        height_cent=(p.height[:,vols0]+p.height[:,vols1]+p.height[:,vols2])/3.0
     274        #elev_cent=(p.elev[:,vols0]+p.elev[:,vols1]+p.elev[:,vols2])/3.0
     275        # Only store elevation centroid once (since it doesn't change)
     276        if(len(p.elev.shape)==2):
     277            elev_cent=(p.elev[0,vols0]+p.elev[0,vols1]+p.elev[0,vols2])/3.0
     278        else:
     279            elev_cent=(p.elev[vols0]+p.elev[vols1]+p.elev[vols2])/3.0
     280
     281        # Here, we need to treat differently the case of momentum extrapolation or
     282        # velocity extrapolation
     283        if velocity_extrapolation:
     284            xvel_cent=(p.xvel[:,vols0]+p.xvel[:,vols1]+p.xvel[:,vols2])/3.0
     285            yvel_cent=(p.yvel[:,vols0]+p.yvel[:,vols1]+p.yvel[:,vols2])/3.0
     286           
     287            # Now compute momenta
     288            xmom_cent=stage_cent*0.0
     289            ymom_cent=stage_cent*0.0
     290
     291            t=len(p.time)
     292
     293            for i in range(t):
     294                xmom_cent[i,:]=xvel_cent[i,:]*(height_cent[i,:]+1e-06)*\
     295                                                (height_cent[i,:]>p.minimum_allowed_height)
     296                ymom_cent[i,:]=yvel_cent[i,:]*(height_cent[i,:]+1e-06)*\
     297                                                (height_cent[i,:]>p.minimum_allowed_height)
     298        else:
     299            xmom_cent=(p.xmom[:,vols0]+p.xmom[:,vols1]+p.xmom[:,vols2])/3.0
     300            ymom_cent=(p.ymom[:,vols0]+p.ymom[:,vols1]+p.ymom[:,vols2])/3.0
     301
     302            # Now compute velocities
     303            xvel_cent=stage_cent*0.0
     304            yvel_cent=stage_cent*0.0
     305
     306            t=len(p.time)
     307
     308            for i in range(t):
     309                xvel_cent[i,:]=xmom_cent[i,:]/(height_cent[i,:]+1.0e-06)*(height_cent[i,:]>p.minimum_allowed_height)
     310                yvel_cent[i,:]=ymom_cent[i,:]/(height_cent[i,:]+1.0e-06)*(height_cent[i,:]>p.minimum_allowed_height)
     311   
    270312    else:
    271         xmom_cent=(p.xmom[:,vols0]+p.xmom[:,vols1]+p.xmom[:,vols2])/3.0
    272         ymom_cent=(p.ymom[:,vols0]+p.ymom[:,vols1]+p.ymom[:,vols2])/3.0
    273 
    274         # Now compute velocities
    275         xvel_cent=stage_cent*0.0
    276         yvel_cent=stage_cent*0.0
    277 
    278         t=len(p.time)
    279 
    280         for i in range(t):
    281             xvel_cent[i,:]=xmom_cent[i,:]/(stage_cent[i,:]-elev_cent+1.0e-06)*(stage_cent[i,:]>elev_cent+p.minimum_allowed_height)
    282             yvel_cent[i,:]=ymom_cent[i,:]/(stage_cent[i,:]-elev_cent+1.0e-06)*(stage_cent[i,:]>elev_cent+p.minimum_allowed_height)
    283 
    284 
    285 
     313        # Get centroid values from file
     314        print 'Reading centroids from file'
     315        stage_cent=fid.variables['stage_c'][:]
     316        height_cent=fid.variables['height_c'][:]
     317        elev_cent=fid.variables['elevation_c'][:]
     318        if(len(elev_cent.shape)==2):
     319            elev_cent=elev_cent[0,:] # Only store elevation centroid once -- since it is constant
     320        xmom_cent=fid.variables['xmomentum_c'][:]*(height_cent>p.minimum_allowed_height)
     321        ymom_cent=fid.variables['ymomentum_c'][:]*(height_cent>p.minimum_allowed_height)
     322        xvel_cent=xmom_cent/(height_cent+1.0e-06)
     323        yvel_cent=ymom_cent/(height_cent+1.0e-06)
     324       
     325   
    286326    # Compute velocity
    287327    vel_cent=(xvel_cent**2 + yvel_cent**2)**0.5
    288328
    289329    return p.time, x_cent, y_cent, stage_cent, xmom_cent,\
    290              ymom_cent, elev_cent, xvel_cent, yvel_cent, vel_cent
    291 
    292 # Make plot of stage over time.
    293 #pylab.close()
    294 #pylab.ion()
    295 #pylab.plot(time, stage[:,1])
    296 #for i in range(201):
    297 #    pylab.plot(time,stage[:,i])
    298 
    299 # Momentum should be 0.
    300 #print 'Momentum max/min is', xmom.max() , xmom.min()
    301 
    302 #pylab.gca().set_aspect('equal')
    303 #pylab.scatter(x,y,c=elev,edgecolors='none')
    304 #pylab.colorbar()
    305 #
    306 #n=xvel.shape[0]-1
    307 #pylab.quiver(x,y,xvel[n,:],yvel[n,:])
    308 #pylab.savefig('Plot1.png')
     330             ymom_cent, height_cent, elev_cent, xvel_cent, yvel_cent, vel_cent
     331
    309332
    310333def animate_1D(time, var, x, ylab=' '): #, x=range(var.shape[1]), vmin=var.min(), vmax=var.max()):
  • trunk/anuga_core/source/anuga_validation_tests/analytical_exact/deep_wave/run_wave.py

    r8776 r9035  
    9898    return [amplitude*sin((1./wave_length)*t*2*pi),0.0,0.0]
    9999
    100 Bw2 = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, waveform)
     100def waveform2(t):
     101    return amplitude*sin((1./wave_length)*t*2*pi)
     102
     103Bw2 = anuga.shallow_water.boundaries.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, waveform2)
    101104#Bw3 = swb2_boundary_conditions.Transmissive_momentum_nudge_stage_boundary(domain, waveform)
    102105Bw3 = anuga.Time_boundary(domain, waveform)
     
    109112
    110113# Associate boundary tags with boundary objects
    111 domain.set_boundary({'left': Bw3, 'right': Bt, 'top': Br, 'bottom': Br})
     114domain.set_boundary({'left': Bw2, 'right': Bt, 'top': Br, 'bottom': Br})
    112115
    113116
  • trunk/anuga_core/source/anuga_validation_tests/parameters.py

    r8933 r9035  
    77__date__ ="$20/08/2012 11:20:00 PM$"
    88
    9 alg = '1_5'
     9alg = 'DE1'
    1010cfl = 1.0
    1111
  • trunk/anuga_core/source/anuga_validation_tests/saved_parameters.tex

    r9001 r9035  
    11\newcommand{\cfl}{\UScore{1.0}}
    2 \newcommand{\alg}{\UScore{1_5}}
     2\newcommand{\alg}{\UScore{DE1}}
    33\newcommand{\majorR}{\UScore{1.3.0-beta}}
    4 \newcommand{\minorR}{\UScore{8993}}
    5 \newcommand{\timeR}{{Sat Sep 28 19:39:45 2013}}
     4\newcommand{\minorR}{\UScore{9003}}
     5\newcommand{\timeR}{{Tue Dec  3 17:21:18 2013}}
  • trunk/anuga_work/development/gareth/experimental/bal_and/plot_utils.py

    r9022 r9035  
    7979                p1.time = numpy.append(p1.time, p_tmp.time)
    8080                p1.stage = numpy.append(p1.stage, p_tmp.stage, axis=0)
    81                 p1.height = numpy.append(p1.stage, p_tmp.stage, axis=0)
     81                p1.height = numpy.append(p1.height, p_tmp.height, axis=0)
    8282                p1.xmom = numpy.append(p1.xmom, p_tmp.xmom, axis=0)
    8383                p1.ymom = numpy.append(p1.ymom, p_tmp.ymom, axis=0)
     
    143143    #          we can then manipulate (e.g. plot, interrogate)
    144144    #
    145     # Output: x, y, time, stage, elev, xmom, ymom, xvel, yvel, vel
     145    # Output: x, y, time, stage, height, elev, xmom, ymom, xvel, yvel, vel
     146    #         x,y are only stored at one time
     147    #         elevation may be stored at one or multiple times
     148    #         everything else is stored every time step for vertices
    146149
    147150    # Import modules
     
    157160
    158161    stage=fid.variables['stage'][:]
    159 
    160     height=fid.variables['height'][:]
    161 
     162   
    162163    elev=fid.variables['elevation'][:]
     164
     165    if(fid.variables.has_key('height')):
     166        height=fid.variables['height'][:]
     167    else:
     168        # Back calculate height if it is not stored
     169        height=fid.variables['stage'][:]
     170        if(len(stage.shape)==len(elev.shape)):
     171            for i in range(stage.shape[0]):
     172                height[i,:]=stage[i,:]-elev[i,:]
     173        else:
     174            for i in range(stage.shape[0]):
     175                height[i,:]=stage[i,:]-elev
     176
    163177
    164178    xmom=fid.variables['xmomentum'][:]
     
    192206        p = util.get_output('my_sww.sww', minimum_allowed_height=0.01) # vertex values
    193207        pc=util.get_centroids(p, velocity_extrapolation=True) # centroid values
     208
     209    NOTE: elevation is only stored once in the output, even if it was stored every timestep
     210         This is done because presently centroid elevations do not change over time.
    194211    """
    195212    def __init__(self,p, velocity_extrapolation=False):
     
    239256        #elev_cent=(p.elev[:,vols0]+p.elev[:,vols1]+p.elev[:,vols2])/3.0
    240257        # Only store elevation centroid once (since it doesn't change)
    241         elev_cent=(p.elev[0,vols0]+p.elev[0,vols1]+p.elev[0,vols2])/3.0
     258        if(len(p.elev.shape)==2):
     259            elev_cent=(p.elev[0,vols0]+p.elev[0,vols1]+p.elev[0,vols2])/3.0
     260        else:
     261            elev_cent=(p.elev[vols0]+p.elev[vols1]+p.elev[vols2])/3.0
    242262
    243263        # Here, we need to treat differently the case of momentum extrapolation or
     
    278298        height_cent=fid.variables['height_c'][:]
    279299        elev_cent=fid.variables['elevation_c'][:]
    280         elev_cent=elev_cent[0,:] # Only store elevation centroid once -- since it is constant
     300        if(len(elev_cent.shape)==2):
     301            elev_cent=elev_cent[0,:] # Only store elevation centroid once -- since it is constant
    281302        xmom_cent=fid.variables['xmomentum_c'][:]*(height_cent>p.minimum_allowed_height)
    282303        ymom_cent=fid.variables['ymomentum_c'][:]*(height_cent>p.minimum_allowed_height)
Note: See TracChangeset for help on using the changeset viewer.