Changeset 1393
- Timestamp:
- May 15, 2005, 10:25:56 PM (20 years ago)
- Location:
- inundation/ga/storm_surge
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/Merimbula/run_merimbula_lake.py
r1363 r1393 79 79 domain.store = True #Store for visualisation purposes 80 80 domain.format = 'sww' #Native netcdf visualisation format 81 domain.filename = 'Merimbula_2003_4days_dry' 81 from normalDate import ND 82 domain.filename = 'Merimbula_2003_4days_dry_%s'%ND() 83 84 print domain.filename 82 85 83 86 #---------------------- -
inundation/ga/storm_surge/parallel/parallel_advection.py
r1387 r1393 66 66 def rectangular_with_ghosts(m, n, len1=1.0, len2=1.0, origin = (0.0, 0.0)): 67 67 68 68 69 """Setup a rectangular grid of triangles 69 70 with m+1 by n+1 grid points … … 74 75 len2: y direction (bottom to top) 75 76 76 Also returns a list of77 78 77 Return to lists: points and elements suitable for creating a Mesh or 79 78 FVMesh object, e.g. Mesh(points, elements) … … 81 80 82 81 from config import epsilon 83 84 #E = m*n*2 #Number of triangular elements 85 #P = (m+1)*(n+1) #Number of initial vertices 82 from Numeric import zeros, Float, Int 86 83 87 84 delta1 = float(len1)/m 88 85 delta2 = float(len2)/n 89 86 90 #Dictionary of vertex objects 91 vertices = {} 92 points = [] 87 #Calculate number of points 88 Np = (m+1)*(n+1) 89 90 class VIndex: 91 92 def __init__(self, n,m): 93 self.n = n 94 self.m = m 95 96 def __call__(self, i,j): 97 return j+i*(self.n+1) 98 99 class EIndex: 100 101 def __init__(self, n,m): 102 self.n = n 103 self.m = m 104 105 def __call__(self, i,j): 106 return 2*(j+i*self.n) 107 108 109 I = VIndex(n,m) 110 E = EIndex(n,m) 111 112 points = zeros( (Np,2), Float) 93 113 94 114 for i in range(m+1): 95 115 for j in range(n+1): 96 vertices[i,j] = len(points) 97 points.append([i*delta1 + origin[0], j*delta2 + origin[1]]) 116 117 points[I(i,j),:] = [i*delta1 + origin[0], j*delta2 + origin[1]] 118 119 #Construct 2 triangles per rectangular element and assign tags to boundary 120 #Calculate number of triangles 121 Nt = 2*m*n 98 122 99 123 100 101 #Construct 2 triangles per rectangular element and assign tags to boundary 102 elements = [] 124 elements = zeros( (Nt,3), Int) 103 125 boundary = {} 126 ghosts = {} 127 nt = -1 104 128 for i in range(m): 105 129 for j in range(n): 106 v1 = vertices[i,j+1]107 v2 = vertices[i,j]108 v3 = vertices[i+1,j+1]109 v4 = vertices[i+1,j]110 130 111 #Update boundary dictionary and create elements 131 i1 = I(i,j+1) 132 i2 = I(i,j) 133 i3 = I(i+1,j+1) 134 i4 = I(i+1,j) 135 136 #Lower Element 137 nt = E(i,j) 112 138 if i == m-1: 113 boundary[(len(elements), 2)] = 'right' 139 ghosts[nt] = E(1,j) 140 if i == 0: 141 ghosts[nt] = E(m-2,j) 142 143 if i == m-1: 144 boundary[nt, 2] = 'right' 114 145 if j == 0: 115 boundary[(len(elements), 1)] = 'bottom' 116 elements.append([v4,v3,v2]) #Lower element 146 boundary[nt, 1] = 'bottom' 147 elements[nt,:] = [i4,i3,i2] 148 149 #Upper Element 150 nt = E(i,j)+1 151 if i == m-1: 152 ghosts[nt] = E(1,j)+1 153 if i == 0: 154 ghosts[nt] = E(m-2,j)+1 117 155 118 156 if i == 0: 119 boundary[ (len(elements), 2)] = 'left'157 boundary[nt, 2] = 'left' 120 158 if j == n-1: 121 boundary[ (len(elements), 1)] = 'top'122 elements .append([v1,v2,v3]) #Upper element159 boundary[nt, 1] = 'top' 160 elements[nt,:] = [i1,i2,i3] 123 161 124 ghosts = {} 125 i=0 126 for j in range(n): 127 v1 = vertices[i,j+1] 128 v2 = vertices[i,j] 129 v3 = vertices[i+1,j+1] 130 v4 = vertices[i+1,j] 131 ghosts.append(elements.index([ 162 return points, elements, boundary, ghosts 132 163 133 return points, elements, boundary -
inundation/ga/storm_surge/parallel/run_parallel_advection.py
r1387 r1393 11 11 from mesh_factory import rectangular 12 12 13 points, vertices, boundary = rectangular(30, 30) 13 N = 4 14 M = 4 15 16 points, vertices, boundary, ghosts = rectangular_with_ghosts(N, M) 17 18 19 print ghosts 14 20 15 21 #Create advection domain with direction (1,-1) … … 47 53 48 54 #Check that the boundary value gets propagated to all elements 49 for t in domain.evolve(yieldstep = 0.01, finaltime = 1.5):55 for t in domain.evolve(yieldstep = 0.01, finaltime = 0.01): 50 56 domain.write_time() -
inundation/ga/storm_surge/pyvolution/data_manager.py
r1363 r1393 342 342 from Scientific.IO.NetCDF import NetCDFFile 343 343 import types 344 344 from time import sleep 345 345 from os import stat 346 346 347 347 348 348 #Get NetCDF 349 350 351 352 349 retries = 0 350 file_open = False 351 while not file_open and retries < 10: 352 try: 353 353 fid = NetCDFFile(self.filename, 'a') #Open existing file 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 354 except IOError: 355 #This could happen if someone was reading the file. 356 #In that case, wait a while and try again 357 msg = 'Warning (store_timestep): File %s could not be opened'\ 358 %self.filename 359 msg += ' - trying again' 360 print msg 361 retries += 1 362 sleep(1) 363 else: 364 file_open = True 365 366 if not file_open: 367 msg = 'File %s could not be opened for append' %self.filename 368 raise msg 369 369 370 370 … … 1995 1995 q = (1-ratio)*Q[index]+ ratio*Q[index+1] 1996 1996 else: 1997 1997 q = Q[index] 1998 1998 #Return vector of interpolated values 1999 1999 return q -
inundation/ga/storm_surge/pyvolution/netherlands.py
r1392 r1393 65 65 66 66 #Wall 67 #if x[i] > 0.995:68 #z[i] = -x[i]/20+0.367 if x[i] > 0.995: 68 z[i] = -x[i]/20+0.3 69 69 70 70 return z/2 … … 103 103 104 104 #Set bed-slope and friction 105 inflow_stage = 0. 2106 manning = 0.0 0105 inflow_stage = 0.1 106 manning = 0.03 107 107 Z = Weir(inflow_stage) 108 108 … … 156 156 t0 = time.time() 157 157 158 for t in domain.evolve(yieldstep = 1.0, finaltime = 100.0): 158 from visual import * 159 160 for t in domain.evolve(yieldstep = 0.1, finaltime = 15.0): 159 161 domain.write_time() 160 162 #domain.visualiser.scale_z = 1.0 161 domain.visualiser.update_quantity_color('xmomentum',scale_z = 4.0) 163 #domain.visualiser.update_quantity_color('xmomentum',scale_z = 4.0) 164 #integral_label.text='Integral=%10.5e'%domain.quantities['stage'].get_integral() 162 165 163 166 -
inundation/ga/storm_surge/pyvolution/quantity.py
r1290 r1393 536 536 537 537 # Create a V like [[0 1 2], [3 4 5]....[3*m-2 3*m-1 3*m]] 538 # These vert_id's will relate to the verts created bel low538 # These vert_id's will relate to the verts created below 539 539 m = len(self.domain) #Number of volumes 540 540 M = 3*m #Total number of unique vertices -
inundation/ga/storm_surge/pyvolution/test_quantity.py
r1018 r1393 201 201 quantity = Quantity(self.mesh4) 202 202 203 204 203 #Try constants first 204 const = 5 205 205 quantity.set_values(const, location = 'vertices') 206 #print 'Q', quantity.get_integral() 207 208 assert allclose(quantity.get_integral(), 209 self.mesh4.get_area() * const) 210 211 #Try with a linear function 206 #print 'Q', quantity.get_integral() 207 208 assert allclose(quantity.get_integral(), self.mesh4.get_area() * const) 209 210 #Try with a linear function 212 211 def f(x, y): 213 212 return x+y … … 216 215 217 216 218 219 220 217 ref_integral = (4.0/3 + 8.0/3 + 10.0/3 + 10.0/3) * 2 218 219 assert allclose (quantity.get_integral(), ref_integral) 221 220 222 221 … … 929 928 runner = unittest.TextTestRunner() 930 929 runner.run(suite) 931 -
inundation/ga/storm_surge/zeus/anuga-workspace.zwi
r1387 r1393 2 2 <workspace name="anuga-workspace"> 3 3 <mode>Debug</mode> 4 <active> steve</active>4 <active>pyvolution</active> 5 5 <project name="Merimbula">Merimbula.zpi</project> 6 6 <project name="parallel">parallel.zpi</project> -
inundation/ga/storm_surge/zeus/pyvolution.zpi
r1271 r1393 99 99 <file>..\pyvolution\netherlands.py</file> 100 100 <file>..\pyvolution\netherlands-chris.py</file> 101 <file>..\pyvolution\normalDate.py</file> 101 102 <file>..\pyvolution\pmesh2domain.py</file> 102 103 <file>..\pyvolution\pressure_force.py</file>
Note: See TracChangeset
for help on using the changeset viewer.