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/scenarios/stage/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
     
    117import os
    128from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    1310
     11#set up the variables for the temporary data storage
    1412home = os.getenv('INUNDATIONHOME')
    1513scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    1614                                     "stage"])
     15store = 'store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen = 'storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
    1719
     20#read the values from the text files
     21f = open(file_path_store,'r+')
     22l = float(f.readline())
     23f.close()
     24f = open(file_path_storen,'r+')
     25tide = float(f.readline())
     26f.close()
    1827
     28#set up variables to store the output of the simulation and the log files
     29scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
     30                                       "stage", "stage-" + str(tide) +"-"+ str(l)])
     31log.log_filename = os.path.join(scenariodirV, "anuga.log")
     32log._setup = False
    1933
     34log.resource_usage_timing(prefix = 'BeforeSimulation')# get memory usage
    2035#------------------------------------------------------------------------------
    2136# Setup computational domain
    2237#------------------------------------------------------------------------------
    23 def runex(l,tide):
     38points, vertices, boundary = anuga.rectangular_cross(100,300,
     39                                                     len1=l, len2=(l/2)) # Mesh
     40domain = anuga.Domain(points, vertices, boundary) # Create domain
     41domain.set_datadir(scenariodirV)
     42domain.set_name('channel1') # Output name
    2443
    25    points, vertices, boundary = anuga.rectangular_cross(50,50,
    26                                                      len1=l, len2=(l/2)) # Mesh
    27 
     44log.resource_usage_timing(prefix = 'AfterMesh')# get memory usage
    2845
    2946#--------------------------------------------------------------------------
    30 # Setup Domain only on processor 0
     47# Setup initial conditions
    3148#--------------------------------------------------------------------------
     49def topography(x, y):
     50    return  0 #flat land
     51domain.set_quantity('elevation', topography) # Use function for elevation
     52domain.set_quantity('friction', 0.01) # Constant friction
     53domain.set_quantity('stage', tide)
    3254
    33    domain = anuga.Domain(points, vertices, boundary) # Create domain
    34    domain.set_datadir(scenariodir)
    35    domain.set_name('channel1') # Output name
    36 
    37    def topography(x, y):
    38        return  0 #-x/10  linear bed slope
    39    domain.set_quantity('elevation', topography) # Use function for elevation
    40    domain.set_quantity('friction', 0.01) # Constant friction
    41    domain.set_quantity('stage', tide)
    42    
     55log.resource_usage_timing(prefix='afterinitialconditions') # get memory usage
    4356
    4457#------------------------------------------------------------------------------
    4558# Setup boundary conditions
    4659#------------------------------------------------------------------------------
    47 #Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    48    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    49    domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
     60Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     61domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
     62
     63log.resource_usage_timing(prefix='afterboundary')# get memory usage
    5064
    5165#------------------------------------------------------------------------------
    5266# Evolve system through time
    5367#------------------------------------------------------------------------------
    54    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    55        domain.write_time()
     68for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     69    domain.write_time()
    5670
    57 #domain.sww_merge()
    58 #finalize()
    59 
     71log.resource_usage_timing(prefix='aftersimulation')# get memory usage
Note: See TracChangeset for help on using the changeset viewer.