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

formatted the experiment scripts

File:
1 edited

Legend:

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

    r8303 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 
    14 
    15 
    161#------------------------------------------------------------------------------
    172# Import necessary modules
    183#------------------------------------------------------------------------------
    19 # Standard modules
    204import os
    215import time
    226import sys
    23 import random
    24 
    25 # Related major packages
    267import anuga
    278from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    2810
     11#set up the variables for the temporary data files
    2912home = os.getenv('INUNDATIONHOME')
    3013scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    3114                                     "rectanglecross"])
     15store ='store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen ='storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
     19storea = 'storea.txt'
     20file_path_storea = os.path.join(scenariodir, storea)
    3221
     22#read the matrix size(number of triangles) and the map size from these files
     23f = open(file_path_store,'r+')
     24a = int(f.readline())
     25f.close()
     26f = open(file_path_storen,'r+')
     27l = float(f.readline())
     28f.close()
    3329
    34 file = 'CAIRNS.sww'
    35 file_path = os.path.join(scenariodir, file)
     30#set up the variables for the simulation out put and log files
     31scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
     32                                       "rectanglecross", "triangles-" + str(a) +"-"+ str(l)])
     33log.log_filename = os.path.join(scenariodirV, "anuga.log")
     34log._setup = False
    3635
    37 h = 'CAIRNS.msh'
    38 file_pathh = os.path.join(scenariodir, h)
    39 
    40 
    41 def runex(l,a):
    42 
    43 
     36log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage
    4437#------------------------------------------------------------------------------
    45 # Create the triangular mesh and domain based on
    46 # overall clipping polygon with a tagged
    47 # boundary and interior regions as defined in project.py
     38# Create the triangular mesh and domain
    4839#------------------------------------------------------------------------------
    49    
    50     points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh
    51     domain = anuga.Domain(points, vertices, boundary) # Create domain
    52 
    53     number=len(domain)
    54 
    55                                
    56 #------------------------------------------------------------------------------
    57 # Setup parameters of computational domain
    58 #------------------------------------------------------------------------------
    59     domain.set_name('CAIRNS.sww') # Name of sww file
    60     domain.set_datadir(scenariodir)                       # Store sww output here
    61 
     40points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh
     41domain = anuga.Domain(points, vertices, boundary) # Create
     42domain.set_name('CAIRNS.sww') # Name of sww file
     43domain.set_datadir(scenariodirV)# Store sww output here
     44log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
    6245#------------------------------------------------------------------------------
    6346# Setup initial conditions
    6447#------------------------------------------------------------------------------
    6548
    66     def topography(x,y):
    67         return 0.0
     49#get the number of triangles
     50number=len(domain)
    6851
    69     tide = 100.0
    70     friction = 0.0
    71     domain.set_quantity('stage', tide)
    72     domain.set_quantity('friction', friction)
    73     domain.set_quantity('elevation',topography,alpha=0.1)
     52def topography(x,y):
     53    return 0.0
    7454
     55tide = 100.0
     56friction = 0.0
     57domain.set_quantity('stage', tide)
     58domain.set_quantity('friction', friction)
     59domain.set_quantity('elevation',topography,alpha=0.1)
    7560
    76 
     61log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    7762#------------------------------------------------------------------------------
    7863# Setup boundary conditions
    7964#------------------------------------------------------------------------------
     65Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
     66Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow
     67Br = anuga.Reflective_boundary(domain)
     68domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
    8069
    81     Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
    82     Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
    83     Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
    84     Br = anuga.Reflective_boundary(domain)
    85 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
    86     domain.set_boundary({'right': Bo,
    87                      'bottom': Br,
    88                      'left': Bi,
    89                      'top': Br})
    90 
     70log.resource_usage_timing(prefix='afterboundary')#get memory usage
    9171#------------------------------------------------------------------------------
    9272# Evolve system through time
    9373#------------------------------------------------------------------------------
     74for t in domain.evolve(yieldstep=120, finaltime=2000):
     75    print domain.timestepping_statistics()
    9476
    95 # Save every two mins leading up to wave approaching land
    96     for t in domain.evolve(yieldstep=120, finaltime=2000):
    97         print domain.timestepping_statistics()
    98    
    99 
    100     return number
    101 
     77log.resource_usage_timing(prefix='aftersimulation')#get memory usage
     78   
     79#write the number of triangles to the text file
     80v = open(file_path_storea, 'r+')
     81v.write(str(number))
Note: See TracChangeset for help on using the changeset viewer.