source: trunk/anuga_work/development/mem_time_tests/scenarios/stage/ex1.py @ 8328

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

metalog and ex1 merge added, code is now correct across all major experiments

  • Property svn:executable set to *
File size: 2.5 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 to store the output of the simulation and the log files
12l = float(sys.argv[1])
13tide = sys.argv[2]
14
15home = os.getenv('INUNDATIONHOME')
16scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
17                                       "stage", "stage-" + str(tide) +"-"+ str(l)])
18log.log_filename = os.path.join(scenariodirV, "anuga.log")
19log._setup = False
20
21log.resource_usage_timing(prefix = 'BeforeSimulation')# get memory usage
22#------------------------------------------------------------------------------
23# Setup computational domain
24#------------------------------------------------------------------------------
25points, vertices, boundary = anuga.rectangular_cross(100,300,
26                                                     len1=l, len2=(l/2.0)) # Mesh
27domain = anuga.Domain(points, vertices, boundary) # Create domain
28domain.set_datadir(scenariodirV) 
29domain.set_name('channel1') # Output name
30
31log.resource_usage_timing(prefix = 'AfterMesh')# get memory usage
32
33#--------------------------------------------------------------------------
34# Setup initial conditions
35#--------------------------------------------------------------------------
36def topography(x, y):
37    return  0 #flat land
38domain.set_quantity('elevation', topography) # Use function for elevation
39domain.set_quantity('friction', 0.01) # Constant friction
40domain.set_quantity('stage', tide)
41
42log.resource_usage_timing(prefix='afterinitialconditions') # get memory usage
43
44#------------------------------------------------------------------------------
45# Setup boundary conditions
46#------------------------------------------------------------------------------
47Br = anuga.Reflective_boundary(domain) # Solid reflective wall
48domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
49
50log.resource_usage_timing(prefix='afterboundary')# get memory usage
51
52#------------------------------------------------------------------------------
53# Evolve system through time
54#------------------------------------------------------------------------------
55for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
56    domain.write_time()
57
58log.resource_usage_timing(prefix='aftersimulation')# get memory usage
Note: See TracBrowser for help on using the repository browser.