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/vel2/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 files
    1412home = os.getenv('INUNDATIONHOME')
    15 scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    16                                      "serial"])
     13scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
     14                                     "velocity"])
     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)
    1721
     22# read the velocity and the map side length from the text files
     23f = open(file_path_store,'r+')
     24k = float(f.readline())
     25f.close()
     26f = open(file_path_storen,'r+')
     27l = float(f.readline())
     28f.close()
     29
     30#set up variables for the simulation output and the log files
     31scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
     32                                       "velocity", "velocity-" + str(k) +"-"+ str(l)])
     33log.log_filename = os.path.join(scenariodirV, "anuga.log")
     34log._setup = False
     35
     36log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
    1837#------------------------------------------------------------------------------
    1938# Setup computational domain
    2039#------------------------------------------------------------------------------
    21 def runex(k,l):
     40points, vertices, boundary = anuga.rectangular_cross(100,300, len1=1000, len2=500) # Mesh
     41domain = anuga.Domain(points, vertices, boundary) # Create domain
     42domain.set_name('channel1') # Output name
     43domain.set_datadir(scenariodirV)
    2244
    23    points, vertices, boundary = anuga.rectangular_cross(100,100,
    24                                                        len1=l, len2=l) # Mesh
     45log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage
     46
     47#get the number of triangles
     48number = len(domain)
    2549
    2650#--------------------------------------------------------------------------
    27 # Setup Domain only on processor 0
     51# Setup initial conditions
    2852#--------------------------------------------------------------------------
    29    domain = anuga.Domain(points, vertices, boundary) # Create domain
    30    domain.set_name('channel1') # Output name
    31    domain.set_datadir(scenariodir)
    32    
    33    number = len(domain)
     53def topography(x, y):
     54    return  0.0
     55domain.set_quantity('elevation', topography) # Use function for elevation
     56domain.set_quantity('friction', 0.01) # Constant friction
     57domain.set_quantity('stage', -1000.0)
    3458
    35    def topography(x, y):
    36        return  0.0
    37 
    38    domain.set_quantity('elevation', topography) # Use function for elevation
    39    domain.set_quantity('friction', 0.01) # Constant friction
    40    domain.set_quantity('stage', -1000.0)
     59log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    4160
    4261#------------------------------------------------------------------------------
    4362# Setup boundary conditions
    4463#------------------------------------------------------------------------------
    45    Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow
    46    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    47    Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
    48    domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
     64Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow
     65Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     66Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
     67domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
     68
     69log.resource_usage_timing(prefix='afterboundary')#get memory usage
    4970
    5071#------------------------------------------------------------------------------
    5172# Evolve system through time
    5273#------------------------------------------------------------------------------
    53    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    54        domain.write_time()
     74for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     75    domain.write_time()
    5576
    56    return number
     77log.resource_usage_timing(prefix='aftersimulation')  #get memory usage
    5778
     79#write the number of triangles to the file
     80c = open(file_path_storea,'r+')
     81c.write(str(number))
Note: See TracChangeset for help on using the changeset viewer.