source: trunk/anuga_work/development/mem_time_tests/scenarios/vel2/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: 3.1 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import time
6import sys
7import os
8from anuga.abstract_2d_finite_volumes.util import add_directories
9from anuga.utilities import log
10
11#set up variables for the simulation output and the log files
12k= sys.argv[1]
13l= float(sys.argv[2])
14
15home = os.getenv('INUNDATIONHOME')
16scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
17                                       "velocity", "velocity-" + str(k) +"-"+ str(l)])
18
19log.timingInfo(msg=('velocity,'+str(k))) #write the variable to be measured to file
20log.timingInfo(msg=('extent,'+str(l**2))) #write the variable to be measured to file
21log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
22
23log.log_filename = os.path.join(scenariodirV, "anuga.log")
24log._setup = False
25
26log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage
27#------------------------------------------------------------------------------
28# Setup computational domain
29#------------------------------------------------------------------------------
30points, vertices, boundary = anuga.rectangular_cross(100,300, len1=1000, len2=500) # Mesh
31domain = anuga.Domain(points, vertices, boundary) # Create domain
32domain.set_name('channel1') # Output name
33domain.set_datadir(scenariodirV) 
34
35log.resource_usage_timing(prefix = 'aftermesh')  #get memory usage
36log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
37
38#get the number of triangles
39number = len(domain)
40log.timingInfo(msg=('numberoftriangles'+str(number))) #write the variable to be measured to file
41
42#--------------------------------------------------------------------------
43# Setup initial conditions
44#--------------------------------------------------------------------------
45def topography(x, y):
46    return  0.0
47domain.set_quantity('elevation', topography) # Use function for elevation
48domain.set_quantity('friction', 0.01) # Constant friction
49domain.set_quantity('stage', -1000.0)
50
51log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
52
53#------------------------------------------------------------------------------
54# Setup boundary conditions
55#------------------------------------------------------------------------------
56Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow
57Br = anuga.Reflective_boundary(domain) # Solid reflective wall
58Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
59domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
60
61log.resource_usage_timing(prefix='afterboundary')#get memory usage
62
63#------------------------------------------------------------------------------
64# Evolve system through time
65#------------------------------------------------------------------------------
66for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
67    domain.write_time()
68
69log.resource_usage_timing(prefix='aftersimulation')  #get memory usage
70log.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.