source: trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py @ 8326

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

formatted the experiment scripts

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4# Import standard shallow water domain and standard boundaries.
5import anuga
6import time
7import random
8import os
9from anuga.abstract_2d_finite_volumes.util import add_directories
10from anuga.utilities import log
11
12#set up the variables for the temporary file directories
13home = os.getenv('INUNDATIONHOME')
14scenariodir = add_directories(home, ["data","mem_time_test", "parameters","timestep"])
15
16store ='store.txt'
17file_path_store = os.path.join(scenariodir, store)
18
19s = open(file_path_store,'r+') # read the timestep from the text file
20f = float(s.readline())
21s.close()
22
23#set up the variables for the log files and data directories
24scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
25                                       "timestep", "timestep-" + str(f)])
26log.log_filename = os.path.join(scenariodirV, "anuga.log")
27log._setup = False
28
29log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
30#------------------------------------------------------------------------------
31# Setup computational domain
32#------------------------------------------------------------------------------
33points, vertices, boundary = anuga.rectangular_cross(10,5,len1=10.0, len2=5.0) # Mesh
34domain = anuga.Domain(points, vertices, boundary) # Create domain
35domain.set_name('channel1') # Output name
36domain.set_datadir(scenariodirV) 
37
38log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
39#------------------------------------------------------------------------------
40# Setup initial conditions
41#------------------------------------------------------------------------------
42def topography(x, y):
43    return -x/10 # linear bed slope
44domain.set_quantity('elevation', topography) # Use function for elevation
45domain.set_quantity('friction', 0.01) # Constant friction
46domain.set_quantity('stage', expression='elevation')
47
48log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
49
50#------------------------------------------------------------------------------
51# Setup boundary conditions
52#------------------------------------------------------------------------------
53Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
54Br = anuga.Reflective_boundary(domain) # Solid reflective wall
55domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
56
57log.resource_usage_timing(prefix='afterboundary') #get memory usage here
58#------------------------------------------------------------------------------
59# Evolve system through time
60#------------------------------------------------------------------------------
61for t in domain.evolve(yieldstep=f, finaltime=40.0):
62    print domain.timestepping_statistics()
63
64log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
65
Note: See TracBrowser for help on using the repository browser.