Ignore:
Timestamp:
Jan 31, 2012, 10:54:12 AM (13 years ago)
Author:
pittj
Message:

formatted the experiment scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py

    r8314 r8326  
    1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.
    2 
    3 Source data such as elevation and boundary data is assumed to be available in
    4 directories specified by project.py
    5 The output sww file is stored in directory named after the scenario, i.e
    6 slide or fixed_wave.
    7 
    8 The scenario is defined by a triangular mesh created from project.polygon,
    9 the elevation data and a tsunami wave generated by a submarine mass failure.
    10 
    11 Geoscience Australia, 2004-present
    12 """
    13 
    141#------------------------------------------------------------------------------
    152# Import necessary modules
    163#------------------------------------------------------------------------------
    17 # Standard modules
    184import os
    195import time
    206import sys
    217import liststore
    22 
    23 # Related major packages
    248import anuga
    259from anuga_parallel import distribute, myid
    2610from anuga.abstract_2d_finite_volumes.util import add_directories
    27 from anuga.utilities import system_tools, log
     11from anuga.utilities import log
    2812
     13#set up the variables for the temporary data files
     14home = os.getenv('INUNDATIONHOME')
     15scenariodir = add_directories(home, ["data", "mem_time_test", "triangles", "area"])
     16storen ='storen.txt'
     17file_path_storen = os.path.join(scenariodir, storen)
     18storel = 'storel.txt'
     19file_path_storel = os.path.join(scenariodir, storel)
     20storea = 'storea.txt'
     21file_path_storea = os.path.join(scenariodir, storea)
    2922
    30 home2 = os.getenv('INUNDATIONHOME')
    31 
    32 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
    33 
    34 h = 'CAIRNS.msh'
    35 file_pathh = os.path.join(scenariodir2, h)
    36 store ='store.txt'
    37 file_path_store = os.path.join(scenariodir2, store)
    38 storen ='storen.txt'
    39 file_path_storen = os.path.join(scenariodir2, storen)
    40 storel = 'storel.txt'
    41 file_path_storel = os.path.join(scenariodir2, storel)
    42 storea = 'storea.txt'
    43 file_path_storea = os.path.join(scenariodir2, storea)
    44 
    45 f = open(file_path_storel,'r+') # SQRT extent this is set
     23#read the maximum triangle area and the map side length from the files
     24f = open(file_path_storel,'r+')
    4625length = float(f.readline())
    4726f.close()
    48 
    49 f = open(file_path_storea,'r+') #maxarea this is set
     27f = open(file_path_storea,'r+')
    5028area = float(f.readline())
    5129f.close()
    5230
    53 system_tools.MemoryUpdate()
     31#set up the variables for the output data and the log files
     32scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
     33                                       "area", "triangles-" + str(area) +"-"+ str(length)])
     34h = 'CAIRNS.msh'
     35file_pathh = os.path.join(scenariodirV, h)
     36log.log_filename = os.path.join(scenariodirV, "anuga.log")
     37log._setup = False
     38
     39log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
    5440#------------------------------------------------------------------------------
    55 # Create the triangular mesh and domain based on
    56 # overall clipping polygon with a tagged
    57 # boundary and interior regions as defined in project.py
     41# Create the triangular mesh and domain on one processor
    5842#------------------------------------------------------------------------------
    5943if myid == 0:
     
    6549                                    maximum_triangle_area=area,
    6650                                    mesh_filename=file_pathh
    67                                     #,interior_regions=INTERIORREGIONS#,
    68                                     #use_cache=True,
    69                                     #verbose=True)
    7051                                    )
     52    #get the number of triangles
     53    n = len(domain)
    7154
    72     n = len(domain)
    7355else:
    7456    domain = None
    75      
    76 domain = distribute(domain)
    77                                
    78 #------------------------------------------------------------------------------
    79 # Setup parameters of computational domain
    80 #------------------------------------------------------------------------------
     57 
     58#parallel   
     59domain = distribute(domain)                               
     60
    8161domain.set_name('CAIRNS.sww') # Name of sww file
    82 domain.set_datadir(scenariodir2)                       # Store sww output here
     62domain.set_datadir(scenariodirV)# Store sww output here
    8363
     64log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
    8465#------------------------------------------------------------------------------
    8566# Setup initial conditions
     
    9576domain.set_quantity('elevation',topography,alpha=0.1)
    9677
    97 
     78log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    9879
    9980#------------------------------------------------------------------------------
     
    10283
    10384Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
    104 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
    105 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
     85Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow
    10686Br = anuga.Reflective_boundary(domain)
    107 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
    108 domain.set_boundary({'right': Bo,
    109                      'bottom': Br,
    110                      'left': Bi,
    111                      'top': Br})
     87domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
    11288
    113 
     89log.resource_usage_timing(prefix='afterboundary')#get memory usage
    11490#------------------------------------------------------------------------------
    11591# Evolve system through time
    11692#------------------------------------------------------------------------------
    117 
    118 # Save every two mins leading up to wave approaching land
    11993for t in domain.evolve(yieldstep=120, finaltime=2000):
    12094    print domain.timestepping_statistics()
    121    
    12295
    123 liststore.store[myid] = system_tools.MemoryUpdate()[0]
    124 a = sum(liststore.store)
     96log.resource_usage_timing(prefix='aftersimulation') #get memory usage
    12597
    126 v = open(file_path_store, 'r+')
    127 v.write(str(a))
    128 
     98#write the number of triangles to file
    12999i = open(file_path_storen, 'r+')
    130100i.write(str(n))
Note: See TracChangeset for help on using the changeset viewer.