1 | """ |
---|
2 | This experiment was based heavily on the cairns demo given in the user manual and found in |
---|
3 | the anuga repository. |
---|
4 | |
---|
5 | However, it has been simplified so that it doesnt require all the files the cairns demo does |
---|
6 | """ |
---|
7 | |
---|
8 | #------------------------------------------------------------------------------ |
---|
9 | # Import necessary modules |
---|
10 | #------------------------------------------------------------------------------ |
---|
11 | import os |
---|
12 | import time |
---|
13 | import sys |
---|
14 | import anuga |
---|
15 | from anuga_parallel import distribute, myid, numprocs |
---|
16 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
17 | from anuga.utilities import log |
---|
18 | |
---|
19 | #set up variables for the correct I/O directories for data storage |
---|
20 | home = os.getenv('INUNDATIONHOME') |
---|
21 | scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "template"]) |
---|
22 | scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", |
---|
23 | "template", "template-" + str(numprocs) +"-"+ str(myid)]) |
---|
24 | h = 'CAIRNS.msh' |
---|
25 | file_pathh = os.path.join(scenariodirV, h) |
---|
26 | log.log_filename = os.path.join(scenariodirV, "anuga.log") |
---|
27 | log._setup = False |
---|
28 | |
---|
29 | log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics here |
---|
30 | #------------------------------------------------------------------------------ |
---|
31 | #Create the domain and mesh for the resource experiment on only one processor |
---|
32 | #------------------------------------------------------------------------------ |
---|
33 | |
---|
34 | if myid == 0: |
---|
35 | domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)], |
---|
36 | boundary_tags={'top': [0], |
---|
37 | 'right': [1], |
---|
38 | 'bottom': [2], |
---|
39 | 'left': [3]}, |
---|
40 | maximum_triangle_area=100.0, |
---|
41 | mesh_filename=file_pathh) |
---|
42 | else: |
---|
43 | domain = None |
---|
44 | |
---|
45 | #parallel |
---|
46 | domain = distribute(domain) |
---|
47 | domain.set_name('CAIRNS') # Name of sww file |
---|
48 | domain.set_datadir(scenariodirV)# Store sww output here |
---|
49 | log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics here |
---|
50 | |
---|
51 | #------------------------------------------------------------------------------ |
---|
52 | # Setup initial conditions |
---|
53 | #------------------------------------------------------------------------------ |
---|
54 | |
---|
55 | def topography(x,y): |
---|
56 | return 0.0 |
---|
57 | |
---|
58 | tide = 100.0 |
---|
59 | friction = 0.0 |
---|
60 | domain.set_quantity('stage', tide) |
---|
61 | domain.set_quantity('friction', friction) |
---|
62 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
63 | |
---|
64 | log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here |
---|
65 | |
---|
66 | #------------------------------------------------------------------------------ |
---|
67 | # Setup boundary conditions |
---|
68 | #------------------------------------------------------------------------------ |
---|
69 | |
---|
70 | Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow |
---|
71 | Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow |
---|
72 | Br = anuga.Reflective_boundary(domain) |
---|
73 | domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) |
---|
74 | |
---|
75 | log.resource_usage_timing(prefix='afterboundary') #get memory statistics here |
---|
76 | #------------------------------------------------------------------------------ |
---|
77 | # Evolve system through time |
---|
78 | #------------------------------------------------------------------------------ |
---|
79 | for t in domain.evolve(yieldstep=120, finaltime=2000): |
---|
80 | print domain.timestepping_statistics() |
---|
81 | |
---|
82 | log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here |
---|