Changeset 9158
- Timestamp:
- Jun 15, 2014, 5:22:06 PM (10 years ago)
- Location:
- trunk/anuga_core/validation_tests/analytical_exact/paraboloid_basin
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/validation_tests/analytical_exact/paraboloid_basin/numerical_paraboloid_basin.py
r9155 r9158 19 19 from time import localtime, strftime, gmtime 20 20 from anuga.geometry.polygon import inside_polygon, is_inside_triangle 21 21 from anuga import myid, finalize, distribute 22 22 23 23 #------------------------------------------------------------------------------- … … 32 32 33 33 34 args = anuga.get_args() 35 alg = args.alg 36 verbose = args.v 37 34 38 #------------------------------------------------------------------------------- 35 39 # Domain … … 41 45 origin = (-4000.0, -4000.0) 42 46 43 points, elements, boundary = anuga.rectangular_cross(m, n, lenx, leny, origin)44 domain = anuga.Domain(points, elements, boundary)45 47 46 48 47 #------------------------------------------------------------------------------- 48 # Provide file name for storing output 49 #------------------------------------------------------------------------------- 50 domain.store = True #False 51 domain.format = 'sww' 52 domain.set_name(output_file) 53 domain.set_datadir(output_dir) 49 #=============================================================================== 50 # Create Sequential Domain 51 #=============================================================================== 52 if myid == 0: 53 points, elements, boundary = anuga.rectangular_cross(m, n, lenx, leny, origin) 54 domain = anuga.Domain(points, elements, boundary) 54 55 55 56 56 #------------------------------------------------------------------------------- 57 # Order of scheme 58 # Good compromise between 59 # limiting and CFL 60 # CUT THIS FOR AUTOMATED TESTS 61 #------------------------------------------------------------------------------- 62 #domain.set_default_order(2) 63 #domain.set_timestepping_method(2) 64 #domain.set_beta(1.5) 65 ##domain.set_CFL(0.6) 66 #domain.smooth = True 57 domain.set_name(output_file) 58 domain.set_datadir(output_dir) 59 60 domain.set_flow_algorithm(alg) 67 61 62 63 #------------------------------------------------------------------------------- 64 # Initial conditions 65 #------------------------------------------------------------------------------- 66 t = 0.0 67 D0 = 1000. 68 L = 2500. 69 R0 = 2000. 70 71 A = (L**4 - R0**4)/(L**4 + R0**4) 72 omega = 2./L*sqrt(2.*g*D0) 73 T = pi/omega 74 75 #------------------ 76 # Set bed elevation 77 def bed_elevation(x,y): 78 n = x.shape[0] 79 z = 0*x 80 for i in range(n): 81 r = sqrt(x[i]*x[i] + y[i]*y[i]) 82 z[i] = -D0*(1.-r*r/L/L) 83 return z 84 domain.set_quantity('elevation', bed_elevation) 85 86 #---------------------------- 87 # Set the initial water level 88 def stage_init(x,y): 89 z = bed_elevation(x,y) 90 n = x.shape[0] 91 w = 0*x 92 for i in range(n): 93 r = sqrt(x[i]*x[i] + y[i]*y[i]) 94 w[i] = D0*((sqrt(1-A*A))/(1.-A*cos(omega*t)) 95 -1.-r*r/L/L*((1.-A*A)/((1.-A*cos(omega*t))**2)-1.)) 96 if w[i] < z[i]: 97 w[i] = z[i] 98 return w 99 domain.set_quantity('stage', stage_init) 68 100 69 #------------------------------------------------------------------------------- 70 # Decide which quantities are to be stored at each timestep 71 #------------------------------------------------------------------------------- 72 #domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum'] 101 else: 102 103 domain = None 104 105 #============================================================================ 106 # Create Parallel Domain 107 #============================================================================ 108 domain = distribute(domain) 73 109 74 75 #-------------------------------------------------------------------------------76 # Reduction operation for get_vertex_values77 from anuga.utilities.numerical_tools import mean78 domain.reduction = mean #domain.reduction = min #Looks better near steep slopes79 80 81 #-------------------------------------------------------------------------------82 # Initial condition83 #-------------------------------------------------------------------------------84 t = 0.085 D0 = 1000.86 L = 2500.87 R0 = 2000.88 89 A = (L**4 - R0**4)/(L**4 + R0**4)90 omega = 2./L*sqrt(2.*g*D0)91 T = pi/omega92 93 #------------------94 # Set bed elevation95 def bed_elevation(x,y):96 n = x.shape[0]97 z = 0*x98 for i in range(n):99 r = sqrt(x[i]*x[i] + y[i]*y[i])100 z[i] = -D0*(1.-r*r/L/L)101 return z102 domain.set_quantity('elevation', bed_elevation)103 104 #----------------------------105 # Set the initial water level106 def stage_init(x,y):107 z = bed_elevation(x,y)108 n = x.shape[0]109 w = 0*x110 for i in range(n):111 r = sqrt(x[i]*x[i] + y[i]*y[i])112 w[i] = D0*((sqrt(1-A*A))/(1.-A*cos(omega*t))113 -1.-r*r/L/L*((1.-A*A)/((1.-A*cos(omega*t))**2)-1.))114 if w[i] < z[i]:115 w[i] = z[i]116 return w117 domain.set_quantity('stage', stage_init)118 110 119 111 #--------- … … 124 116 domain.set_boundary({'left': D, 'right': D, 'top': D, 'bottom': D}) 125 117 126 #---------------------------------------------127 # Find triangle that contains the point Point128 # and print to file129 #---------------------------------------------130 Point = (0.0, 0.0)131 for n in range(len(domain.triangles)):132 tri = domain.get_vertex_coordinates(n)133 if is_inside_triangle(Point,tri):134 #print 'Point is within triangle with vertices '+'%s'%tri135 n_point = n136 break137 print 'n_point = ',n_point138 #bla139 140 #t = domain.triangles[n_point]141 #print 't = ', t142 #tri = domain.get_vertex_coordinates(n)143 144 filename=domain.get_name()145 file = open(filename,'w')146 147 #----------148 # Evolution149 import time150 t0 = time.time()151 152 time_array = []153 stage_array = []154 Stage = domain.quantities['stage']155 Xmomentum = domain.quantities['xmomentum']156 Ymomentum = domain.quantities['ymomentum']157 158 #interactive_visualisation = True159 #===============================================================================160 ##if interactive_visualisation:161 ## from anuga.visualiser import RealtimeVisualiser162 ## vis = RealtimeVisualiser(domain)163 ## vis.render_quantity_height("stage", zScale =1000, dynamic=True)164 ## vis.colour_height_quantity('stage', (1.0, 0.5, 0.5))165 ## vis.start()166 #===============================================================================167 168 118 169 119 #------------------------------------------------------------------------------ 170 120 # Produce a documentation of parameters 171 121 #------------------------------------------------------------------------------ 172 parameter_file=open('parameters.tex', 'w') 173 parameter_file.write('\\begin{verbatim}\n') 174 from pprint import pprint 175 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 176 parameter_file.write('\\end{verbatim}\n') 177 parameter_file.close() 122 if myid == 0: 123 parameter_file=open('parameters.tex', 'w') 124 parameter_file.write('\\begin{verbatim}\n') 125 from pprint import pprint 126 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 127 parameter_file.write('\\end{verbatim}\n') 128 parameter_file.close() 178 129 130 import time 131 t0 = time.time() 179 132 for t in domain.evolve(yieldstep = 1.0, finaltime = 200.0): 180 domain.write_time()133 if myid == 0 and verbose : domain.write_time() 181 134 182 #tri_array = asarray(tri) 183 #t_array = asarray([[0,1,2]]) 184 #interp = Interpolation(tri_array,t_array,[points]) 135 if myid==0 and verbose: print 'That took %s secs' % str(time.time()- t0) 185 136 186 stage = Stage.get_values(location='centroids',indices=[n_point]) 187 xmomentum = Xmomentum.get_values(location='centroids',indices=[n_point]) 188 ymomentum = Ymomentum.get_values(location='centroids',indices=[n_point]) 189 #print '%10.6f %10.6f %10.6f %10.6f\n'%(t,stage,xmomentum,ymomentum) 190 file.write( '%10.6f %10.6f %10.6f %10.6f\n'%(t,stage,xmomentum,ymomentum) ) 137 domain.sww_merge(delete_old=True) 191 138 192 #time_array.append(t) 193 #stage_array.append(stage) 194 195 #if interactive_visualisation: 196 # vis.update() 197 """ 198 file.close() 199 print 'That took %.2f seconds' %(time.time()-t0) 200 from pylab import * 201 #ion() 202 hold(False) 203 plot(time_array, stage_array, 'r.-') 204 #title('Gauge %s' %name) 205 xlabel('time (s)') 206 ylabel('stage (m)') 207 #legend(('Observed', 'Modelled'), shadow=True, loc='upper left') 208 #savefig(name, dpi = 300) 209 210 #raw_input('Next') 211 show() 212 """ 213 214 #if interactive_visualisation: 215 # vis.evolveFinished() 139 finalize() -
trunk/anuga_core/validation_tests/analytical_exact/paraboloid_basin/produce_results.py
r9117 r9158 2 2 # import modules 3 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 4 import anuga 5 from anuga.validation_utilities import produce_report 6 7 args = anuga.get_args() 8 9 produce_report('numerical_paraboloid_basin.py', args=args) 7 10 8 11 9 # Setup the python scripts which produce the output for this10 # validation test11 def build():12 run_validation_script('numerical_paraboloid_basin.py')13 run_validation_script('plot_results_cross_section.py')14 run_validation_script('plot_results_origin_wrt_time.py')15 typeset_report()16 17 def clean():18 autoclean()19 20 main()
Note: See TracChangeset
for help on using the changeset viewer.