source: trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/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.7 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 experiment data and the log file
12length = sys.argv[1]
13lower = sys.argv[2]
14
15home = os.getenv('INUNDATIONHOME')
16scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
17                                       "channelflow", "channelflow-" + str(lower) +"-"+ str(length)])
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(50,150,len1=length, len2=length) # Mesh
26domain = anuga.Domain(points, vertices, boundary) # Create domain
27domain.set_datadir(scenariodirV) 
28domain.set_name('channel1.sww') # Output name
29
30log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
31#--------------------------------------------------------------------------
32# Setup Initial Conditions
33#--------------------------------------------------------------------------
34def topography(x, y):
35    z = -x/10
36    N = len(x)
37   
38    #makes a step
39    for i in range(N):
40
41        if y[i] > lower:
42           z[i] += 1
43             
44    return  z
45
46domain.set_quantity('elevation', topography) # Use function for elevation
47domain.set_quantity('friction', 0.01) # Constant friction
48domain.set_quantity('stage', -10000000000000000000000.0)
49
50log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
51#------------------------------------------------------------------------------
52# Setup boundary conditions
53#------------------------------------------------------------------------------
54Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow
55Bo = anuga.Dirichlet_boundary([-100,0,0]) 
56Br = anuga.Reflective_boundary(domain) # Solid reflective wall
57domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
58
59log.resource_usage_timing(prefix='afterboundary')#get memory usage
60#------------------------------------------------------------------------------
61# Evolve system through time
62#------------------------------------------------------------------------------
63for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
64    domain.write_time()
65
66log.resource_usage_timing(prefix='aftersimulation') #get memory usage
Note: See TracBrowser for help on using the repository browser.