Changeset 8485
- Timestamp:
- Jul 31, 2012, 9:36:38 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/operators/run_polygon_erosion.py
r8484 r8485 13 13 from anuga import Time_boundary 14 14 15 from anuga.operators.erosion_operators import Polygonal_erosion_operator16 15 17 #------------------------------------------------------------------------------18 # Setup computational domain19 #------------------------------------------------------------------------------20 length = 24.21 width = 5.22 dx = dy = 0.1 #.1 # Resolution: Length of subdivisions on both axes23 16 24 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 25 len1=length, len2=width) 26 domain = Domain(points, vertices, boundary) 27 domain.set_name('polygon_erosion') # Output name 28 print domain.statistics() 29 domain.set_quantities_to_be_stored({'elevation': 2, 30 'stage': 2, 31 'xmomentum': 2, 32 'ymomentum': 2}) 17 #=============================================================================== 18 # Stick all the class and function definitions here 19 #=============================================================================== 33 20 34 #------------------------------------------------------------------------------ 35 # Setup initial conditions36 #------------------------------------------------------------------------------ 21 #------------------------------------------------------------------------------- 22 # Here are the def's for defining quantities 23 #------------------------------------------------------------------------------- 37 24 def topography(x,y): 38 25 """Complex topography defined by a function of vectors x and y.""" … … 54 41 z[i] += 0.4 55 42 56 43 57 44 return z 58 45 46 47 #------------------------------------------------------------------------------- 48 # Inherit from erosion operator 49 #------------------------------------------------------------------------------- 50 from anuga.operators.erosion_operators import Polygonal_erosion_operator 51 52 class My_polygon_erosion_operator(Polygonal_erosion_operator): 53 """ 54 Local version of erosion confined to a polygon 55 56 """ 57 58 def __init__(self, domain, 59 threshold=0.0, 60 base=0.0, 61 polygon=None, 62 verbose=False): 63 64 65 Polygonal_erosion_operator.__init__(self, domain, threshold, base, polygon, verbose) 66 67 68 69 def update_quantities(self): 70 """Update the vertex values of the quantities to model erosion 71 """ 72 import numpy as num 73 74 t = self.get_time() 75 dt = self.get_timestep() 76 77 78 updated = True 79 80 if self.indices is None: 81 82 #-------------------------------------- 83 # Update all three vertices for each cell 84 #-------------------------------------- 85 self.elev_v[:] = self.elev_v + 0.0 86 87 else: 88 89 #-------------------------------------- 90 # Update all three vertices for each cell 91 #-------------------------------------- 92 ind = self.indices 93 m = num.sqrt(self.xmom_c[ind]**2 + self.ymom_c[ind]**2) 94 m = num.vstack((m,m,m)).T 95 m = num.where(m>self.threshold, m, 0.0) 96 self.elev_v[ind] = num.maximum(self.elev_v[ind] - m*dt, self.base) 97 #num.maximum(self.elev_v[ind] - momentum*dt, Z) 98 99 100 return updated 101 102 103 104 #=============================================================================== 105 # Now to the standard model setup 106 #=============================================================================== 107 108 109 #------------------------------------------------------------------------------- 110 # Setup computational domain 111 #------------------------------------------------------------------------------- 112 length = 24. 113 width = 5. 114 dx = dy = 0.1 #.1 # Resolution: Length of subdivisions on both axes 115 116 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 117 len1=length, len2=width) 118 domain = Domain(points, vertices, boundary) 119 domain.set_name('polygon_erosion') # Output name 120 print domain.statistics() 121 domain.set_quantities_to_be_stored({'elevation': 2, 122 'stage': 2, 123 'xmomentum': 2, 124 'ymomentum': 2}) 125 126 #------------------------------------------------------------------------------- 127 # Setup initial conditions 128 #------------------------------------------------------------------------------- 59 129 60 130 … … 63 133 domain.set_quantity('stage', expression='elevation') # Dry initial condition 64 134 65 #------------------------------------------------------------------------------ 135 #------------------------------------------------------------------------------- 66 136 # Setup boundary conditions 67 #------------------------------------------------------------------------------ 137 #------------------------------------------------------------------------------- 68 138 Bi = Dirichlet_boundary([0.5, 0, 0]) # Inflow 69 139 Br = Reflective_boundary(domain) # Solid reflective wall … … 72 142 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br}) 73 143 74 #------------------------------------------------------------------------------ 144 #------------------------------------------------------------------------------- 75 145 # Setup erosion operator in the middle of dam 76 #------------------------------------------------------------------------------ 77 146 #------------------------------------------------------------------------------- 78 147 polygon1 = [ [12., 0.0], [13., 0.0], [13., 5.0], [12., 5.0] ] 79 op1 = Polygonal_erosion_operator(domain, threshold=0.0, base=-0.1, polygon=polygon1)148 op1 = My_polygon_erosion_operator(domain, threshold=0.0, base=-0.1, polygon=polygon1) 80 149 81 150 82 #------------------------------------------------------------------------------ 151 #------------------------------------------------------------------------------- 83 152 # Evolve system through time 84 #------------------------------------------------------------------------------ 153 #------------------------------------------------------------------------------- 85 154 for t in domain.evolve(yieldstep=0.2, finaltime=40.0): 86 155 domain.print_timestepping_statistics() … … 95 164 96 165 97
Note: See TracChangeset
for help on using the changeset viewer.