Changeset 3647
- Timestamp:
- Sep 21, 2006, 3:20:23 PM (18 years ago)
- Location:
- anuga_validation/okushiri_2005
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_validation/okushiri_2005/create_okushiri.py
r3646 r3647 6 6 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 7 7 8 from Numeric import array, zeros, Float, allclose 9 8 10 from anuga.pmesh.mesh import * 9 11 from anuga.coordinate_transforms.geo_reference import Geo_reference 10 12 13 import project 14 15 16 def prepare_timeboundary(filename): 17 """Converting benchmark 2 time series to NetCDF tms file. 18 This is a 'throw-away' code taylor made for files like 19 'Benchmark_2_input.txt' from the LWRU2 benchmark 20 """ 21 22 print 'Preparing time boundary from %s' %filename 23 from Numeric import array 24 25 fid = open(filename) 26 27 #Skip first line 28 line = fid.readline() 29 30 #Read remaining lines 31 lines = fid.readlines() 32 fid.close() 33 34 35 N = len(lines) 36 T = zeros(N, Float) #Time 37 Q = zeros(N, Float) #Values 38 39 for i, line in enumerate(lines): 40 fields = line.split() 41 42 T[i] = float(fields[0]) 43 Q[i] = float(fields[1]) 44 45 46 #Create tms file 47 from Scientific.IO.NetCDF import NetCDFFile 48 49 outfile = filename[:-4] + '.tms' 50 print 'Writing to', outfile 51 fid = NetCDFFile(outfile, 'w') 52 53 fid.institution = 'Geoscience Australia' 54 fid.description = 'Input wave for Benchmark 2' 55 fid.starttime = 0.0 56 fid.createDimension('number_of_timesteps', len(T)) 57 fid.createVariable('time', Float, ('number_of_timesteps',)) 58 fid.variables['time'][:] = T 59 60 fid.createVariable('stage', Float, ('number_of_timesteps',)) 61 fid.variables['stage'][:] = Q[:] 62 63 fid.createVariable('xmomentum', Float, ('number_of_timesteps',)) 64 fid.variables['xmomentum'][:] = 0.0 65 66 fid.createVariable('ymomentum', Float, ('number_of_timesteps',)) 67 fid.variables['ymomentum'][:] = 0.0 68 69 fid.close() 70 71 11 72 #------------------------------------------------------------- 12 73 if __name__ == "__main__": 13 74 75 #Preparing points 76 #(Only when using original Benchmark_2_Bathymetry.txt file) 77 #from anuga.abstract_2d_finite_volumes.data_manager import xya2pts 78 #xya2pts(project.bathymetry_filename, verbose = True, 79 # z_func = lambda z: -z) 80 81 82 83 84 85 # Prepare time boundary 86 prepare_timeboundary(project.boundary_filename) 87 88 89 # Create Mesh 14 90 15 91 #Basic geometry -
anuga_validation/okushiri_2005/lwru2.py
r3637 r3647 10 10 """ 11 11 12 # Module imports 13 from Numeric import array, zeros, Float, allclose 14 15 from anuga.shallow_water import Domain 16 from anuga.shallow_water import Reflective_boundary 17 from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary 18 from anuga.abstract_2d_finite_volumes.util import file_function 19 20 import project 21 22 23 #------------------------- 24 # Create Domain 25 #------------------------- 12 26 13 27 use_variable_mesh = True #Use large variable mesh generated by create_mesh.py 14 28 #use_variable_mesh = False #Use small structured mesh for speed 15 29 16 17 #import sys18 #from os import sep19 #sys.path.append('..'+sep+'..'+sep) #FIXME: Shouldn't be necessary20 21 def prepare_timeboundary(filename):22 """Converting benchmark 2 time series to NetCDF tms file.23 This is a 'throw-away' code taylor made for files like24 'Benchmark_2_input.txt' from the LWRU2 benchmark25 """26 27 print 'Preparing time boundary from %s' %filename28 from Numeric import array29 30 fid = open(filename)31 32 #Skip first line33 line = fid.readline()34 35 #Read remaining lines36 lines = fid.readlines()37 fid.close()38 39 40 N = len(lines)41 T = zeros(N, Float) #Time42 Q = zeros(N, Float) #Values43 44 for i, line in enumerate(lines):45 fields = line.split()46 47 T[i] = float(fields[0])48 Q[i] = float(fields[1])49 50 51 #Create tms file52 from Scientific.IO.NetCDF import NetCDFFile53 54 outfile = filename[:-4] + '.tms'55 print 'Writing to', outfile56 fid = NetCDFFile(outfile, 'w')57 58 fid.institution = 'Geoscience Australia'59 fid.description = 'Input wave for Benchmark 2'60 fid.starttime = 0.061 fid.createDimension('number_of_timesteps', len(T))62 fid.createVariable('time', Float, ('number_of_timesteps',))63 fid.variables['time'][:] = T64 65 fid.createVariable('stage', Float, ('number_of_timesteps',))66 fid.variables['stage'][:] = Q[:]67 68 fid.createVariable('xmomentum', Float, ('number_of_timesteps',))69 fid.variables['xmomentum'][:] = 0.070 71 fid.createVariable('ymomentum', Float, ('number_of_timesteps',))72 fid.variables['ymomentum'][:] = 0.073 74 fid.close()75 76 77 # Module imports78 from anuga.shallow_water import Domain, Reflective_boundary,\79 File_boundary, Transmissive_Momentum_Set_Stage_boundary80 81 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross82 from anuga.abstract_2d_finite_volumes.pmesh2domain import pmesh_to_domain_instance83 from Numeric import array, zeros, Float, allclose84 import project85 from caching import cache86 87 #Preparing time boundary88 prepare_timeboundary(project.boundary_filename)89 90 #Preparing points (Only when using original Benchmark_2_Bathymetry.txt file)91 #from anuga.abstract_2d_finite_volumes.data_manager import xya2pts92 #xya2pts(project.bathymetry_filename, verbose = True,93 # z_func = lambda z: -z)94 95 96 97 #######################98 # Create Domain99 30 if use_variable_mesh is True: 100 31 print 'Creating domain from', project.mesh_filename 101 32 102 33 domain = Domain(project.mesh_filename, use_cache=True, verbose=True) 103 104 34 else: 105 35 print 'Creating regular mesh' … … 113 43 114 44 115 116 117 import sys, os 118 base = os.path.basename(sys.argv[0]) 119 domain.filename, _ = os.path.splitext(base) 120 domain.default_order = 2 121 domain.store = True #Store for visualisation purposes 45 domain.set_name('lwru2') 46 domain.set_default_order(2) 122 47 123 48 #domain.check_integrity() … … 127 52 128 53 129 130 ####################### 54 #------------------------- 131 55 # Initial Conditions 132 print 'Initial values' 133 56 #------------------------- 57 domain.set_quantity('friction', 0.0) 58 domain.set_quantity('stage', 0.0) 134 59 domain.set_quantity('elevation', 135 60 filename = project.bathymetry_filename[:-4] + '.pts', 136 #alpha = 0.01,137 61 alpha = 0.02, 138 62 verbose = True, 139 63 use_cache = True) 140 64 141 domain.set_quantity('friction', 0.0) 142 domain.set_quantity('stage', 0.0) 143 144 145 146 ###################### 65 #------------------------- 147 66 # Boundary Conditions 148 # 149 print 'Boundaries' 67 #------------------------- 150 68 Br = Reflective_boundary(domain) 151 69 152 from anuga.abstract_2d_finite_volumes.util import file_function153 70 function = file_function(project.boundary_filename[:-4] + '.tms', 154 71 domain, 155 72 verbose = True) 73 156 74 Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function) 157 75 … … 163 81 164 82 165 166 # ######################167 # Evolve83 #------------------------- 84 # Evolve through time 85 #------------------------- 168 86 import time 169 87 t0 = time.time() -
anuga_validation/okushiri_2005/okushiri_parallel.py
r3645 r3647 23 23 24 24 import project 25 26 27 28 def prepare_timeboundary(filename):29 """Converting benchmark 2 time series to NetCDF tms file.30 This is a 'throw-away' code taylor made for files like31 'Benchmark_2_input.txt' from the LWRU2 benchmark32 """33 34 print 'Preparing time boundary from %s' %filename35 fid = open(filename)36 37 #Skip first line38 line = fid.readline()39 40 #Read remaining lines41 lines = fid.readlines()42 fid.close()43 44 45 N = len(lines)46 T = zeros(N, Float) #Time47 Q = zeros(N, Float) #Values48 49 for i, line in enumerate(lines):50 fields = line.split()51 52 T[i] = float(fields[0])53 Q[i] = float(fields[1])54 55 56 #Create tms file57 from Scientific.IO.NetCDF import NetCDFFile58 59 outfile = filename[:-4] + '.tms'60 print 'Writing to', outfile61 fid = NetCDFFile(outfile, 'w')62 63 fid.institution = 'Geoscience Australia'64 fid.description = 'Input wave for Benchmark 2'65 fid.starttime = 0.066 fid.createDimension('number_of_timesteps', len(T))67 fid.createVariable('time', Float, ('number_of_timesteps',))68 fid.variables['time'][:] = T69 70 fid.createVariable('stage', Float, ('number_of_timesteps',))71 fid.variables['stage'][:] = Q[:]72 73 fid.createVariable('xmomentum', Float, ('number_of_timesteps',))74 fid.variables['xmomentum'][:] = 0.075 76 fid.createVariable('ymomentum', Float, ('number_of_timesteps',))77 fid.variables['ymomentum'][:] = 0.078 79 fid.close()80 81 82 83 #----------------------84 # Preparing time boundary85 #-------------------------86 if myid == 0:87 prepare_timeboundary(project.boundary_filename)88 25 89 26
Note: See TracChangeset
for help on using the changeset viewer.