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

Last change on this file since 8427 was 8427, checked in by davies, 13 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 2.9 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=('runnumber,'+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
33log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
34
35#------------------------------------------------------------------------------
36# Setup initial conditions
37#------------------------------------------------------------------------------
38def topography(x, y):
39    return -x/10 # linear bed slope
40domain.set_quantity('elevation', topography) # Use function for elevation
41domain.set_quantity('friction', 0.01) # Constant friction
42domain.set_quantity('stage',expression='elevation')
43log.resource_usage_timing(prefix='afterinitialconditions')
44
45#------------------------------------------------------------------------------
46# Setup boundary conditions
47#------------------------------------------------------------------------------
48Bi = anuga.Dirichlet_boundary([400, 0, 0]) # Inflow
49Br = anuga.Reflective_boundary(domain) # Solid reflective wall
50domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
51
52log.resource_usage_timing(prefix='afterboundary')  #get memory usage here
53#------------------------------------------------------------------------------
54# Evolve system through time
55#------------------------------------------------------------------------------
56for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
57    print domain.timestepping_statistics()
58
59log.resource_usage_timing(prefix='aftersimulation')  #get memory usage here
60log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation
61
Note: See TracBrowser for help on using the repository browser.