Changeset 8326


Ignore:
Timestamp:
Jan 31, 2012, 10:54:12 AM (12 years ago)
Author:
pittj
Message:

formatted the experiment scripts

Location:
trunk/anuga_work/development/mem_time_tests
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/mem_time_tests/NCIparallel/area/main.py

    r8324 r8326  
    2222# Setup computational domain
    2323#------------------------------------------------------------------------------
    24 a = []
    2524#SpaceUsed = 0.0
    2625#number = 0
    2726
    2827home1 = os.getenv('INUNDATIONHOME')
    29 scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","area"])
     28scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","logarea"])
    3029file1 = 'ex1.csv'
    3130file_path = os.path.join(scenariodir, file1)
     
    3938file_path_storen = os.path.join(scenariodir, storen)
    4039
    41 log.log_filename = os.path.join(scenariodir, 'log.txt
    4240
    4341spamWriter = csv.writer(open(file_path, 'wb'))
     
    5351
    5452
    55 def rum(d):
    56      f = 4
    57      for l in range(400,500,100):
     53for m in range(1,2,1):
     54     for l in range(700,800,100):
    5855
    5956        g = open(file_path_storel,'r+')
     
    6158
    6259        h = open(file_path_storea,'r+')
    63         h.write(str(d))
     60        h.write(str(m))
    6461
    6562        z = time.time()
    66         subprocess.call(['mpirun','-np','8','-x','PYTHONPATH','-x','INUNDATIONHOME','python','runcairns.py'])
    67         #subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado','-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'ru$
    68         #subprocess.call(['python2.5', 'runcairns.py'])
     63        #subprocess.call(['mpirun','-np','8','-x','PYTHONPATH','-x','INUNDATIONHOME','python','runcairns.py'])
     64        #subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado','-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'runcairns.py'])
     65        subprocess.call(['python2.5', 'runcairns.py'])
    6966        y = time.time()
    7067
     
    7774        f.close()
    7875
    79         spamWriter.writerow([i,d,(l*l),x ,(y-z)])
     76        spamWriter.writerow(['i,d,(l*l),x ,(y-z)'])
    8077        liststore.store = [0,0,0,0]
    8178
    82 for m in range(90,100,10):
    83     rum(m)
    8479
    8580print 'Done'
  • trunk/anuga_work/development/mem_time_tests/NCIparallel/area/runcairns.py

    r8324 r8326  
    3030home2 = os.getenv('INUNDATIONHOME')
    3131
    32 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
     32scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "logarea"])
    3333
    3434h = 'CAIRNS.msh'
     
    5252
    5353scenariodirV = add_directories(home2, ["data","mem_time_test", "triangles",
    54                                      "area", "triangles-" + str(area) +"-"+ str(length)])
     54                                       "logarea", "triangles-" + str(area) +"-"+ str(length)])
    5555
    5656h = 'CAIRNS.msh'
     
    6060log._setup = False
    6161
    62 system_tools.MemoryUpdate()
     62log.resource_usage_timing(prefix = 'BeforeSimulation')
    6363#------------------------------------------------------------------------------
    6464# Create the triangular mesh and domain based on
     
    8282else:
    8383    domain = None
    84      
     84
     85log.resource_usage_timing(prefix = 'AfterMesh')     
    8586domain = distribute(domain)
    8687                               
     
    9798def topography(x,y):
    9899    return 0.0
    99 
     100log.resource_usage_timing(prefix='beforeinitialconditions')
    100101tide = 100.0
    101102friction = 0.0
     
    103104domain.set_quantity('friction', friction)
    104105domain.set_quantity('elevation',topography,alpha=0.1)
    105 
     106log.resource_usage_timing(prefix='afterinitialconditions')
    106107
    107108
     
    120121                     'top': Br})
    121122
    122 
     123log.resource_usage_timing(prefix='afterboundary')
    123124#------------------------------------------------------------------------------
    124125# Evolve system through time
     
    126127
    127128# Save every two mins leading up to wave approaching land
    128 for t in domain.evolve(yieldstep=500, finaltime=2000):
    129     print domain.timestepping_statistics()
     129#for t in domain.evolve(yieldstep=500, finaltime=2000):
     130#    print domain.timestepping_statistics()
    130131   
    131132
    132 liststore.store[myid] = system_tools.MemoryUpdate()[0]
    133 a = sum(liststore.store)
     133#liststore.store[myid] = system_tools.MemoryUpdate()[0]
     134#a = sum(liststore.store)
    134135
     136a = 1
    135137v = open(file_path_store, 'r+')
    136138v.write(str(a))
  • trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py

    r8320 r8326  
    55# Import necessary modules
    66#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    87import anuga
    9 import random
    108import subprocess
    119import csv
    1210import os
    1311import time
    14 import liststore
    15 from anuga.utilities import system_tools, log
    1612from anuga.abstract_2d_finite_volumes.util import add_directories
     13from anuga.utilities.log_analyser import analyse_log
    1714
    18 
    19 #------------------------------------------------------------------------------
    20 # Setup computational domain
    21 #------------------------------------------------------------------------------
    22 a = []
     15#--------------------------------------------------------------------------------------
     16# Set up variables for the correct directories to store the output
     17#--------------------------------------------------------------------------------------
    2318host = os.getenv('HOST')
    24 home1 = os.getenv('INUNDATIONHOME')
    25 scenariodir = add_directories(home1, ["data","mem_time_test", "parallel","cairns"])
     19home = os.getenv('INUNDATIONHOME')
     20scenariodir = add_directories(home, ["data","mem_time_test", "parallel","cairns"])
    2621file1 = 'ex1.csv'
    2722file_path = os.path.join(scenariodir, file1)
    28 store ='store.txt'
    29 file_path_store = os.path.join(scenariodir, store)
    30 
    31 log.log_filename = os.path.join(scenariodir, 'log.txt')
    3223
    3324spamWriter = csv.writer(open(file_path, 'wb'))
    3425spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s'])
    35 e = open(file_path_store,'a')
    36 e.close()
    3726
     27
     28# main loop that runs macpus - 1 times
    3829maxcpus = 18
    3930
    4031for n in range(1,maxcpus,1):
    41     z = time.time()
    42     y = time.time()
     32    z = time.time() # time it
    4333
     34    #the necessary ways to run this script in parallel on the different hosts we use
    4435    if (host == 'cyclone.agso.gov.au'):
    45         subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
     36        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    4637    if (host == 'tornado.agso.gov.au'):
    47         subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
     38        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    4839    if (host == 'vayu1'):
    4940        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
     
    5344        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    5445
    55     liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    56     f = open(file_path_store,'r+')
    57     x = float(f.readline())
    58     f.close()
    59     spamWriter.writerow([n,x ,(y-z)])
    60 print a
     46    y = time.time()# time it
     47    spamWriter.writerow([n,'x' ,(y-z)]) # write recorded results
     48print 'DONE'
    6149
     50analyse_log(scenariodir, 'metalog.csv') # interrogate log files for the memory usage information
  • trunk/anuga_work/development/mem_time_tests/hardware/cairns/project.py

    r8311 r8326  
    11""" Common filenames and locations for topographic data, meshes and outputs.
    22    This file defines the parameters of the scenario you wish to run.
     3
     4    Parameters differ from example to make the code run faster, and so the data is stored and found in the correct places
    35"""
    46
  • trunk/anuga_work/development/mem_time_tests/hardware/cairns/runcairns.py

    r8311 r8326  
    1010
    1111Geoscience Australia, 2004-present
     12
     13This has remained unchanged aside from the parallelism added, the resource statistics
     14and the output directories, its also been scaled down so it runs faster
    1215"""
    1316
     
    1922import time
    2023import sys
     24import anuga
     25from anuga_parallel import distribute, myid, numprocs
     26from anuga.abstract_2d_finite_volumes.util import add_directories
     27from anuga.utilities import log
    2128
    22 # Related major packages
    23 import anuga
    24 import liststore
    2529
    2630# Application specific imports
    2731import project                 # Definition of file names and polygons
    2832
    29 from anuga_parallel import distribute, myid, numprocs, finalize, barrier
    30 from anuga.abstract_2d_finite_volumes.util import add_directories
    31 from anuga.utilities import system_tools, log
     33
     34# set up variables for the correct output directories
     35home = os.getenv('INUNDATIONHOME')
     36scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "cairns"])
     37h = 'CAIRNS.msh'
     38file_pathh = os.path.join(scenariodir, h)
     39store ='store.txt'
     40file_path_store = os.path.join(scenariodir, store)
     41scenariodirV = add_directories(home, ["data","mem_time_test", "parallel",
     42                                       "cairns", "parrallel-" + str(numprocs) +"-"+str(myid)])
     43log.log_filename = os.path.join(scenariodirV, "anuga.log")
     44log._setup = False
    3245
    3346
    34 home2 = os.getenv('INUNDATIONHOME')
    35 
    36 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "parallel", "cairns"])
    37 
    38 h = 'CAIRNS.msh'
    39 file_pathh = os.path.join(scenariodir2, h)
    40 store ='store.txt'
    41 file_path_store = os.path.join(scenariodir2, store)
    42 
    43 
    44 system_tools.MemoryUpdate()
    45 
     47log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics at this point
    4648#------------------------------------------------------------------------------
    4749# Preparation of topographic data
     
    4951#------------------------------------------------------------------------------
    5052# Create DEM from asc data
    51 anuga.asc2dem(os.path.join(scenariodir2, 'cairns.asc'), use_cache=True, verbose=True)
     53anuga.asc2dem(os.path.join(scenariodir, 'cairns.asc'), use_cache=True, verbose=True)
    5254
    5355# Create pts file for onshore DEM
    54 anuga.dem2pts(os.path.join(scenariodir2,'cairns.dem'), use_cache=True, verbose=True)
     56anuga.dem2pts(os.path.join(scenariodir,'cairns.dem'), use_cache=True, verbose=True)
    5557
    5658#------------------------------------------------------------------------------
     
    5860# overall clipping polygon with a tagged
    5961# boundary and interior regions as defined in project.py
     62# (in serial, so the set up only runs once)
    6063#------------------------------------------------------------------------------
    6164if myid == 0:
     
    7780else:
    7881    domain = None
     82
     83log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics at this point
    7984     
     85#parallel
    8086domain = distribute(domain)
    8187                               
     
    8490#------------------------------------------------------------------------------
    8591domain.set_name('cairns_' + project.scenario) # Name of sww file
    86 domain.set_datadir(scenariodir2)                       # Store sww output here
     92domain.set_datadir(scenariodirV)                       # Store sww output here
    8793domain.set_minimum_storable_height(0.01)      # Store only depth > 1cm
    8894
     
    95101domain.set_quantity('friction', 0.0)
    96102domain.set_quantity('elevation',
    97                     filename=os.path.join(scenariodir2, 'cairns.pts'),
     103                    filename=os.path.join(scenariodir, 'cairns.pts'),
    98104                    use_cache=True,
    99105                    verbose=True,
    100106                    alpha=0.1)
     107log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics at this point
    101108
    102109#------------------------------------------------------------------------------
     
    138145                         'onshore': Bd,
    139146                         'top': Bd})
    140 
     147log.resource_usage_timing(prefix='afterboundary') #get memory statistics at this point
    141148#------------------------------------------------------------------------------
    142149# Evolve system through time
     
    175182        print domain.boundary_statistics(tags='ocean_east')
    176183           
     184
    177185print 'That took %.2f seconds' %(time.time()-t0)
    178186
    179 liststore.spacelist[myid] = system_tools.MemoryUpdate()[0]
    180 a = sum(liststore.spacelist)
    181 
    182 f = open(file_path_store, 'r+')
    183 f.write(str(a))
    184 
     187log.resource_usage_timing(prefix='aftersimulation') #get memory statistics at this point
  • trunk/anuga_work/development/mem_time_tests/hardware/template/main.py

    r8320 r8326  
    55# Import necessary modules
    66#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    87import anuga
    98import random
    109import subprocess
    11 import run_parallel
    1210import csv
    1311import os
    1412import time
    15 import liststore
    16 from anuga.utilities import system_tools, log
    1713from anuga.abstract_2d_finite_volumes.util import add_directories
     14from anuga.utilities.log_analyser import analyse_log
    1815
    19 
    20 #------------------------------------------------------------------------------
    21 # Setup computational domain
    22 #------------------------------------------------------------------------------
    23 a = []
     16#-------------------------------------------------------------------------------
     17# Set up variables for the correct directories to store the output
     18#-------------------------------------------------------------------------------
    2419host = os.getenv('HOST')
    2520home = os.getenv('INUNDATIONHOME')
     
    2722file1 = 'ex1.csv'
    2823file_path = os.path.join(scenariodir, file1)
    29 storel ='storel.txt'
    30 file_path_storel = os.path.join(scenariodir, storel)
    31 storea ='storea.txt'
    32 file_path_storea = os.path.join(scenariodir, storea)
    33 store ='store.txt'
    34 file_path_store = os.path.join(scenariodir, store)
    35 storen ='storen.txt'
    36 file_path_storen = os.path.join(scenariodir, storen)
    37 
    38 log.log_filename = os.path.join(scenariodir, 'log.txt')
    39 
    4024spamWriter = csv.writer(open(file_path, 'wb'))
    4125spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s','Total Space'])
    42 e = open(file_path_store,'a')
    43 e.close()
    4426
    4527
     28#main loop that runs maxcpus - 1 times
     29maxcpus = 40
    4630
    47 for n in range(1,40,1):
    48     z = time.time()
     31for n in range(1,maxcpus,1):
     32    z = time.time()# time it
     33
     34    #the different ways each HOST requires the parallel script to be run
    4935    if (host == 'cyclone.agso.gov.au'):
    50         subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
     36        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    5137    if (host == 'tornado.agso.gov.au'):
    52         subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
     38        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    5339    if (host == 'vayu1'):
    5440        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
     
    5743    if (host == 'xe'):
    5844        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    59  
    60     y = time.time()
    61     f = open(file_path_store,'r+')
    62     x = float(f.readline())
    63     f.close()
    64     spamWriter.writerow([n,liststore.spacelist,(y-z),x])
    65     liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    66 print a
     45   
    6746
     47    y = time.time() #time it
     48    spamWriter.writerow([n,(y-z)]) #record it
     49
     50print 'Done'
     51
     52analyse_log(scenariodir, 'metalog.csv') #get all the memory usage statistics
  • trunk/anuga_work/development/mem_time_tests/hardware/template/runcairns.py

    r8311 r8326  
    1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.
     1"""
     2This experiment was based heavily on the cairns demo given in the user manual and found in
     3the anuga repository.
    24
    3 Source data such as elevation and boundary data is assumed to be available in
    4 directories specified by project.py
    5 The output sww file is stored in directory named after the scenario, i.e
    6 slide or fixed_wave.
    7 
    8 The scenario is defined by a triangular mesh created from project.polygon,
    9 the elevation data and a tsunami wave generated by a submarine mass failure.
    10 
    11 Geoscience Australia, 2004-present
     5However, it has been simplified so that it doesnt require all the files the cairns demo does
    126"""
    137
     
    159# Import necessary modules
    1610#------------------------------------------------------------------------------
    17 # Standard modules
    1811import os
    1912import time
    2013import sys
     14import anuga
     15from anuga_parallel import distribute, myid, numprocs
     16from anuga.abstract_2d_finite_volumes.util import add_directories
     17from anuga.utilities import log
    2118
    22 # Related major packages
    23 import anuga
     19#set up variables for the correct I/O directories for data storage
     20home = os.getenv('INUNDATIONHOME')
     21scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "template"])
     22scenariodirV = add_directories(home, ["data","mem_time_test", "parallel",
     23                                       "template", "template-" + str(numprocs) +"-"+ str(myid)])
     24h = 'CAIRNS.msh'
     25file_pathh = os.path.join(scenariodirV, h)
     26log.log_filename = os.path.join(scenariodirV, "anuga.log")
     27log._setup = False
    2428
    25 from anuga_parallel import distribute, myid
    26 import liststore
    27 from anuga.abstract_2d_finite_volumes.util import add_directories
    28 from anuga.utilities import system_tools, log
     29log.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#------------------------------------------------------------------------------
    2933
    30 
    31 home2 = os.getenv('INUNDATIONHOME')
    32 
    33 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
    34 
    35 store ='store.txt'
    36 file_path_store = os.path.join(scenariodir2, store)
    37 h = 'cairnsmesh.msh'
    38 file_pathh = os.path.join(scenariodir2, h)
    39 
    40 
    41 system_tools.MemoryUpdate()
    42 #------------------------------------------------------------------------------
    43 # Create the triangular mesh and domain based on
    44 # overall clipping polygon with a tagged
    45 # boundary and interior regions as defined in project.py
    46 #------------------------------------------------------------------------------
    4734if myid == 0:
    4835    domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)],
     
    5239                                                   'left': [3]},
    5340                                    maximum_triangle_area=100.0,
    54                                     mesh_filename=file_pathh
    55                                     #,interior_regions=INTERIORREGIONS#,
    56                                     #use_cache=True,
    57                                     #verbose=True)
    58                                     )
    59 
    60     # Print some stats about mesh and domain
    61     #print 'Number of triangles = ', len(domain)
    62     #print 'The extent is ', domain.get_extent()
    63     #print domain.statistics()
     41                                    mesh_filename=file_pathh)
    6442else:
    6543    domain = None
    66      
     44
     45#parallel   
    6746domain = distribute(domain)
    68                                
    69 #------------------------------------------------------------------------------
    70 # Setup parameters of computational domain
    71 #------------------------------------------------------------------------------
    7247domain.set_name('CAIRNS') # Name of sww file
    73 domain.set_datadir(scenariodir2)                       # Store sww output here
     48domain.set_datadir(scenariodirV)# Store sww output here
     49log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics here
    7450
    7551#------------------------------------------------------------------------------
     
    8662domain.set_quantity('elevation',topography,alpha=0.1)
    8763
    88 
     64log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here
    8965
    9066#------------------------------------------------------------------------------
     
    9470Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
    9571Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
    96 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
    9772Br = anuga.Reflective_boundary(domain)
    98 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
    99 domain.set_boundary({'right': Bo,
    100                      'bottom': Br,
    101                      'left': Bi,
    102                      'top': Br})
     73domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
    10374
     75log.resource_usage_timing(prefix='afterboundary') #get memory statistics here
    10476#------------------------------------------------------------------------------
    10577# Evolve system through time
    10678#------------------------------------------------------------------------------
    107 
    108 # Save every two mins leading up to wave approaching land
    10979for t in domain.evolve(yieldstep=120, finaltime=2000):
    11080    print domain.timestepping_statistics()
    111    
    11281
    113 liststore.spacelist[myid] = system_tools.MemoryUpdate()[0]
    114 a = sum(liststore.spacelist)
    115 print liststore.spacelist
    116 
    117 f = open(file_path_store, 'r+')
    118 f.write(str(a))
    119 
     82log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here 
  • trunk/anuga_work/development/mem_time_tests/parameters/friction/ex1.py

    r8304 r8326  
    1010import os
    1111from anuga.abstract_2d_finite_volumes.util import add_directories
     12from anuga.utilities import log
    1213
    1314home = os.getenv('INUNDATIONHOME')
     
    1617
    1718
    18 file = 'CAIRNS.sww'
    19 file_path = os.path.join(scenariodir, file)
     19#store = 'store.txt'
     20#file_path_store = os.path.join(scenariodir, store)
    2021
    21 h = 'CAIRNS.msh'
    22 file_pathh = os.path.join(scenariodir, h)
     22f = open(os.path.join(scenariodir, "store.txt"),'r+') # SQRT extent this is set
     23friction = float(f.readline())
     24f.close()
     25
     26scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
     27                                     "friction","friction-" + str(friction)])
     28
     29log.log_filename = os.path.join(scenariodirV, "anuga.log")
     30log._setup = False
     31
     32log.resource_usage_timing(prefix = 'BeforeSimulation')
     33
    2334#------------------------------------------------------------------------------
    2435# Setup computational domain
    2536#------------------------------------------------------------------------------
     37points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
     38domain = anuga.Domain(points, vertices, boundary) # Create domain
     39domain.set_datadir(scenariodirV)
     40domain.set_name('channel1') # Output name
    2641
    27 
    28 
    29 def runex(f):
    30    points, vertices, boundary = anuga.rectangular_cross(10,5,
    31    len1=10.0, len2=5.0) # Mesh
    32    domain = anuga.Domain(points, vertices, boundary) # Create domain
    33    domain.set_datadir(scenariodir)
    34    domain.set_name('channel1') # Output name
    35  
     42log.resource_usage_timing(prefix = 'AfterMesh')
    3643   
    3744#------------------------------------------------------------------------------
    3845# Setup initial conditions
    3946#------------------------------------------------------------------------------
    40    def topography(x, y):
    41        return -x/10 # linear bed slope
    42        domain.set_quantity('elevation', topography) # Use function for elevation
    43        domain.set_quantity('friction', f) # Constant friction
    44        domain.set_quantity('stage', # Dry bed
     47def topography(x, y):
     48    return -x/10 # linear bed slope
     49
     50log.resource_usage_timing(prefix = 'BeforeInitial')
     51domain.set_quantity('elevation', topography) # Use function for elevation
     52domain.set_quantity('friction', friction) # Constant friction
     53domain.set_quantity('stage', # Dry bed
    4554                           expression='elevation')
     55log.resource_usage_timing(prefix = 'AfterInitial')
    4656
    4757#------------------------------------------------------------------------------
    4858# Setup boundary conditions
    4959#------------------------------------------------------------------------------
    50    Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    51    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    52    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     60log.resource_usage_timing(prefix = 'BeforeBoundary')
     61Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
     62Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     63domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     64log.resource_usage_timing(prefix = 'AfterBoundary')
    5365
    5466#------------------------------------------------------------------------------
    5567# Evolve system through time
    5668#------------------------------------------------------------------------------
    57    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    58       print domain.timestepping_statistics()
    59    return f
     69for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     70    print domain.timestepping_statistics()
    6071
    61 
     72log.resource_usage_timing(prefix = 'AfterSimulation')
  • trunk/anuga_work/development/mem_time_tests/parameters/friction/main.py

    r8304 r8326  
    99import time
    1010import subprocess
    11 import ex1
    1211import csv
    1312import os
    1413from anuga.utilities import system_tools, log
    1514from anuga.abstract_2d_finite_volumes.util import add_directories
     15from anuga.utilities.log_analyser import analyse_log
    1616#------------------------------------------------------------------------------
    1717# Setup computational domain
    1818#------------------------------------------------------------------------------
    19 a = []
    2019home = os.getenv('INUNDATIONHOME')
    2120
     
    2423file = 'ex1.csv'
    2524file_path = os.path.join(scenariodir, file)
     25store ='store.txt'
     26file_path_store = os.path.join(scenariodir, store)
    2627
    27 log.log_filename = os.path.join(scenariodir, 'log.txt')
     28e = open(file_path_store,'a')
     29e.close()
     30
     31
     32
    2833
    2934spamWriter = csv.writer(open(file_path, 'wb'))
     
    3237
    3338for n in range(1,10000,100):
    34     system_tools.MemoryUpdate()
     39    f = open(file_path_store,'wb')
     40    f.write(str(n))
    3541    x = time.clock()
    36     h = ex1.runex(n)
     42    subprocess.call(['python2.5', 'ex1.py'])
    3743    y = time.clock()
    38     b = system_tools.MemoryUpdate()[0]
    39     spamWriter.writerow([n ,(y-x),b])
    40 print a
     44    spamWriter.writerow([n ,(y-x)])
     45print 'Done'
    4146
     47analyse_log(scenariodir, 'metalog.csv')
  • trunk/anuga_work/development/mem_time_tests/parameters/nothing/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
    106import os
    11 
     7from anuga.utilities import log
    128from anuga.abstract_2d_finite_volumes.util import add_directories
    139
     10#set up the variables to correctly store the temporary data
    1411home = os.getenv('INUNDATIONHOME')
    15 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    16                                      "nothing"])
     12scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"])
     13store ='store.txt'
     14file_path_store = os.path.join(scenariodir, store)
    1715
     16#get the run number from the store text file
     17f = open(file_path_store,'r+')
     18n = float(f.readline())
     19f.close()
    1820
    19 file = 'CAIRNS.sww'
    20 file_path = os.path.join(scenariodir, file)
     21#set up the variables to correctly store the output data and log file
     22scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
     23                                     "nothing","nothing"+"-"+str(n)])
    2124
    22 h = 'CAIRNS.msh'
    23 file_pathh = os.path.join(scenariodir, h)
     25log.log_filename = os.path.join(scenariodirV, "anuga.log")
     26log._setup = False
    2427
     28log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
    2529#------------------------------------------------------------------------------
    2630# Setup computational domain
    2731#------------------------------------------------------------------------------
     32points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
     33domain = anuga.Domain(points, vertices, boundary) # Create domain
    2834
     35domain.set_name('channel1') # Output name
     36domain.set_datadir(scenariodir)
    2937
     38log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
    3039
    31 def runex():
    32    points, vertices, boundary = anuga.rectangular_cross(10,5,
    33    len1=10.0, len2=5.0) # Mesh
    34    domain = anuga.Domain(points, vertices, boundary) # Create domain
    35    domain.set_name('channel1') # Output name
    36    domain.set_datadir(scenariodir)
    3740#------------------------------------------------------------------------------
    3841# Setup initial conditions
    3942#------------------------------------------------------------------------------
    40    def topography(x, y):
    41        return -x/10 # linear bed slope
    42        domain.set_quantity('elevation', topography) # Use function for elevation
    43        domain.set_quantity('friction', 0.01) # Constant friction
    44        domain.set_quantity('stage', # Dry bed
    45                            expression='elevation')
     43def topography(x, y):
     44    return -x/10 # linear bed slope
     45domain.set_quantity('elevation', topography) # Use function for elevation
     46domain.set_quantity('friction', 0.01) # Constant friction
     47domain.set_quantity('stage',expression='elevation')
     48log.resource_usage_timing(prefix='afterinitialconditions')
    4649
    4750#------------------------------------------------------------------------------
    4851# Setup boundary conditions
    4952#------------------------------------------------------------------------------
    50    Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    51    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    52    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     53Bi = anuga.Dirichlet_boundary([400, 0, 0]) # Inflow
     54Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     55domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
    5356
     57log.resource_usage_timing(prefix='afterboundary')  #get memory usage here
    5458#------------------------------------------------------------------------------
    5559# Evolve system through time
    5660#------------------------------------------------------------------------------
    57    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    58       print domain.timestepping_statistics()
    59    return len(domain)
     61for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     62    print domain.timestepping_statistics()
    6063
    61 
     64log.resource_usage_timing(prefix='aftersimulation')  #get memory usage here
  • trunk/anuga_work/development/mem_time_tests/parameters/nothing/main.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
    106import random
    117import subprocess
    12 import ex1
    138import csv
    149import os
    1510from anuga.utilities import system_tools, log
    1611from anuga.abstract_2d_finite_volumes.util import add_directories
    17 #------------------------------------------------------------------------------
    18 # Setup computational domain
    19 #------------------------------------------------------------------------------
    20 a = []
     12from anuga.utilities.log_analyser import analyse_log
    2113
     14#--------------------------------------------------------------------------------------
     15# Set up variables for the correct directories to store the output
     16#--------------------------------------------------------------------------------------
    2217home = os.getenv('INUNDATIONHOME')
    23 
    24 
    25 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    26                                      "nothing"])
     18scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"])
    2719file = 'ex1.csv'
    28 
    29 log.log_filename = os.path.join(scenariodir, 'log.txt')
    30 
    3120file_path = os.path.join(scenariodir, file)
     21store = 'store.txt'
     22file_path_store = os.path.join(scenariodir, store)
    3223
    3324spamWriter = csv.writer(open(file_path, 'wb'))
     25spamWriter.writerow(['Run Number' , 'Time Taken','Space Used'])
     26e = open(file_path_store,'a') #create the file
     27e.close()
    3428
    35 spamWriter.writerow(['Run Number' , 'Time Taken','Space Used'])
     29#main loop, that stores the current run number so that unique folders exist for the information
     30for n in range(0,300,1):
    3631
     32    e = open(file_path_store,'r+')
     33    e.write(str(n)) #store the run number
     34   
     35    x = time.clock() #time it
     36    subprocess.call(['python2.5', 'ex1.py']) #run script
     37    y = time.clock() #time it
    3738
    38 for n in range(0,300,1):
    39     system_tools.MemoryUpdate()
    40     x = time.clock()
    41     ex1.runex()
    42     y = time.clock()
    43     d = system_tools.MemoryUpdate()[0]
    44     spamWriter.writerow([n ,(y-x),d])
    45     a.append((n,y-x,d))
    46 print a
     39    spamWriter.writerow([n ,(y-x)])
    4740
     41print "DONE"
     42
     43analyse_log(scenariodir, 'metalog.csv') #get the memory usage from the log files
  • trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/ex1.py

    r8311 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
    106import random
    117import os
    12 #------------------------------------------------------------------------------
    13 # Setup computational domain
    14 #------------------------------------------------------------------------------
    158from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    1610
     11#set up variables to store the temporary data
    1712home = os.getenv('INUNDATIONHOME')
    1813scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    1914                                     "timelen-over-timestep"])
     15store ='store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen ='storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
    2019
    21 def runex(g,f):
    22    points, vertices, boundary = anuga.rectangular_cross(10,5,
    23    len1=10.0, len2=5.0) # Mesh
    24    domain = anuga.Domain(points, vertices, boundary) # Create domain
    25    domain.set_name('channel1') # Output name
    26    domain.set_datadir(scenariodir)
     20#get the time length and time step from the text files
     21f = open(file_path_store,'r+')
     22g = float(f.readline())
     23f.close()
     24f = open(file_path_storen,'r+')
     25h = float(f.readline())
     26f.close()
     27
     28#set up variables to store the data and the log files
     29scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
     30                                       "timelen-over-timestep", "TT-" + str(g) +"-"+ str(h)])
     31log.log_filename = os.path.join(scenariodirV, "anuga.log")
     32log._setup = False
     33
     34
     35log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
     36
     37#------------------------------------------------------------------------------
     38#Create Domain and Mesh
     39#------------------------------------------------------------------------------
     40points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
     41domain = anuga.Domain(points, vertices, boundary) # Create domain
     42domain.set_name('channel1') # Output name
     43domain.set_datadir(scenariodirV)
     44
     45log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
     46
    2747#------------------------------------------------------------------------------
    2848# Setup initial conditions
    2949#------------------------------------------------------------------------------
    30    def topography(x, y):
    31        return -x/10 # linear bed slope
    32        domain.set_quantity('elevation', topography) # Use function for elevation
    33        domain.set_quantity('friction', 0.01) # Constant friction
    34        domain.set_quantity('stage', # Dry bed
    35                            expression='elevation')
     50def topography(x, y):
     51    return -x/10 # linear bed slope
     52
     53domain.set_quantity('elevation', topography) # Use function for elevation
     54domain.set_quantity('friction', 0.01) # Constant friction
     55domain.set_quantity('stage', expression='elevation')
     56log.resource_usage_timing(prefix='afterinitialconditions')  #get memory usage here
    3657
    3758#------------------------------------------------------------------------------
    3859# Setup boundary conditions
    3960#------------------------------------------------------------------------------
    40    Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    41    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    42    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
    43 
     61Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
     62Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     63domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     64log.resource_usage_timing(prefix='afterboundary')  #get memory usage here
    4465#------------------------------------------------------------------------------
    4566# Evolve system through time
    4667#------------------------------------------------------------------------------
    47    for t in domain.evolve(yieldstep=f, finaltime=g):
    48       print domain.timestepping_statistics()
     68for t in domain.evolve(yieldstep=h, finaltime=g):
     69    print domain.timestepping_statistics()
    4970
    50 
     71log.resource_usage_timing(prefix='aftersimulation')  #get memory usage here
  • trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py

    r8315 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
     
    107import random
    118import subprocess
    12 import ex1
    139import csv
    1410import os
    15 from anuga.utilities import system_tools, log
    1611from anuga.abstract_2d_finite_volumes.util import add_directories
    17 #------------------------------------------------------------------------------
    18 # Setup computational domain
    19 #------------------------------------------------------------------------------
    20 a = []
    21 home = os.getenv('INUNDATIONHOME')
     12from anuga.utilities.log_analyser import analyse_log
    2213
    2314
     15#------------------------------------------------------------------------------
     16# Set up variables for the correct directories to store the output
     17#------------------------------------------------------------------------------
     18home = os.getenv('INUNDATIONHOME')
    2419scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    2520                                     "timelen-over-timestep"])
    2621file = 'ex1.csv'
     22file_path = os.path.join(scenariodir, file)
     23spamWriter = csv.writer(open(file_path, 'wb'))
     24spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used'])
     25store ='store.txt'
     26file_path_store = os.path.join(scenariodir, store)
     27storen ='storen.txt'
     28file_path_storen = os.path.join(scenariodir, storen)
    2729
    28 log.log_filename = os.path.join(scenariodir, 'log.txt')
     30#create each file
     31e = open(file_path_store,'a')
     32e.close()
     33e = open(file_path_storen,'a')
     34e.close()
    2935
    30 file_path = os.path.join(scenariodir, file)
    3136
    32 spamWriter = csv.writer(open(file_path, 'wb'))
    3337
    34 spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used'])
    35 
     38# main loops that give the time length (m) and the time step (n)
    3639for m in range(1,1000,50):
    3740
    3841    for n in range(1,1000,5):
    39         n = n/1000.0
    40         system_tools.MemoryUpdate()
    41         x = time.clock()
    42         ex1.runex(float(m),n)
    43         y = time.clock()
    44         b = system_tools.MemoryUpdate()[0]
    45         spamWriter.writerow([m,n ,(y-x),b])
    46         a.append((n,y-x,b))
    47 print a
     42        n = n/1000.0 #adjust it so its small enough to see the nature of the relationship
    4843
     44        #write to file
     45        s = open(file_path_store,'r+')
     46        s.write(str(float(m)))
     47        t = open(file_path_storen,'r+')
     48        t.write(str(n))
     49
     50        x = time.clock()#time it
     51        subprocess.call(['python2.5', 'ex1.py'])#run it
     52        y = time.clock()#time it
     53        spamWriter.writerow([m,n ,(y-x),'b'])#write the results
     54
     55print 'Done'
     56
     57analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the log files
  • trunk/anuga_work/development/mem_time_tests/parameters/timelen/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
    106import os
    11 #------------------------------------------------------------------------------
    12 # Setup computational domain
    13 #------------------------------------------------------------------------------
    147from anuga.abstract_2d_finite_volumes.util import add_directories
     8from anuga.utilities import log
    159
     10#set up variables for the temporary data files
    1611home = os.getenv('INUNDATIONHOME')
    1712scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    1813                                     "timelength"])
     14store ='store.txt'
     15file_path_store = os.path.join(scenariodir, store)
    1916
    20 def runex(f):
    21    points, vertices, boundary = anuga.rectangular_cross(10,5,
    22    len1=10.0, len2=5.0) # Mesh
    23    domain = anuga.Domain(points, vertices, boundary) # Create domain
    24    domain.set_name('channel1') # Output name
    25    domain.set_datadir(scenariodir) 
     17#get the time length from the store text file
     18s = open(file_path_store,'r+')
     19f = float(s.readline())
     20s.close()
     21
     22#set up variables to store the results and the log files of each experiment
     23scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
     24                                       "timelength", "timelength-" + str(f)])
     25log.log_filename = os.path.join(scenariodirV, "anuga.log")
     26log._setup = False
     27
     28log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
     29
     30#------------------------------------------------------------------------------
     31# Create the domain and the mesh of the run
     32#------------------------------------------------------------------------------
     33points, vertices, boundary = anuga.rectangular_cross(100,300,len1=1000.0, len2=500.0) # Mesh
     34domain = anuga.Domain(points, vertices, boundary) # Create domain
     35domain.set_name('channel1') # Output name
     36domain.set_datadir(scenariodirV) 
     37
     38log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here
    2639#------------------------------------------------------------------------------
    2740# Setup initial conditions
    2841#------------------------------------------------------------------------------
    29    def topography(x, y):
    30        return -x/10 # linear bed slope
    31        domain.set_quantity('elevation', topography) # Use function for elevation
    32        domain.set_quantity('friction', 0.01) # Constant friction
    33        domain.set_quantity('stage', # Dry bed
    34                            expression='elevation')
     42def topography(x, y):
     43    return -x/10 # linear bed slope
     44domain.set_quantity('elevation', topography) # Use function for elevation
     45domain.set_quantity('friction', 0.01) # Constant friction
     46domain.set_quantity('stage',expression='elevation')
     47
     48log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
    3549
    3650#------------------------------------------------------------------------------
    3751# Setup boundary conditions
    3852#------------------------------------------------------------------------------
    39    Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    40    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    41    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     53Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
     54Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     55domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     56
     57log.resource_usage_timing(prefix='afterboundary')#get memory usage here
    4258
    4359#------------------------------------------------------------------------------
    4460# Evolve system through time
    4561#------------------------------------------------------------------------------
    46    for t in domain.evolve(yieldstep=0.2, finaltime=f):
    47       print domain.timestepping_statistics()
    48    return f
     62for t in domain.evolve(yieldstep=0.2, finaltime=f):
     63    print domain.timestepping_statistics()
    4964
    5065
     66log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
     67
  • trunk/anuga_work/development/mem_time_tests/parameters/timelen/main.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
    10 import random
    116import subprocess
    12 import ex1
    137import csv
    148import os
    159from anuga.utilities import system_tools, log
    1610from anuga.abstract_2d_finite_volumes.util import add_directories
    17 #------------------------------------------------------------------------------
    18 # Setup computational domain
    19 #------------------------------------------------------------------------------
    20 a = []
    21 
    22 home = os.getenv('INUNDATIONHOME')
     11from anuga.utilities.log_analyser import analyse_log
    2312
    2413
     14#------------------------------------------------------------------------------
     15# Set up variables for the correct directories to store the output
     16#------------------------------------------------------------------------------
     17home = os.getenv('INUNDATIONHOME')
    2518scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    2619                                     "timelength"])
    2720file = 'ex1.csv'
    28 
    29 log.log_filename = os.path.join(scenariodir, 'log.txt')
    30 
    3121file_path = os.path.join(scenariodir, file)
     22store ='store.txt'
     23file_path_store = os.path.join(scenariodir, store)
    3224
    3325spamWriter = csv.writer(open(file_path, 'wb'))
     26spamWriter.writerow(['Time Length(s)' , 'Time Taken(s)', 'Space Used'])
     27e = open(file_path_store,'a')
     28e.close()
    3429
    35 spamWriter.writerow(['Number Of Triangles' , 'Time Taken', 'Space Used'])
     30#main loop that does the same experiment with different time lengths
     31for n in range(1,100000,100):
    3632
     33    h = open(file_path_store,'r+')
     34    h.write(str(n)) #store the time length
    3735
    38 for n in range(1,1000,100):
    39     system_tools.MemoryUpdate()
    40     x = time.clock()
    41     h = ex1.runex(n)
    42     y = time.clock()
    43     b = system_tools.MemoryUpdate()[0]
    44     spamWriter.writerow([h ,(y-x),b])
    45     a.append((h,y-x,b))
    46 print a
     36    x = time.clock() #time it
     37    subprocess.call(['python2.5', 'ex1.py']) #run script
     38    y = time.clock() #time it
     39    spamWriter.writerow([n ,(y-x)]) #write results
    4740
     41print 'Done'
     42
     43#get the memory usage from the log files of each run
     44analyse_log(scenariodir, 'metalog.csv')
  • trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
     
    107import random
    118import os
     9from anuga.abstract_2d_finite_volumes.util import add_directories
     10from anuga.utilities import log
     11
     12#set up the variables for the temporary file directories
     13home = os.getenv('INUNDATIONHOME')
     14scenariodir = add_directories(home, ["data","mem_time_test", "parameters","timestep"])
     15
     16store ='store.txt'
     17file_path_store = os.path.join(scenariodir, store)
     18
     19s = open(file_path_store,'r+') # read the timestep from the text file
     20f = float(s.readline())
     21s.close()
     22
     23#set up the variables for the log files and data directories
     24scenariodirV = add_directories(home, ["data","mem_time_test", "parameters",
     25                                       "timestep", "timestep-" + str(f)])
     26log.log_filename = os.path.join(scenariodirV, "anuga.log")
     27log._setup = False
     28
     29log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here
    1230#------------------------------------------------------------------------------
    1331# Setup computational domain
    1432#------------------------------------------------------------------------------
    15 from anuga.abstract_2d_finite_volumes.util import add_directories
     33points, vertices, boundary = anuga.rectangular_cross(10,5,len1=10.0, len2=5.0) # Mesh
     34domain = anuga.Domain(points, vertices, boundary) # Create domain
     35domain.set_name('channel1') # Output name
     36domain.set_datadir(scenariodirV)
    1637
    17 home = os.getenv('INUNDATIONHOME')
    18 scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    19                                      "timestep"])
    20 
    21 def runex(f):
    22    points, vertices, boundary = anuga.rectangular_cross(10,5,
    23    len1=10.0, len2=5.0) # Mesh
    24    domain = anuga.Domain(points, vertices, boundary) # Create domain
    25    domain.set_name('channel1') # Output name
    26    domain.set_datadir(scenariodir)
     38log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage here
    2739#------------------------------------------------------------------------------
    2840# Setup initial conditions
    2941#------------------------------------------------------------------------------
    30    def topography(x, y):
    31        return -x/10 # linear bed slope
    32        domain.set_quantity('elevation', topography) # Use function for elevation
    33        domain.set_quantity('friction', 0.01) # Constant friction
    34        domain.set_quantity('stage', # Dry bed
    35                            expression='elevation')
     42def topography(x, y):
     43    return -x/10 # linear bed slope
     44domain.set_quantity('elevation', topography) # Use function for elevation
     45domain.set_quantity('friction', 0.01) # Constant friction
     46domain.set_quantity('stage', expression='elevation')
     47
     48log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here
    3649
    3750#------------------------------------------------------------------------------
    3851# Setup boundary conditions
    3952#------------------------------------------------------------------------------
    40    Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    41    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    42    domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     53Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
     54Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     55domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
    4356
     57log.resource_usage_timing(prefix='afterboundary') #get memory usage here
    4458#------------------------------------------------------------------------------
    4559# Evolve system through time
    4660#------------------------------------------------------------------------------
    47    for t in domain.evolve(yieldstep=f, finaltime=40.0):
    48       print domain.timestepping_statistics()
     61for t in domain.evolve(yieldstep=f, finaltime=40.0):
     62    print domain.timestepping_statistics()
    4963
     64log.resource_usage_timing(prefix='aftersimulation') #get memory usage here
    5065
  • trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
    10 import random
    116import subprocess
    12 import ex1
    137import csv
    148import os
    15 from anuga.utilities import system_tools, log
     9from anuga.utilities import log
    1610from anuga.abstract_2d_finite_volumes.util import add_directories
     11from anuga.utilities.log_analyser import analyse_log
     12
    1713#------------------------------------------------------------------------------
    18 # Setup computational domain
     14# Set up variables for the correct directories to store the output
    1915#------------------------------------------------------------------------------
    20 a = []
    2116home = os.getenv('INUNDATIONHOME')
    22 
    23 
    2417scenariodir = add_directories(home, ["data","mem_time_test", "parameters",
    2518                                     "timestep"])
    2619file = 'ex1.csv'
    27 
    28 log.log_filename = os.path.join(scenariodir, 'log.txt')
    29 
    3020file_path = os.path.join(scenariodir, file)
     21store ='store.txt'
     22file_path_store = os.path.join(scenariodir, store)
    3123
    3224spamWriter = csv.writer(open(file_path, 'wb'))
     25spamWriter.writerow(['TimeStep' , 'Time Taken','Space Used'])
    3326
    34 spamWriter.writerow(['Friction' , 'Time Taken','Space Used'])
     27e = open(file_path_store,'a') # create file
     28e.close()
    3529
     30#main loop that runs the script with different time steps (yield steps)
     31for n in range(1,10000,10):
     32    n = n/100.0 # get it in the right range
    3633
    37 for n in range(1,100,1):
    38     n = n/100.0
    39     system_tools.MemoryUpdate()
    40     x = time.clock()
    41     ex1.runex(n)
    42     y = time.clock()
    43     b = system_tools.MemoryUpdate()[0]
    44     spamWriter.writerow([n ,(y-x),b])
    45     a.append((n,y-x,b))
    46 print a
     34    g = open(file_path_store,'r+')
     35    g.write(str(n)) #write the time step to the file
    4736
     37    x = time.clock()#time it
     38    subprocess.call(['python2.5', 'ex1.py']) # run it
     39    y = time.clock() #time it
     40    spamWriter.writerow([n ,(y-x),'b']) #record results
     41
     42print 'Done'
     43
     44analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
  • trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
     
    117import os
    128from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    1310
     11#set up the variables for the temporary storage files
    1412home = os.getenv('INUNDATIONHOME')
    1513scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    1614                                     "channelflow"])
     15store = 'store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen = 'storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
    1719
     20#read the percentage of water coverage and the length of the boundary
     21f = open(file_path_store,'r+')
     22length = float(f.readline())
     23f.close()
     24f = open(file_path_storen,'r+')
     25lower = float(f.readline())
     26f.close()
     27
     28#set up variables to store the experiment data and the log file
     29scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
     30                                       "channelflow", "channelflow-" + str(lower) +"-"+ str(length)])
     31log.log_filename = os.path.join(scenariodirV, "anuga.log")
     32log._setup = False
     33
     34log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage
    1835#------------------------------------------------------------------------------
    1936# Setup computational domain
    2037#------------------------------------------------------------------------------
    21 def runex(lower,length):
    22    points, vertices, boundary = anuga.rectangular_cross(50,50,
    23                                                      len1=length, len2=length) # Mesh
     38points, vertices, boundary = anuga.rectangular_cross(100,300,len1=length, len2=length) # Mesh
     39domain = anuga.Domain(points, vertices, boundary) # Create domain
     40domain.set_datadir(scenariodir)
     41domain.set_name('channel1.sww') # Output name
    2442
     43log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
    2544#--------------------------------------------------------------------------
    26 # Setup Domain only on processor 0
     45# Setup Initial Conditions
    2746#--------------------------------------------------------------------------
    28    domain = anuga.Domain(points, vertices, boundary) # Create domain
    29    domain.set_datadir(scenariodir)
    30    domain.set_name('channel1.sww') # Output name
     47def topography(x, y):
     48    z = -x/10
     49    N = len(x)
     50   
     51    #makes a step
     52    for i in range(N):
    3153
    32    def topography(x, y):
    33       z = -x/10
    34       N = len(x)
    35       for i in range(N):
    36          if y[i] > lower:
    37             z[i] += 1
     54        if y[i] > lower:
     55           z[i] += 1
    3856             
    39       return  z
     57    return  z
    4058
    41    domain.set_quantity('elevation', topography) # Use function for elevation
    42    domain.set_quantity('friction', 0.01) # Constant friction
    43    domain.set_quantity('stage', -1000.0)
     59domain.set_quantity('elevation', topography) # Use function for elevation
     60domain.set_quantity('friction', 0.01) # Constant friction
     61domain.set_quantity('stage', -10000000000000000000000.0)
    4462
    45 
     63log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    4664#------------------------------------------------------------------------------
    4765# Setup boundary conditions
    4866#------------------------------------------------------------------------------
    49    Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow
    50    Bo = anuga.Dirichlet_boundary([-100,0,0])
    51    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    52    domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
     67Bi = anuga.Dirichlet_boundary([0.5, 1, 0]) # Inflow
     68Bo = anuga.Dirichlet_boundary([-100,0,0])
     69Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     70domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
    5371
     72log.resource_usage_timing(prefix='afterboundary')#get memory usage
    5473#------------------------------------------------------------------------------
    5574# Evolve system through time
    5675#------------------------------------------------------------------------------
    57    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    58      #if myid == 0:
    59        domain.write_time()
     76for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     77    domain.write_time()
    6078
    61 #domain.sww_merge()
    62 #finalize()
    63 
     79log.resource_usage_timing(prefix='aftersimulation') #get memory usage
  • trunk/anuga_work/development/mem_time_tests/scenarios/channelflow/main.py

    r8320 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import random
    106import subprocess
    11 import ex1
    127import csv
    138import os
    149import time
    15 from anuga.utilities import system_tools, log
    1610from anuga.abstract_2d_finite_volumes.util import add_directories
     11from anuga.utilities.log_analyser import analyse_log
    1712
    1813#------------------------------------------------------------------------------
    19 # Setup computational domain
     14# Set up variables for the correct directories to store the output
    2015#------------------------------------------------------------------------------
    21 a = []
    22 
    23 
    2416home = os.getenv('INUNDATIONHOME')
    2517scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    2618                                     "channelflow"])
    27 
    28 log.log_filename = os.path.join(scenariodir, 'log.txt')
    29 
     19store ='store.txt'
     20file_path_store = os.path.join(scenariodir, store)
     21storen ='storen.txt'
     22file_path_storen = os.path.join(scenariodir, storen)
    3023file = 'ex1.csv'
    3124file_path = os.path.join(scenariodir, file)
    3225
     26#set up the output files
    3327spamWriter = csv.writer(open(file_path, 'wb'))
    3428spamWriter.writerow(['Length','Stage','Time','Space'])
     29e = open(file_path_store,'a')
     30e.close()
     31e = open(file_path_storen,'a')
     32e.close()
    3533
     34#the main loops that give the length of the inflow boundary (i) and the place to begin the step (n)
    3635for i in range(100,100000,10000):
     36    for n in range(1,i/10,i/100):
     37       
     38        #adjust
     39        i = i /100.0
     40        n = n/10.0
    3741
    38     for n in range(1,i/10,i/100):
    39         i = i /100.0
    40         n = n/float(i)
    41         system_tools.MemoryUpdate()
    42         z = time.time()
    43         ex1.runex(n,i)
    44         b = system_tools.MemoryUpdate()[0]
    45         y = time.time()
    46         spamWriter.writerow([i,(n/float(i)) ,(y-z), b])
    47 print a
     42        #write these values to files
     43        g = open(file_path_store,'r+')
     44        g.write(str(i))
     45        h = open(file_path_storen,'r+')
     46        h.write(str(n))
    4847
     48        z = time.time() #time it
     49        subprocess.call(['python2.5', 'ex1.py'])#run the script
     50        y = time.time() #time it
     51
     52        spamWriter.writerow([i,n,(y-z), 'b'])#record it
     53print 'DONE'
     54
     55analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the various log files
  • trunk/anuga_work/development/mem_time_tests/scenarios/stage/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
     
    117import os
    128from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    1310
     11#set up the variables for the temporary data storage
    1412home = os.getenv('INUNDATIONHOME')
    1513scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    1614                                     "stage"])
     15store = 'store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen = 'storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
    1719
     20#read the values from the text files
     21f = open(file_path_store,'r+')
     22l = float(f.readline())
     23f.close()
     24f = open(file_path_storen,'r+')
     25tide = float(f.readline())
     26f.close()
    1827
     28#set up variables to store the output of the simulation and the log files
     29scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
     30                                       "stage", "stage-" + str(tide) +"-"+ str(l)])
     31log.log_filename = os.path.join(scenariodirV, "anuga.log")
     32log._setup = False
    1933
     34log.resource_usage_timing(prefix = 'BeforeSimulation')# get memory usage
    2035#------------------------------------------------------------------------------
    2136# Setup computational domain
    2237#------------------------------------------------------------------------------
    23 def runex(l,tide):
     38points, vertices, boundary = anuga.rectangular_cross(100,300,
     39                                                     len1=l, len2=(l/2)) # Mesh
     40domain = anuga.Domain(points, vertices, boundary) # Create domain
     41domain.set_datadir(scenariodirV)
     42domain.set_name('channel1') # Output name
    2443
    25    points, vertices, boundary = anuga.rectangular_cross(50,50,
    26                                                      len1=l, len2=(l/2)) # Mesh
    27 
     44log.resource_usage_timing(prefix = 'AfterMesh')# get memory usage
    2845
    2946#--------------------------------------------------------------------------
    30 # Setup Domain only on processor 0
     47# Setup initial conditions
    3148#--------------------------------------------------------------------------
     49def topography(x, y):
     50    return  0 #flat land
     51domain.set_quantity('elevation', topography) # Use function for elevation
     52domain.set_quantity('friction', 0.01) # Constant friction
     53domain.set_quantity('stage', tide)
    3254
    33    domain = anuga.Domain(points, vertices, boundary) # Create domain
    34    domain.set_datadir(scenariodir)
    35    domain.set_name('channel1') # Output name
    36 
    37    def topography(x, y):
    38        return  0 #-x/10  linear bed slope
    39    domain.set_quantity('elevation', topography) # Use function for elevation
    40    domain.set_quantity('friction', 0.01) # Constant friction
    41    domain.set_quantity('stage', tide)
    42    
     55log.resource_usage_timing(prefix='afterinitialconditions') # get memory usage
    4356
    4457#------------------------------------------------------------------------------
    4558# Setup boundary conditions
    4659#------------------------------------------------------------------------------
    47 #Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow
    48    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    49    domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
     60Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     61domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
     62
     63log.resource_usage_timing(prefix='afterboundary')# get memory usage
    5064
    5165#------------------------------------------------------------------------------
    5266# Evolve system through time
    5367#------------------------------------------------------------------------------
    54    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    55        domain.write_time()
     68for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     69    domain.write_time()
    5670
    57 #domain.sww_merge()
    58 #finalize()
    59 
     71log.resource_usage_timing(prefix='aftersimulation')# get memory usage
  • trunk/anuga_work/development/mem_time_tests/scenarios/stage/main.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import random
    106import subprocess
    11 import ex1
    127import csv
    138import os
    149import time
    15 from anuga.utilities import system_tools, log
    1610from anuga.abstract_2d_finite_volumes.util import add_directories
    17 
     11from anuga.utilities.log_analyser import analyse_log
    1812
    1913#------------------------------------------------------------------------------
    20 # Setup computational domain
     14# Set up variables for the correct directories to store the output
    2115#------------------------------------------------------------------------------
    22 a = []
    23 
    2416home = os.getenv('INUNDATIONHOME')
    2517scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    2618                                     "stage"])
    27 
    28 log.log_filename = os.path.join(scenariodir, 'log.txt')
    2919file = 'ex1.csv'
    3020file_path = os.path.join(scenariodir, file)
     21store ='store.txt'
     22file_path_store = os.path.join(scenariodir, store)
     23storen ='storen.txt'
     24file_path_storen = os.path.join(scenariodir, storen)
    3125
     26#create files
    3227spamWriter = csv.writer(open(file_path, 'wb'))
    3328spamWriter.writerow(['Stage','Extent','Time','Space'])
     29e = open(file_path_store,'a')
     30e.close()
     31e = open(file_path_storen,'a')
     32e.close()
    3433
     34#these are the main loops that determine the side length of the bounding square(m)
     35#and the depth of the initial water (n)
     36for m in range(100,1000,100):
     37    for n in range(1,100,10):
     38 
     39        # thsese values are written to the files
     40        g = open(file_path_store,'r+')
     41        g.write(str(m))
     42        h = open(file_path_storen,'r+')
     43        h.write(str(n))
    3544
    36 def onevar(b):
    37     for n in range(1,100,10):
    38         system_tools.MemoryUpdate()
    39         z = time.time()
    40         ex1.runex(b,n)
    41         y = time.time()
    42         a = system_tools.MemoryUpdate()[0]
    43         spamWriter.writerow([n ,((b**2)/2),(y-z),a])
    44     print a
     45        z = time.time() #time it
     46        subprocess.call(['python2.5', 'ex1.py']) # run the simulation script
     47        y = time.time() #time it
     48        spamWriter.writerow([n ,((m**2)/2),(y-z),'a']) #record it
     49print 'DONE'
    4550
    46 for m in range(100,1000,100):
    47     onevar(m)
    48 
     51analyse_log(scenariodir, 'metalog.csv') #get the memory usage information from the log files
  • trunk/anuga_work/development/mem_time_tests/scenarios/vel2/ex1.py

    r8304 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import time
     
    117import os
    128from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    1310
     11# set up the variables for the temporary files
    1412home = os.getenv('INUNDATIONHOME')
    15 scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    16                                      "serial"])
     13scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
     14                                     "velocity"])
     15store ='store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen = 'storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
     19storea = 'storea.txt'
     20file_path_storea = os.path.join(scenariodir, storea)
    1721
     22# read the velocity and the map side length from the text files
     23f = open(file_path_store,'r+')
     24k = float(f.readline())
     25f.close()
     26f = open(file_path_storen,'r+')
     27l = float(f.readline())
     28f.close()
     29
     30#set up variables for the simulation output and the log files
     31scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios",
     32                                       "velocity", "velocity-" + str(k) +"-"+ str(l)])
     33log.log_filename = os.path.join(scenariodirV, "anuga.log")
     34log._setup = False
     35
     36log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
    1837#------------------------------------------------------------------------------
    1938# Setup computational domain
    2039#------------------------------------------------------------------------------
    21 def runex(k,l):
     40points, vertices, boundary = anuga.rectangular_cross(100,300, len1=1000, len2=500) # Mesh
     41domain = anuga.Domain(points, vertices, boundary) # Create domain
     42domain.set_name('channel1') # Output name
     43domain.set_datadir(scenariodirV)
    2244
    23    points, vertices, boundary = anuga.rectangular_cross(100,100,
    24                                                        len1=l, len2=l) # Mesh
     45log.resource_usage_timing(prefix = 'AfterMesh')  #get memory usage
     46
     47#get the number of triangles
     48number = len(domain)
    2549
    2650#--------------------------------------------------------------------------
    27 # Setup Domain only on processor 0
     51# Setup initial conditions
    2852#--------------------------------------------------------------------------
    29    domain = anuga.Domain(points, vertices, boundary) # Create domain
    30    domain.set_name('channel1') # Output name
    31    domain.set_datadir(scenariodir)
    32    
    33    number = len(domain)
     53def topography(x, y):
     54    return  0.0
     55domain.set_quantity('elevation', topography) # Use function for elevation
     56domain.set_quantity('friction', 0.01) # Constant friction
     57domain.set_quantity('stage', -1000.0)
    3458
    35    def topography(x, y):
    36        return  0.0
    37 
    38    domain.set_quantity('elevation', topography) # Use function for elevation
    39    domain.set_quantity('friction', 0.01) # Constant friction
    40    domain.set_quantity('stage', -1000.0)
     59log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    4160
    4261#------------------------------------------------------------------------------
    4362# Setup boundary conditions
    4463#------------------------------------------------------------------------------
    45    Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow
    46    Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    47    Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
    48    domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
     64Bi = anuga.Dirichlet_boundary([0.5, k, 0]) # Inflow
     65Br = anuga.Reflective_boundary(domain) # Solid reflective wall
     66Bo = anuga.Dirichlet_boundary([-0.5, 0, 0]) # Outflow
     67domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
     68
     69log.resource_usage_timing(prefix='afterboundary')#get memory usage
    4970
    5071#------------------------------------------------------------------------------
    5172# Evolve system through time
    5273#------------------------------------------------------------------------------
    53    for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
    54        domain.write_time()
     74for t in domain.evolve(yieldstep=0.2, finaltime=40.0):
     75    domain.write_time()
    5576
    56    return number
     77log.resource_usage_timing(prefix='aftersimulation')  #get memory usage
    5778
     79#write the number of triangles to the file
     80c = open(file_path_storea,'r+')
     81c.write(str(number))
  • trunk/anuga_work/development/mem_time_tests/scenarios/vel2/main.py

    r8320 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import random
    106import subprocess
    11 import ex1
    127import csv
    138import os
    149import time
    15 from anuga.utilities import log
    16 from anuga.utilities import system_tools
    1710from anuga.abstract_2d_finite_volumes.util import add_directories
     11from anuga.utilities.log_analyser import analyse_log
    1812
    1913#------------------------------------------------------------------------------
    20 # Setup computational domain
     14# Set up variables for the correct directories to store the output
    2115#------------------------------------------------------------------------------
    22 a = []
    23 
    2416home = os.getenv('INUNDATIONHOME')
    2517scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
    2618                                     "velocity"])
    27 
    2819file = 'ex1.csv'
    2920file_path = os.path.join(scenariodir, file)
     21storea ='storea.txt'
     22file_path_storea = os.path.join(scenariodir, storea)
     23store ='store.txt'
     24file_path_store = os.path.join(scenariodir, store)
     25storen ='storen.txt'
     26file_path_storen = os.path.join(scenariodir, storen)
    3027
    31 log.log_filename = os.path.join(scenariodir, 'log.txt')
    32 
     28#create and set up the files
    3329spamWriter = csv.writer(open(file_path, 'wb'))
    3430spamWriter.writerow(['Velocity','Number Of Triangles','Extent','Time','Space'])
    35 system_tools.MemoryUpdate()
     31e = open(file_path_storea,'a')
     32e.close()
     33e = open(file_path_store,'a')
     34e.close()
     35e = open(file_path_storen,'a')
     36e.close()
    3637
     38# these are the main loops that give the velocity of inflow (m) and the map side length(n)
     39for m in range(0,250,10):
     40     for n in range(1,2000,300): 
     41        #write these values to the temporary file
     42        g = open(file_path_store,'r+')
     43        g.write(str(m))
     44        h = open(file_path_storen,'r+')
     45        h.write(str(n))
    3746
    38 for m in range(0,250,10):
    39      for i in range(1,2000,100): 
    40         system_tools.MemoryUpdate()[0]
    41         z = time.time()
    42         h = ex1.runex(k,i)
    43         b = system_tools.MemoryUpdate()[0]
    44         y = time.time()
    45         spamWriter.writerow([k,h,(i*i),(y-z), b])
     47        z = time.time() #time it
     48        subprocess.call(['python2.5', 'ex1.py'])#run simulation script
     49        y = time.time() #time it
    4650
     51        # read the number of triangles from this text file
     52        f = open(file_path_storea,'r+')
     53        h = float(f.readline())
     54        f.close()
     55       
     56        spamWriter.writerow([m,h,(n*n),(y-z), 'b'])# record it
    4757print 'DONE' 
     58
     59analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
  • trunk/anuga_work/development/mem_time_tests/triangles/area/main.py

    r8320 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import subprocess
     
    128import time
    139import liststore
    14 from anuga.utilities import system_tools, log
    1510from anuga.abstract_2d_finite_volumes.util import add_directories
    16 
     11from anuga.utilities.log_analyser import analyse_log
    1712
    1813#------------------------------------------------------------------------------
    19 # Setup computational domain
     14# Set up variables for the correct directories to store the output
    2015#------------------------------------------------------------------------------
    21 a = []
    22 #SpaceUsed = 0.0
    23 #number = 0
    24 
    25 home1 = os.getenv('INUNDATIONHOME')
     16home = os.getenv('INUNDATIONHOME')
    2617host = os.getenv('HOST')
    27 scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","area"])
     18scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"])
    2819file1 = 'ex1.csv'
    2920file_path = os.path.join(scenariodir, file1)
     
    3223storea ='storea.txt'
    3324file_path_storea = os.path.join(scenariodir, storea)
    34 store ='store.txt'
    35 file_path_store = os.path.join(scenariodir, store)
    3625storen ='storen.txt'
    3726file_path_storen = os.path.join(scenariodir, storen)
    3827
    39 log.log_filename = os.path.join(scenariodir, 'log.txt')
    40 
     28#create and set up the files
    4129spamWriter = csv.writer(open(file_path, 'wb'))
    4230spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s'])
    43 e = open(file_path_store,'a')
    44 e.close()
    4531e = open(file_path_storea,'a')
    4632e.close()
     
    5036e.close()
    5137
     38# this is the main loops that assigns the maximum triangle area (m) and the map side length(l)
    5239
     40n = 4 #number of processors to use
    5341for m in range(90,100,10):
    54      n = 4 #number of processors to use
    5542     for l in range(100,2000,100):
    5643       
     44        #write these values to file
    5745        g = open(file_path_storel,'r+')
    5846        g.write(str(l))
     47        h = open(file_path_storea,'r+')
     48        h.write(str(m))
     49       
     50        z = time.time()# time it
    5951
    60         h = open(file_path_storea,'r+')
    61         h.write(str(d))
    62        
    63         z = time.time()
     52        #the different ways each host calls MPI properly
    6453        if (host == 'cyclone.agso.gov.au'):
    65             subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
     54            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    6655        if (host == 'tornado.agso.gov.au'):
    67             subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
     56            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    6857        if (host == 'vayu1'):
    6958            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
     
    7362            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    7463       
    75         y = time.time()
     64        y = time.time()# time it
    7665
    77         f = open(file_path_store,'r+')
    78         x = float(f.readline())
    79         f.close()
    80 
     66        # read the number of triangles from this file
    8167        f = open(file_path_storen,'r+')
    8268        i = float(f.readline())
    8369        f.close()
    8470
    85         spamWriter.writerow([i,d,(l*l),x ,(y-z)])
    86         liststore.store = [0,0,0,0]
    87 
     71        spamWriter.writerow([i,d,(l*l),'x' ,(y-z)])# record it
    8872
    8973print 'Done'
    9074
     75analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
     76
  • trunk/anuga_work/development/mem_time_tests/triangles/area/runcairns.py

    r8314 r8326  
    1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.
    2 
    3 Source data such as elevation and boundary data is assumed to be available in
    4 directories specified by project.py
    5 The output sww file is stored in directory named after the scenario, i.e
    6 slide or fixed_wave.
    7 
    8 The scenario is defined by a triangular mesh created from project.polygon,
    9 the elevation data and a tsunami wave generated by a submarine mass failure.
    10 
    11 Geoscience Australia, 2004-present
    12 """
    13 
    141#------------------------------------------------------------------------------
    152# Import necessary modules
    163#------------------------------------------------------------------------------
    17 # Standard modules
    184import os
    195import time
    206import sys
    217import liststore
    22 
    23 # Related major packages
    248import anuga
    259from anuga_parallel import distribute, myid
    2610from anuga.abstract_2d_finite_volumes.util import add_directories
    27 from anuga.utilities import system_tools, log
     11from anuga.utilities import log
    2812
     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)
    2922
    30 home2 = os.getenv('INUNDATIONHOME')
    31 
    32 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])
    33 
    34 h = 'CAIRNS.msh'
    35 file_pathh = os.path.join(scenariodir2, h)
    36 store ='store.txt'
    37 file_path_store = os.path.join(scenariodir2, store)
    38 storen ='storen.txt'
    39 file_path_storen = os.path.join(scenariodir2, storen)
    40 storel = 'storel.txt'
    41 file_path_storel = os.path.join(scenariodir2, storel)
    42 storea = 'storea.txt'
    43 file_path_storea = os.path.join(scenariodir2, storea)
    44 
    45 f = open(file_path_storel,'r+') # SQRT extent this is set
     23#read the maximum triangle area and the map side length from the files
     24f = open(file_path_storel,'r+')
    4625length = float(f.readline())
    4726f.close()
    48 
    49 f = open(file_path_storea,'r+') #maxarea this is set
     27f = open(file_path_storea,'r+')
    5028area = float(f.readline())
    5129f.close()
    5230
    53 system_tools.MemoryUpdate()
     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
    5440#------------------------------------------------------------------------------
    55 # Create the triangular mesh and domain based on
    56 # overall clipping polygon with a tagged
    57 # boundary and interior regions as defined in project.py
     41# Create the triangular mesh and domain on one processor
    5842#------------------------------------------------------------------------------
    5943if myid == 0:
     
    6549                                    maximum_triangle_area=area,
    6650                                    mesh_filename=file_pathh
    67                                     #,interior_regions=INTERIORREGIONS#,
    68                                     #use_cache=True,
    69                                     #verbose=True)
    7051                                    )
     52    #get the number of triangles
     53    n = len(domain)
    7154
    72     n = len(domain)
    7355else:
    7456    domain = None
    75      
    76 domain = distribute(domain)
    77                                
    78 #------------------------------------------------------------------------------
    79 # Setup parameters of computational domain
    80 #------------------------------------------------------------------------------
     57 
     58#parallel   
     59domain = distribute(domain)                               
     60
    8161domain.set_name('CAIRNS.sww') # Name of sww file
    82 domain.set_datadir(scenariodir2)                       # Store sww output here
     62domain.set_datadir(scenariodirV)# Store sww output here
    8363
     64log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
    8465#------------------------------------------------------------------------------
    8566# Setup initial conditions
     
    9576domain.set_quantity('elevation',topography,alpha=0.1)
    9677
    97 
     78log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    9879
    9980#------------------------------------------------------------------------------
     
    10283
    10384Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
    104 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
    105 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
     85Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow
    10686Br = anuga.Reflective_boundary(domain)
    107 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
    108 domain.set_boundary({'right': Bo,
    109                      'bottom': Br,
    110                      'left': Bi,
    111                      'top': Br})
     87domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
    11288
    113 
     89log.resource_usage_timing(prefix='afterboundary')#get memory usage
    11490#------------------------------------------------------------------------------
    11591# Evolve system through time
    11692#------------------------------------------------------------------------------
    117 
    118 # Save every two mins leading up to wave approaching land
    11993for t in domain.evolve(yieldstep=120, finaltime=2000):
    12094    print domain.timestepping_statistics()
    121    
    12295
    123 liststore.store[myid] = system_tools.MemoryUpdate()[0]
    124 a = sum(liststore.store)
     96log.resource_usage_timing(prefix='aftersimulation') #get memory usage
    12597
    126 v = open(file_path_store, 'r+')
    127 v.write(str(a))
    128 
     98#write the number of triangles to file
    12999i = open(file_path_storen, 'r+')
    130100i.write(str(n))
  • trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py

    r8303 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import subprocess
    10 import runcairns
    116import csv
    127import os
    138import time
    14 from anuga.utilities import system_tools, log
    159from anuga.abstract_2d_finite_volumes.util import add_directories
     10from anuga.utilities.log_analyser import analyse_log
    1611
    1712#------------------------------------------------------------------------------
    18 # Setup computational domain
     13# Set up variables for the correct directories to store the output
    1914#------------------------------------------------------------------------------
    20 a = []
    21 
    22 
    2315home = os.getenv('INUNDATIONHOME')
    2416scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    2517                                     "fromregions"])
    26 log.log_filename = os.path.join(scenariodir, 'log.txt')
    27 
     18storea ='storea.txt'
     19file_path_storea = os.path.join(scenariodir, storea)
     20store ='store.txt'
     21file_path_store = os.path.join(scenariodir, store)
     22storen ='storen.txt'
     23file_path_storen = os.path.join(scenariodir, storen)
    2824file = 'ex1.csv'
    2925file_path = os.path.join(scenariodir, file)
    3026
     27#create and set up the files
    3128spamWriter = csv.writer(open(file_path, 'wb'))
    3229spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s'])
     30e = open(file_path_storea,'a')
     31e.close()
     32e = open(file_path_store,'a')
     33e.close()
     34e = open(file_path_storen,'a')
     35e.close()
    3336
     37#these are the main loops that determine the maximum triangle area (m) and the map side length(n)
     38for m in range(1,100,10):
     39    for n in range(1,1000,100):
    3440
     41        #write these values to file
     42        g = open(file_path_store,'r+')
     43        g.write(str(m))
     44        h = open(file_path_storen,'r+')
     45        h.write(str(n))
    3546
    36 def runlist(r):
    37     for n in range(1,2000,100):
    38         system_tools.MemoryUpdate()
    39         z = time.time()
    40         h = runcairns.runex(n,r)
    41         y = time.time()
    42         x = system_tools.MemoryUpdate()[0]
    43         spamWriter.writerow([h,r,(n*n),x ,(y-z)])
     47        z = time.time() #time it
     48        subprocess.call(['python2.5', 'runcairns.py'])#run simulation
     49        y = time.time() #time it
    4450
    45 for m in range(1,100,10):
    46     runlist(m)
     51        #read the number of triangles from this text file
     52        f = open(file_path_storea,'r+')
     53        h = float(f.readline())
     54        f.close()
    4755
     56        spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it
    4857print 'DONE'
    4958
     59analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
  • trunk/anuga_work/development/mem_time_tests/triangles/fromregions/runcairns.py

    r8303 r8326  
    1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.
    2 
    3 Source data such as elevation and boundary data is assumed to be available in
    4 directories specified by project.py
    5 The output sww file is stored in directory named after the scenario, i.e
    6 slide or fixed_wave.
    7 
    8 The scenario is defined by a triangular mesh created from project.polygon,
    9 the elevation data and a tsunami wave generated by a submarine mass failure.
    10 
    11 Geoscience Australia, 2004-present
    12 """
    13 
    14 
    15 
    161#------------------------------------------------------------------------------
    172# Import necessary modules
    183#------------------------------------------------------------------------------
    19 # Standard modules
    204import os
    215import time
    226import sys
    237import random
    24 
    25 # Related major packages
    26 
    278import anuga
    289from anuga.abstract_2d_finite_volumes.util import add_directories
     10from anuga.utilities import log
    2911
    30 
     12# set up the variables for the temporary files
    3113home = os.getenv('INUNDATIONHOME')
    3214scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    3315                                     "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)
    3422
     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()
    3530
    36 file = 'CAIRNS.sww'
    37 file_path = os.path.join(scenariodir, file)
     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
    3838
    39 h = 'CAIRNS.msh'
    40 file_pathh = os.path.join(scenariodir, h)
    41 
    42 def runex(l,a):
    43 
     39log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage
    4440#------------------------------------------------------------------------------
    45 # Create the triangular mesh and domain based on
    46 # overall clipping polygon with a tagged
    47 # boundary and interior regions as defined in project.py
     41# Create the triangular mesh and domain
    4842#------------------------------------------------------------------------------
    49     domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
     43domain = anuga.create_domain_from_regions([(0.0,0.0),(l,l),(0.0,l),(l,0.0)],
    5044                                    boundary_tags={'top': [0],
    5145                                                   'right': [1],
     
    5448                                    maximum_triangle_area=a,
    5549                                    mesh_filename=file_pathh
    56                                     #,interior_regions=INTERIORREGIONS#,
    57                                     #use_cache=True,
    58                                     #verbose=True)
    59                                     )
    60 
    61     number=len(domain)
    62 
    63                                
    64 #------------------------------------------------------------------------------
    65 # Setup parameters of computational domain
    66 #------------------------------------------------------------------------------
    67     domain.set_name('CAIRNS.sww') # Name of sww file
    68     domain.set_datadir(scenariodir)                       # Store sww output here
    69 
     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
    7054#------------------------------------------------------------------------------
    7155# Setup initial conditions
    7256#------------------------------------------------------------------------------
    7357
    74     def topography(x,y):
    75         return 0.0
     58#get the number of triangles
     59number=len(domain)
    7660
    77     tide = 100.0
    78     friction = 0.0
    79     domain.set_quantity('stage', tide)
    80     domain.set_quantity('friction', friction)
    81     domain.set_quantity('elevation',topography,alpha=0.1)
     61def topography(x,y):
     62    return 0.0
    8263
     64tide = 100.0
     65friction = 0.0
     66domain.set_quantity('stage', tide)
     67domain.set_quantity('friction', friction)
     68domain.set_quantity('elevation',topography,alpha=0.1)
    8369
     70log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    8471
    8572#------------------------------------------------------------------------------
    8673# Setup boundary conditions
    8774#------------------------------------------------------------------------------
     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})
    8880
    89     Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
    90     Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
    91     Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
    92     Br = anuga.Reflective_boundary(domain)
    93 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
    94     domain.set_boundary({'right': Bo,
    95                      'bottom': Br,
    96                      'left': Bi,
    97                      'top': Br})
    98 
     81log.resource_usage_timing(prefix='afterboundary')#get memory usage
    9982#------------------------------------------------------------------------------
    10083# Evolve system through time
    10184#------------------------------------------------------------------------------
    102 
    103 # Save every two mins leading up to wave approaching land
    104     for t in domain.evolve(yieldstep=120, finaltime=2000):
    105         print domain.timestepping_statistics()
    106    
    107 
    108     return number
    109 
     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))
  • trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/main.py

    r8303 r8326  
    1 """Simple water flow example using ANUGA
    2 Water flowing down a channel
    3 """
    41#------------------------------------------------------------------------------
    52# Import necessary modules
    63#------------------------------------------------------------------------------
    7 # Import standard shallow water domain and standard boundaries.
    84import anuga
    95import subprocess
    10 import runcairns
    116import csv
    127import os
    138import time
     9from anuga.abstract_2d_finite_volumes.util import add_directories
     10from anuga.utilities.log_analyser import analyse_log
    1411
    15 from anuga.utilities import system_tools, log
    16 from anuga.abstract_2d_finite_volumes.util import add_directories
    17 
     12#------------------------------------------------------------------------------
     13# Set up variables for the correct directories to store the output
     14#------------------------------------------------------------------------------
    1815home = os.getenv('INUNDATIONHOME')
    1916scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    2017                                     "rectanglecross"])
    21 
    22 log.log_filename = os.path.join(scenariodir, 'log.txt')
    23 
     18storea ='storea.txt'
     19file_path_storea = os.path.join(scenariodir, storea)
     20store ='store.txt'
     21file_path_store = os.path.join(scenariodir, store)
     22storen ='storen.txt'
     23file_path_storen = os.path.join(scenariodir, storen)
    2424file = 'ex1.csv'
    2525file_path = os.path.join(scenariodir, file)
    2626
    27 #------------------------------------------------------------------------------
    28 # Setup computational domain
    29 #------------------------------------------------------------------------------
    30 a = []
     27#create and set up the output files
    3128spamWriter = csv.writer(open(file_path, 'wb'))
    3229spamWriter.writerow(['Number Of Triangles' ,'MxM Rectangular Mesh', 'Extent', 'Space Used MB' , 'Time Taken s'])
     30e = open(file_path_storea,'a')
     31e.close()
     32e = open(file_path_store,'a')
     33e.close()
     34e = open(file_path_storen,'a')
     35e.close()
    3336
     37#these main loops assign the matrix size[number of triangles] (m) and the map side length(n)
     38for m in range(1,500,10):
     39    for n in range(1,1000,100):
    3440
     41        #write these values to file
     42        g = open(file_path_store,'r+')
     43        g.write(str(m))
     44        h = open(file_path_storen,'r+')
     45        h.write(str(n))
    3546
    36 def runlist(r):
    37     for n in range(1,2000,100):
    38         system_tools.MemoryUpdate()
    39         z = time.time()
    40         h = runcairns.runex(n,r)
    41         y = time.time()
    42         x = system_tools.MemoryUpdate()[0]
    43         spamWriter.writerow([h,r,(n*n),x ,(y-z)])
     47        z = time.time() #time it
     48        subprocess.call(['python2.5', 'runcairns.py']) #run the simulation
     49        y = time.time() #time it
    4450
    45 for m in range(1,100,10):
    46     runlist(m)
     51        #read the number of triangles from this file
     52        f = open(file_path_storea,'r+')
     53        h = float(f.readline())
     54        f.close()
    4755
     56        spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it
    4857print 'DONE'
    4958
     59analyse_log(scenariodir, 'metalog.csv')#get the memory statistics from the log files
     60
  • trunk/anuga_work/development/mem_time_tests/triangles/rectanglecross/runcairns.py

    r8303 r8326  
    1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia.
    2 
    3 Source data such as elevation and boundary data is assumed to be available in
    4 directories specified by project.py
    5 The output sww file is stored in directory named after the scenario, i.e
    6 slide or fixed_wave.
    7 
    8 The scenario is defined by a triangular mesh created from project.polygon,
    9 the elevation data and a tsunami wave generated by a submarine mass failure.
    10 
    11 Geoscience Australia, 2004-present
    12 """
    13 
    14 
    15 
    161#------------------------------------------------------------------------------
    172# Import necessary modules
    183#------------------------------------------------------------------------------
    19 # Standard modules
    204import os
    215import time
    226import sys
    23 import random
    24 
    25 # Related major packages
    267import anuga
    278from anuga.abstract_2d_finite_volumes.util import add_directories
     9from anuga.utilities import log
    2810
     11#set up the variables for the temporary data files
    2912home = os.getenv('INUNDATIONHOME')
    3013scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
    3114                                     "rectanglecross"])
     15store ='store.txt'
     16file_path_store = os.path.join(scenariodir, store)
     17storen ='storen.txt'
     18file_path_storen = os.path.join(scenariodir, storen)
     19storea = 'storea.txt'
     20file_path_storea = os.path.join(scenariodir, storea)
    3221
     22#read the matrix size(number of triangles) and the map size from these files
     23f = open(file_path_store,'r+')
     24a = int(f.readline())
     25f.close()
     26f = open(file_path_storen,'r+')
     27l = float(f.readline())
     28f.close()
    3329
    34 file = 'CAIRNS.sww'
    35 file_path = os.path.join(scenariodir, file)
     30#set up the variables for the simulation out put and log files
     31scenariodirV = add_directories(home, ["data","mem_time_test", "triangles",
     32                                       "rectanglecross", "triangles-" + str(a) +"-"+ str(l)])
     33log.log_filename = os.path.join(scenariodirV, "anuga.log")
     34log._setup = False
    3635
    37 h = 'CAIRNS.msh'
    38 file_pathh = os.path.join(scenariodir, h)
    39 
    40 
    41 def runex(l,a):
    42 
    43 
     36log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory usage
    4437#------------------------------------------------------------------------------
    45 # Create the triangular mesh and domain based on
    46 # overall clipping polygon with a tagged
    47 # boundary and interior regions as defined in project.py
     38# Create the triangular mesh and domain
    4839#------------------------------------------------------------------------------
    49    
    50     points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh
    51     domain = anuga.Domain(points, vertices, boundary) # Create domain
    52 
    53     number=len(domain)
    54 
    55                                
    56 #------------------------------------------------------------------------------
    57 # Setup parameters of computational domain
    58 #------------------------------------------------------------------------------
    59     domain.set_name('CAIRNS.sww') # Name of sww file
    60     domain.set_datadir(scenariodir)                       # Store sww output here
    61 
     40points, vertices, boundary = anuga.rectangular_cross(a, a,len1 = l,len2 = l) # Basic mesh
     41domain = anuga.Domain(points, vertices, boundary) # Create
     42domain.set_name('CAIRNS.sww') # Name of sww file
     43domain.set_datadir(scenariodirV)# Store sww output here
     44log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage
    6245#------------------------------------------------------------------------------
    6346# Setup initial conditions
    6447#------------------------------------------------------------------------------
    6548
    66     def topography(x,y):
    67         return 0.0
     49#get the number of triangles
     50number=len(domain)
    6851
    69     tide = 100.0
    70     friction = 0.0
    71     domain.set_quantity('stage', tide)
    72     domain.set_quantity('friction', friction)
    73     domain.set_quantity('elevation',topography,alpha=0.1)
     52def topography(x,y):
     53    return 0.0
    7454
     55tide = 100.0
     56friction = 0.0
     57domain.set_quantity('stage', tide)
     58domain.set_quantity('friction', friction)
     59domain.set_quantity('elevation',topography,alpha=0.1)
    7560
    76 
     61log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage
    7762#------------------------------------------------------------------------------
    7863# Setup boundary conditions
    7964#------------------------------------------------------------------------------
     65Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
     66Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # outflow
     67Br = anuga.Reflective_boundary(domain)
     68domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br})
    8069
    81     Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow
    82     Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow
    83     Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
    84     Br = anuga.Reflective_boundary(domain)
    85 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0])
    86     domain.set_boundary({'right': Bo,
    87                      'bottom': Br,
    88                      'left': Bi,
    89                      'top': Br})
    90 
     70log.resource_usage_timing(prefix='afterboundary')#get memory usage
    9171#------------------------------------------------------------------------------
    9272# Evolve system through time
    9373#------------------------------------------------------------------------------
     74for t in domain.evolve(yieldstep=120, finaltime=2000):
     75    print domain.timestepping_statistics()
    9476
    95 # Save every two mins leading up to wave approaching land
    96     for t in domain.evolve(yieldstep=120, finaltime=2000):
    97         print domain.timestepping_statistics()
    98    
    99 
    100     return number
    101 
     77log.resource_usage_timing(prefix='aftersimulation')#get memory usage
     78   
     79#write the number of triangles to the text file
     80v = open(file_path_storea, 'r+')
     81v.write(str(number))
  • trunk/anuga_work/development/mem_time_tests/triangles/serial/main.py

    r8320 r8326  
    1313import os
    1414import time
    15 from anuga.utilities import system_tools, log
     15from anuga.utilities import system_tools, log, log_analyser
    1616from anuga.abstract_2d_finite_volumes.util import add_directories
    17 import logAnalyser
     17
    1818#------------------------------------------------------------------------------
    1919# Setup computational domain
     
    2828                                     "serial"])
    2929file = 'ex1.csv'
    30 
    31 #log.log_filename = os.path.join(scenariodir, 'anuga.log')
    32 
    3330file_path = os.path.join(scenariodir, file)
    34 #print "file_path",file_path
    3531
    3632spamWriter = csv.writer(open(file_path, 'wb'))
     
    4036
    4137
    42 def runlist(r):
    43     n = 1 #20
    44     while (n > 0):
    45         c = 2 #random.random() * 2000 + 1
     38for m in range(40000,50000,10000):
     39
     40    for n in range(9,10,1):
    4641        z = time.time()
    47         h = runcairns.runex(c,r)
     42        h = runcairns.runex(n,m)
    4843        y = time.time()
    4944        n = n -1
    50         #subprocess.call(['python','timingScript.py',scenariodir,outputresource])
    51         logAnalyser.AnalyseLog()
    5245        spamWriter.writerow([h,r,(c*c),'x' ,(y-z)])
    53 
    54 while (m > 0):
    55     m = m -1
    56     d = 101 #random.random() * 100 +1
    57    
    58     runlist(d)
    59 
    6046print 'DONE'
    6147
Note: See TracChangeset for help on using the changeset viewer.