[8326] | 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 | |
---|
[8311] | 8 | #------------------------------------------------------------------------------ |
---|
| 9 | # Import necessary modules |
---|
| 10 | #------------------------------------------------------------------------------ |
---|
| 11 | import os |
---|
| 12 | import time |
---|
| 13 | import sys |
---|
[8326] | 14 | import anuga |
---|
| 15 | from anuga_parallel import distribute, myid, numprocs |
---|
[8311] | 16 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
[8326] | 17 | from anuga.utilities import log |
---|
[8311] | 18 | |
---|
[8326] | 19 | #set up variables for the correct I/O directories for data storage |
---|
| 20 | home = os.getenv('INUNDATIONHOME') |
---|
| 21 | scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", |
---|
| 22 | "template", "template-" + str(numprocs) +"-"+ str(myid)]) |
---|
| 23 | h = 'CAIRNS.msh' |
---|
| 24 | file_pathh = os.path.join(scenariodirV, h) |
---|
| 25 | log.log_filename = os.path.join(scenariodirV, "anuga.log") |
---|
| 26 | log._setup = False |
---|
[8311] | 27 | |
---|
[8342] | 28 | log.timingInfo(msg=('numberofcpus,'+str(numprocs))) #write the variable to be measured to file |
---|
| 29 | log.timingInfo(msg=('myid,'+str(myid))) #write the variable to be measured to file |
---|
[8331] | 30 | |
---|
| 31 | log.timingInfo(msg=('beforetime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
| 32 | |
---|
| 33 | log.resource_usage_timing(prefix = 'beforesimulation')#get memory statistics here |
---|
[8311] | 34 | #------------------------------------------------------------------------------ |
---|
[8326] | 35 | #Create the domain and mesh for the resource experiment on only one processor |
---|
[8311] | 36 | #------------------------------------------------------------------------------ |
---|
[8326] | 37 | |
---|
[8311] | 38 | if myid == 0: |
---|
| 39 | domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)], |
---|
| 40 | boundary_tags={'top': [0], |
---|
| 41 | 'right': [1], |
---|
| 42 | 'bottom': [2], |
---|
| 43 | 'left': [3]}, |
---|
| 44 | maximum_triangle_area=100.0, |
---|
[8326] | 45 | mesh_filename=file_pathh) |
---|
[8311] | 46 | else: |
---|
| 47 | domain = None |
---|
[8326] | 48 | |
---|
| 49 | #parallel |
---|
| 50 | domain = distribute(domain) |
---|
[8311] | 51 | domain.set_name('CAIRNS') # Name of sww file |
---|
[8344] | 52 | domain.set_datadir(scenariodirV)# Store sww output here |
---|
| 53 | |
---|
[8331] | 54 | log.resource_usage_timing(prefix = 'aftermesh')#get memory statistics here |
---|
[8342] | 55 | log.timingInfo(msg=('aftermeshtime,'+str(log.TimeStamp()))) #get the time at the beginning of the simulation |
---|
[8311] | 56 | |
---|
| 57 | #------------------------------------------------------------------------------ |
---|
| 58 | # Setup initial conditions |
---|
| 59 | #------------------------------------------------------------------------------ |
---|
| 60 | |
---|
| 61 | def topography(x,y): |
---|
| 62 | return 0.0 |
---|
| 63 | |
---|
| 64 | tide = 100.0 |
---|
| 65 | friction = 0.0 |
---|
| 66 | domain.set_quantity('stage', tide) |
---|
| 67 | domain.set_quantity('friction', friction) |
---|
| 68 | domain.set_quantity('elevation',topography,alpha=0.1) |
---|
[8326] | 69 | |
---|
| 70 | log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here |
---|
[8311] | 71 | |
---|
| 72 | #------------------------------------------------------------------------------ |
---|
| 73 | # Setup boundary conditions |
---|
| 74 | #------------------------------------------------------------------------------ |
---|
[8326] | 75 | |
---|
[8311] | 76 | Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow |
---|
| 77 | Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow |
---|
| 78 | Br = anuga.Reflective_boundary(domain) |
---|
[8326] | 79 | domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) |
---|
| 80 | |
---|
| 81 | log.resource_usage_timing(prefix='afterboundary') #get memory statistics here |
---|
[8311] | 82 | #------------------------------------------------------------------------------ |
---|
| 83 | # Evolve system through time |
---|
| 84 | #------------------------------------------------------------------------------ |
---|
[8347] | 85 | for t in domain.evolve(yieldstep=2000, finaltime=2000): |
---|
[8326] | 86 | print domain.timestepping_statistics() |
---|
[8311] | 87 | |
---|
[8331] | 88 | log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here |
---|
| 89 | log.timingInfo(msg=('aftertime,'+str(log.TimeStamp()))) #get the time at the end of the simulation |
---|
[8336] | 90 | |
---|