source: trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/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.2 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.timingInfo(msg=('length,'+str(length))) #write the variable to be measured to file
22log.timingInfo(msg=('stepplace,'+str(lower))) #write the variable to be measured to file
23log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
24
25log.resource_usage_timing(prefix = 'beforesimulation')#get memory usage
26#------------------------------------------------------------------------------
27# Setup computational domain
28#------------------------------------------------------------------------------
29points, vertices, boundary = anuga.rectangular_cross(100,300,len1=length, len2=length) # Mesh
30domain = anuga.Domain(points, vertices, boundary) # Create domain
31domain.set_datadir(scenariodirV) 
32domain.set_name('channel1.sww') # Output name
33
34log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
35log.resource_usage_timing(prefix = 'aftermesh') #get memory usage
36#--------------------------------------------------------------------------
37# Setup Initial Conditions
38#--------------------------------------------------------------------------
39def topography(x, y):
40    z = 0
41    N = len(x)
42   
43    #makes a step
44    for i in range(N):
45
46        if y[i] > lower:
47           z[i] += 1
48             
49    return  z
50
51domain.set_quantity('elevation', topography) # Use function for elevation
52domain.set_quantity('friction', 0.01) # Constant friction
53domain.set_quantity('stage', -10000000000000000000000.0)
54
55log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
56#------------------------------------------------------------------------------
57# Setup boundary conditions
58#------------------------------------------------------------------------------
59Bi = anuga.Dirichlet_boundary([0.5, 10, 0]) # Inflow
60Bo = anuga.Dirichlet_boundary([-0.5,0,0]) #outflow
61Br = anuga.Reflective_boundary(domain) # Solid reflective wall
62domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
63
64log.resource_usage_timing(prefix='afterboundary')#get memory usage
65#------------------------------------------------------------------------------
66# Evolve system through time
67#------------------------------------------------------------------------------
68for t in domain.evolve(yieldstep=120, finaltime=3600):
69    domain.write_time()
70
71log.resource_usage_timing(prefix='aftersimulation') #get memory usage
72log.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.