Changeset 550
- Timestamp:
- Nov 16, 2004, 11:06:07 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/analytical solutions/Analytical solution_wave_runup.py
r547 r550 16 16 ###################### 17 17 # Module imports 18 #19 20 18 import sys 21 19 from os import sep 22 20 sys.path.append('..'+sep+'pyvolution') 23 21 24 from shallow_water import Transmissive_boundary, Reflective_boundary,\ 25 Dirichlet_boundary 26 from shallow_water import Constant_height 27 from shallow_water import Time_boundary 28 from domain import Domain, Volume 29 from Numeric import array 22 from shallow_water import Domain, Reflective_boundary, Time_boundary 30 23 from math import sqrt, cos, sin, pi 24 from mesh_factory import strang_mesh 31 25 32 import visualise2 as visualise 33 26 #Convenience functions 34 27 def imag(a): 35 28 return a.imag … … 40 33 41 34 ###################### 42 # Boundary conditions43 # Not required for this problem44 45 from domain import Strang_domain, Volume46 47 ######################48 35 # Domain 49 36 # Strang_domain will search through the file and test to see if there are 50 37 # two or three entries. Two entries are for points and three for triangles. 51 38 52 domain = Strang_domain('run-up.pt') 39 points, elements = strang_mesh('run-up.pt') 40 domain = Domain(points, elements) 53 41 54 42 domain.default_order = 2 … … 65 53 66 54 # Provide file name for storing output 67 domain.filename="run-up_second_order" 55 domain.store = True 56 domain.format = 'sww' 57 domain.filename = 'run-up_second_order' 68 58 69 print "Number of triangles = ", len(Volume.instances) 70 71 domain.visualise = False 72 domain.checkpoint = False # 73 domain.store = True #Store for visualisation purposes 74 domain.format = 'sww' #Native netcdf visualisation format 59 print "Number of triangles = ", len(domain) 75 60 76 61 #Reduction operation for get_vertex_values 77 from pytools.statsimport mean62 from util import mean 78 63 domain.reduction = mean 79 64 #domain.reduction = min #Looks better near steep slopes … … 130 115 return [stage, uh, vh] 131 116 132 def boundary_ height(t):117 def boundary_level(t): 133 118 x = -200 134 119 return stage_setup(x,t) … … 137 122 ###################### 138 123 #Initial condition 139 #140 124 print 'Initial condition' 141 125 t_star1 = 0.0 … … 150 134 return z 151 135 152 domain.set_ field_values(x_slope, None)136 domain.set_quantity('elevation', x_slope) 153 137 154 138 #Set the water depth 155 def height(x,y):139 def level(x,y): 156 140 z = x_slope(x,y) 157 141 n = x.shape[0] … … 165 149 return w 166 150 167 domain.set_conserved_quantities(height, None, None) 151 domain.set_quantity('level', level) 152 168 153 169 154 ##################### 170 155 #Set up boundary conditions 171 Br = Reflective_boundary( )172 Bw = Time_boundary(domain, boundary_ height)156 Br = Reflective_boundary(domain) 157 Bw = Time_boundary(domain, boundary_level) 173 158 domain.set_boundary({'left': Bw, 'external': Br}) 174 159 175 160 176 177 ######################178 #Visualisation179 if domain.visualise:180 visualise.create_surface(domain)181 182 183 161 ###################### 184 162 #Evolution 185 186 163 import time 187 164 t0 = time.time() 188 for t in domain.evolve( max_timestep = 1.0,yieldstep = 1., finaltime = 100):165 for t in domain.evolve(yieldstep = 1., finaltime = 100): 189 166 domain.write_time() 190 print boundary_height(domain.time) 191 192 # Remove the following if Visual Python not required 193 if domain.visualise: 194 visualise.update(domain, index=0, smooth=True) 167 print boundary_level(domain.time) 195 168 196 169 print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracChangeset
for help on using the changeset viewer.