source: trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py @ 8342

Last change on this file since 8342 was 8342, checked in by pittj, 13 years ago

all variables now have the correct name

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