Changeset 9156


Ignore:
Timestamp:
Jun 14, 2014, 11:44:13 PM (10 years ago)
Author:
steve
Message:

combined plot scripts

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  
    55#--------
    66import anuga
     7from anuga import myid, finalize, distribute
    78import numpy
    89from math import sqrt, cos, sin, pi
     
    2223#start_screen_catcher(output_dir+'_')
    2324
    24 #-------------------------------------------------------------------------------
    25 # Domain
    26 #-------------------------------------------------------------------------------
     25args = anuga.get_args()
     26alg = args.alg
     27verbose = args.v
     28
    2729m = 200
    2830n = 10
     
    3133origin = (-20.0, -1.0)
    3234
    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)
    3835
    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#-------------------------------------------------------------------------------
     39if 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   
     74else:
     75   
     76    domain = None
     77   
     78#--------------------------------------------------------------------
     79# Parallel Domain
     80#--------------------------------------------------------------------
     81domain = distribute(domain)
     82   
    7383#--------------------------
    7484# Setup boundary conditions
     
    104114# Produce a documentation of parameters
    105115#------------------------------------------------------------------------------
    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()
     116if 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()
    112123
    113124
     
    116127#------------------------------
    117128for 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
     131domain.sww_merge(delete_old=True)
     132
     133finalize()
     134
     135
     136
     137
  • trunk/anuga_core/validation_tests/analytical_exact/parabolic_basin/produce_results.py

    r9117 r9156  
    22# import modules
    33#--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     4import anuga
     5from anuga.validation_utilities import produce_report
    76
     7args = anuga.get_args()
    88
    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()
     9produce_report('numerical_parabolic_basin.py', args=args)
Note: See TracChangeset for help on using the changeset viewer.