source: trunk/anuga_work/development/mem_time_tests/hardware/template/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: 3.9 KB
Line 
1"""
2This experiment was based heavily on the cairns demo given in the user manual and found in
3the anuga repository.
4
5However, it has been simplified so that it doesnt require all the files the cairns demo does
6"""
7
8#------------------------------------------------------------------------------
9# Import necessary modules
10#------------------------------------------------------------------------------
11import os
12import time
13import sys
14import anuga
15from anuga_parallel import distribute, myid, numprocs
16from anuga.abstract_2d_finite_volumes.util import add_directories
17from anuga.utilities import log
18
19#set up variables for the correct I/O directories for data storage
20home = os.getenv('INUNDATIONHOME')
21scenariodirV = add_directories(home, ["data","mem_time_test", "parallel",
22                                       "template", "template-" + str(numprocs) +"-"+ str(myid)])
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=('numberofcpus,'+str(numprocs))) #write the variable to be measured to file
29log.timingInfo(msg=('myid,'+str(myid))) #write the variable to be measured to file
30
31log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
32
33log.resource_usage_timing(prefix = 'beforesimulation')#get memory statistics here
34#------------------------------------------------------------------------------
35#Create the domain and mesh for the resource experiment on only one processor
36#------------------------------------------------------------------------------
37
38if myid == 0:
39    domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)],
40                                    boundary_tags={'top': [0],
41                                                   'right': [1],
42                                                   'bottom': [2],
43                                                   'left': [3]},
44                                    maximum_triangle_area=100.0,
45                                    mesh_filename=file_pathh)
46else:
47    domain = None
48
49#parallel   
50domain = distribute(domain)
51domain.set_name('CAIRNS') # Name of sww file
52domain.set_datadir(scenariodirV)# Store sww output here
53
54log.resource_usage_timing(prefix = 'aftermesh')#get memory statistics here
55log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
56
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 statistics here
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]) # inflow
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 statistics here
82#------------------------------------------------------------------------------
83# Evolve system through time
84#------------------------------------------------------------------------------
85for t in domain.evolve(yieldstep=2000, finaltime=2000): 
86    print domain.timestepping_statistics()
87
88log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here
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.