Changeset 9224
- Timestamp:
- Jun 28, 2014, 11:49:17 PM (10 years ago)
- 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 13 13 from numpy import zeros, ones, float 14 14 from time import localtime, strftime, gmtime 15 #from balanced_dev import * 15 from anuga import myid, finalize, distribute 16 16 17 17 … … 29 29 #start_screen_catcher(output_dir+'_') 30 30 31 args = anuga.get_args() 32 alg = args.alg 33 verbose = args.verbose 31 34 32 35 #------------------------------------------------------------------------------ … … 38 41 W = 3*dx 39 42 40 # structured mesh 41 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0)) 43 if 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) 42 53 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) 72 else: 73 domain = None 45 74 46 domain.set_name(output_file) 47 domain.set_datadir(output_dir) 48 75 #----------------------------------------------------------------------------- 76 # Create Parallel Domain 49 77 #------------------------------------------------------------------------------ 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 78 domain = distribute(domain) 79 77 80 #----------------------------------------------------------------------------- 78 81 # Setup boundary conditions … … 88 91 89 92 90 #===============================================================================91 ##from anuga.visualiser import RealtimeVisualiser92 ##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 99 93 #------------------------------------------------------------------------------ 100 94 # Produce a documentation of parameters 101 95 #------------------------------------------------------------------------------ 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() 96 if 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() 108 103 109 104 #------------------------------------------------------------------------------ 110 105 # Evolve system through time 111 106 #------------------------------------------------------------------------------ 112 for t in domain.evolve(yieldstep = 1.0, finaltime = 300.):107 for t in domain.evolve(yieldstep = 1.0, finaltime = 100.): 113 108 #print domain.timestepping_statistics(track_speeds=True) 114 print domain.timestepping_statistics()109 if myid == 0 and verbose: print domain.timestepping_statistics() 115 110 #vis.update() 116 111 112 domain.sww_merge(delete_old=True) 117 113 118 #test against know data 119 120 #vis.evolveFinished() 114 finalize() 121 115 -
trunk/anuga_core/validation_tests/analytical_exact/transcritical_with_shock/plot_results.py
r8799 r9224 14 14 v2=(p2_st.y==v) 15 15 16 tid = -1 17 16 18 h,z = analytic_sol(p2_st.x[v2]) 17 19 18 20 #Plot the stages############################################################## 19 21 pyplot.clf() 20 pyplot.plot(p2_st.x[v2], p2_st.stage[ 300,v2], 'b.-', label='numerical stage') # 0*T/622 pyplot.plot(p2_st.x[v2], p2_st.stage[tid,v2], 'b.-', label='numerical stage') # 0*T/6 21 23 pyplot.plot(p2_st.x[v2], h+z,'r-', label='analytical stage') 22 24 pyplot.plot(p2_st.x[v2], z,'k-', label='bed elevation') 23 pyplot.title('Stage at an instant in time')25 pyplot.title('Stage at time %s secs'% p2_st.time[tid]) 24 26 ##pyplot.ylim(-5.0,5.0) 25 27 pyplot.legend(loc='best') … … 31 33 #Plot the momentums########################################################## 32 34 pyplot.clf() 33 pyplot.plot(p2_st.x[v2], p2_st.xmom[ 300,v2], 'b.-', label='numerical') # 0*T/635 pyplot.plot(p2_st.x[v2], p2_st.xmom[tid,v2], 'b.-', label='numerical') # 0*T/6 34 36 pyplot.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')37 pyplot.title('Xmomentum at time %s secs'% p2_st.time[tid]) 36 38 pyplot.legend(loc='best') 37 39 pyplot.xlabel('Xposition') … … 43 45 #Plot the velocities######################################################### 44 46 pyplot.clf() 45 pyplot.plot(p2_st.x[v2], p2_st.xvel[ 300,v2], 'b.-', label='numerical') # 0*T/647 pyplot.plot(p2_st.x[v2], p2_st.xvel[tid,v2], 'b.-', label='numerical') # 0*T/6 46 48 pyplot.plot(p2_st.x[v2], 0.18/h,'r-', label='analytical') 47 pyplot.title('Xvelocity at an instant in time')49 pyplot.title('Xvelocity at time %s secs'% p2_st.time[tid]) 48 50 pyplot.legend(loc='best') 49 51 pyplot.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 1 import anuga 2 from anuga.validation_utilities import produce_report 3 4 args = anuga.get_args() 5 6 produce_report('numerical_transcritical.py', args=args) 7 7 8 8 9 # Setup the python scripts which produce the output for this10 # validation test11 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()18 9 19 main()20 10 -
trunk/anuga_core/validation_tests/analytical_exact/transcritical_without_shock/numerical_transcritical.py
r9155 r9224 14 14 from time import localtime, strftime, gmtime 15 15 from anuga.operators.set_w_uh_vh_operators import Polygonal_set_w_uh_vh_operator 16 16 from anuga import myid, finalize, distribute 17 17 18 18 #------------------------------------------------------------------------------- … … 29 29 #start_screen_catcher(output_dir+'_') 30 30 31 args = anuga.get_args() 32 alg = args.alg 33 verbose = args.verbose 31 34 32 35 #------------------------------------------------------------------------------ … … 41 44 BC_polygonR = [[L,0.],[L,W], [L-dx,W], [L-dx,0.]] 42 45 43 # structured mesh 44 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0)) 46 if 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) 45 56 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) 77 else: 78 domain = None 79 80 #----------------------------------------------------------------------------- 81 # create Parallel Domain 52 82 #------------------------------------------------------------------------------ 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) 83 domain = distribute(domain) 80 84 81 85 #----------------------------------------------------------------------------- … … 92 96 domain.set_boundary({'left': BdL, 'right': BdR, 'top': Br, 'bottom': Br}) 93 97 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) 106 102 107 103 … … 109 105 # Produce a documentation of parameters 110 106 #------------------------------------------------------------------------------ 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() 107 if 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() 117 114 118 115 #------------------------------------------------------------------------------ 119 116 # Evolve system through time 120 117 #------------------------------------------------------------------------------ 121 for t in domain.evolve(yieldstep = 1.0, finaltime = 300.):118 for t in domain.evolve(yieldstep = 1.0, finaltime = 100.): 122 119 #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() 125 121 126 122 127 #test against know data 128 #vis.evolveFinished() 123 domain.sww_merge(delete_old=True) 129 124 125 finalize() -
trunk/anuga_core/validation_tests/analytical_exact/transcritical_without_shock/plot_results.py
r8800 r9224 16 16 h,z = analytic_sol(p2_st.x[v2]) 17 17 18 tid = 100 19 18 20 #Plot the stages############################################################## 19 21 pyplot.clf() 20 pyplot.plot(p2_st.x[v2], p2_st.stage[ 300,v2], 'b.-', label='numerical stage') # 0*T/622 pyplot.plot(p2_st.x[v2], p2_st.stage[tid,v2], 'b.-', label='numerical stage') # 0*T/6 21 23 pyplot.plot(p2_st.x[v2], h+z,'r-', label='analytical stage') 22 24 pyplot.plot(p2_st.x[v2], z,'k-', label='bed elevation') 23 pyplot.title('Stage at an instant in time')25 pyplot.title('Stage at time %s secs'% p2_st.time[tid]) 24 26 ##pyplot.ylim(-5.0,5.0) 25 27 pyplot.legend(loc='best') … … 31 33 #Plot the momentums########################################################## 32 34 pyplot.clf() 33 pyplot.plot(p2_st.x[v2], p2_st.xmom[ 300,v2], 'b.-', label='numerical') # 0*T/635 pyplot.plot(p2_st.x[v2], p2_st.xmom[tid,v2], 'b.-', label='numerical') # 0*T/6 34 36 pyplot.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')37 pyplot.title('Xmomentum at time %s secs'% p2_st.time[tid]) 36 38 pyplot.legend(loc='best') 37 39 pyplot.ylim([1.52,1.54]) … … 44 46 #Plot the velocities######################################################### 45 47 pyplot.clf() 46 pyplot.plot(p2_st.x[v2], p2_st.xvel[ 300,v2], 'b.-', label='numerical') # 0*T/648 pyplot.plot(p2_st.x[v2], p2_st.xvel[tid,v2], 'b.-', label='numerical') # 0*T/6 47 49 pyplot.plot(p2_st.x[v2], 1.53/h,'r-', label='analytical') 48 pyplot.title('Xvelocity at an instant in time')50 pyplot.title('Xvelocity at time %s secs'% p2_st.time[tid]) 49 51 pyplot.legend(loc='best') 50 52 pyplot.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 1 import anuga 2 from anuga.validation_utilities import produce_report 3 4 args = anuga.get_args() 5 6 produce_report('numerical_transcritical.py', args=args) 7 7 8 8 9 # Setup the python scripts which produce the output for this10 # validation test11 def build():12 run_validation_script('numerical_transcritical.py')13 run_validation_script('plot_results.py')14 typeset_report()15 9 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 9 9 from math import sin, pi, exp, sqrt 10 10 from anuga import Domain 11 from anuga import myid, finalize, distribute 11 12 12 #--------- 13 #Setup computational domain 14 #--------- 15 domain = anuga.rectangular_cross_domain(15,15, len1=1., len2=1.) 13 args = anuga.get_args() 14 alg = args.alg 15 verbose = args.verbose 16 16 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 17 if 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 34 else: 35 domain = None 36 37 #-------------------------- 38 # Create Parallel Domain 39 #-------------------------- 40 domain = distribute(domain) 40 41 41 42 #-------------------------- … … 54 55 # Produce a documentation of parameters 55 56 #------------------------------------------------------------------------------ 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() 57 if 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() 62 64 63 65 #------------------------------ 64 66 #Evolve the system through time 65 67 #------------------------------ 66 for t in domain.evolve(yieldstep=10.,finaltime=1000.0): 67 print domain.timestepping_statistics() 68 print 'Finished' 68 for t in domain.evolve(yieldstep=10.,finaltime=200.0): 69 if myid == 0 and verbose: print domain.timestepping_statistics() 70 71 domain.sww_merge(delete_old=True) 72 73 finalize() -
trunk/anuga_core/validation_tests/behaviour_only/lid_driven_cavity/plot_results.py
r8825 r9224 23 23 #-------------------- 24 24 pyplot.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')37 25 38 26 # Plot vertex values 39 27 pyplot.clf() 40 28 t1=int(len(p1.time)/2) 41 t2= len(p1.time)-129 t2=-1 42 30 #pyplot.scatter(p1.x,p1.y,c=p1.elev,edgecolors='none', s=25) 43 31 #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 1 import anuga 2 from anuga.validation_utilities import produce_report 3 4 args = anuga.get_args() 5 6 produce_report('numerical_lid_driven_cavity.py', args=args) 7 7 8 8 9 # Setup the python scripts which produce the output for this10 # validation test11 def build():12 run_validation_script('numerical_lid_driven_cavity.py')13 run_validation_script('plot_results.py')14 typeset_report()15 9 16 def clean():17 autoclean()18 10 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 1 import anuga 2 from anuga.validation_utilities import produce_report 3 4 args = anuga.get_args() 5 6 produce_report('runup.py', args=args) 7 7 8 8 9 # Setup the python scripts which produce the output for this10 # validation test11 def build():12 run_validation_script('runup.py')13 run_validation_script('runuplot.py')14 typeset_report()15 9 16 def clean():17 autoclean()18 19 main()20 -
trunk/anuga_core/validation_tests/behaviour_only/weir_1/runup.py
r9174 r9224 7 7 8 8 import numpy 9 from anuga import myid, finalize, distribute 9 10 10 11 from math import exp 11 from anuga.shallow_water.shallow_water_domain import Domain as Domain12 12 13 args = anuga.get_args() 14 alg = args.alg 15 verbose = args.verbose 16 17 scale_me=1.0 13 18 14 19 ## Set up mesh … … 40 45 [35., 35., 3.0*3.0*0.5] ] 41 46 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) 47 if 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 92 else: 93 domain = None 56 94 57 domain=anuga.create_domain_from_file('runup.msh') 95 #====================================================================== 96 # create Parallel Domain 97 #====================================================================== 98 domain = distribute(domain) 58 99 59 from anuga.utilities.argparsing import parse_standard_args60 alg, cfl = parse_standard_args()61 domain.set_flow_algorithm(alg)62 #domain.set_CFL(cfl)63 100 64 domain.set_name('runup_riverwall')65 domain.set_datadir('.')66 #domain.set_flow_algorithm('DE1')67 domain.set_store_vertices_uniquely()68 101 domain.riverwallData.create_riverwalls(riverWall, riverWall_Par) 69 70 #------------------71 # Define topography72 #------------------73 74 scale_me=1.075 76 def topography(x,y):77 return -x/150.*scale_me78 79 def stagefun(x,y):80 stg=-0.5*scale_me81 return stg82 83 domain.set_quantity('elevation',topography) # Use function for elevation84 85 domain.set_quantity('friction',0.03) # Constant friction86 87 domain.set_quantity('stage', stagefun) # Constant negative initial stage88 102 89 103 #-------------------------- … … 99 113 return output 100 114 101 Bin_tmss = anuga. shallow_water.boundaries.Transmissive_momentum_set_stage_boundary(domain=domain, function = boundaryFun)115 Bin_tmss = anuga.Transmissive_momentum_set_stage_boundary(domain=domain, function = boundaryFun) 102 116 103 117 #---------------------------------------------- … … 109 123 # Produce a documentation of parameters 110 124 #------------------------------------------------------------------------------ 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() 125 if 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() 117 132 118 133 #------------------------------ … … 121 136 122 137 for 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() 124 139 # Print velocity as we go 125 uh=domain.quantities['xmomentum'].centroid_values126 vh=domain.quantities['ymomentum'].centroid_values127 depth=domain.quantities['height'].centroid_values128 depth=depth*(depth>1.0e-06) + 1.0e-06129 vel=((uh/depth)**2 + (vh/depth)**2)**0.5130 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() 131 146 132 print 'Finished'133 147 148 domain.sww_merge(delete_old=True) 149 150 finalize() 151 #print 'Finished' 152
Note: See TracChangeset
for help on using the changeset viewer.