Ignore:
Timestamp:
Oct 23, 2007, 4:00:41 PM (17 years ago)
Author:
duncan
Message:

simplify

Location:
anuga_validation/UQ_runup_2006
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_validation/UQ_runup_2006/create_mesh.py

    r4748 r4750  
    77
    88
    9 def generate(mesh_filename, gate_position, flume_length, is_course = False):
     9def generate(mesh_filename, gate_position, is_course = False):
    1010    #Basic geometry
    1111   
  • anuga_validation/UQ_runup_2006/project.py

    r4748 r4750  
    22Also includes origin for slump scenario.
    33"""
    4 
    5 from os import sep, environ, getenv, getcwd
    6 import sys
    7 from time import localtime, strftime
    8 from os import mkdir, access, F_OK
    9                
    10 #Making assumptions about the location of scenario data
    11 scenario_dir_name = 'data'+sep+'flumes'+sep+'dam_2007'
    12 
    13 #swollen/ all data output
    14 basename = 'source'
    15 
    16 if sys.platform == 'win32':
    17     try:
    18         home = environ['INUNDATIONHOME']     #Sandpit's parent dir
    19     except:
    20         home = '.'
    21 else:   
    22     home = getenv('INUNDATIONHOME', sep+'d'+sep+'cit'+sep+'1'+sep+'cit'+sep+'risk_assessment_methods_project'+sep+'inundation')     
     4basename = "uq"
     5depth_filename = "depth.csv"
     6velocity_x_filename =  "velocity_x.csv"
     7velocity_y_filename =  "velocity_y.csv"
    238
    249
    25 if not access(home, F_OK):
    26     home = '.'
    27    
    28 #Derive subdirectories and filenames
    29 time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir
    30 # time = "boom"
    31 scenariodir =  home+sep+scenario_dir_name
    32 outputdir = scenariodir+sep+'output'+sep
    33 outputtimedir = outputdir+time+sep
    34 meshdir = scenariodir+sep+'meshes'+sep
     10mesh_filename = 'uq-mesh.tsh'
    3511
    36 depth_filename = outputtimedir + "depth.csv"
    37 velocity_x_filename = outputtimedir + "velocity_x.csv"
    38 velocity_y_filename = outputtimedir + "velocity_y.csv"
    39 
    40 
    41 # creates copy of output dir structure, if it doesn't exist
    42 if not access(scenariodir,F_OK):
    43     mkdir (scenariodir)
    44 
    45 if not access(meshdir,F_OK):
    46     mkdir (meshdir)
    47 
    48 if not access(outputdir,F_OK):
    49     mkdir (outputdir)
    50        
    51 if not access(outputtimedir,F_OK):
    52     mkdir (outputtimedir)
    53 
    54 codedir = getcwd()+sep
    55                                
    56 codedirname = codedir + 'project.py'
    57 
    58 meshname = meshdir + basename
    59 
    60 outputname = outputtimedir + basename  #Used by post processing
    61 
    62 mesh_filename = meshname+'.tsh'
    63 
  • anuga_validation/UQ_runup_2006/run_dam.py

    r4748 r4750  
    2525import create_mesh
    2626
     27import project
     28
     29
    2730# Application specific imports
    2831
     
    3437    inital_depths = [0.2] #can enter multiple initial depths eg [0.1, 0.2]
    3538    gate_positions = [0.75]
    36     flume_lengths = [3] #can enter multiple flume lengths eg [3.0, 5.0]
    37     # NOTE flume_lengths is not used.  It's hardcoded into create_mesh
    38    
    39     for slope in slopes:
    40         for friction in frictions:
    41             for inital_depth in inital_depths:
    42                 for flume_length in flume_lengths:
    43                     for gate_position in gate_positions:
    44                         scenario(slope, friction, inital_depth, gate_position, flume_length)
     39   
     40    scenario(0, 0.01, 0.02, 0.75)
    4541           
    4642
    47 def scenario(slope, friction, inital_depth, gate_position, flume_length):
    48    
    49     import project                 # Definition of file names and polygons
    50 
    51     #-------------------------------------------------------------------------
    52     # Setup archiving of simulations
    53     #-------------------------------------------------------------------------
    54 
    55     id = 'd'+ str(inital_depth) + '_s'+str(slope)+'_g'+ str(gate_position)+ '_n'+ str(friction)
    56     copy (project.codedirname, project.outputtimedir + 'project.py')
    57     run_name = 'run_dam.py'
    58     run_name_out = 'run_dam'+id+'.py'
    59 
    60     copy (project.codedir + run_name, project.outputtimedir + run_name_out)
    61     copy (project.codedir + 'create_mesh.py',
    62           project.outputtimedir + 'create_mesh.py')
    63     print'output dir', project.outputtimedir
     43def scenario(slope, friction, inital_depth, gate_position):
    6444
    6545    #-------------------------------------------------------------------------
     
    6848
    6949    create_mesh.generate(project.mesh_filename,
    70                          gate_position, flume_length,
    71                          #is_course=True) # this creates the mesh
    72                          is_course=False) # this creates the mesh
     50                         gate_position,
     51                         is_course=True) # this creates the mesh
     52                         #is_course=False) # this creates the mesh
    7353
    7454    head,tail = path.split(project.mesh_filename)
    75     copy (project.mesh_filename,
    76           project.outputtimedir + tail )
    7755    #-------------------------------------------------------------------------
    7856    # Setup computational domain
     
    8664
    8765   
    88     domain.set_name(project.basename + id)
    89     domain.set_datadir(project.outputtimedir)
     66    domain.set_name(project.basename)
     67    domain.set_datadir('.')
    9068    domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
    9169    domain.set_minimum_storable_height(0.001)
     
    123101        print 'finished'
    124102       
    125     points = [[gate_position - 0.65,0.2],
    126               [gate_position - 0.55,0.2],
    127               [gate_position - 0.45,0.2],
    128               [gate_position - 0.35,0.2],
    129               [0.45,0.2],
    130               [gate_position - 0.25,0.2]
    131               ]
     103    points = [[0.4,0.2]]
    132104    #-------------------------------------------------------------------------
    133105    # Calculate gauge info
    134106    #-------------------------------------------------------------------------
    135     print "name", project.outputtimedir + project.basename \
    136                    + id+".sww"
    137     interpolate_sww2csv(project.outputtimedir + project.basename \
    138                    + id+".sww",
     107    print "name",project.basename +".sww"
     108    interpolate_sww2csv( project.basename +".sww",
    139109                        points,
    140                         project.depth_filename + id + '.csv',
    141                         project.velocity_x_filename + id + '.csv',
    142                         project.velocity_y_filename + id + '.csv')
     110                        project.depth_filename + '.csv',
     111                        project.velocity_x_filename + '.csv',
     112                        project.velocity_y_filename + '.csv')
    143113
    144114
Note: See TracChangeset for help on using the changeset viewer.