Changeset 1913


Ignore:
Timestamp:
Oct 14, 2005, 7:57:07 AM (19 years ago)
Author:
steve
Message:

Testing Oblique shocks in analytic solutions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/analytical solutions/Analytical solution_oblique_shock_01.py

    r1909 r1913  
    3131from shallow_water import Domain, Constant_height
    3232from shallow_water import Transmissive_boundary, Reflective_boundary,\
    33      Dirichlet_boundary
     33     Dirichlet_boundary , Transmissive_Momentum_Set_Stage_boundary
    3434
    3535from math import sqrt, cos, sin, pi
     
    4242leny = 30.
    4343lenx = 40.
    44 n = 50
    45 m = 60
    46 n=n*4
    47 m=m*4
     44f = 4
     45n = 60*f
     46m = 80*f
    4847
    4948points, elements, boundary = oblique_cross(m, n, lenx, leny)
     
    5251# Order of solver
    5352domain.default_order=2
     53domain.beta_w = 0.8
    5454
    5555# Store output
     
    6161
    6262# Provide file name for storing output
    63 domain.filename="oblique"
     63domain.filename="oblique_cross"
    6464
    6565# Visualization smoothing
    6666domain.smooth=True
    67 domain.visualise=True
     67#domain.visualise=True
    6868
    6969#######################
     
    7171def x_slope(x, y):
    7272    return 0*x
     73
     74def shock_hb(t):
     75    return 2.5
     76
     77def shock_hh(t):
     78    return 2.5
     79
     80def shock_pb(t):
     81    return 10
     82
     83def shock_pp(t):
     84    return 10
     85
     86
     87def shock_h(x,y):
     88    n = x.shape[0]
     89    w = 0*x
     90    for i in range(n):
     91        if x[i]<0:
     92            w[i] = shock_hh(0.0)
     93        else:
     94            w[i] = 1.0
     95    return w
     96
     97
     98def shock_p(x,y):
     99    n = x.shape[0]
     100    w = 0*x
     101    for i in range(n):
     102        if x[i]<0:
     103            w[i] = shock_pp(0.0)
     104        else:
     105            w[i] = 0.0
     106    return w
     107
    73108
    74109domain.set_quantity('elevation', x_slope)
     
    80115R = Reflective_boundary(domain)
    81116T = Transmissive_boundary(domain)
    82 D = Dirichlet_boundary([1.82, 8.49, 0.0])
    83 
     117D = Dirichlet_boundary([shock_hb(0.0) , shock_pb(0.0), 0.0])
     118Bts = Transmissive_Momentum_Set_Stage_boundary(domain, shock_hb)
    84119
    85120domain.set_boundary({'left': D, 'right': T, 'top': R, 'bottom': R})
     
    87122######################
    88123#Initial condition
    89 h = 0.5
    90 domain.set_quantity('stage', Constant_height(x_slope, h) )
     124
     125domain.set_quantity('stage', shock_h )
     126domain.set_quantity('xmomentum',shock_p )
    91127
    92128
     
    99135import time
    100136t0 = time.time()
    101 for t in domain.evolve(yieldstep = 0.1, finaltime = 5):
     137for t in domain.evolve(yieldstep = 0.5, finaltime = 5.0):
    102138    domain.write_time()
    103     print domain.quantities['stage'].get_values(location='centroids',indices=[3399])
    104     print domain.quantities['xmomentum'].get_values(location='centroids',indices=[3399])
    105     print domain.quantities['ymomentum'].get_values(location='centroids',indices=[3399])
     139    id = 3399
     140    print domain.quantities['stage'].get_values(location='centroids',indices=[id])
     141    print domain.quantities['xmomentum'].get_values(location='centroids',indices=[id])
     142    print domain.quantities['ymomentum'].get_values(location='centroids',indices=[id])
     143    id = 12719
     144    print domain.quantities['stage'].get_values(location='centroids',indices=[id])
     145    print domain.quantities['xmomentum'].get_values(location='centroids',indices=[id])
     146    print domain.quantities['ymomentum'].get_values(location='centroids',indices=[id])
    106147
    107148print 'That took %.2f seconds' %(time.time()-t0)
     
    114155#im = ImageGrab.grab()
    115156#im.save("ccube.eps")
    116 
Note: See TracChangeset for help on using the changeset viewer.