source: trunk/anuga_work/development/mem_time_tests/parameters/nothing/ex1.py @ 8331

Last change on this file since 8331 was 8331, checked in by pittj, 12 years ago

update for the new experiments

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import time
6import os
7import sys
8from anuga.utilities import log
9from anuga.abstract_2d_finite_volumes.util import add_directories
10
11#set up the variables to correctly store the output data and log file
12n = sys.argv[1]
13home = os.getenv('INUNDATIONHOME')
14scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
15                                     "nothing","nothing"+"-"+str(n)])
16
17log.log_filename = os.path.join(scenariodirV, "anuga.log")
18log._setup = False
19
20log.timingInfo(msg=('variable1,'+str(n))) #write the variable to be measured to file
21log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
22log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage here
23#------------------------------------------------------------------------------
24# Setup computational domain
25#------------------------------------------------------------------------------
26points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
27domain = anuga.Domain(points, vertices, boundary) # Create domain
28
29domain.set_name('channel1') # Output name
30domain.set_datadir(scenariodirV) 
31
32log.resource_usage_timing(prefix = 'aftermesh')  #get memory usage here
33
34#------------------------------------------------------------------------------
35# Setup initial conditions
36#------------------------------------------------------------------------------
37def topography(x, y):
38    return -x/10 # linear bed slope
39domain.set_quantity('elevation', topography) # Use function for elevation
40domain.set_quantity('friction', 0.01) # Constant friction
41domain.set_quantity('stage',expression='elevation')
42log.resource_usage_timing(prefix='afterinitialconditions')
43
44#------------------------------------------------------------------------------
45# Setup boundary conditions
46#------------------------------------------------------------------------------
47Bi = anuga.Dirichlet_boundary([400, 0, 0]) # Inflow
48Br = anuga.Reflective_boundary(domain) # Solid reflective wall
49domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
50
51log.resource_usage_timing(prefix='afterboundary')  #get memory usage here
52#------------------------------------------------------------------------------
53# Evolve system through time
54#------------------------------------------------------------------------------
55for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
56    print domain.timestepping_statistics()
57
58log.resource_usage_timing(prefix='aftersimulation')  #get memory usage here
59log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation
Note: See TracBrowser for help on using the repository browser.