source: trunk/anuga_work/development/mem_time_tests/triangles/fromregions/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.7 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import os
5import time
6import sys
7import anuga
8from anuga.abstract_2d_finite_volumes.util import add_directories
9from anuga.utilities import log
10
11#set up the variables for the simulation output and the log files
12a = sys.argv[1]
13l = float(sys.argv[2])
14
15home = os.getenv('INUNDATIONHOME')
16scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
17                                       "fromregions", "triangles-" + str(a) +"-"+ str(l)])
18h = 'CAIRNS.msh'
19file_pathh = os.path.join(scenariodirV, h)
20log._setup = False
21log.log_filename = os.path.join(scenariodirV, "anuga.log")
22
23log.timingInfo(msg=('trianglearea,'+str(a))) #write the variable to be measured to file
24log.timingInfo(msg=('extent,'+str(l**2))) #write the variable to be measured to file
25
26log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
27
28log.resource_usage_timing(prefix = 'beforesimulation') #get memory usage
29#------------------------------------------------------------------------------
30# Create the triangular mesh and domain
31#------------------------------------------------------------------------------
32domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
33                                    boundary_tags={'top': [0],
34                                                   'right': [1],
35                                                   'bottom': [2],
36                                                   'left': [3]},
37                                    maximum_triangle_area=a,
38                                    mesh_filename=file_pathh
39                                    )                           
40domain.set_name('CAIRNS.sww') # Name of sww file
41domain.set_datadir(scenariodirV)# Store sww output here
42log.resource_usage_timing(prefix = 'aftermesh') #get memory usage
43log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation
44#------------------------------------------------------------------------------
45# Setup initial conditions
46#------------------------------------------------------------------------------
47
48#get the number of triangles
49number=len(domain)
50log.timingInfo(msg=('numberoftriangles,'+str(number))) #write the variable to be measured to file
51
52def topography(x,y):
53    return 0.0
54
55tide = 100.0
56friction = 0.0
57domain.set_quantity('stage', tide)
58domain.set_quantity('friction', friction) 
59domain.set_quantity('elevation',topography,alpha=0.1)
60
61log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
62
63#------------------------------------------------------------------------------
64# Setup boundary conditions
65#------------------------------------------------------------------------------
66Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
67Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
68Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
69Br = anuga.Reflective_boundary(domain)
70domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
71
72log.resource_usage_timing(prefix='afterboundary')#get memory usage
73#------------------------------------------------------------------------------
74# Evolve system through time
75#------------------------------------------------------------------------------
76for t in domain.evolve(yieldstep=120, finaltime=2000): 
77    print domain.timestepping_statistics()
78 
79log.resource_usage_timing(prefix='aftersimulation')#get memory usage
80log.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.