- 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/scenarios/stage/ex1.py
r8304 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules 6 3 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 4 import anuga 9 5 import time … … 11 7 import os 12 8 from anuga.abstract_2d_finite_volumes.util import add_directories 9 from anuga.utilities import log 13 10 11 #set up the variables for the temporary data storage 14 12 home = os.getenv('INUNDATIONHOME') 15 13 scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", 16 14 "stage"]) 15 store = 'store.txt' 16 file_path_store = os.path.join(scenariodir, store) 17 storen = 'storen.txt' 18 file_path_storen = os.path.join(scenariodir, storen) 17 19 20 #read the values from the text files 21 f = open(file_path_store,'r+') 22 l = float(f.readline()) 23 f.close() 24 f = open(file_path_storen,'r+') 25 tide = float(f.readline()) 26 f.close() 18 27 28 #set up variables to store the output of the simulation and the log files 29 scenariodirV = add_directories(home, ["data","mem_time_test", "scenarios", 30 "stage", "stage-" + str(tide) +"-"+ str(l)]) 31 log.log_filename = os.path.join(scenariodirV, "anuga.log") 32 log._setup = False 19 33 34 log.resource_usage_timing(prefix = 'BeforeSimulation')# get memory usage 20 35 #------------------------------------------------------------------------------ 21 36 # Setup computational domain 22 37 #------------------------------------------------------------------------------ 23 def runex(l,tide): 38 points, vertices, boundary = anuga.rectangular_cross(100,300, 39 len1=l, len2=(l/2)) # Mesh 40 domain = anuga.Domain(points, vertices, boundary) # Create domain 41 domain.set_datadir(scenariodirV) 42 domain.set_name('channel1') # Output name 24 43 25 points, vertices, boundary = anuga.rectangular_cross(50,50, 26 len1=l, len2=(l/2)) # Mesh 27 44 log.resource_usage_timing(prefix = 'AfterMesh')# get memory usage 28 45 29 46 #-------------------------------------------------------------------------- 30 # Setup Domain only on processor 047 # Setup initial conditions 31 48 #-------------------------------------------------------------------------- 49 def topography(x, y): 50 return 0 #flat land 51 domain.set_quantity('elevation', topography) # Use function for elevation 52 domain.set_quantity('friction', 0.01) # Constant friction 53 domain.set_quantity('stage', tide) 32 54 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 55 log.resource_usage_timing(prefix='afterinitialconditions') # get memory usage 43 56 44 57 #------------------------------------------------------------------------------ 45 58 # Setup boundary conditions 46 59 #------------------------------------------------------------------------------ 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}) 60 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 61 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 62 63 log.resource_usage_timing(prefix='afterboundary')# get memory usage 50 64 51 65 #------------------------------------------------------------------------------ 52 66 # Evolve system through time 53 67 #------------------------------------------------------------------------------ 54 55 68 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 69 domain.write_time() 56 70 57 #domain.sww_merge() 58 #finalize() 59 71 log.resource_usage_timing(prefix='aftersimulation')# get memory usage
Note: See TracChangeset
for help on using the changeset viewer.