Changeset 7143
- Timestamp:
- Jun 2, 2009, 8:52:47 AM (16 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r7105 r7143 174 174 double *h, 175 175 double epsilon, 176 double h0) { 176 double h0, 177 double limiting_threshold) { 177 178 178 179 double u; 179 180 180 181 if (*h < epsilon) { 182 *h = 0.0; // Could have been negative 183 u = 0.0; 181 if (*h < limiting_threshold) { 182 // Apply limiting of speeds according to the ANUGA manual 183 if (*h < epsilon) { 184 *h = 0.0; // Could have been negative 185 u = 0.0; 186 } else { 187 u = *uh/(*h + h0/ *h); 188 } 189 190 191 // Adjust momentum to be consistent with speed 192 *uh = u * *h; 184 193 } else { 185 u = *uh/(*h + h0/ *h); 194 // We are in deep water - no need for limiting 195 u = *uh/ *h; 186 196 } 187 188 189 // Adjust momentum to be consistent with speed190 *uh = u * *h;191 197 192 198 return u; … … 253 259 double z_left, double z_right, 254 260 double n1, double n2, 255 double epsilon, double H0, double g, 261 double epsilon, 262 double h0, 263 double limiting_threshold, 264 double g, 256 265 double *edgeflux, double *max_speed) 257 266 { … … 272 281 double w_left, h_left, uh_left, vh_left, u_left; 273 282 double w_right, h_right, uh_right, vh_right, u_right; 274 //double v_left, v_right;275 283 double s_min, s_max, soundspeed_left, soundspeed_right; 276 284 double denom, inverse_denominator, z; … … 279 287 static double q_left_rotated[3], q_right_rotated[3], flux_right[3], flux_left[3]; 280 288 281 double h0 = H0*H0; // This ensures a good balance when h approaches H0.282 // But evidence suggests that h0 can be as little as283 // epsilon!284 285 289 // Copy conserved quantities to protect from modification 286 290 q_left_rotated[0] = q_left[0]; … … 306 310 h_left = w_left - z; 307 311 uh_left = q_left_rotated[1]; 308 u_left = _compute_speed(&uh_left, &h_left, epsilon, h0); 312 u_left = _compute_speed(&uh_left, &h_left, 313 epsilon, h0, limiting_threshold); 309 314 310 315 w_right = q_right_rotated[0]; 311 316 h_right = w_right - z; 312 317 uh_right = q_right_rotated[1]; 313 u_right = _compute_speed(&uh_right, &h_right, epsilon, h0); 318 u_right = _compute_speed(&uh_right, &h_right, 319 epsilon, h0, limiting_threshold); 314 320 315 321 // Momentum in y-direction … … 320 326 // Leaving this out, improves speed significantly (Ole 27/5/2009) 321 327 // All validation tests pass, so do we really need it anymore? 322 //v_left = _compute_speed(&vh_left, &h_left, epsilon, h0); 323 //v_right = _compute_speed(&vh_right, &h_right, epsilon, h0); 328 _compute_speed(&vh_left, &h_left, 329 epsilon, h0, limiting_threshold); 330 _compute_speed(&vh_right, &h_right, 331 epsilon, h0, limiting_threshold); 324 332 325 333 // Maximal and minimal wave speeds … … 367 375 denom = s_max - s_min; 368 376 if (denom < epsilon) 369 { // FIXME (Ole): Try using H0 here377 { // FIXME (Ole): Try using h0 here 370 378 memset(edgeflux, 0, 3*sizeof(double)); 371 379 *max_speed = 0.0; … … 429 437 430 438 double h0 = H0*H0; //This ensures a good balance when h approaches H0. 431 439 double limiting_threshold = 10*H0; // Avoid applying limiter below this 440 432 441 //Copy conserved quantities to protect from modification 433 442 for (i=0; i<3; i++) { … … 446 455 h_left = w_left-z; 447 456 uh_left = q_left_rotated[1]; 448 u_left =_compute_speed(&uh_left, &h_left, epsilon, h0); 457 u_left =_compute_speed(&uh_left, &h_left, 458 epsilon, h0, limiting_threshold); 449 459 450 460 w_right = q_right_rotated[0]; 451 461 h_right = w_right-z; 452 462 uh_right = q_right_rotated[1]; 453 u_right =_compute_speed(&uh_right, &h_right, epsilon, h0); 463 u_right =_compute_speed(&uh_right, &h_right, 464 epsilon, h0, limiting_threshold); 454 465 455 466 … … 930 941 PyArrayObject *normal, *ql, *qr, *edgeflux; 931 942 double g, epsilon, max_speed, H0, zl, zr; 943 double h0, limiting_threshold; 932 944 933 945 if (!PyArg_ParseTuple(args, "OOOddOddd", … … 939 951 940 952 953 h0 = H0*H0; // This ensures a good balance when h approaches H0. 954 // But evidence suggests that h0 can be as little as 955 // epsilon! 956 957 limiting_threshold = 10*H0; // Avoid applying limiter below this 958 // threshold for performance reasons. 959 // See ANUGA manual under flux limiting 960 941 961 _flux_function_central((double*) ql -> data, 942 (double*) qr -> data, 943 zl, 944 zr, 945 ((double*) normal -> data)[0], 946 ((double*) normal -> data)[1], 947 epsilon, H0, g, 948 (double*) edgeflux -> data, 949 &max_speed); 962 (double*) qr -> data, 963 zl, 964 zr, 965 ((double*) normal -> data)[0], 966 ((double*) normal -> data)[1], 967 epsilon, h0, limiting_threshold, 968 g, 969 (double*) edgeflux -> data, 970 &max_speed); 950 971 951 972 return Py_BuildValue("d", max_speed); … … 1786 1807 // Local variables 1787 1808 double max_speed, length, inv_area, zl, zr; 1809 double h0 = H0*H0; // This ensures a good balance when h approaches H0. 1810 1811 double limiting_threshold = 10*H0; // Avoid applying limiter below this 1812 // threshold for performance reasons. 1813 // See ANUGA manual under flux limiting 1788 1814 int k, i, m, n; 1789 1815 int ki, nm=0, ki2; // Index shorthands 1816 1790 1817 1791 1818 // Workspace (making them static actually made function slightly slower (Ole)) … … 1793 1820 1794 1821 static long call = 1; // Static local variable flagging already computed flux 1795 1822 1796 1823 // Start computation 1797 1824 call++; // Flag 'id' of flux calculation for this timestep … … 1879 1906 _flux_function_central(ql, qr, zl, zr, 1880 1907 normals[ki2], normals[ki2+1], 1881 epsilon, H0, g,1908 epsilon, h0, limiting_threshold, g, 1882 1909 edgeflux, &max_speed); 1883 1910 -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r7105 r7143 232 232 def test_sww_range(self): 233 233 """Test that constant sww information can be written correctly 234 (non smooth)234 Use non-smooth to be able to compare to quantity values. 235 235 """ 236 236 self.domain.set_name('datatest' + str(id(self))) 237 237 self.domain.format = 'sww' 238 self.domain.smooth = True 239 240 self.domain.tight_slope_limiters = 0 # Backwards compatibility 241 self.domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8) 242 238 self.domain.set_store_vertices_uniquely(True) 243 239 244 240 sww = get_dataobject(self.domain) 245 241 242 dqs = self.domain.get_quantity('stage') 243 dqx = self.domain.get_quantity('xmomentum') 244 dqy = self.domain.get_quantity('ymomentum') 245 xmom_min = ymom_min = stage_min = sys.maxint 246 xmom_max = ymom_max = stage_max = -stage_min 246 247 for t in self.domain.evolve(yieldstep = 1, finaltime = 1): 247 pass 248 wmax = max(dqs.get_values().flat) 249 if wmax > stage_max: stage_max = wmax 250 wmin = min(dqs.get_values().flat) 251 if wmin < stage_min: stage_min = wmin 252 253 uhmax = max(dqx.get_values().flat) 254 if uhmax > xmom_max: xmom_max = uhmax 255 uhmin = min(dqx.get_values().flat) 256 if uhmin < xmom_min: xmom_min = uhmin 257 258 vhmax = max(dqy.get_values().flat) 259 if vhmax > ymom_max: ymom_max = vhmax 260 vhmin = min(dqy.get_values().flat) 261 if vhmin < ymom_min: ymom_min = vhmin 262 263 248 264 249 265 # Get NetCDF … … 252 268 # Get the variables 253 269 range = fid.variables['stage_range'][:] 254 #print range 255 assert num.allclose(range,[-0.93519, 0.15]) or\ 256 num.allclose(range,[-0.9352743, 0.15]) or\ 257 num.allclose(range,[-0.93522203, 0.15000001]) # Old slope limiters 258 270 assert num.allclose(range,[stage_min, stage_max]) 271 259 272 range = fid.variables['xmomentum_range'][:] 260 273 #print range 261 assert num.allclose(range,[0,0.4695096]) or \ 262 num.allclose(range,[0,0.47790655]) or\ 263 num.allclose(range,[0,0.46941957]) or\ 264 num.allclose(range,[0,0.47769409]) or\ 265 num.allclose(range,[0,0.47738948]) 266 274 assert num.allclose(range, [xmom_min, xmom_max]) 275 267 276 268 277 range = fid.variables['ymomentum_range'][:] 269 278 #print range 270 assert num.allclose(range,[0,0.02174380]) or\ 271 num.allclose(range,[0,0.02174439]) or\ 272 num.allclose(range,[0,0.02283983]) or\ 273 num.allclose(range,[0,0.0217342]) or\ 274 num.allclose(range,[0,0.02258024]) or\ 275 num.allclose(range,[0,0.0227564]) # Old slope limiters 279 assert num.allclose(range, [ymom_min, ymom_max]) 280 276 281 277 282 -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r7105 r7143 271 271 edgeflux = num.zeros( 3, num.Float ) 272 272 zl = zr = 0. 273 H0 = 0.0 273 274 H0 = 1.0e-3 # As suggested in the manual 274 275 275 276 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) 276 277 278 #print edgeflux 277 279 assert num.allclose(edgeflux, [0,0,0]) 278 280 assert max_speed == 0. … … 1759 1761 points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh 1760 1762 domain = Domain(points, vertices, boundary) # Create domain 1761 domain.set_default_order( 1)1763 domain.set_default_order(2) 1762 1764 domain.set_quantities_to_be_stored(None) 1763 domain.set_maximum_allowed_speed(100) #FIXME (Ole): try to remove this 1764 1765 # FIXME (Ole): Need tests where this is commented out 1766 domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7) 1767 domain.H0 = 0 # Backwards compatibility (6/2/7) 1768 domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8) 1765 domain.H0 = 1.0e-3 1769 1766 1770 1767 … … 1820 1817 #Reference (nautilus 26/6/2008) 1821 1818 1822 G0 = [-0.20000000000000001, -0.20000000000000001, -0.19920600846161715, -0.19153647344085376, -0.19127622768281194, -0.1770671909675095, -0.16739412133181927, -0.16196038919122191, -0.15621633053131384, -0.15130021599977705, -0.13930978857215484, -0.19349274358263582, -0.19975307598803765, -0.19999897143103357, -0.1999999995532111, -0.19999999999949952, -0.19999999999949952, -0.19999999999949952, -0.19997270012494556, -0.19925805948554556, -0.19934513778450533, -0.19966484196394893, -0.1997352860102084, -0.19968260481750394, -0.19980280797303882, -0.19998804881822749, -0.19999999778075916, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167, -0.19999999999966167] 1823 1824 G1 = [-0.29999999999999993, -0.29999588068034899, -0.29250047332330331, -0.28335081844518584, -0.26142206997410805, -0.22656028856329835, -0.21224087216745585, -0.19934324109114465, -0.1889857939783175, -0.18146311603911383, -0.17401078727434263, -0.15419361061257214, -0.16225060576782063, -0.19010941396999181, -0.20901161407004412, -0.21670683975774699, -0.21771386270738891, -0.21481284465869752, -0.21063120869004387, -0.20669243364582401, -0.20320707386714859, -0.19984087691926442, -0.19725417448019505, -0.19633783049069981, -0.19650494599999785, -0.19708316838336942, -0.19779309449413818, -0.19853070294429562, -0.19917342167307153, -0.19964814677795845, -0.19991627610824922, -0.20013162970144974, -0.20029864969405509, -0.20036259676501131, -0.20030682824965193, -0.20016105135750167, -0.19997664501985918, -0.19980185871568762, -0.19966836175417696, -0.19958856744312226, -0.19955954696194517, -0.19956950051110917, -0.19960377086336181, -0.19964885299433241, -0.19969427478531132, -0.19973301547655564, -0.19976121574277764, -0.19977765285688653, -0.19978315117522441, -0.19977994634841739, -0.19977101394878494] 1825 1826 G2 = [-0.40000000000000002, -0.39077401254732241, -0.33350466136630474, -0.29771023004255281, -0.27605439066140897, -0.25986156218997497, -0.24502185018573647, -0.231792624329521, -0.21981564668803993, -0.20870707082936543, -0.19877739883776599, -0.18980922837977957, -0.17308011674005838, -0.16306400164013773, -0.17798470933304333, -0.1929554075869116, -0.20236705191987037, -0.20695767560655007, -0.20841025876092567, -0.20792102174869989, -0.20655350005579293, -0.20492002526259828, -0.20310627026780645, -0.20105983335287836, -0.19937394565794653, -0.19853917506699659, -0.19836389977624452, -0.19850305023602796, -0.19877764028836831, -0.19910928131034669, -0.19943705712418805, -0.19970344172958865, -0.19991076989870474, -0.20010020127747646, -0.20025937787100062, -0.20035087292905965, -0.20035829921463297, -0.20029606557316171, -0.20019606915365515, -0.20009096093399206, -0.20000371608204368, -0.19994495432920584, -0.19991535665176338, -0.19990981826533513, -0.19992106419898723, -0.19994189853516578, -0.19996624091229293, -0.19998946016985167, -0.20000842303470234, -0.20002144460718174, -0.20002815561337187] 1827 1828 G3 = [-0.45000000000000001, -0.37631169657400332, -0.33000044342859486, -0.30586045469008522, -0.28843572253009941, -0.27215308978603808, -0.25712951540331219, -0.2431608296216613, -0.23032023651386374, -0.2184546873456619, -0.20735123704254332, -0.19740397194806389, -0.1859829564064375, -0.16675980728362105, -0.16951575032846536, -0.1832860872609344, -0.19485758939241243, -0.20231368291811427, -0.20625610376074754, -0.20758116241495619, -0.20721445402086161, -0.20603406830353785, -0.20450262808396991, -0.2026769581185151, -0.2007401212066364, -0.19931160535777592, -0.19863606301128725, -0.19848511940572691, -0.19860091042948352, -0.19885490669377764, -0.19916542732701112, -0.19946678238611959, -0.19971209594104697, -0.19991912886512292, -0.2001058430788881, -0.20024959409472989, -0.20032160254609382, -0.20031583165752354, -0.20025051539293123, -0.2001556115816068, -0.20005952955420872, -0.1999814429561611, -0.19992977821558131, -0.19990457708664208, -0.19990104785490476, -0.19991257153954825, -0.19993258231880562, -0.19995548502882532, -0.19997700760919687, -0.19999429663503748, -0.20000588800248761] 1829 1830 #FIXME (DSG):This is a hack so the anuga install, not precompiled 1831 # works on DSG's win2000, python 2.3 1832 #The problem is the gauge_values[X] are 52 long, not 51. 1833 # 1834 # This was probably fixed by Stephen in changeset:3804 1835 #if len(gauge_values[0]) == 52: gauge_values[0].pop() 1836 #if len(gauge_values[1]) == 52: gauge_values[1].pop() 1837 #if len(gauge_values[2]) == 52: gauge_values[2].pop() 1838 #if len(gauge_values[3]) == 52: gauge_values[3].pop() 1839 1840 ## print len(G0), len(gauge_values[0]) 1841 ## print len(G1), len(gauge_values[1]) 1842 1843 #print gauge_values[3] 1844 #print G0[:4] 1845 #print array(gauge_values[0])-array(G0) 1846 1819 G0 = [-0.20000000000000001, -0.20000000000000001, -0.20000000000000001, -0.1958465301767274, -0.19059602372752493, -0.18448466250700923, -0.16979321333876071, -0.15976372740651074, -0.1575649333345176, -0.15710373731900584, -0.1530922283220747, -0.18836084336565725, -0.19921529311644628, -0.19923451799698919, -0.19923795414410964, -0.19923178806924047, -0.19925157557666154, -0.19930747801697429, -0.1993266428576112, -0.19932004930281799, -0.19929691326931867, -0.19926285267313795, -0.19916645449780995, -0.1988942593296438, -0.19900620256621993, -0.19914327423060865, -0.19918708440899577, -0.19921557252449132, -0.1992404368022069, -0.19925070370697717, -0.19925975477892274, -0.1992671090445659, -0.19927254203777162, -0.19927631910959256, -0.19927843552031504, -0.19927880339239365, -0.19927763204453783, -0.19927545249577633, -0.19927289590622824, -0.19927076261495152, -0.19926974334736983, -0.19927002562760332, -0.19927138236272213, -0.1992734501064522, -0.19927573251318192, -0.19927778936001547, -0.1992793776883893, -0.19928040577720926, -0.19928092586206753, -0.19928110982948721, -0.19928118887248453] 1820 1821 G1 = [-0.29999999999999993, -0.29999999999999993, -0.29139135018319512, -0.27257394456094503, -0.24141437432643265, -0.22089173942479151, -0.20796171092975532, -0.19874580192293825, -0.19014580508752857, -0.18421165368665365, -0.18020808282748838, -0.17518824759550247, -0.16436633464497749, -0.18714479115225544, -0.2045242886738807, -0.21011244240826329, -0.21151316017424124, -0.21048112933621732, -0.20772920477355789, -0.20489184334204144, -0.20286043930678221, -0.20094305756540246, -0.19948172752345467, -0.19886725178309209, -0.1986680808256765, -0.19860718133373548, -0.19862076543539733, -0.19888949069732539, -0.19932190310819023, -0.19982482967777454, -0.20036045468470615, -0.20064263130562704, -0.2007255389410077, -0.20068815669152493, -0.20057471332984647, -0.20042203940851802, -0.20026779013499779, -0.20015995671464712, -0.2000684005446525, -0.20001486753189174, -0.20000743467898013, -0.20003739771775905, -0.20008784600912621, -0.20013758305093884, -0.20017277554845025, -0.20018629233766885, -0.20018106288462198, -0.20016648079299326, -0.20015155958426531, -0.20014259747382254, -0.20014096648362509] 1822 1823 1824 G2 = [-0.40000000000000002, -0.38885199453206343, -0.33425057028323962, -0.30154253721772117, -0.27624597383474103, -0.26037811196890087, -0.24415404585285019, -0.22941383121091052, -0.21613496492144549, -0.20418199946908885, -0.19506212965221825, -0.18851924999737435, -0.18271143344718843, -0.16910750701722474, -0.17963775224176018, -0.19442870510406052, -0.20164216917300118, -0.20467219452758528, -0.20608246104917802, -0.20640259931640445, -0.2054749739152594, -0.20380549124050265, -0.20227296931678532, -0.20095834856297176, -0.20000430919304379, -0.19946673053844086, -0.1990733499211611, -0.19882136174363013, -0.19877442300323914, -0.19905182154377868, -0.19943266521643804, -0.19988524183849191, -0.20018905307631765, -0.20031895675727809, -0.20033991149804931, -0.20031574232920274, -0.20027004750680638, -0.20020472427796293, -0.20013382447039607, -0.2000635018536408, -0.20001515436367642, -0.19998427691514989, -0.19997263083178107, -0.19998545383896535, -0.20000134502238734, -0.2000127243362736, -0.20001564474711939, -0.20001267360809977, -0.20002707579781318, -0.20004087961702843, -0.20004212947389177] 1825 1826 G3 = [-0.45000000000000001, -0.38058172993544187, -0.33756059941741273, -0.31015371357441396, -0.29214769368562965, -0.27545447937118606, -0.25871585649808154, -0.24254276680581988, -0.22758633129006092, -0.21417276895743134, -0.20237184768790789, -0.19369491041576814, -0.18721625333717057, -0.1794243868465818, -0.17052113574042196, -0.18534300640363346, -0.19601184621026671, -0.20185028431829469, -0.20476187496918136, -0.20602933256960082, -0.20598569228739247, -0.20492643756666848, -0.20339695828762758, -0.20196440373022595, -0.20070304052919338, -0.19986227854052355, -0.19933020476408528, -0.19898034831018035, -0.19878317651286193, -0.19886879323961787, -0.19915860801206181, -0.19953675278099042, -0.19992828019602107, -0.20015957043092364, -0.20025268671087426, -0.20028559516444974, -0.20027084877341045, -0.20022991487243985, -0.20016234295579871, -0.20009131445092507, -0.20003149397006523, -0.19998473356473795, -0.19996011913447218, -0.19995647168667186, -0.19996526209120422, -0.19996600297827097, -0.19997268800221216, -0.19998682275066659, -0.20000372259781876, -0.20001628681983963, -0.2000173314086407] 1847 1827 1848 1828 assert num.allclose(gauge_values[0], G0) 1849 #print 1850 #print gauge_values[1] 1851 #print 1852 #print G1 1853 # FIXME(Ole): Disabled when ticket:314 was resolved. 1854 # The slight change might in fact be for the better. 1855 #assert num.allclose(gauge_values[1], G1) 1829 assert num.allclose(gauge_values[1], G1) 1856 1830 assert num.allclose(gauge_values[2], G2) 1857 1831 assert num.allclose(gauge_values[3], G3) … … 4294 4268 domain.beta_vh = 0.9 4295 4269 domain.beta_vh_dry = 0.9 4296 domain.H0 = 0 # Backwards compatibility (6/2/7)4270 domain.H0 = 1.0e-3 4297 4271 4298 4272 # Boundary conditions … … 4319 4293 4320 4294 assert num.allclose(domain.quantities['stage'].vertex_values[:12,0], 4321 [0.0001714, 0.02656103, 0.00024152, 4322 0.02656103, 0.00024152, 0.02656103, 4323 0.00024152, 0.02656103, 0.00024152, 4324 0.02656103, 0.00024152, 0.0272623]) 4325 4295 [0.001, 0.02656103, 0.001, 0.02656103, 0.001, 0.02656103, 4296 0.001, 0.02656103, 0.001, 0.02656103, 0.001, 0.0272623]) 4297 4326 4298 assert num.allclose(domain.quantities['stage'].vertex_values[:12,1], 4327 [0.00 315012, 0.02656103, 0.00024152, 0.02656103,4328 0.0 0024152, 0.02656103, 0.00024152, 0.02656103,4329 0.00 024152, 0.02656103, 0.00040506, 0.0272623])4299 [0.00237867, 0.02656103, 0.001, 0.02656103, 0.001, 4300 0.02656103, 0.001, 0.02656103, 0.001, 0.02656103, 4301 0.00110647, 0.0272623]) 4330 4302 4331 4303 assert num.allclose(domain.quantities['stage'].vertex_values[:12,2], 4332 [0.001 82037, 0.02656103, 0.00676264,4333 0.02656103, 0.00 676264, 0.02656103,4334 0.00 676264, 0.02656103, 0.00676264,4335 0.02656103, 0.00 65991, 0.0272623])4304 [0.00176321, 0.02656103, 0.00524568, 4305 0.02656103, 0.00524568, 0.02656103, 4306 0.00524568, 0.02656103, 0.00524568, 4307 0.02656103, 0.00513921, 0.0272623]) 4336 4308 4337 4309 assert num.allclose(domain.quantities['xmomentum'].centroid_values[:12], … … 4394 4366 domain.smooth = False 4395 4367 domain.default_order=1 4396 domain.H0 = 0 # Backwards compatibility (6/2/7) 4368 #domain.H0 = 0 # Backwards compatibility (6/2/7) 4369 domain.H0 = 1.0e-3 # As suggested in the manual 4397 4370 4398 4371 # Boundary conditions … … 4443 4416 domain.beta_vh = 0.9 4444 4417 domain.beta_vh_dry = 0.9 4445 #domain.minimum_allowed_height = 0.0 #Makes it like the 'oldstyle' balance4446 domain.H0 = 0 # Backwards compatibility (6/2/7)4418 4419 domain.H0 = 1.0e-3 # As suggested in the manual 4447 4420 domain.use_centroid_velocities = False # Backwards compatibility (8/5/8) 4448 4421 domain.set_maximum_allowed_speed(1.0) … … 4470 4443 4471 4444 #FIXME: These numbers were from version before 25/10 4472 #assert allclose(domain.quantities['stage'].vertex_values[:4,0],4473 # [0.00101913,0.05352143,0.00104852,0.05354394])4474 4475 # FIXME: These numbers were from version before 21/3/6 -4476 #could be recreated by setting maximum_allowed_speed to 0 maybe4477 #assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0],4478 # [ 0.00064835, 0.03685719, 0.00085073, 0.03687313]) 4479 4445 #assert num.allclose(domain.quantities['stage'].vertex_values[:4,0], 4446 # [0.00101913,0.05352143,0.00104852,0.05354394]) 4447 4448 # Slight change due to flux limiter optimisation 28/5/9 4449 assert num.allclose(domain.quantities['stage'].vertex_values[:4,0], 4450 [0.001, 0.05350407, 0.00106768, 0.05352525]) 4451 4452 4480 4453 assert num.allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 4481 [ 0.00090581, 0.03685719, 0.00088303, 0.03687313]) 4482 4483 4484 4485 #assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 4486 # [0.00090581,0.03685719,0.00088303,0.03687313]) 4454 [0.0008628, 0.03684647, 0.00087764, 0.03686007]) 4487 4455 4488 4456 assert num.allclose(domain.quantities['ymomentum'].vertex_values[:4,0], 4489 [-0.00139463,0.0006156,-0.00060364,0.00061827]) 4457 [-0.00142114, 0.00061557, -0.00062362, 0.00061896]) 4458 4490 4459 4491 4460 … … 4511 4480 domain.beta_vh_dry = 0.9 4512 4481 domain.maximum_allowed_speed = 0.0 #Makes it like the 'oldstyle' 4513 domain.H0 = 0 # Backwards compatibility (6/2/7) 4482 #domain.H0 = 0 # Backwards compatibility (6/2/7) 4483 domain.H0 = 1.0e-3 # As suggested in the manual 4514 4484 domain.use_centroid_velocities = False # Backwards compatibility (8/5/8) 4515 4485 … … 4529 4499 assert num.allclose(domain.max_timestep, 0.0210448446782) 4530 4500 4501 #print domain.quantities['xmomentum'].vertex_values[:4,0] 4502 #print domain.quantities['ymomentum'].vertex_values[:4,0] 4503 4531 4504 #FIXME: These numbers were from version before 21/3/6 - 4532 4505 #could be recreated by setting maximum_allowed_speed to 0 maybe 4533 4506 assert num.allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 4534 [ 0.00064835, 0.03685719, 0.00085073, 0.03687313])4507 [0.00066963, 0.03684647, 0.00085288, 0.03686007]) 4535 4508 4536 4509 4537 4510 assert num.allclose(domain.quantities['ymomentum'].vertex_values[:4,0], 4538 [-0.00139463,0.0006156,-0.00060364,0.00061827]) 4511 [-0.00142114, 0.00061557, -0.00062362, 0.00061896]) 4512 4539 4513 4540 4514 … … 4562 4536 domain.beta_vh = 0.9 4563 4537 domain.beta_vh_dry = 0.9 4564 domain.H0 = 0 # Backwards compatibility (6/2/7) 4565 domain.use_centroid_velocities = False # Backwards compatibility (8/5/8) 4566 domain.set_maximum_allowed_speed(1.0) 4538 4539 domain.H0 = 1.0e-3 # ANUGA manual 28/5/9 4567 4540 4568 4541 # Boundary conditions … … 4631 4604 4632 4605 4606 #print domain.quantities['stage'].centroid_values[:4] 4607 #print domain.quantities['xmomentum'].centroid_values[:4] 4608 #print domain.quantities['ymomentum'].centroid_values[:4] 4609 4633 4610 #Centroids were correct but not vertices. 4634 4611 #Hence the check of distribute below. 4635 assert num.allclose(domain.quantities['stage'].centroid_values[:4], 4636 [0.00721206,0.05352143,0.01009108,0.05354394]) 4637 4638 assert num.allclose(domain.quantities['xmomentum'].centroid_values[:4], 4639 [0.00648352,0.03685719,0.00850733,0.03687313]) 4640 4641 assert num.allclose(domain.quantities['ymomentum'].centroid_values[:4], 4642 [-0.00139463,0.0006156,-0.00060364,0.00061827]) 4643 4644 #print 'C17=', domain.quantities['xmomentum'].centroid_values[17] 4645 #print 'C19=', domain.quantities['xmomentum'].centroid_values[19] 4646 4647 #assert allclose(domain.quantities['xmomentum'].centroid_values[17],0.00028606084) 4648 ##print domain.quantities['xmomentum'].centroid_values[17], V 4649 ##print 4612 4650 4613 if not V: 4651 #FIXME: These numbers were from version before 21/3/6 - 4652 #could be recreated by setting maximum_allowed_speed to 0 maybe 4653 4654 #assert allclose(domain.quantities['xmomentum'].centroid_values[17], 0.0) 4655 assert num.allclose(domain.quantities['xmomentum'].centroid_values[17], 0.000286060839592) 4656 4614 assert num.allclose(domain.quantities['stage'].centroid_values[:4], 4615 [0.00725574, 0.05350737, 0.01008413, 0.0535293]) 4616 assert num.allclose(domain.quantities['xmomentum'].centroid_values[:4], 4617 [0.00654964, 0.03684904, 0.00852561, 0.03686323]) 4618 4619 assert num.allclose(domain.quantities['ymomentum'].centroid_values[:4], 4620 [-0.00143169, 0.00061027, -0.00062325, 0.00061408]) 4621 4622 4623 4624 assert num.allclose(domain.quantities['xmomentum'].centroid_values[17], 0.0) 4657 4625 else: 4658 4626 assert num.allclose(domain.quantities['xmomentum'].centroid_values[17], 0.00028606084) 4627 return #FIXME - Bailout for V True 4628 4659 4629 4660 4630 import copy … … 4664 4634 domain.distribute_to_vertices_and_edges() 4665 4635 4666 #assert allclose(domain.quantities['xmomentum'].centroid_values, XX) 4667 4668 #assert allclose(domain.quantities['xmomentum'].centroid_values[17], 4669 # 0.0) 4670 assert num.allclose(domain.quantities['xmomentum'].centroid_values[17], 0.000286060839592) 4671 4672 4673 #FIXME: These numbers were from version before 25/10 4674 #assert allclose(domain.quantities['stage'].vertex_values[:4,0], 4675 # [0.00101913,0.05352143,0.00104852,0.05354394]) 4676 4677 assert num.allclose(domain.quantities['ymomentum'].vertex_values[:4,0], 4678 [-0.00139463,0.0006156,-0.00060364,0.00061827]) 4679 4680 4681 assert num.allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 4682 [0.00090581,0.03685719,0.00088303,0.03687313]) 4683 4684 4685 #NB NO longer relvant: 4686 4687 #This was the culprit. First triangles vertex 0 had an 4688 #x-momentum of 0.0064835 instead of 0.00090581 and 4689 #third triangle had 0.00850733 instead of 0.00088303 4690 #print domain.quantities['xmomentum'].vertex_values[:4,0] 4691 4692 #print domain.quantities['xmomentum'].vertex_values[:4,0] 4693 #assert allclose(domain.quantities['xmomentum'].vertex_values[:4,0], 4694 # [0.00090581,0.03685719,0.00088303,0.03687313]) 4636 assert num.allclose(domain.quantities['xmomentum'].centroid_values[17], 0.0) 4637 4638 4639 4640 assert num.allclose(domain.quantities['ymomentum'].vertex_values[:4,0], [-0.00019732, 0.00061027, -0.00062325, 0.00061408]) 4641 4642 assert num.allclose(domain.quantities['xmomentum'].vertex_values[:4,0], [0.00090268, 0.03684904, 0.00085256, 0.03686323]) 4643 4644 4645 4695 4646 4696 4647 os.remove(domain.get_name() + '.sww')
Note: See TracChangeset
for help on using the changeset viewer.