source: trunk/anuga_work/development/mem_time_tests/triangles/fromregions/runcairns.py @ 8328

Last change on this file since 8328 was 8328, checked in by pittj, 12 years ago

metalog and ex1 merge added, code is now correct across all major experiments

  • Property svn:executable set to *
File size: 3.5 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 temporary files
12home = os.getenv('INUNDATIONHOME')
13scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
14                                     "fromregions"])
15storea = 'storea.txt'
16file_path_storea = os.path.join(scenariodir, storea)
17
18
19#set up the variables for the simulation output and the log files
20a = sys.argv[1]
21l = sys.argv[2]
22
23scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
24                                       "fromregions", "triangles-" + str(a) +"-"+ str(l)])
25h = 'CAIRNS.msh'
26file_pathh = os.path.join(scenariodirV, h)
27log._setup = False
28log.log_filename = os.path.join(scenariodirV, "anuga.log")
29
30log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
31#------------------------------------------------------------------------------
32# Create the triangular mesh and domain
33#------------------------------------------------------------------------------
34domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
35                                    boundary_tags={'top': [0],
36                                                   'right': [1],
37                                                   'bottom': [2],
38                                                   'left': [3]},
39                                    maximum_triangle_area=a,
40                                    mesh_filename=file_pathh
41                                    )                           
42domain.set_name('CAIRNS.sww') # Name of sww file
43domain.set_datadir(scenariodirV)# Store sww output here
44log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
45#------------------------------------------------------------------------------
46# Setup initial conditions
47#------------------------------------------------------------------------------
48
49#get the number of triangles
50number=len(domain)
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
80 
81#write the number of triangles to file
82i = open(file_path_storea, 'r+')
83i.write(str(number))
Note: See TracBrowser for help on using the repository browser.