Changeset 4713


Ignore:
Timestamp:
Sep 10, 2007, 4:09:23 PM (17 years ago)
Author:
steve
Message:

Implemented 2nd and 3rd order timestepping via the domain.set_timestepping_method method

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r4712 r4713  
    208208        self.min_timestep = self.max_timestep = 0.0
    209209        self.starttime = 0 #Physical starttime if any (0 is 1 Jan 1970 00:00:00)
     210        self.timestep = 0.0
     211        self.flux_timestep = 0.0
    210212
    211213        # Monitoring
     
    242244
    243245
    244     def set_default_order(self, n):
    245         """Set default (spatial) order to either 1 or 2
    246         """
    247 
    248         msg = 'Default order must be either 1 or 2. I got %s' %n
    249         assert n in [1,2], msg
    250 
    251         self.default_order = n
    252         self._order_ = self.default_order
     246
    253247
    254248
     
    295289
    296290        return self.time
     291
     292    def set_default_order(self, n):
     293        """Set default (spatial) order to either 1 or 2
     294        """
     295
     296        msg = 'Default order must be either 1 or 2. I got %s' %n
     297        assert n in [1,2], msg
     298
     299        self.default_order = n
     300        self._order_ = self.default_order
     301       
    297302
    298303    def set_quantity_vertices_dict(self, quantity_dict):
     
    964969    def set_timestepping_method(self,timestepping_method):
    965970       
    966         if timestepping_method in ['euler', 'rk2']:
     971        if timestepping_method in ['euler', 'rk2', 'rk3']:
    967972            self.timestepping_method = timestepping_method
    968973            return
     
    11131118               
    11141119            elif self.get_timestepping_method() == 'rk2':
    1115                 self.evolve_one_rk2_step(yieldstep,finaltime)               
    1116 
     1120                self.evolve_one_rk2_step(yieldstep,finaltime)
     1121
     1122            elif self.get_timestepping_method() == 'rk3':
     1123                self.evolve_one_rk3_step(yieldstep,finaltime)               
     1124           
    11171125            # Update extrema if necessary (for reporting)
    11181126            self.update_extrema()           
     
    11831191
    11841192
    1185     def evolve_one_rk2_step(self,yieldstep, finaltime):
     1193    def evolve_one_rk2_step(self, yieldstep, finaltime):
    11861194        """One 2nd order RK timestep"""
    11871195
     
    12261234        #------------------------------------
    12271235        #Combine initial and final values
    1228         #of conserved quantities
     1236        #of conserved quantities and cleanup
    12291237        #------------------------------------
    1230 
     1238        #combine steps
    12311239        self.saxpy_conserved_quantities(0.5, 0.5)
     1240 
     1241        #update ghosts
     1242        self.update_ghosts()
     1243
     1244        #Update vertex and edge values
     1245        self.distribute_to_vertices_and_edges()
     1246
     1247        #Update boundary values
     1248        self.update_boundary()
     1249
     1250
     1251
     1252    def evolve_one_rk3_step(self, yieldstep, finaltime):
     1253        """One 2nd order RK timestep"""
     1254
     1255
     1256
     1257        #Save initial initial conserved quantities values
     1258        self.backup_conserved_quantities()           
     1259
     1260        initial_time = self.time
     1261       
     1262        #--------------------------------------
     1263        #First euler step
     1264        #--------------------------------------
     1265
     1266        #Compute fluxes across each element edge
     1267        self.compute_fluxes()
     1268
     1269        #Update timestep to fit yieldstep and finaltime
     1270        self.update_timestep(yieldstep, finaltime)
     1271
     1272        #Update conserved quantities
     1273        self.update_conserved_quantities()
     1274
     1275        #update ghosts
     1276        self.update_ghosts()
     1277
     1278        #Update vertex and edge values
     1279        self.distribute_to_vertices_and_edges()
     1280
     1281        #Update boundary values
     1282        self.update_boundary()
     1283
     1284        #Update time
     1285        self.time += self.timestep
    12321286
    12331287        #------------------------------------
    1234         #Clean up rk step
     1288        #Second Euler step
    12351289        #------------------------------------
    12361290           
     1291        #Compute fluxes across each element edge
     1292        self.compute_fluxes()
     1293
     1294        #Update conserved quantities
     1295        self.update_conserved_quantities()
     1296
     1297        #------------------------------------
     1298        #Combine final and initial values
     1299        #of conserved quantities and cleanup
     1300        #------------------------------------
     1301        #combine steps
     1302        self.saxpy_conserved_quantities(0.25, 0.75)
     1303 
    12371304        #update ghosts
    12381305        self.update_ghosts()
     
    12431310        #Update boundary values
    12441311        self.update_boundary()
     1312
     1313        #set substep time
     1314        self.time = initial_time + self.timestep*0.5
     1315
     1316        #------------------------------------
     1317        #Third Euler step
     1318        #------------------------------------
     1319           
     1320        #Compute fluxes across each element edge
     1321        self.compute_fluxes()
     1322
     1323        #Update conserved quantities
     1324        self.update_conserved_quantities()
     1325
     1326        #------------------------------------
     1327        #Combine final and initial values
     1328        #of conserved quantities and cleanup
     1329        #------------------------------------
     1330        #combine steps
     1331        self.saxpy_conserved_quantities(2.0/3.0, 1.0/3.0)
     1332 
     1333        #update ghosts
     1334        self.update_ghosts()
     1335
     1336        #Update vertex and edge values
     1337        self.distribute_to_vertices_and_edges()
     1338
     1339        #Update boundary values
     1340        self.update_boundary()
     1341
     1342        #set substep time
     1343        self.time = initial_time + self.timestep       
     1344       
     1345
    12451346
    12461347
     
    13441445        # self.timestep is calculated from speed of characteristics
    13451446        # Apply CFL condition here
    1346         timestep = min(self.CFL*self.timestep, max_timestep)
     1447        timestep = min(self.CFL*self.flux_timestep, max_timestep)
    13471448
    13481449        #Record maximal and minimal values of timestep for reporting
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r4712 r4713  
    824824
    825825
    826     domain.timestep = timestep
     826    domain.flux_timestep = timestep
    827827
    828828#MH090605 The following method belongs to the shallow_water domain class
     
    875875         compute_fluxes_ext_central as compute_fluxes_ext
    876876
    877     domain.timestep = compute_fluxes_ext(timestep, domain.epsilon,
     877    domain.flux_timestep = compute_fluxes_ext(timestep, domain.epsilon,
    878878                                         domain.H0,
    879879                                         domain.g,
  • anuga_work/development/demos/netherlands.py

    r4539 r4713  
    8383N = 130 #size = 33800
    8484N = 600 #Size = 720000
    85 N = 50
     85N = 100
    8686
    8787
     
    9797domain.check_integrity()
    9898
     99domain.set_timestepping_method('rk3')
     100domain.set_default_order(2)
     101
    99102#Setup order and all the beta's for the limiters (these should become defaults
    100 domain.default_order = 2
    101 domain.beta_w      = 1.0
    102 domain.beta_w_dry  = 0.2
    103 domain.beta_uh     = 1.0
    104 domain.beta_uh_dry = 0.2
    105 domain.beta_vh     = 1.0
    106 domain.beta_vh_dry = 0.2
    107103
    108 domain.alpha_balance = 100.0
     104## domain.beta_w      = 1.0
     105## domain.beta_w_dry  = 0.2
     106## domain.beta_uh     = 1.0
     107## domain.beta_uh_dry = 0.2
     108## domain.beta_vh     = 1.0
     109## domain.beta_vh_dry = 0.2
     110
     111## domain.alpha_balance = 100.0
    109112
    110113#Output params
     
    117120#Set bed-slope and friction
    118121inflow_stage = 0.5
    119 manning = 0.03
     122manning = 0.0
    120123Z = Weir(inflow_stage)
    121124
     
    186189
    187190
    188 v.join()
     191vis.join()
Note: See TracChangeset for help on using the changeset viewer.