Changeset 4978 for anuga_core/source/anuga/advection/advection.py
- Timestamp:
- Jan 28, 2008, 6:14:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/advection/advection.py
r4975 r4978 66 66 numproc=numproc) 67 67 68 68 import Numeric 69 69 if velocity is None: 70 self.velocity = [1,0]70 self.velocity = Numeric.array([1,0],'d') 71 71 else: 72 self.velocity = velocity72 self.velocity = Numeric.array(velocity,'d') 73 73 74 74 #Only first is implemented for advection … … 108 108 return flux, max_speed 109 109 110 111 110 112 def compute_fluxes(self): 111 112 113 self.compute_fluxes_ext() 114 ## try: 115 ## self.compute_fluxes_ext() 116 ## except: 117 ## self.compute_fluxes_python() 118 113 """Compute all fluxes and the timestep suitable for all volumes 114 in domain. 115 116 Compute total flux for each conserved quantity using "flux_function" 117 118 Fluxes across each edge are scaled by edgelengths and summed up 119 Resulting flux is then scaled by area and stored in 120 domain.explicit_update 121 122 The maximal allowable speed computed by the flux_function 123 for each volume 124 is converted to a timestep that must not be exceeded. The minimum of 125 those is computed as the next overall timestep. 126 127 Post conditions: 128 domain.explicit_update is reset to computed flux values 129 domain.timestep is set to the largest step satisfying all volumes. 130 """ 131 132 import sys 133 from Numeric import zeros, Float 134 from anuga.config import max_timestep 135 136 137 huge_timestep = float(sys.maxint) 138 Stage = self.quantities['stage'] 139 140 """ 141 print "======================================" 142 print "BEFORE compute_fluxes" 143 print "stage_update",Stage.explicit_update 144 print "stage_edge",Stage.edge_values 145 print "stage_bdry",Stage.boundary_values 146 print "neighbours",self.neighbours 147 print "neighbour_edges",self.neighbour_edges 148 print "normals",self.normals 149 print "areas",self.areas 150 print "radii",self.radii 151 print "edgelengths",self.edgelengths 152 print "tri_full_flag",self.tri_full_flag 153 print "huge_timestep",huge_timestep 154 print "max_timestep",max_timestep 155 print "velocity",self.velocity 156 """ 157 158 import advection_ext 159 self.timestep = advection_ext.compute_fluxes(self, Stage, huge_timestep, max_timestep) 160 161 162 163 def evolve(self, 164 yieldstep = None, 165 finaltime = None, 166 duration = None, 167 skip_initial_step = False): 168 169 """Specialisation of basic evolve method from parent class 170 """ 171 172 #Call basic machinery from parent class 173 for t in Generic_domain.evolve(self, 174 yieldstep=yieldstep, 175 finaltime=finaltime, 176 duration=duration, 177 skip_initial_step=skip_initial_step): 178 179 #Pass control on to outer loop for more specific actions 180 yield(t) 181 182 119 183 120 184 … … 207 271 self.timestep = timestep 208 272 209 210 def compute_fluxes_ext(self):211 """Compute all fluxes and the timestep suitable for all volumes212 in domain.213 214 Compute total flux for each conserved quantity using "flux_function"215 216 Fluxes across each edge are scaled by edgelengths and summed up217 Resulting flux is then scaled by area and stored in218 domain.explicit_update219 220 The maximal allowable speed computed by the flux_function221 for each volume222 is converted to a timestep that must not be exceeded. The minimum of223 those is computed as the next overall timestep.224 225 Post conditions:226 domain.explicit_update is reset to computed flux values227 domain.timestep is set to the largest step satisfying all volumes.228 """229 230 import sys231 from Numeric import zeros, Float232 from anuga.config import max_timestep233 234 ntri = len(self)235 236 timestep = max_timestep237 238 #Shortcuts239 Stage = self.quantities['stage']240 241 #Arrays242 neighbours = self.neighbours243 neighbour_edges = self.neighbour_edges244 normals = self.normals245 areas = self.areas246 radii = self.radii247 edgelengths = self.edgelengths248 tri_full_flag = self.tri_full_flag249 250 stage_edge = Stage.edge_values251 stage_bdry = Stage.boundary_values252 stage_update = Stage.explicit_update253 254 huge_timestep = float(sys.maxint)255 256 v = self.velocity257 258 nbdry = len(stage_bdry)259 260 from advection_ext import compute_fluxes261 262 print "stage_update",stage_update263 print "stage_edge",stage_edge264 print "stage_bdry",stage_bdry265 print "neighbours",neighbours266 print "neighbour_edges",neighbour_edges267 print "normals",normals268 print "areas",areas269 print "radii",radii270 print "edgelengths",edgelengths271 print "tri_full_flag",tri_full_flag272 print "huge_timestep",huge_timestep273 print "max_timestep",max_timestep274 print "v",v275 print "ntri",ntri276 print "nbdry",nbdry277 278 279 280 timestep = compute_fluxes(stage_update,stage_edge,stage_bdry,281 neighbours,neighbour_edges,normals,282 areas,radii,edgelengths,283 tri_full_flag,284 huge_timestep,max_timestep,v,ntri,nbdry)285 286 print "stage_update",stage_update287 288 #print 'timestep out2 =',timestep289 290 self.timestep = timestep291 292 293 def evolve(self,294 yieldstep = None,295 finaltime = None,296 duration = None,297 skip_initial_step = False):298 299 """Specialisation of basic evolve method from parent class300 """301 302 #Call basic machinery from parent class303 for t in Generic_domain.evolve(self,304 yieldstep=yieldstep,305 finaltime=finaltime,306 duration=duration,307 skip_initial_step=skip_initial_step):308 309 #Pass control on to outer loop for more specific actions310 yield(t)
Note: See TracChangeset
for help on using the changeset viewer.