source: trunk/anuga_work/development/mem_time_tests/NCIparallel/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: 5.2 KB
Line 
1"""Script for running a tsunami inundation scenario for Cairns, QLD Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in directory named after the scenario, i.e
6slide or fixed_wave.
7
8The scenario is defined by a triangular mesh created from project.polygon,
9the elevation data and a tsunami wave generated by a submarine mass failure.
10
11Geoscience Australia, 2004-present
12"""
13
14#------------------------------------------------------------------------------
15# Import necessary modules
16#------------------------------------------------------------------------------
17# Standard modules
18import os
19import time
20import sys
21import liststore
22
23# Related major packages
24import anuga
25from anuga_parallel import distribute, myid
26from anuga.abstract_2d_finite_volumes.util import add_directories
27from anuga.utilities import system_tools, log
28
29
30home2 = os.getenv('INUNDATIONHOME')
31
32scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "logarea"])
33
34h = 'CAIRNS.msh'
35file_pathh = os.path.join(scenariodir2, h)
36store ='store.txt'
37file_path_store = os.path.join(scenariodir2, store)
38storen ='storen.txt'
39file_path_storen = os.path.join(scenariodir2, storen)
40storel = 'storel.txt'
41file_path_storel = os.path.join(scenariodir2, storel)
42storea = 'storea.txt'
43file_path_storea = os.path.join(scenariodir2, storea)
44
45f = open(file_path_storel,'r+') # SQRT extent this is set
46length = float(f.readline())
47f.close()
48
49f = open(file_path_storea,'r+') #maxarea this is set
50area = float(f.readline())
51f.close()
52
53scenariodirV = add_directories(home2, ["data","mem_time_test", "triangles",
54                                       "logarea", "triangles-" + str(area) +"-"+ str(length)])
55
56h = 'CAIRNS.msh'
57file_pathh = os.path.join(scenariodirV, h)
58
59log.log_filename = os.path.join(scenariodirV, "anuga.log")
60log._setup = False
61
62log.resource_usage_timing(prefix = 'BeforeSimulation')
63#------------------------------------------------------------------------------
64# Create the triangular mesh and domain based on
65# overall clipping polygon with a tagged
66# boundary and interior regions as defined in project.py
67#------------------------------------------------------------------------------
68if myid == 0:
69    domain = anuga.create_domain_from_regions([(0.0,0.0),(length,length),(0.0,length),(length,0.0)],
70                                    boundary_tags={'top': [0],
71                                                   'right': [1],
72                                                   'bottom': [2],
73                                                   'left': [3]},
74                                    maximum_triangle_area=area,
75                                    mesh_filename=file_pathh
76                                    #,interior_regions=INTERIORREGIONS#,
77                                    #use_cache=True,
78                                    #verbose=True)
79                                    )
80
81    n = len(domain)
82else:
83    domain = None
84
85log.resource_usage_timing(prefix = 'AfterMesh')     
86domain = distribute(domain)
87                               
88#------------------------------------------------------------------------------
89# Setup parameters of computational domain
90#------------------------------------------------------------------------------
91domain.set_name('CAIRNS.sww') # Name of sww file
92domain.set_datadir(scenariodirV)                       # Store sww output here
93
94#------------------------------------------------------------------------------
95# Setup initial conditions
96#------------------------------------------------------------------------------
97
98def topography(x,y):
99    return 0.0
100log.resource_usage_timing(prefix='beforeinitialconditions')
101tide = 100.0
102friction = 0.0
103domain.set_quantity('stage', tide)
104domain.set_quantity('friction', friction) 
105domain.set_quantity('elevation',topography,alpha=0.1)
106log.resource_usage_timing(prefix='afterinitialconditions')
107
108
109#------------------------------------------------------------------------------
110# Setup boundary conditions
111#------------------------------------------------------------------------------
112
113Bi = anuga.Dirichlet_boundary([tide, 0, 0]) # inflow
114Bo = anuga.Dirichlet_boundary([-tide,0, 0]) # inflow
115Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
116Br = anuga.Reflective_boundary(domain)
117#Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
118domain.set_boundary({'right': Bo,
119                     'bottom': Br,
120                     'left': Bi,
121                     'top': Br})
122
123log.resource_usage_timing(prefix='afterboundary')
124#------------------------------------------------------------------------------
125# Evolve system through time
126#------------------------------------------------------------------------------
127
128# Save every two mins leading up to wave approaching land
129#for t in domain.evolve(yieldstep=500, finaltime=2000):
130#    print domain.timestepping_statistics()
131   
132
133#liststore.store[myid] = system_tools.MemoryUpdate()[0]
134#a = sum(liststore.store)
135
136a = 1
137v = open(file_path_store, 'r+')
138v.write(str(a))
139
140i = open(file_path_storen, 'r+')
141i.write(str(n))
142
143
Note: See TracBrowser for help on using the repository browser.