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

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

formatted the experiment scripts

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