source: trunk/anuga_work/development/mem_time_tests/triangles/fromregions/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.8 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import os
5import time
6import sys
7import random
8import anuga
9from anuga.abstract_2d_finite_volumes.util import add_directories
10from anuga.utilities import log
11
12# set up the variables for the temporary files
13home = os.getenv('INUNDATIONHOME')
14scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
15                                     "fromregions"])
16store ='store.txt'
17file_path_store = os.path.join(scenariodir, store)
18storen ='storen.txt'
19file_path_storen = os.path.join(scenariodir, storen)
20storea = 'storea.txt'
21file_path_storea = os.path.join(scenariodir, storea)
22
23#read the maximum triangle area and map side length from the text files
24f = open(file_path_store,'r+')
25a = float(f.readline())
26f.close()
27f = open(file_path_storen,'r+')
28l = float(f.readline())
29f.close()
30
31#set up the variables for the simulation output and the log files
32scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
33                                       "fromregions", "triangles-" + str(a) +"-"+ str(l)])
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
42#------------------------------------------------------------------------------
43domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
44                                    boundary_tags={'top': [0],
45                                                   'right': [1],
46                                                   'bottom': [2],
47                                                   'left': [3]},
48                                    maximum_triangle_area=a,
49                                    mesh_filename=file_pathh
50                                    )                           
51domain.set_name('CAIRNS.sww') # Name of sww file
52domain.set_datadir(scenariodirV)# Store sww output here
53log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
54#------------------------------------------------------------------------------
55# Setup initial conditions
56#------------------------------------------------------------------------------
57
58#get the number of triangles
59number=len(domain)
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#------------------------------------------------------------------------------
75Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
76Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
77Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
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
89 
90#write the number of triangles to file
91i = open(file_path_storea, 'r+')
92i.write(str(number))
Note: See TracBrowser for help on using the repository browser.