source: trunk/anuga_work/development/mem_time_tests/linearregression/area/runcairns.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: 4.7 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import os
5import time
6import sys
7import liststore
8import anuga
9from anuga_parallel import distribute, numprocs, myid
10from anuga.abstract_2d_finite_volumes.util import add_directories
11from anuga.utilities import log
12
13#set up the variables for the output data and the log files
14sidelength = float(sys.argv[3])
15timestep = float(sys.argv[1])
16finaltime2 = float(sys.argv[2])
17depth = (sidelength * sidelength * 0.0004)
18velocity = 10
19maxtrianglearea = 20
20
21home = os.getenv('INUNDATIONHOME')
22scenariodirV = add_directories(home, ["data","mem_time_test","linearregression","run", "variables-" +str(sidelength)+"-"+ str(timestep) +"-"+ str(finaltime2)])
23h = 'CAIRNS.msh'
24file_pathh = os.path.join(scenariodirV, h)
25log.log_filename = os.path.join(scenariodirV, "anuga.log")
26log._setup = False
27
28log.timingInfo(msg=('sidelength,'+str(sidelength))) #write the variable to be measured to file
29log.timingInfo(msg=('timestep,'+str(timestep))) #write the variable to be measured to file
30log.timingInfo(msg=('finaltime,'+str(finaltime2))) #write the variable to be measured to file
31log.timingInfo(msg=('depthofwater,'+str(depth))) #write the variable to be measured to file
32log.timingInfo(msg=('velocity,'+str(velocity))) #write the variable to be measured to file
33log.timingInfo(msg=('maxtrianglearea,'+str(maxtrianglearea))) #write the variable to be measured to file
34log.timingInfo(msg=('percentageofwatercover,'+str(100.0))) #write the variable to be measured to file
35log.timingInfo(msg=('extent,'+str(sidelength * sidelength))) #write the variable to be measured to file
36log.timingInfo(msg=('numberofcpus,'+str(numprocs))) #write the variable to be measured to file
37log.timingInfo(msg=('host,'+str(os.getenv('HOST')))) #write the variable to be measured to file
38
39
40log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
41
42log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage
43#------------------------------------------------------------------------------
44# Create the triangular mesh and domain on one processor
45#------------------------------------------------------------------------------
46if myid == 0:
47    domain = anuga.create_domain_from_regions([(0.0,0.0),(sidelength,sidelength),(0.0,sidelength),(sidelength,0.0)],
48                                    boundary_tags={'top': [0],
49                                                   'right': [1],
50                                                   'bottom': [2],
51                                                   'left': [3]},
52                                    maximum_triangle_area=maxtrianglearea,
53                                    mesh_filename=file_pathh
54                                    )
55    #get the number of triangles
56    n = len(domain)
57    log.timingInfo(msg=('numberoftriangles,'+str(n))) #write the variable to be measured to file
58
59else:
60    domain = None
61 
62
63#parallel   
64domain = distribute(domain)                               
65
66domain.set_name('CAIRNS.sww') # Name of sww file
67domain.set_datadir(scenariodirV)# Store sww output here
68
69log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
70log.resource_usage_timing(prefix = 'aftermesh') #get memory usage
71#------------------------------------------------------------------------------
72# Setup initial conditions
73#------------------------------------------------------------------------------
74
75def topography(x,y):
76    return 0.0
77
78domain.set_quantity('stage', depth)
79domain.set_quantity('friction', 0) 
80domain.set_quantity('elevation',topography,alpha=0.1)
81
82log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
83
84#------------------------------------------------------------------------------
85# Setup boundary conditions
86#------------------------------------------------------------------------------
87
88Bi = anuga.Dirichlet_boundary([depth, velocity, 0]) # inflow
89Bo = anuga.Dirichlet_boundary([-depth, velocity, 0]) # outflow
90Br = anuga.Reflective_boundary(domain)
91domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
92
93log.resource_usage_timing(prefix='afterboundary')#get memory usage
94#------------------------------------------------------------------------------
95# Evolve system through time
96#------------------------------------------------------------------------------
97for t in domain.evolve(yieldstep=timestep, finaltime=finaltime2): 
98    print domain.timestepping_statistics()
99
100log.resource_usage_timing(prefix='aftersimulation') #get memory usage
101log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation
102
Note: See TracBrowser for help on using the repository browser.