Changeset 9156
- Timestamp:
- Jun 14, 2014, 11:44:13 PM (10 years ago)
- Location:
- trunk/anuga_core/validation_tests/analytical_exact/parabolic_basin
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/validation_tests/analytical_exact/parabolic_basin/numerical_parabolic_basin.py
r9155 r9156 5 5 #-------- 6 6 import anuga 7 from anuga import myid, finalize, distribute 7 8 import numpy 8 9 from math import sqrt, cos, sin, pi … … 22 23 #start_screen_catcher(output_dir+'_') 23 24 24 #------------------------------------------------------------------------------- 25 # Domain 26 #------------------------------------------------------------------------------- 25 args = anuga.get_args() 26 alg = args.alg 27 verbose = args.v 28 27 29 m = 200 28 30 n = 10 … … 31 33 origin = (-20.0, -1.0) 32 34 33 points, elements, boundary = anuga.rectangular_cross(m, n, lenx, leny, origin)34 domain = anuga.Domain(points, elements, boundary)35 domain.set_name(output_file)36 domain.set_datadir(output_dir)37 #domain.set_minimum_allowed_height(0.01)38 35 39 40 #------------------------------------------------------------------------------ 41 # Setup Algorithm, either using command line arguments 42 # or override manually yourself 43 #------------------------------------------------------------------------------ 44 from anuga.utilities.argparsing import parse_standard_args 45 alg, cfl = parse_standard_args() 46 domain.set_flow_algorithm(alg) 47 #domain.set_CFL(cfl) 48 49 #------------------ 50 # Define topography 51 #------------------ 52 53 # Parameters for analytical solution 54 D0=4.0 55 L=10.0 56 A = 2.0 57 58 def topography(x,y): 59 return (D0/(L**2.))*x**2. 60 61 def stage_init(x,y): 62 wat= D0 + (2.0*A*D0/L**2.)*(x-A/2.0) # Water elevation inside the parabola 63 top=topography(x,y) # Bed elevation 64 # Return the maximum of the water elevation and the bed elvation 65 return wat*(wat>top) + top*(wat<=top) 66 67 68 domain.set_quantity('elevation',topography) # Use function for elevation 69 domain.set_quantity('friction',0.0) # No friction 70 domain.set_quantity('stage', stage_init) # Constant negative initial stage 71 72 36 #------------------------------------------------------------------------------- 37 # Sequential Domain 38 #------------------------------------------------------------------------------- 39 if myid == 0: 40 points, elements, boundary = anuga.rectangular_cross(m, n, lenx, leny, origin) 41 domain = anuga.Domain(points, elements, boundary) 42 domain.set_name(output_file) 43 domain.set_datadir(output_dir) 44 #domain.set_minimum_allowed_height(0.01) 45 46 47 48 domain.set_flow_algorithm(alg) 49 50 51 #------------------ 52 # Define topography 53 #------------------ 54 55 # Parameters for analytical solution 56 D0=4.0 57 L=10.0 58 A = 2.0 59 60 def topography(x,y): 61 return (D0/(L**2.))*x**2. 62 63 def stage_init(x,y): 64 wat= D0 + (2.0*A*D0/L**2.)*(x-A/2.0) # Water elevation inside the parabola 65 top=topography(x,y) # Bed elevation 66 # Return the maximum of the water elevation and the bed elvation 67 return wat*(wat>top) + top*(wat<=top) 68 69 70 domain.set_quantity('elevation',topography) # Use function for elevation 71 domain.set_quantity('friction',0.0) # No friction 72 domain.set_quantity('stage', stage_init) # Constant negative initial stage 73 74 else: 75 76 domain = None 77 78 #-------------------------------------------------------------------- 79 # Parallel Domain 80 #-------------------------------------------------------------------- 81 domain = distribute(domain) 82 73 83 #-------------------------- 74 84 # Setup boundary conditions … … 104 114 # Produce a documentation of parameters 105 115 #------------------------------------------------------------------------------ 106 parameter_file=open('parameters.tex', 'w') 107 parameter_file.write('\\begin{verbatim}\n') 108 from pprint import pprint 109 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 110 parameter_file.write('\\end{verbatim}\n') 111 parameter_file.close() 116 if myid == 0: 117 parameter_file=open('parameters.tex', 'w') 118 parameter_file.write('\\begin{verbatim}\n') 119 from pprint import pprint 120 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4) 121 parameter_file.write('\\end{verbatim}\n') 122 parameter_file.close() 112 123 113 124 … … 116 127 #------------------------------ 117 128 for t in domain.evolve(yieldstep=0.05,finaltime=10.0): 118 print domain.timestepping_statistics() 119 print 'Finished' 129 if myid == 0: print domain.timestepping_statistics() 130 131 domain.sww_merge(delete_old=True) 132 133 finalize() 134 135 136 137 -
trunk/anuga_core/validation_tests/analytical_exact/parabolic_basin/produce_results.py
r9117 r9156 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 7 6 7 args = anuga.get_args() 8 8 9 # Setup the python scripts which produce the output for this 10 # validation test 11 def build(): 12 run_validation_script('numerical_parabolic_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() 9 produce_report('numerical_parabolic_basin.py', args=args)
Note: See TracChangeset
for help on using the changeset viewer.