Changeset 9224


Ignore:
Timestamp:
Jun 28, 2014, 11:49:17 PM (10 years ago)
Author:
steve
Message:

Adapting validation tests to rn in parallel

Location:
trunk/anuga_core/validation_tests
Files:
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/validation_tests/analytical_exact/transcritical_with_shock/numerical_transcritical.py

    r9155 r9224  
    1313from numpy import zeros, ones, float
    1414from time import localtime, strftime, gmtime
    15 #from balanced_dev import *
     15from anuga import myid, finalize, distribute
    1616
    1717
     
    2929#start_screen_catcher(output_dir+'_')
    3030
     31args = anuga.get_args()
     32alg = args.alg
     33verbose = args.verbose
    3134
    3235#------------------------------------------------------------------------------
     
    3841W = 3*dx
    3942
    40 # structured mesh
    41 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))
     43if myid == 0:
     44    # structured mesh
     45    points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))
     46   
     47    #domain = anuga.Domain(points, vertices, boundary)
     48    domain = Domain(points, vertices, boundary)
     49   
     50    domain.set_name(output_file)               
     51    domain.set_datadir(output_dir)
     52    domain.set_flow_algorithm(alg)
    4253
    43 #domain = anuga.Domain(points, vertices, boundary)
    44 domain = Domain(points, vertices, boundary)
     54    #------------------------------------------------------------------------------
     55    # Setup initial conditions
     56    #------------------------------------------------------------------------------
     57    def elevation(x,y):
     58        z_b = zeros(len(x))
     59        for i in range(len(x)):
     60            if (8.0 <= x[i] <= 12.0):
     61                z_b[i] = 0.2 - 0.05*(x[i]-10.0)**2.0
     62            else:
     63                z_b[i] = 0.0
     64        return z_b
     65    domain.set_quantity('elevation',elevation)
     66    domain.set_quantity('friction', 0.0)
     67   
     68   
     69    def stage(x,y):
     70        return 2.0*ones(len(x))
     71    domain.set_quantity('stage', stage)
     72else:
     73    domain = None
    4574
    46 domain.set_name(output_file)               
    47 domain.set_datadir(output_dir)
    48 
     75#-----------------------------------------------------------------------------
     76# Create Parallel Domain
    4977#------------------------------------------------------------------------------
    50 # Setup Algorithm, either using command line arguments
    51 # or override manually yourself
    52 #------------------------------------------------------------------------------
    53 from anuga.utilities.argparsing import parse_standard_args
    54 alg, cfl = parse_standard_args()
    55 domain.set_flow_algorithm(alg)
    56 #domain.set_CFL(cfl)
    57 
    58 #------------------------------------------------------------------------------
    59 # Setup initial conditions
    60 #------------------------------------------------------------------------------
    61 def elevation(x,y):
    62     z_b = zeros(len(x))
    63     for i in range(len(x)):
    64         if (8.0 <= x[i] <= 12.0):
    65             z_b[i] = 0.2 - 0.05*(x[i]-10.0)**2.0
    66         else:
    67             z_b[i] = 0.0
    68     return z_b
    69 domain.set_quantity('elevation',elevation)
    70 domain.set_quantity('friction', 0.0)
    71 
    72 
    73 def stage(x,y):
    74     return 2.0*ones(len(x))
    75 domain.set_quantity('stage', stage)
    76 
     78domain = distribute(domain)
     79 
    7780#-----------------------------------------------------------------------------
    7881# Setup boundary conditions
     
    8891
    8992
    90 #===============================================================================
    91 ##from anuga.visualiser import RealtimeVisualiser
    92 ##vis = RealtimeVisualiser(domain)
    93 ##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
    94 ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
    95 ##vis.start()
    96 #===============================================================================
    97 
    98 
    9993#------------------------------------------------------------------------------
    10094# Produce a documentation of parameters
    10195#------------------------------------------------------------------------------
    102 parameter_file=open('parameters.tex', 'w')
    103 parameter_file.write('\\begin{verbatim}\n')
    104 from pprint import pprint
    105 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    106 parameter_file.write('\\end{verbatim}\n')
    107 parameter_file.close()
     96if myid == 0:
     97    parameter_file=open('parameters.tex', 'w')
     98    parameter_file.write('\\begin{verbatim}\n')
     99    from pprint import pprint
     100    pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     101    parameter_file.write('\\end{verbatim}\n')
     102    parameter_file.close()
    108103
    109104#------------------------------------------------------------------------------
    110105# Evolve system through time
    111106#------------------------------------------------------------------------------
    112 for t in domain.evolve(yieldstep = 1.0, finaltime = 300.):
     107for t in domain.evolve(yieldstep = 1.0, finaltime = 100.):
    113108    #print domain.timestepping_statistics(track_speeds=True)
    114     print domain.timestepping_statistics()
     109    if myid == 0 and verbose: print domain.timestepping_statistics()
    115110    #vis.update()
    116111
     112domain.sww_merge(delete_old=True)
    117113
    118 #test against know data
    119    
    120 #vis.evolveFinished()
     114finalize()
    121115
  • trunk/anuga_core/validation_tests/analytical_exact/transcritical_with_shock/plot_results.py

    r8799 r9224  
    1414v2=(p2_st.y==v)
    1515
     16tid = -1
     17
    1618h,z = analytic_sol(p2_st.x[v2])
    1719
    1820#Plot the stages##############################################################
    1921pyplot.clf()
    20 pyplot.plot(p2_st.x[v2], p2_st.stage[300,v2], 'b.-', label='numerical stage') # 0*T/6
     22pyplot.plot(p2_st.x[v2], p2_st.stage[tid,v2], 'b.-', label='numerical stage') # 0*T/6
    2123pyplot.plot(p2_st.x[v2], h+z,'r-', label='analytical stage')
    2224pyplot.plot(p2_st.x[v2], z,'k-', label='bed elevation')
    23 pyplot.title('Stage at an instant in time')
     25pyplot.title('Stage at time %s secs'% p2_st.time[tid])
    2426##pyplot.ylim(-5.0,5.0)
    2527pyplot.legend(loc='best')
     
    3133#Plot the momentums##########################################################
    3234pyplot.clf()
    33 pyplot.plot(p2_st.x[v2], p2_st.xmom[300,v2], 'b.-', label='numerical') # 0*T/6
     35pyplot.plot(p2_st.x[v2], p2_st.xmom[tid,v2], 'b.-', label='numerical') # 0*T/6
    3436pyplot.plot(p2_st.x[v2], 0.18*ones(len(p2_st.x[v2])),'r-', label='analytical')
    35 pyplot.title('Xmomentum at an instant in time')
     37pyplot.title('Xmomentum at time %s secs'% p2_st.time[tid])
    3638pyplot.legend(loc='best')
    3739pyplot.xlabel('Xposition')
     
    4345#Plot the velocities#########################################################
    4446pyplot.clf()
    45 pyplot.plot(p2_st.x[v2], p2_st.xvel[300,v2], 'b.-', label='numerical') # 0*T/6
     47pyplot.plot(p2_st.x[v2], p2_st.xvel[tid,v2], 'b.-', label='numerical') # 0*T/6
    4648pyplot.plot(p2_st.x[v2], 0.18/h,'r-', label='analytical')
    47 pyplot.title('Xvelocity at an instant in time')
     49pyplot.title('Xvelocity at time %s secs'% p2_st.time[tid])
    4850pyplot.legend(loc='best')
    4951pyplot.xlabel('Xposition')
  • trunk/anuga_core/validation_tests/analytical_exact/transcritical_with_shock/produce_results.py

    r9117 r9224  
    1 #--------------------------------
    2 # import modules
    3 #--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     1import anuga
     2from anuga.validation_utilities import produce_report
     3
     4args = anuga.get_args()
     5
     6produce_report('numerical_transcritical.py', args=args)
    77
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('numerical_transcritical.py')
    13     run_validation_script('plot_results.py')
    14     typeset_report()
    15    
    16 def clean():
    17     autoclean()
    189
    19 main()
    2010
  • trunk/anuga_core/validation_tests/analytical_exact/transcritical_without_shock/numerical_transcritical.py

    r9155 r9224  
    1414from time import localtime, strftime, gmtime
    1515from anuga.operators.set_w_uh_vh_operators import Polygonal_set_w_uh_vh_operator
    16 
     16from anuga import myid, finalize, distribute
    1717
    1818#-------------------------------------------------------------------------------
     
    2929#start_screen_catcher(output_dir+'_')
    3030
     31args = anuga.get_args()
     32alg = args.alg
     33verbose = args.verbose
    3134
    3235#------------------------------------------------------------------------------
     
    4144BC_polygonR = [[L,0.],[L,W], [L-dx,W], [L-dx,0.]]
    4245
    43 # structured mesh
    44 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))
     46if myid == 0:
     47    # structured mesh
     48    points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))
     49   
     50    #domain = anuga.Domain(points, vertices, boundary)
     51    domain = Domain(points, vertices, boundary)
     52   
     53    domain.set_name(output_file)               
     54    domain.set_datadir(output_dir)
     55    domain.set_flow_algorithm(alg)
    4556
    46 #domain = anuga.Domain(points, vertices, boundary)
    47 domain = Domain(points, vertices, boundary)
    48 
    49 domain.set_name(output_file)               
    50 domain.set_datadir(output_dir)
    51 
     57   
     58    #------------------------------------------------------------------------------
     59    # Setup initial conditions
     60    #------------------------------------------------------------------------------
     61    def elevation(x,y):
     62        z_b = zeros(len(x))
     63        for i in range(len(x)):
     64            if (8.0 <= x[i] <= 12.0):
     65                z_b[i] = 0.2 - 0.05*(x[i]-10.0)**2
     66            else:
     67                z_b[i] = 0.0
     68        return z_b
     69    domain.set_quantity('elevation',elevation)
     70    domain.set_quantity('friction', 0.0)
     71    domain.set_quantity('xmomentum', 0.0)
     72   
     73   
     74    def stage(x,y):
     75        return 0.66*ones(len(x))
     76    domain.set_quantity('stage', stage)
     77else:
     78    domain = None
     79   
     80#-----------------------------------------------------------------------------
     81# create Parallel Domain
    5282#------------------------------------------------------------------------------
    53 # Setup Algorithm, either using command line arguments
    54 # or override manually yourself
    55 #------------------------------------------------------------------------------
    56 from anuga.utilities.argparsing import parse_standard_args
    57 alg, cfl = parse_standard_args()
    58 domain.set_flow_algorithm(alg)
    59 #domain.set_CFL(cfl)
    60 
    61 #------------------------------------------------------------------------------
    62 # Setup initial conditions
    63 #------------------------------------------------------------------------------
    64 def elevation(x,y):
    65     z_b = zeros(len(x))
    66     for i in range(len(x)):
    67         if (8.0 <= x[i] <= 12.0):
    68             z_b[i] = 0.2 - 0.05*(x[i]-10.0)**2
    69         else:
    70             z_b[i] = 0.0
    71     return z_b
    72 domain.set_quantity('elevation',elevation)
    73 domain.set_quantity('friction', 0.0)
    74 domain.set_quantity('xmomentum', 0.0)
    75 
    76 
    77 def stage(x,y):
    78     return 0.66*ones(len(x))
    79 domain.set_quantity('stage', stage)
     83domain = distribute(domain)
    8084
    8185#-----------------------------------------------------------------------------
     
    9296domain.set_boundary({'left': BdL, 'right': BdR, 'top': Br, 'bottom': Br})
    9397
    94 w_uh_vhL= [1.0144468506259066, 1.53, 0.]
    95 w_uh_vhR= [0.4057809296474606, 1.53, 0.]
    96 Polygonal_set_w_uh_vh_operator(domain,w_uh_vhL,BC_polygonL)
    97 Polygonal_set_w_uh_vh_operator(domain,w_uh_vhR,BC_polygonR)
    98 
    99 #===============================================================================
    100 ##from anuga.visualiser import RealtimeVisualiser
    101 ##vis = RealtimeVisualiser(domain)
    102 ##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
    103 ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
    104 ##vis.start()
    105 #===============================================================================
     98# w_uh_vhL= [1.0144468506259066, 1.53, 0.]
     99# w_uh_vhR= [0.4057809296474606, 1.53, 0.]
     100# Polygonal_set_w_uh_vh_operator(domain,w_uh_vhL,BC_polygonL)
     101# Polygonal_set_w_uh_vh_operator(domain,w_uh_vhR,BC_polygonR)
    106102
    107103
     
    109105# Produce a documentation of parameters
    110106#------------------------------------------------------------------------------
    111 parameter_file=open('parameters.tex', 'w')
    112 parameter_file.write('\\begin{verbatim}\n')
    113 from pprint import pprint
    114 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    115 parameter_file.write('\\end{verbatim}\n')
    116 parameter_file.close()
     107if myid == 0:
     108    parameter_file=open('parameters.tex', 'w')
     109    parameter_file.write('\\begin{verbatim}\n')
     110    from pprint import pprint
     111    pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     112    parameter_file.write('\\end{verbatim}\n')
     113    parameter_file.close()
    117114
    118115#------------------------------------------------------------------------------
    119116# Evolve system through time
    120117#------------------------------------------------------------------------------
    121 for t in domain.evolve(yieldstep = 1.0, finaltime = 300.):
     118for t in domain.evolve(yieldstep = 1.0, finaltime = 100.):
    122119    #print domain.timestepping_statistics(track_speeds=True)
    123     print domain.timestepping_statistics()
    124     #vis.update()
     120    if myid == 0 and verbose: print domain.timestepping_statistics()
    125121
    126122
    127 #test against know data   
    128 #vis.evolveFinished()
     123domain.sww_merge(delete_old=True)
    129124
     125finalize()
  • trunk/anuga_core/validation_tests/analytical_exact/transcritical_without_shock/plot_results.py

    r8800 r9224  
    1616h,z = analytic_sol(p2_st.x[v2])
    1717
     18tid = 100
     19
    1820#Plot the stages##############################################################
    1921pyplot.clf()
    20 pyplot.plot(p2_st.x[v2], p2_st.stage[300,v2], 'b.-', label='numerical stage') # 0*T/6
     22pyplot.plot(p2_st.x[v2], p2_st.stage[tid,v2], 'b.-', label='numerical stage') # 0*T/6
    2123pyplot.plot(p2_st.x[v2], h+z,'r-', label='analytical stage')
    2224pyplot.plot(p2_st.x[v2], z,'k-', label='bed elevation')
    23 pyplot.title('Stage at an instant in time')
     25pyplot.title('Stage at time %s secs'% p2_st.time[tid])
    2426##pyplot.ylim(-5.0,5.0)
    2527pyplot.legend(loc='best')
     
    3133#Plot the momentums##########################################################
    3234pyplot.clf()
    33 pyplot.plot(p2_st.x[v2], p2_st.xmom[300,v2], 'b.-', label='numerical') # 0*T/6
     35pyplot.plot(p2_st.x[v2], p2_st.xmom[tid,v2], 'b.-', label='numerical') # 0*T/6
    3436pyplot.plot(p2_st.x[v2], 1.53*ones(len(p2_st.x[v2])),'r-', label='analytical')
    35 pyplot.title('Xmomentum at an instant in time')
     37pyplot.title('Xmomentum at time %s secs'% p2_st.time[tid])
    3638pyplot.legend(loc='best')
    3739pyplot.ylim([1.52,1.54])
     
    4446#Plot the velocities#########################################################
    4547pyplot.clf()
    46 pyplot.plot(p2_st.x[v2], p2_st.xvel[300,v2], 'b.-', label='numerical') # 0*T/6
     48pyplot.plot(p2_st.x[v2], p2_st.xvel[tid,v2], 'b.-', label='numerical') # 0*T/6
    4749pyplot.plot(p2_st.x[v2], 1.53/h,'r-', label='analytical')
    48 pyplot.title('Xvelocity at an instant in time')
     50pyplot.title('Xvelocity at time %s secs'% p2_st.time[tid])
    4951pyplot.legend(loc='best')
    5052pyplot.xlabel('Xposition')
  • trunk/anuga_core/validation_tests/analytical_exact/transcritical_without_shock/produce_results.py

    r9117 r9224  
    1 #--------------------------------
    2 # import modules
    3 #--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     1import anuga
     2from anuga.validation_utilities import produce_report
     3
     4args = anuga.get_args()
     5
     6produce_report('numerical_transcritical.py', args=args)
    77
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('numerical_transcritical.py')
    13     run_validation_script('plot_results.py')
    14     typeset_report()
    159
    16 def clean():
    17     autoclean()
    18 
    19 main()
    20 
  • trunk/anuga_core/validation_tests/behaviour_only/lid_driven_cavity/numerical_lid_driven_cavity.py

    r9174 r9224  
    99from math import sin, pi, exp, sqrt
    1010from anuga import Domain
     11from anuga import myid, finalize, distribute
    1112
    12 #---------
    13 #Setup computational domain
    14 #---------
    15 domain = anuga.rectangular_cross_domain(15,15, len1=1., len2=1.)
     13args = anuga.get_args()
     14alg = args.alg
     15verbose = args.verbose
    1616
    17 
    18 #------------------------------------------------------------------------------
    19 # Setup Algorithm, either using command line arguments
    20 # or override manually yourself
    21 #------------------------------------------------------------------------------
    22 from anuga.utilities.argparsing import parse_standard_args
    23 alg, cfl = parse_standard_args()
    24 domain.set_flow_algorithm(alg)
    25 #domain.set_CFL(cfl)
    26 
    27 domain.set_name('dimensional_lid_driven')   # Output to file runup.sww
    28 domain.set_datadir('.')         # Use current folder
    29 #domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
    30 domain.set_minimum_allowed_height(0.01)
    31 
    32 
    33 #------------------
    34 # Define topography
    35 #------------------
    36 domain.set_quantity('elevation',0.0)      # Use function for elevation
    37 domain.set_quantity('friction',0.0)       # Constant friction
    38 domain.set_quantity('stage',1.)          # Constant negative initial stage
    39 
     17if myid == 0:
     18    #---------
     19    #Setup computational domain
     20    #---------
     21    domain = anuga.rectangular_cross_domain(15,15, len1=1., len2=1.)
     22    domain.set_flow_algorithm(alg)
     23 
     24    domain.set_name('dimensional_lid_driven')   # Output to file runup.sww
     25    domain.set_datadir('.')         # Use current folder
     26   
     27   
     28    #------------------
     29    # Define topography
     30    #------------------
     31    domain.set_quantity('elevation',0.0)      # Use function for elevation
     32    domain.set_quantity('friction',0.0)       # Constant friction
     33    domain.set_quantity('stage',1.)          # Constant negative initial stage
     34else:
     35    domain = None
     36   
     37#--------------------------
     38# Create Parallel Domain
     39#--------------------------
     40domain = distribute(domain)
    4041
    4142#--------------------------
     
    5455# Produce a documentation of parameters
    5556#------------------------------------------------------------------------------
    56 parameter_file=open('parameters.tex', 'w')
    57 parameter_file.write('\\begin{verbatim}\n')
    58 from pprint import pprint
    59 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    60 parameter_file.write('\\end{verbatim}\n')
    61 parameter_file.close()
     57if myid == 0:
     58    parameter_file=open('parameters.tex', 'w')
     59    parameter_file.write('\\begin{verbatim}\n')
     60    from pprint import pprint
     61    pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     62    parameter_file.write('\\end{verbatim}\n')
     63    parameter_file.close()
    6264
    6365#------------------------------
    6466#Evolve the system through time
    6567#------------------------------
    66 for t in domain.evolve(yieldstep=10.,finaltime=1000.0):
    67     print domain.timestepping_statistics()
    68 print 'Finished'
     68for t in domain.evolve(yieldstep=10.,finaltime=200.0):
     69    if myid == 0 and verbose: print domain.timestepping_statistics()
     70
     71domain.sww_merge(delete_old=True)
     72
     73finalize()
  • trunk/anuga_core/validation_tests/behaviour_only/lid_driven_cavity/plot_results.py

    r8825 r9224  
    2323#--------------------
    2424pyplot.close() #If the plot is open, there will be problems
    25 ##pyplot.ion()
    26 ##if True:
    27 ##    line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,(p2.xvel[:,v].min(),p2.xvel[:,v].max() ) )
    28 ##    for i in range(p2.xmom.shape[0]):
    29 ##        line.set_xdata(p2.x[v])
    30 ##        line.set_ydata(p2.xvel[i,v])
    31 ##        pyplot.draw()
    32 ##        pyplot.plot( (0,1),(0,0), 'r' )
    33 ##        pyplot.title(str(i)+'/40') # : velocity does not converge to zero' )
    34 ##        pyplot.xlabel('Xposition')
    35 ##        pyplot.ylabel('Xvelocity')
    36 ##    pyplot.savefig('runup_x_velocities.png')
    3725
    3826# Plot vertex values
    3927pyplot.clf()
    4028t1=int(len(p1.time)/2)
    41 t2=len(p1.time)-1
     29t2=-1
    4230#pyplot.scatter(p1.x,p1.y,c=p1.elev,edgecolors='none', s=25)
    4331#pyplot.colorbar()
  • trunk/anuga_core/validation_tests/behaviour_only/lid_driven_cavity/produce_results.py

    r9117 r9224  
    1 #--------------------------------
    2 # import modules
    3 #--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     1import anuga
     2from anuga.validation_utilities import produce_report
     3
     4args = anuga.get_args()
     5
     6produce_report('numerical_lid_driven_cavity.py', args=args)
    77
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('numerical_lid_driven_cavity.py')
    13     run_validation_script('plot_results.py')
    14     typeset_report()
    159
    16 def clean():
    17     autoclean()
    1810
    19 main()
    20 
  • trunk/anuga_core/validation_tests/behaviour_only/weir_1/produce_results.py

    r9121 r9224  
    1 #--------------------------------
    2 # import modules
    3 #--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     1import anuga
     2from anuga.validation_utilities import produce_report
     3
     4args = anuga.get_args()
     5
     6produce_report('runup.py', args=args)
    77
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('runup.py')
    13     run_validation_script('runuplot.py')
    14     typeset_report()
    159
    16 def clean():
    17     autoclean()
    18 
    19 main()
    20 
  • trunk/anuga_core/validation_tests/behaviour_only/weir_1/runup.py

    r9174 r9224  
    77
    88import numpy
     9from anuga import myid, finalize, distribute
    910
    1011from math import exp
    11 from anuga.shallow_water.shallow_water_domain import Domain as Domain
    1212
     13args = anuga.get_args()
     14alg = args.alg
     15verbose = args.verbose
     16
     17scale_me=1.0
    1318
    1419## Set up mesh
     
    4045                [35., 35., 3.0*3.0*0.5] ]
    4146
    42 anuga.create_mesh_from_regions(boundaryPolygon,
    43                          boundary_tags={'left': [0],
    44                                         'top': [1],
    45                                         'right': [2],
    46                                         'bottom': [3]},
    47                            maximum_triangle_area = 1.0e+20,
    48                            minimum_triangle_angle = 28.0,
    49                            filename = 'runup.msh',
    50                            interior_regions = [ [higherResPolygon, 1.*1.*0.5],
    51                                                 [midResPolygon, 3.0*3.0*0.5]],
    52                            breaklines=riverWall.values(),
    53                            use_cache=False,
    54                            verbose=True,
    55                            regionPtArea=regionPtAreas)
     47if myid == 0:
     48    #==================================================================
     49    # Create Sequential Domain
     50    #==================================================================
     51    anuga.create_mesh_from_regions(boundaryPolygon,
     52                             boundary_tags={'left': [0],
     53                                            'top': [1],
     54                                            'right': [2],
     55                                            'bottom': [3]},
     56                               maximum_triangle_area = 1.0e+20,
     57                               minimum_triangle_angle = 28.0,
     58                               filename = 'runup.msh',
     59                               interior_regions = [ [higherResPolygon, 1.*1.*0.5],
     60                                                    [midResPolygon, 3.0*3.0*0.5]],
     61                               breaklines=riverWall.values(),
     62                               use_cache=False,
     63                               verbose=True,
     64                               regionPtArea=regionPtAreas)
     65   
     66    domain=anuga.create_domain_from_file('runup.msh')
     67   
     68   
     69    domain.set_flow_algorithm(alg)
     70   
     71   
     72    domain.set_name('runup_riverwall')                         
     73    domain.set_datadir('.')                         
     74    domain.set_store_vertices_uniquely()
     75   
     76    #------------------
     77    # Define topography
     78    #------------------
     79   
     80    def topography(x,y):
     81        return -x/150.*scale_me
     82   
     83    def stagefun(x,y):
     84        stg=-0.5*scale_me
     85        return stg
     86   
     87    domain.set_quantity('elevation',topography)     # Use function for elevation
     88   
     89    domain.set_quantity('friction',0.03)             # Constant friction
     90   
     91    domain.set_quantity('stage', stagefun)              # Constant negative initial stage
     92else:
     93    domain = None
    5694
    57 domain=anuga.create_domain_from_file('runup.msh')
     95#======================================================================
     96# create Parallel Domain
     97#======================================================================   
     98domain = distribute(domain)
    5899
    59 from anuga.utilities.argparsing import parse_standard_args
    60 alg, cfl = parse_standard_args()
    61 domain.set_flow_algorithm(alg)
    62 #domain.set_CFL(cfl)
    63100
    64 domain.set_name('runup_riverwall')                         
    65 domain.set_datadir('.')                         
    66 #domain.set_flow_algorithm('DE1')
    67 domain.set_store_vertices_uniquely()
    68101domain.riverwallData.create_riverwalls(riverWall, riverWall_Par)
    69 
    70 #------------------
    71 # Define topography
    72 #------------------
    73 
    74 scale_me=1.0
    75 
    76 def topography(x,y):
    77         return -x/150.*scale_me
    78 
    79 def stagefun(x,y):
    80     stg=-0.5*scale_me
    81     return stg
    82 
    83 domain.set_quantity('elevation',topography)     # Use function for elevation
    84 
    85 domain.set_quantity('friction',0.03)             # Constant friction
    86 
    87 domain.set_quantity('stage', stagefun)              # Constant negative initial stage
    88102
    89103#--------------------------
     
    99113    return output 
    100114
    101 Bin_tmss = anuga.shallow_water.boundaries.Transmissive_momentum_set_stage_boundary(domain=domain, function = boundaryFun)
     115Bin_tmss = anuga.Transmissive_momentum_set_stage_boundary(domain=domain, function = boundaryFun)
    102116
    103117#----------------------------------------------
     
    109123# Produce a documentation of parameters
    110124#------------------------------------------------------------------------------
    111 parameter_file=open('parameters.tex', 'w')
    112 parameter_file.write('\\begin{verbatim}\n')
    113 from pprint import pprint
    114 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    115 parameter_file.write('\\end{verbatim}\n')
    116 parameter_file.close()
     125if myid == 0:
     126    parameter_file=open('parameters.tex', 'w')
     127    parameter_file.write('\\begin{verbatim}\n')
     128    from pprint import pprint
     129    pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     130    parameter_file.write('\\end{verbatim}\n')
     131    parameter_file.close()
    117132
    118133#------------------------------
     
    121136
    122137for t in domain.evolve(yieldstep=10.0,finaltime=4000.0):
    123     print domain.timestepping_statistics()
     138    if myid == 0 and verbose: print domain.timestepping_statistics()
    124139    # Print velocity as we go
    125     uh=domain.quantities['xmomentum'].centroid_values
    126     vh=domain.quantities['ymomentum'].centroid_values
    127     depth=domain.quantities['height'].centroid_values
    128     depth=depth*(depth>1.0e-06) + 1.0e-06
    129     vel=((uh/depth)**2 + (vh/depth)**2)**0.5
    130     print 'peak speed is', vel.max()
     140#     uh=domain.quantities['xmomentum'].centroid_values
     141#     vh=domain.quantities['ymomentum'].centroid_values
     142#     depth=domain.quantities['height'].centroid_values
     143#     depth=depth*(depth>1.0e-06) + 1.0e-06
     144#     vel=((uh/depth)**2 + (vh/depth)**2)**0.5
     145#     print 'peak speed is', vel.max()
    131146
    132 print 'Finished'
    133147
     148domain.sww_merge(delete_old=True)
     149
     150finalize()
     151#print 'Finished'
     152
Note: See TracChangeset for help on using the changeset viewer.