- Timestamp:
- Jan 31, 2012, 10:54:12 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/parameters/timestep/ex1.py
r8304 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules … … 10 7 import random 11 8 import os 9 from anuga.abstract_2d_finite_volumes.util import add_directories 10 from anuga.utilities import log 11 12 #set up the variables for the temporary file directories 13 home = os.getenv('INUNDATIONHOME') 14 scenariodir = add_directories(home, ["data","mem_time_test", "parameters","timestep"]) 15 16 store ='store.txt' 17 file_path_store = os.path.join(scenariodir, store) 18 19 s = open(file_path_store,'r+') # read the timestep from the text file 20 f = float(s.readline()) 21 s.close() 22 23 #set up the variables for the log files and data directories 24 scenariodirV = add_directories(home, ["data","mem_time_test", "parameters", 25 "timestep", "timestep-" + str(f)]) 26 log.log_filename = os.path.join(scenariodirV, "anuga.log") 27 log._setup = False 28 29 log.resource_usage_timing(prefix = 'BeforeSimulation') #get memory usage here 12 30 #------------------------------------------------------------------------------ 13 31 # Setup computational domain 14 32 #------------------------------------------------------------------------------ 15 from anuga.abstract_2d_finite_volumes.util import add_directories 33 points, vertices, boundary = anuga.rectangular_cross(10,5,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(scenariodirV) 16 37 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) 38 log.resource_usage_timing(prefix = 'AfterMesh') #get memory usage here 27 39 #------------------------------------------------------------------------------ 28 40 # Setup initial conditions 29 41 #------------------------------------------------------------------------------ 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') 42 def topography(x, y): 43 return -x/10 # linear bed slope 44 domain.set_quantity('elevation', topography) # Use function for elevation 45 domain.set_quantity('friction', 0.01) # Constant friction 46 domain.set_quantity('stage', expression='elevation') 47 48 log.resource_usage_timing(prefix='afterinitialconditions')#get memory usage here 36 49 37 50 #------------------------------------------------------------------------------ 38 51 # Setup boundary conditions 39 52 #------------------------------------------------------------------------------ 40 41 42 53 Bi = anuga.Dirichlet_boundary([0.4, 0, 0]) # Inflow 54 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 55 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) 43 56 57 log.resource_usage_timing(prefix='afterboundary') #get memory usage here 44 58 #------------------------------------------------------------------------------ 45 59 # Evolve system through time 46 60 #------------------------------------------------------------------------------ 47 48 61 for t in domain.evolve(yieldstep=f, finaltime=40.0): 62 print domain.timestepping_statistics() 49 63 64 log.resource_usage_timing(prefix='aftersimulation') #get memory usage here 50 65
Note: See TracChangeset
for help on using the changeset viewer.