Changeset 5832
- Timestamp:
- Oct 11, 2008, 12:38:18 PM (16 years ago)
- Location:
- anuga_work/development/anuga_1d
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anuga_1d/comp_flux_ext.c
r5831 r5832 188 188 // Update timestep based on edge i and possibly neighbour n 189 189 if (max_speed > epsilon) { 190 191 192 timestep = min(timestep, 0.5*cfl*areas[k]/max_speed); //Here, CFL=1.0 is assumed. ?????????????????????????????????????????????193 194 timestep = min(timestep, 0.5*cfl*areas[n]/max_speed); //Here, CFL=1.0 is assumed. ?????????????????????????????????????????????195 190 // Original CFL calculation 191 192 timestep = min(timestep, 0.5*cfl*areas[k]/max_speed); 193 if (n>=0) { 194 timestep = min(timestep, 0.5*cfl*areas[n]/max_speed); 195 } 196 196 } 197 197 } // End edge i (and neighbour n) … … 263 263 // Call underlying flux computation routine and update 264 264 // the explicit update arrays 265 timestep = _compute_fluxes_ext( 266 cfl, 265 timestep = _compute_fluxes_ext(cfl, 267 266 timestep, 268 267 epsilon, … … 329 328 g = get_python_double(domain,"g"); 330 329 h0 = get_python_double(domain,"h0"); 331 cfl = get_python_double(domain,"cfl");330 cfl = get_python_double(domain,"CFL"); 332 331 333 332 … … 358 357 // the explicit update arrays 359 358 timestep = _compute_fluxes_ext( 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 359 cfl, 360 timestep, 361 epsilon, 362 g, 363 h0, 364 (long*) neighbours -> data, 365 (long*) neighbour_vertices -> data, 366 (double*) normals -> data, 367 (double*) areas -> data, 368 (double*) stage_vertex_values -> data, 369 (double*) xmom_vertex_values -> data, 370 (double*) bed_vertex_values -> data, 371 (double*) stage_boundary_values -> data, 372 (double*) xmom_boundary_values -> data, 373 (double*) stage_explicit_update -> data, 374 (double*) xmom_explicit_update -> data, 375 number_of_elements, 376 (double*) max_speed_array -> data); 378 377 379 378 -
anuga_work/development/anuga_1d/comp_flux_ext_wellbalanced.c
r5827 r5832 31 31 int i; 32 32 double z_left, z_right; 33 double ql[2], qr[2],flux_left[2], flux_right[2];33 double flux_left[2], flux_right[2]; 34 34 double z_star, w_left, h_left, h_left_star, uh_left, soundspeed_left, u_left; 35 35 double w_right, h_right, h_right_star, uh_right, soundspeed_right, u_right; //h_right, … … 136 136 137 137 double flux[2], ql[3], qr[3], edgeflux[2]; 138 double zl, zr,max_speed, normal;138 double max_speed, normal; 139 139 int k, i, ki, n, m, nm=0; 140 140 -
anuga_work/development/anuga_1d/domain.py
r5742 r5832 7 7 Geoscience Australia 8 8 """ 9 9 10 from generic_boundary_conditions import * 10 #from coordinate_transforms.geo_reference import Geo_reference 11 11 12 12 13 class Domain: 13 14 14 def __init__(self, coordinates, boundary = None, 15 conserved_quantities = None, other_quantities = None, 15 def __init__(self, 16 coordinates, 17 boundary = None, 18 conserved_quantities = None, 19 evolved_quantities = None, 20 other_quantities = None, 16 21 tagged_elements = None): 17 22 """ … … 23 28 from config import timestepping_method 24 29 from config import CFL 25 26 27 30 28 31 #Store Points 29 32 self.coordinates = array(coordinates) 30 33 31 # # if geo_reference is None:32 # # self. = Geo_reference() #Use defaults33 # # else:34 # # self.geo_reference = geo_reference35 34 36 35 #Register number of Elements … … 38 37 39 38 self.beta = 1.0 40 self. limiter = "minmod_kurganov"41 self. CFL = CFL39 self.set_limiter("minmod_kurganov") 40 self.set_CFL(CFL) 42 41 self.set_timestepping_method(timestepping_method) 43 42 … … 124 123 self.conserved_quantities = conserved_quantities 125 124 125 if evolved_quantities is None: 126 self.evolved_quantities = self.conserved_quantities 127 else: 128 self.evolved_quantities = evolved_quantities 129 126 130 if other_quantities is None: 127 131 self.other_quantities = [] … … 133 137 self.quantities = {} 134 138 139 #print self.conserved_quantities 140 #print self.evolved_quantities 141 142 135 143 #FIXME: remove later - maybe OK, though.... 136 for name in self. conserved_quantities:144 for name in self.evolved_quantities: 137 145 self.quantities[name] = Quantity(self) 138 146 for name in self.other_quantities: … … 160 168 self.number_of_steps = 0 161 169 self.number_of_first_order_steps = 0 162 self.CFL = CFL163 170 164 171 #Model time … … 169 176 #Checkpointing and storage 170 177 from config import default_datadir 171 self. datadir = default_datadir178 self.set_datadir(default_datadir) 172 179 self.filename = 'domain' 173 180 self.checkpoint = False … … 490 497 491 498 return q 499 500 501 def get_evolved_quantities(self, vol_id, vertex=None):#, edge=None): 502 """Get evolved quantities at volume vol_id 503 504 If vertex is specified use it as index for vertex values 505 If edge is specified use it as index for edge values 506 If neither are specified use centroid values 507 If both are specified an exeception is raised 508 509 Return value: Vector of length == number_of_evolved quantities 510 511 """ 512 513 from Numeric import zeros, Float 514 515 #if not (vertex is None):# or edge is None): 516 # msg = 'Values for both vertex and edge was specified.' 517 # msg += 'Only one (or none) is allowed.' 518 # raise msg 519 520 q = zeros( len(self.evolved_quantities), Float) 521 522 for i, name in enumerate(self.evolved_quantities): 523 Q = self.quantities[name] 524 if vertex is not None: 525 q[i] = Q.vertex_values[vol_id, vertex] 526 #elif edge is not None: 527 # q[i] = Q.edge_values[vol_id, edge] 528 else: 529 q[i] = Q.centroid_values[vol_id] 530 531 return q 492 532 493 533 … … 677 717 def check_integrity(self): 678 718 #Mesh.check_integrity(self) 719 720 #print self.quantities 721 #print self.conserved_quantities 679 722 680 723 for quantity in self.conserved_quantities: 681 724 msg = 'Conserved quantities must be a subset of all quantities' 682 725 assert quantity in self.quantities, msg 726 727 for quantity in self.evolved_quantities: 728 msg = 'Evolved quantities must be a subset of all quantities' 729 assert quantity in self.quantities, msg 683 730 684 731 # #assert hasattr(self, 'boundary_objects') … … 720 767 self.datadir = name 721 768 722 769 def set_CFL(self, cfl): 770 if cfl > 1.0: 771 print 'WARNING: Setting CFL condition to %f which is greater than 1' % cfl 772 self.CFL = cfl 773 774 def get_CFL(self): 775 return self.CFL 776 777 def set_filename(self, name): 778 self.filename = name 779 780 def get_filename(self): 781 return self.filename 782 783 def get_limiter(self): 784 return self.limiter 785 786 def set_limiter(self,limiter): 787 788 possible_limiters = \ 789 ['pyvolution', 'steve_minmod', 'minmod', 'minmod_kurganov', 'superbee', 'vanleer', 'vanalbada'] 790 791 if limiter in possible_limiters: 792 self.limiter = limiter 793 return 794 795 msg = '%s is an incorrect limiter type.\n'% limiter 796 msg += 'Possible types are: '+ ", ".join(["%s" % el for el in possible_limiters]) 797 raise Exception, msg 798 799 723 800 #-------------------------- 724 801 # Main components of evolve … … 915 992 """ 916 993 917 # Save initial initialconserved quantities values994 # Save initial conserved quantities values 918 995 self.backup_conserved_quantities() 919 996 … … 1382 1459 q = B.evaluate(vol_id, vertex_id) 1383 1460 1384 for j, name in enumerate(self. conserved_quantities):1461 for j, name in enumerate(self.evolved_quantities): 1385 1462 Q = self.quantities[name] 1386 1463 Q.boundary_values[i] = q[j] -
anuga_work/development/anuga_1d/dry_dam_sudi.py
r5827 r5832 81 81 import time 82 82 83 finaltime = 20.084 yieldstep = 20.083 finaltime = 5.0 84 yieldstep = finaltime 85 85 L = 2000.0 # Length of channel (m) 86 number_of_cells = [ 810]#,200,500,1000,2000,5000,10000,20000]86 number_of_cells = [1610]#,200,500,1000,2000,5000,10000,20000] 87 87 h_error = zeros(len(number_of_cells),Float) 88 88 uh_error = zeros(len(number_of_cells),Float) … … 101 101 domain.set_boundary({'exterior': Reflective_boundary(domain)}) 102 102 domain.order = 2 103 domain.set_timestepping_method('rk 2')103 domain.set_timestepping_method('rk3') 104 104 domain.cfl = 1.0 105 105 domain.limiter = "vanleer" -
anuga_work/development/anuga_1d/shallow_water_domain.py
r5741 r5832 54 54 conserved_quantities = ['stage', 'xmomentum'] 55 55 other_quantities = ['elevation', 'friction'] 56 Generic_Domain.__init__(self, coordinates, boundary, 57 conserved_quantities, other_quantities, 58 tagged_elements) 56 Generic_Domain.__init__(self, 57 coordinates = coordinates, 58 boundary = boundary, 59 conserved_quantities = conserved_quantities, 60 other_quantities = other_quantities, 61 tagged_elements = tagged_elements) 59 62 60 63 from config import minimum_allowed_height, g, h0 … … 68 71 #print "\nI have Removed forcing terms line 64 1dsw" 69 72 70 #Realtime visualisation71 self.visualiser = None72 self.visualise = False73 self.visualise_color_stage = False74 self.visualise_stage_range = 1.075 self.visualise_timer = True76 self.visualise_range_z = None77 73 78 74 #Stored output … … 82 78 83 79 #Evolve parametrs 84 self. cfl = 1.080 self.set_CFL(1.0) 85 81 86 82 #Reduction operation for get_vertex_values … … 89 85 #self.reduction = min #Looks better near steep slopes 90 86 91 self. quantities_to_be_stored = ['stage','xmomentum']87 self.set_quantities_to_be_stored(['stage','xmomentum']) 92 88 93 89 self.__doc__ = 'shallow_water_domain' 94 90 91 self.check_integrity() 95 92 96 93 def set_quantities_to_be_stored(self, q): … … 125 122 126 123 127 def initialise_visualiser(self,scale_z=1.0,rect=None):128 #Realtime visualisation129 if self.visualiser is None:130 from realtime_visualisation_new import Visualiser131 self.visualiser = Visualiser(self,scale_z,rect)132 self.visualiser.setup['elevation']=True133 self.visualiser.updating['stage']=True134 self.visualise = True135 if self.visualise_color_stage == True:136 self.visualiser.coloring['stage'] = True137 self.visualiser.qcolor['stage'] = (0.0, 0.0, 0.8)138 print 'initialise visualiser'139 print self.visualiser.setup140 print self.visualiser.updating141 142 124 def check_integrity(self): 143 Generic_Domain.check_integrity(self) 125 144 126 #Check that we are solving the shallow water wave equation 145 127 … … 149 131 assert self.conserved_quantities[1] == 'xmomentum', msg 150 132 133 msg = 'First evolved quantity must be "stage"' 134 assert self.evolved_quantities[0] == 'stage', msg 135 msg = 'Second evolved quantity must be "xmomentum"' 136 assert self.evolved_quantities[1] == 'xmomentum', msg 137 138 Generic_Domain.check_integrity(self) 139 151 140 def extrapolate_second_order_sw(self): 152 141 #Call correct module function … … 584 573 import sys 585 574 575 cfl = domain.get_CFL() 586 576 587 577 timestep = float(sys.maxint) … … 596 586 #print 'g=',g 597 587 #print 'The type of g is',type(g) 588 589 h0 = domain.h0 598 590 599 591 neighbours = domain.neighbours … … 652 644 from comp_flux_ext import compute_fluxes_ext 653 645 654 domain.flux_timestep = compute_fluxes_ext(timestep, 655 epsilon, 656 g, 657 neighbours, 658 neighbour_vertices, 659 normals, 660 areas, 661 stage_edge_values, 662 xmom_edge_values, 663 bed_edge_values, 664 stage_boundary_values, 665 xmom_boundary_values, 666 stage_explicit_update, 667 xmom_explicit_update, 668 number_of_elements, 669 max_speed_array) 646 domain.flux_timestep = compute_fluxes_ext(cfl, 647 timestep, 648 epsilon, 649 g, 650 h0, 651 neighbours, 652 neighbour_vertices, 653 normals, 654 areas, 655 stage_edge_values, 656 xmom_edge_values, 657 bed_edge_values, 658 stage_boundary_values, 659 xmom_boundary_values, 660 stage_explicit_update, 661 xmom_explicit_update, 662 number_of_elements, 663 max_speed_array) 670 664 671 665 -
anuga_work/development/anuga_1d/shallow_water_domain_suggestion1.py
r5827 r5832 53 53 54 54 conserved_quantities = ['stage', 'xmomentum'] 55 other_quantities = ['elevation', 'friction', 'height', 'velocity'] 56 Generic_Domain.__init__(self, coordinates, boundary, 57 conserved_quantities, other_quantities, 58 tagged_elements) 55 evolved_quantities = ['stage', 'xmomentum', 'elevation', 'height', 'velocity'] 56 other_quantities = ['friction'] 57 Generic_Domain.__init__(self, 58 coordinates = coordinates, 59 boundary = boundary, 60 conserved_quantities = conserved_quantities, 61 evolved_quantities = evolved_quantities, 62 other_quantities = other_quantities, 63 tagged_elements = tagged_elements) 59 64 60 65 from config import minimum_allowed_height, g, h0 … … 68 73 #print "\nI have Removed forcing terms line 64 1dsw" 69 74 70 #Realtime visualisation71 self.visualiser = None72 self.visualise = False73 self.visualise_color_stage = False74 self.visualise_stage_range = 1.075 self.visualise_timer = True76 self.visualise_range_z = None77 75 78 76 #Stored output … … 81 79 self.smooth = True 82 80 83 #Evolve parametrs84 self.cfl = 1.085 81 86 82 #Reduction operation for get_vertex_values … … 89 85 #self.reduction = min #Looks better near steep slopes 90 86 91 self. quantities_to_be_stored = ['stage','xmomentum']87 self.set_quantities_to_be_stored(['stage','xmomentum']) 92 88 93 89 self.__doc__ = 'shallow_water_domain' 90 91 self.check_integrity() 94 92 95 93 … … 125 123 126 124 127 def initialise_visualiser(self,scale_z=1.0,rect=None):128 #Realtime visualisation129 if self.visualiser is None:130 from realtime_visualisation_new import Visualiser131 self.visualiser = Visualiser(self,scale_z,rect)132 self.visualiser.setup['elevation']=True133 self.visualiser.updating['stage']=True134 self.visualise = True135 if self.visualise_color_stage == True:136 self.visualiser.coloring['stage'] = True137 self.visualiser.qcolor['stage'] = (0.0, 0.0, 0.8)138 print 'initialise visualiser'139 print self.visualiser.setup140 print self.visualiser.updating141 142 125 def check_integrity(self): 143 Generic_Domain.check_integrity(self) 126 144 127 #Check that we are solving the shallow water wave equation 145 128 … … 148 131 msg = 'Second conserved quantity must be "xmomentum"' 149 132 assert self.conserved_quantities[1] == 'xmomentum', msg 133 134 msg = 'First evolved quantity must be "stage"' 135 assert self.evolved_quantities[0] == 'stage', msg 136 msg = 'Second evolved quantity must be "xmomentum"' 137 assert self.evolved_quantities[1] == 'xmomentum', msg 138 msg = 'Third evolved quantity must be "elevation"' 139 assert self.evolved_quantities[2] == 'elevation', msg 140 msg = 'Fourth evolved quantity must be "height"' 141 assert self.evolved_quantities[3] == 'height', msg 142 msg = 'Fifth evolved quantity must be "velocity"' 143 assert self.evolved_quantities[4] == 'velocity', msg 144 145 Generic_Domain.check_integrity(self) 150 146 151 147 def extrapolate_second_order_sw(self): … … 1080 1076 1081 1077 #Handy shorthands 1082 #self.stage = domain.quantities['stage'].edge_values1083 #self.xmom = domain.quantities['xmomentum'].edge_values1084 #self.ymom = domain.quantities['ymomentum'].edge_values1085 self. normals = domain.normals1086 self. stage = domain.quantities['stage'].vertex_values1087 self. xmom = domain.quantities['xmomentum'].vertex_values1078 self.normals = domain.normals 1079 self.stage = domain.quantities['stage'].vertex_values 1080 self.xmom = domain.quantities['xmomentum'].vertex_values 1081 self.bed = domain.quantities['elevation'].vertex_values 1082 self.height = domain.quantities['height'].vertex_values 1083 self.velocity = domain.quantities['velocity'].vertex_values 1088 1084 1089 1085 from Numeric import zeros, Float 1090 1086 #self.conserved_quantities = zeros(3, Float) 1091 self. conserved_quantities = zeros(2, Float)1087 self.evolved_quantities = zeros(5, Float) 1092 1088 1093 1089 def __repr__(self): … … 1100 1096 """ 1101 1097 1102 q = self. conserved_quantities1098 q = self.evolved_quantities 1103 1099 q[0] = self.stage[vol_id, edge_id] 1104 q[1] = self.xmom[vol_id, edge_id] 1105 #q[2] = self.ymom[vol_id, edge_id] 1106 #normal = self.normals[vol_id, 2*edge_id:2*edge_id+2] 1107 #normal = self.normals[vol_id, 2*edge_id:2*edge_id+1] 1108 normal = self.normals[vol_id,edge_id] 1109 1110 #r = rotate(q, normal, direction = 1) 1111 #r[1] = -r[1] 1112 #q = rotate(r, normal, direction = -1) 1113 r = q 1114 r[1] = normal*r[1] 1115 r[1] = -r[1] 1116 r[1] = normal*r[1] 1117 q = r 1118 #For start interval there is no outward momentum so do not need to 1119 #reverse direction in this case 1100 q[1] = -self.xmom[vol_id, edge_id] 1101 q[2] = self.bed[vol_id, edge_id] 1102 q[3] = self.height[vol_id, edge_id] 1103 q[1] = -self.velocity[vol_id, edge_id] 1104 1120 1105 1121 1106 return q … … 1127 1112 1128 1113 1129 def __init__(self, conserved_quantities=None):1114 def __init__(self, evolved_quantities=None): 1130 1115 Boundary.__init__(self) 1131 1116 1132 if conserved_quantities is None:1117 if evolved_quantities is None: 1133 1118 msg = 'Must specify one value for each conserved quantity' 1134 1119 raise msg 1135 1120 1136 1121 from Numeric import array, Float 1137 self. conserved_quantities=array(conserved_quantities).astype(Float)1122 self.evolved_quantities=array(evolved_quantities).astype(Float) 1138 1123 1139 1124 def __repr__(self): … … 1141 1126 1142 1127 def evaluate(self, vol_id=None, edge_id=None): 1143 return self. conserved_quantities1128 return self.evolved_quantities 1144 1129 1145 1130 -
anuga_work/development/anuga_1d/test_shallow_water.py
r5742 r5832 5 5 6 6 7 from shallow_water_domain_new import * 8 from shallow_water_domain_new import flux_function as domain_flux_function 7 #from shallow_water_domain import * 8 #from shallow_water_domain import flux_function as domain_flux_function 9 10 from shallow_water_domain_suggestion1 import * 11 from shallow_water_domain_suggestion1 import flux_function as domain_flux_function 9 12 10 13 from Numeric import allclose, array, ones, Float, maximum, zeros … … 36 39 37 40 stage_ud, xmom_ud = local_compute_fluxes(domain) 38 41 42 domain.distribute_to_vertices_and_edges() 39 43 domain.compute_fluxes() 40 44 41 #print domain.quantities['stage'].explicit_update 42 #print domain.quantities['xmomentum'].explicit_update 43 #print stage_ud 45 print domain.quantities['stage'].explicit_update 46 print domain.quantities['xmomentum'].explicit_update 47 print stage_ud 48 print xmom_ud 44 49 45 50 assert allclose( domain.quantities['stage'].explicit_update, stage_ud ) … … 316 321 try: 317 322 #timestep = min(timestep, 0.5*domain.radii[k]/max_speed) 318 timestep = min(timestep, domain. cfl*0.5*domain.areas[k]/max_speed)323 timestep = min(timestep, domain.CFL*0.5*domain.areas[k]/max_speed) 319 324 except ZeroDivisionError: 320 325 pass
Note: See TracChangeset
for help on using the changeset viewer.