- Timestamp:
- Nov 3, 2013, 8:49:42 PM (11 years ago)
- Location:
- trunk/anuga_work/development/gareth
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/experimental/bal_and/swb2_domain_ext.c
r9014 r9015 958 958 959 959 960 961 //962 //for(k=0; k<number_of_elements;k++){963 // // Count the wet neighbours964 // count_wet_neighbours[k]=0;965 // for (i=0; i<3; i++){966 // ktmp = surrogate_neighbours[3*k+i];967 // if( (ktmp >= 0) && cell_wetness_scale[ktmp]>0.){968 // count_wet_neighbours[k]+=1;969 // }else if(ktmp<=0){970 // // Boundary condition -- FIXME: assume wet971 // count_wet_neighbours[k]+=1;972 // }973 //974 //975 // }976 //}977 978 960 if(extrapolate_velocity_second_order==1){ 979 961 … … 997 979 } 998 980 999 // First treat all 'fully wet' cells, then treat 'partially dry' cells 1000 //for(k_wetdry=0; k_wetdry<2; k_wetdry++){ 1001 1002 // Begin extrapolation routine 1003 for (k = 0; k < number_of_elements; k++) 981 // Begin extrapolation routine 982 for (k = 0; k < number_of_elements; k++) 983 { 984 985 // Useful indices 986 k3=k*3; 987 k6=k*6; 988 989 if (number_of_boundaries[k]==3) 990 { 991 // No neighbours, set gradient on the triangle to zero 992 993 stage_edge_values[k3] = stage_centroid_values[k]; 994 stage_edge_values[k3+1] = stage_centroid_values[k]; 995 stage_edge_values[k3+2] = stage_centroid_values[k]; 996 997 //xmom_centroid_values[k] = 0.; 998 //ymom_centroid_values[k] = 0.; 999 1000 xmom_edge_values[k3] = xmom_centroid_values[k]; 1001 xmom_edge_values[k3+1] = xmom_centroid_values[k]; 1002 xmom_edge_values[k3+2] = xmom_centroid_values[k]; 1003 ymom_edge_values[k3] = ymom_centroid_values[k]; 1004 ymom_edge_values[k3+1] = ymom_centroid_values[k]; 1005 ymom_edge_values[k3+2] = ymom_centroid_values[k]; 1006 dk = max(stage_centroid_values[k] - elevation_centroid_values[k], 0.); 1007 height_edge_values[k3] = dk; 1008 height_edge_values[k3+1] = dk; 1009 height_edge_values[k3+2] = dk; 1010 1011 continue; 1012 } 1013 else 1014 { 1015 // Triangle k has one or more neighbours. 1016 // Get centroid and edge coordinates of the triangle 1017 1018 // Get the edge coordinates 1019 xv0 = edge_coordinates[k6]; 1020 yv0 = edge_coordinates[k6+1]; 1021 xv1 = edge_coordinates[k6+2]; 1022 yv1 = edge_coordinates[k6+3]; 1023 xv2 = edge_coordinates[k6+4]; 1024 yv2 = edge_coordinates[k6+5]; 1025 1026 // Get the centroid coordinates 1027 coord_index = 2*k; 1028 x = centroid_coordinates[coord_index]; 1029 y = centroid_coordinates[coord_index+1]; 1030 1031 // Store x- and y- differentials for the edges of 1032 // triangle k relative to the centroid 1033 dxv0 = xv0 - x; 1034 dxv1 = xv1 - x; 1035 dxv2 = xv2 - x; 1036 dyv0 = yv0 - y; 1037 dyv1 = yv1 - y; 1038 dyv2 = yv2 - y; 1039 1040 } 1041 1042 1043 1044 if (number_of_boundaries[k]<=1) 1045 { 1046 //============================================== 1047 // Number of boundaries <= 1 1048 // 'Typical case' 1049 //============================================== 1050 1051 1052 // If no boundaries, auxiliary triangle is formed 1053 // from the centroids of the three neighbours 1054 // If one boundary, auxiliary triangle is formed 1055 // from this centroid and its two neighbours 1056 1057 k0 = surrogate_neighbours[k3]; 1058 k1 = surrogate_neighbours[k3 + 1]; 1059 k2 = surrogate_neighbours[k3 + 2]; 1060 1061 // Test to see whether we accept the surrogate neighbours 1062 // Note that if ki is replaced with k in more than 1 neighbour, then the 1063 // triangle area will be zero, and a first order extrapolation will be 1064 // used 1065 // FIXME: Remove cell_wetness_scale if you don't need it 1066 if(k2<0 || (cell_wetness_scale[k2]==-10.0 && stage_centroid_values[k]<max_elevation_edgevalue[k])){ 1067 k2 = k ; 1068 } 1069 if(k0 < 0 || (cell_wetness_scale[k0]==-10.0 && stage_centroid_values[k]<max_elevation_edgevalue[k])){ 1070 k0 = k ; 1071 } 1072 if(k1 < 0 || (cell_wetness_scale[k1]==-10.0 && stage_centroid_values[k]<max_elevation_edgevalue[k])){ 1073 k1 = k ; 1074 } 1075 1076 // Take note if the max neighbour bed elevation is greater than the min 1077 // neighbour stage -- suggests a 'steep' bed relative to the flow 1078 //bedmax = max(elevation_centroid_values[k], 1079 // max(elevation_centroid_values[k0], 1080 // max(elevation_centroid_values[k1], 1081 // elevation_centroid_values[k2]))); 1082 //bedmin = min(elevation_centroid_values[k], 1083 // min(elevation_centroid_values[k0], 1084 // min(elevation_centroid_values[k1], 1085 // elevation_centroid_values[k2]))); 1086 //stagemin = min(max(stage_centroid_values[k], elevation_centroid_values[k]), 1087 // min(max(stage_centroid_values[k0], elevation_centroid_values[k0]), 1088 // min(max(stage_centroid_values[k1], elevation_centroid_values[k1]), 1089 // max(stage_centroid_values[k2], elevation_centroid_values[k2])))); 1090 1091 // Get the auxiliary triangle's vertex coordinates 1092 // (really the centroids of neighbouring triangles) 1093 coord_index = 2*k0; 1094 x0 = centroid_coordinates[coord_index]; 1095 y0 = centroid_coordinates[coord_index+1]; 1096 1097 coord_index = 2*k1; 1098 x1 = centroid_coordinates[coord_index]; 1099 y1 = centroid_coordinates[coord_index+1]; 1100 1101 coord_index = 2*k2; 1102 x2 = centroid_coordinates[coord_index]; 1103 y2 = centroid_coordinates[coord_index+1]; 1104 1105 // Store x- and y- differentials for the vertices 1106 // of the auxiliary triangle 1107 dx1 = x1 - x0; 1108 dx2 = x2 - x0; 1109 dy1 = y1 - y0; 1110 dy2 = y2 - y0; 1111 1112 // Calculate 2*area of the auxiliary triangle 1113 // The triangle is guaranteed to be counter-clockwise 1114 area2 = dy2*dx1 - dy1*dx2; 1115 1116 //// Treat triangles with zero or 1 wet neighbours (area2 <=0.) 1117 if ((area2 <= 0.) )//|| (cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0)) 1004 1118 { 1005 1119 1006 //// First treat all 'fully wet' cells, then treat 'partially dry' cells 1007 //// For partially wet cells, we now know that the edges of neighbouring 1008 //// fully wet cells have been defined 1009 //if( cell_wetness_scale[k]==1.0*(1-k_wetdry) ){ 1010 // continue; 1011 //} 1012 1013 // Useful indices 1014 k3=k*3; 1015 k6=k*6; 1016 1017 if (number_of_boundaries[k]==3) 1018 { 1019 // No neighbours, set gradient on the triangle to zero 1120 // Isolated wet cell -- constant stage/depth extrapolation 1121 //stage_edge_values[k3] = stage_centroid_values[k]; 1122 //stage_edge_values[k3+1] = stage_centroid_values[k]; 1123 //stage_edge_values[k3+2] = stage_centroid_values[k]; 1124 1125 dk=height_centroid_values[k]; //max(stage_centroid_values[k]-elevation_centroid_values[k],0.); 1126 height_edge_values[k3] = dk; 1127 height_edge_values[k3+1] = dk; 1128 height_edge_values[k3+2] = dk; 1020 1129 1021 stage_edge_values[k3] = stage_centroid_values[k];1022 stage_edge_values[k3+1] = stage_centroid_values[k];1023 stage_edge_values[k3+2] = stage_centroid_values[k];1024 1025 // xmom_centroid_values[k] = 0.;1026 // ymom_centroid_values[k] = 0.;1027 1130 stage_edge_values[k3] = elevation_centroid_values[k]+dk; 1131 stage_edge_values[k3+1] = elevation_centroid_values[k]+dk; 1132 stage_edge_values[k3+2] = elevation_centroid_values[k]+dk; 1133 //stage_edge_values[k3] = elevation_edge_values[k3]+dk; 1134 //stage_edge_values[k3+1] = elevation_edge_values[k3+1]+dk; 1135 //stage_edge_values[k3+2] = elevation_edge_values[k3+2]+dk; 1136 1028 1137 xmom_edge_values[k3] = xmom_centroid_values[k]; 1029 1138 xmom_edge_values[k3+1] = xmom_centroid_values[k]; … … 1032 1141 ymom_edge_values[k3+1] = ymom_centroid_values[k]; 1033 1142 ymom_edge_values[k3+2] = ymom_centroid_values[k]; 1034 dk = max(stage_centroid_values[k] - elevation_centroid_values[k], 0.); 1035 height_edge_values[k3] = dk; 1036 height_edge_values[k3+1] = dk; 1037 height_edge_values[k3+2] = dk; 1038 1143 1039 1144 continue; 1040 } 1041 else 1042 { 1043 // Triangle k has one or more neighbours. 1044 // Get centroid and edge coordinates of the triangle 1045 1046 // Get the edge coordinates 1047 xv0 = edge_coordinates[k6]; 1048 yv0 = edge_coordinates[k6+1]; 1049 xv1 = edge_coordinates[k6+2]; 1050 yv1 = edge_coordinates[k6+3]; 1051 xv2 = edge_coordinates[k6+4]; 1052 yv2 = edge_coordinates[k6+5]; 1053 1054 // Get the centroid coordinates 1055 coord_index = 2*k; 1056 x = centroid_coordinates[coord_index]; 1057 y = centroid_coordinates[coord_index+1]; 1058 1059 // Store x- and y- differentials for the edges of 1060 // triangle k relative to the centroid 1061 dxv0 = xv0 - x; 1062 dxv1 = xv1 - x; 1063 dxv2 = xv2 - x; 1064 dyv0 = yv0 - y; 1065 dyv1 = yv1 - y; 1066 dyv2 = yv2 - y; 1067 1068 1069 // Compute bed slope as a reference 1070 //area_e = (yv2-yv0)*(xv1-xv0) - (yv1-yv0)*(xv2-xv0); 1071 //inv_area_e=1.0/area_e; 1072 //a_bs = (yv2 - yv0)*(elevation_edge_values[k3+1]-elevation_edge_values[k3+0]) - 1073 // (yv1 - yv0)*(elevation_edge_values[k3+2]-elevation_edge_values[k3+0]); 1074 //a_bs *= inv_area_e; 1075 1076 //b_bs = -(xv2 - xv0)*(elevation_edge_values[k3+1]-elevation_edge_values[k3+0]) + 1077 // (xv1 - xv0)*(elevation_edge_values[k3+2]-elevation_edge_values[k3+0]); 1078 //b_bs *= inv_area_e; 1079 1080 //printf("slopes: %f, %f \n", a_bs, b_bs); 1081 } 1082 1083 1084 1085 if (number_of_boundaries[k]<=1) 1086 { 1087 //============================================== 1088 // Number of boundaries <= 1 1089 // 'Typical case' 1090 //============================================== 1145 } 1146 1147 // Calculate heights of neighbouring cells 1148 hc = stage_centroid_values[k] - elevation_centroid_values[k]; 1149 h0 = stage_centroid_values[k0] - elevation_centroid_values[k0]; 1150 h1 = stage_centroid_values[k1] - elevation_centroid_values[k1]; 1151 h2 = stage_centroid_values[k2] - elevation_centroid_values[k2]; 1152 1153 hmin = min(min(h0, min(h1, h2)), hc); 1154 hmax = max(max(h0, max(h1, h2)), hc); 1155 1156 // Look for strong changes in cell depth, or shallow cell depths, as an indicator of near-wet-dry 1157 hfactor= max(0., min(2.0*max(hmin,0.0)/max(hc,1.0e-06)-0.1, 1158 min(2.0*max(hc,0.)/max(hmax,1.0e-06)-0.1, 1.0)) 1159 ); 1160 //hfactor=1.0; 1161 hfactor=min( max(hmin,0.)/(max(hmin,0.)+1.*minimum_allowed_height), hfactor); 1162 1163 //----------------------------------- 1164 // stage 1165 //----------------------------------- 1166 1167 // Calculate the difference between vertex 0 of the auxiliary 1168 // triangle and the centroid of triangle k 1169 dq0 = stage_centroid_values[k0] - stage_centroid_values[k]; 1170 1171 // Calculate differentials between the vertices 1172 // of the auxiliary triangle (centroids of neighbouring triangles) 1173 dq1 = stage_centroid_values[k1] - stage_centroid_values[k0]; 1174 dq2 = stage_centroid_values[k2] - stage_centroid_values[k0]; 1175 1176 inv_area2 = 1.0/area2; 1177 // Calculate the gradient of stage on the auxiliary triangle 1178 a = dy2*dq1 - dy1*dq2; 1179 a *= inv_area2; 1180 b = dx1*dq2 - dx2*dq1; 1181 b *= inv_area2; 1182 // Calculate provisional jumps in stage from the centroid 1183 // of triangle k to its vertices, to be limited 1184 dqv[0] = a*dxv0 + b*dyv0; 1185 dqv[1] = a*dxv1 + b*dyv1; 1186 dqv[2] = a*dxv2 + b*dyv2; 1187 1188 // Now we want to find min and max of the centroid and the 1189 // vertices of the auxiliary triangle and compute jumps 1190 // from the centroid to the min and max 1191 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1192 1193 beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor; 1194 //beta_tmp = beta_w_dry*0. + (beta_w - beta_w_dry*0.) * hfactor; 1195 //beta_tmp=1.0; 1196 1197 1198 // Limit the gradient 1199 limit_gradient(dqv, qmin, qmax, beta_tmp); 1200 1201 stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1202 stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1203 stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1204 1205 1206 //----------------------------------- 1207 // height 1208 //----------------------------------- 1209 1210 // Calculate the difference between vertex 0 of the auxiliary 1211 // triangle and the centroid of triangle k 1212 dq0 = height_centroid_values[k0] - height_centroid_values[k]; 1213 1214 // Calculate differentials between the vertices 1215 // of the auxiliary triangle (centroids of neighbouring triangles) 1216 dq1 = height_centroid_values[k1] - height_centroid_values[k0]; 1217 dq2 = height_centroid_values[k2] - height_centroid_values[k0]; 1218 1219 inv_area2 = 1.0/area2; 1220 // Calculate the gradient of height on the auxiliary triangle 1221 a = dy2*dq1 - dy1*dq2; 1222 a *= inv_area2; 1223 b = dx1*dq2 - dx2*dq1; 1224 b *= inv_area2; 1225 // Calculate provisional jumps in height from the centroid 1226 // of triangle k to its vertices, to be limited 1227 dqv[0] = a*dxv0 + b*dyv0; 1228 dqv[1] = a*dxv1 + b*dyv1; 1229 dqv[2] = a*dxv2 + b*dyv2; 1230 1231 // Now we want to find min and max of the centroid and the 1232 // vertices of the auxiliary triangle and compute jumps 1233 // from the centroid to the min and max 1234 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1235 1236 beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor; 1237 //beta_tmp=beta_w; 1238 1239 // Limit the gradient 1240 limit_gradient(dqv, qmin, qmax, beta_tmp); 1241 1242 height_edge_values[k3+0] = height_centroid_values[k] + dqv[0]; 1243 height_edge_values[k3+1] = height_centroid_values[k] + dqv[1]; 1244 height_edge_values[k3+2] = height_centroid_values[k] + dqv[2]; 1245 1246 1247 // REDEFINE hfactor for momentum terms -- make MORE first order 1248 hfactor= max(0., min(1.6*max(hmin,0.0)/max(hc,1.0e-06)-0.5, 1249 min(1.6*max(hc,0.)/max(hmax,1.0e-06)-0.5, 1.0)) 1250 ); 1251 hfactor=min( max(hmin,0.)/(max(hmin,0.)+10.*minimum_allowed_height), hfactor); 1252 1253 //----------------------------------- 1254 // xmomentum 1255 //----------------------------------- 1256 1257 // Calculate the difference between vertex 0 of the auxiliary 1258 // triangle and the centroid of triangle k 1259 dq0 = xmom_centroid_values[k0] - xmom_centroid_values[k]; 1260 1261 // Calculate differentials between the vertices 1262 // of the auxiliary triangle 1263 dq1 = xmom_centroid_values[k1] - xmom_centroid_values[k0]; 1264 dq2 = xmom_centroid_values[k2] - xmom_centroid_values[k0]; 1265 1266 // Calculate the gradient of xmom on the auxiliary triangle 1267 a = dy2*dq1 - dy1*dq2; 1268 a *= inv_area2; 1269 b = dx1*dq2 - dx2*dq1; 1270 b *= inv_area2; 1271 1272 // Calculate provisional jumps in stage from the centroid 1273 // of triangle k to its vertices, to be limited 1274 dqv[0] = a*dxv0+b*dyv0; 1275 dqv[1] = a*dxv1+b*dyv1; 1276 dqv[2] = a*dxv2+b*dyv2; 1277 1278 // Now we want to find min and max of the centroid and the 1279 // vertices of the auxiliary triangle and compute jumps 1280 // from the centroid to the min and max 1281 // 1282 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1283 1284 beta_tmp = beta_uh_dry + (beta_uh - beta_uh_dry) * hfactor; 1285 1286 // Limit the gradient 1287 limit_gradient(dqv, qmin, qmax, beta_tmp); 1288 1289 for (i=0; i < 3; i++) 1290 { 1291 xmom_edge_values[k3+i] = xmom_centroid_values[k] + dqv[i]; 1292 } 1293 1294 //----------------------------------- 1295 // ymomentum 1296 //----------------------------------- 1297 1298 // Calculate the difference between vertex 0 of the auxiliary 1299 // triangle and the centroid of triangle k 1300 dq0 = ymom_centroid_values[k0] - ymom_centroid_values[k]; 1301 1302 // Calculate differentials between the vertices 1303 // of the auxiliary triangle 1304 dq1 = ymom_centroid_values[k1] - ymom_centroid_values[k0]; 1305 dq2 = ymom_centroid_values[k2] - ymom_centroid_values[k0]; 1306 1307 // Calculate the gradient of xmom on the auxiliary triangle 1308 a = dy2*dq1 - dy1*dq2; 1309 a *= inv_area2; 1310 b = dx1*dq2 - dx2*dq1; 1311 b *= inv_area2; 1312 1313 // Calculate provisional jumps in stage from the centroid 1314 // of triangle k to its vertices, to be limited 1315 dqv[0] = a*dxv0 + b*dyv0; 1316 dqv[1] = a*dxv1 + b*dyv1; 1317 dqv[2] = a*dxv2 + b*dyv2; 1318 1319 // Now we want to find min and max of the centroid and the 1320 // vertices of the auxiliary triangle and compute jumps 1321 // from the centroid to the min and max 1322 // 1323 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1324 1325 beta_tmp = beta_vh_dry + (beta_vh - beta_vh_dry) * hfactor; 1326 1327 // Limit the gradient 1328 limit_gradient(dqv, qmin, qmax, beta_tmp); 1329 1330 for (i=0;i<3;i++) 1331 { 1332 ymom_edge_values[k3 + i] = ymom_centroid_values[k] + dqv[i]; 1333 } 1334 1335 } // End number_of_boundaries <=1 1336 else 1337 { 1338 1339 //============================================== 1340 // Number of boundaries == 2 1341 //============================================== 1091 1342 1092 1093 // If no boundaries, auxiliary triangle is formed 1094 // from the centroids of the three neighbours 1095 // If one boundary, auxiliary triangle is formed 1096 // from this centroid and its two neighbours 1097 1098 k0 = surrogate_neighbours[k3]; 1099 k1 = surrogate_neighbours[k3 + 1]; 1100 k2 = surrogate_neighbours[k3 + 2]; 1101 1102 // Test to see whether we accept the surrogate neighbours 1103 // Note that if ki is replaced with k in more than 1 neighbour, then the 1104 // triangle area will be zero, and a first order extrapolation will be 1105 // used 1106 //if(stage_centroid_values[k2]<=max_elevation_edgevalue[k2]+epsilon){ 1107 //if(stage_centroid_values[k2]<=elevation_centroid_values[k2]+minimum_allowed_height+epsilon){ 1108 // FIXME: Remove cell_wetness_scale if you don't need it 1109 if(k2<0 || (cell_wetness_scale[k2]==-10.0 && stage_centroid_values[k]<max_elevation_edgevalue[k])){ 1110 k2 = k ; 1343 // One internal neighbour and gradient is in direction of the neighbour's centroid 1344 1345 // Find the only internal neighbour (k1?) 1346 for (k2 = k3; k2 < k3 + 3; k2++) 1347 { 1348 // Find internal neighbour of triangle k 1349 // k2 indexes the edges of triangle k 1350 1351 if (surrogate_neighbours[k2] != k) 1352 { 1353 break; 1111 1354 } 1112 //if(stage_centroid_values[k0]<=max_elevation_edgevalue[k0]+epsilon){ 1113 //if(stage_centroid_values[k0]<=elevation_centroid_values[k0]+minimum_allowed_height+epsilon){ 1114 if(k0 < 0 || (cell_wetness_scale[k0]==-10.0 && stage_centroid_values[k]<max_elevation_edgevalue[k])){ 1115 k0 = k ; 1116 } 1117 //if(stage_centroid_values[k1]<=max_elevation_edgevalue[k1]+epsilon){ 1118 //if(stage_centroid_values[k1]<=elevation_centroid_values[k1]+minimum_allowed_height+epsilon){ 1119 //if(k1 < 0 || (cell_wetness_scale[k1]==0.0 && stage_centroid_values[k]<elevation_edge_values[3*k+1])){ 1120 if(k1 < 0 || (cell_wetness_scale[k1]==-10.0 && stage_centroid_values[k]<max_elevation_edgevalue[k])){ 1121 k1 = k ; 1122 } 1123 1124 // Take note if the max neighbour bed elevation is greater than the min 1125 // neighbour stage -- suggests a 'steep' bed relative to the flow 1126 bedmax = max(elevation_centroid_values[k], 1127 max(elevation_centroid_values[k0], 1128 max(elevation_centroid_values[k1], 1129 elevation_centroid_values[k2]))); 1130 bedmin = min(elevation_centroid_values[k], 1131 min(elevation_centroid_values[k0], 1132 min(elevation_centroid_values[k1], 1133 elevation_centroid_values[k2]))); 1134 //stagemin = min(max(stage_centroid_values[k], elevation_centroid_values[k]), 1135 // min(max(stage_centroid_values[k0], elevation_centroid_values[k0]), 1136 // min(max(stage_centroid_values[k1], elevation_centroid_values[k1]), 1137 // max(stage_centroid_values[k2], elevation_centroid_values[k2])))); 1138 1139 // Get the auxiliary triangle's vertex coordinates 1140 // (really the centroids of neighbouring triangles) 1141 coord_index = 2*k0; 1142 x0 = centroid_coordinates[coord_index]; 1143 y0 = centroid_coordinates[coord_index+1]; 1144 1145 coord_index = 2*k1; 1146 x1 = centroid_coordinates[coord_index]; 1147 y1 = centroid_coordinates[coord_index+1]; 1148 1149 coord_index = 2*k2; 1150 x2 = centroid_coordinates[coord_index]; 1151 y2 = centroid_coordinates[coord_index+1]; 1152 1153 // Store x- and y- differentials for the vertices 1154 // of the auxiliary triangle 1155 dx1 = x1 - x0; 1156 dx2 = x2 - x0; 1157 dy1 = y1 - y0; 1158 dy2 = y2 - y0; 1159 1160 // Calculate 2*area of the auxiliary triangle 1161 // The triangle is guaranteed to be counter-clockwise 1162 area2 = dy2*dx1 - dy1*dx2; 1163 1164 //// Treat triangles with zero or 1 wet neighbours (area2 <=0.) 1165 if ((area2 <= 0.) )//|| (cell_wetness_scale[k]==0.)) //|(count_wet_neighbours[k]==0)) 1166 { 1167 1168 // Isolated wet cell -- constant stage/depth extrapolation 1169 //stage_edge_values[k3] = stage_centroid_values[k]; 1170 //stage_edge_values[k3+1] = stage_centroid_values[k]; 1171 //stage_edge_values[k3+2] = stage_centroid_values[k]; 1172 1173 dk=height_centroid_values[k]; //max(stage_centroid_values[k]-elevation_centroid_values[k],0.); 1174 height_edge_values[k3] = dk; 1175 height_edge_values[k3+1] = dk; 1176 height_edge_values[k3+2] = dk; 1177 1178 stage_edge_values[k3] = elevation_centroid_values[k]+dk; 1179 stage_edge_values[k3+1] = elevation_centroid_values[k]+dk; 1180 stage_edge_values[k3+2] = elevation_centroid_values[k]+dk; 1181 //stage_edge_values[k3] = elevation_edge_values[k3]+dk; 1182 //stage_edge_values[k3+1] = elevation_edge_values[k3+1]+dk; 1183 //stage_edge_values[k3+2] = elevation_edge_values[k3+2]+dk; 1184 1185 xmom_edge_values[k3] = xmom_centroid_values[k]; 1186 xmom_edge_values[k3+1] = xmom_centroid_values[k]; 1187 xmom_edge_values[k3+2] = xmom_centroid_values[k]; 1188 ymom_edge_values[k3] = ymom_centroid_values[k]; 1189 ymom_edge_values[k3+1] = ymom_centroid_values[k]; 1190 ymom_edge_values[k3+2] = ymom_centroid_values[k]; 1191 1192 continue; 1193 } 1194 1195 // Calculate heights of neighbouring cells 1196 hc = stage_centroid_values[k] - elevation_centroid_values[k]; 1197 h0 = stage_centroid_values[k0] - elevation_centroid_values[k0]; 1198 h1 = stage_centroid_values[k1] - elevation_centroid_values[k1]; 1199 h2 = stage_centroid_values[k2] - elevation_centroid_values[k2]; 1200 //h0=0.; 1201 //h1=0.; 1202 //h2=0.; 1203 1204 //if(k!=k0) h0 = stage_centroid_values[k0] - elevation_centroid_values[k0]; 1205 //if(k!=k1) h1 = stage_centroid_values[k1] - elevation_centroid_values[k1]; 1206 //if(k!=k2) h2 = stage_centroid_values[k2] - elevation_centroid_values[k2]; 1207 1208 hmin = min(min(h0, min(h1, h2)), hc); 1209 hmax = max(max(h0, max(h1, h2)), hc); 1210 //// GD FIXME: No longer needed? 1211 //hfactor = 0.0; 1212 ////if (hmin > 0.001) 1213 //if (hmin > 0.) 1214 ////if (hc>0.0) 1215 //{ 1216 // hfactor = 1.0 ;//hmin/(hmin + 0.004); 1217 //hfactor=hmin/(hmin + 0.004); 1218 //} 1219 //hfactor= min(2.0*max(hmin,0.0)/max(hc,max(1.0*(max_elevation_edgevalue[k]-min_elevation_edgevalue[k]),minimum_allowed_height*1.)), 1.0); 1220 1221 // Look for strong changes in cell wetness as an indicator of near-wet-dry 1222 hfactor= min(2.0*max(hmin,0.0)/max(hc,minimum_allowed_height), 1223 min(2.0*max(hc,0.)/max(hmax,minimum_allowed_height), 1.0)); 1224 //hfactor= min(2.0*max(hc,0.)/max(hmax,minimum_allowed_height), 1.0); 1225 //hfactor=0.; 1226 //if(hmin==hc) hfactor=0.; 1227 //hfactor= min(2.0*max(hmin,0.0)/max(hc,minimum_allowed_height+bedmax-bedmin), 1228 // min(2.0*max(hc,0.)/max(hmax,minimum_allowed_height+bedmax-bedmin), 1.0)); 1229 1230 //hfactor=1.0; 1231 //hfactor=min( max(hmin,0.)/(max(hmin,0.)+10.*minimum_allowed_height), 1.0); 1232 //if(hc<minimum_allowed_height*10.) hfactor=0.; 1233 //if(cell_wetness_scale[k0]==0 | cell_wetness_scale[k1]==0 | cell_wetness_scale[k2]==0) hfactor=0; 1234 //hfactor=1.0; 1235 1236 //----------------------------------- 1237 // stage 1238 //----------------------------------- 1239 1240 // Calculate the difference between vertex 0 of the auxiliary 1241 // triangle and the centroid of triangle k 1242 dq0 = stage_centroid_values[k0] - stage_centroid_values[k]; 1243 1244 // Calculate differentials between the vertices 1245 // of the auxiliary triangle (centroids of neighbouring triangles) 1246 dq1 = stage_centroid_values[k1] - stage_centroid_values[k0]; 1247 dq2 = stage_centroid_values[k2] - stage_centroid_values[k0]; 1248 1249 inv_area2 = 1.0/area2; 1250 // Calculate the gradient of stage on the auxiliary triangle 1251 a = dy2*dq1 - dy1*dq2; 1252 a *= inv_area2; 1253 b = dx1*dq2 - dx2*dq1; 1254 b *= inv_area2; 1255 // Calculate provisional jumps in stage from the centroid 1256 // of triangle k to its vertices, to be limited 1257 dqv[0] = a*dxv0 + b*dyv0; 1258 dqv[1] = a*dxv1 + b*dyv1; 1259 dqv[2] = a*dxv2 + b*dyv2; 1260 1261 // Now we want to find min and max of the centroid and the 1262 // vertices of the auxiliary triangle and compute jumps 1263 // from the centroid to the min and max 1264 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1265 1266 beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor; 1267 //beta_tmp = beta_w_dry*0. + (beta_w - beta_w_dry*0.) * hfactor; 1268 //beta_tmp=1.0; 1269 1270 1271 // Limit the gradient 1272 limit_gradient(dqv, qmin, qmax, beta_tmp); 1273 1274 stage_edge_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1275 stage_edge_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1276 stage_edge_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1277 1278 1279 //----------------------------------- 1280 // height 1281 //----------------------------------- 1282 1283 // Calculate the difference between vertex 0 of the auxiliary 1284 // triangle and the centroid of triangle k 1285 dq0 = height_centroid_values[k0] - height_centroid_values[k]; 1286 1287 // Calculate differentials between the vertices 1288 // of the auxiliary triangle (centroids of neighbouring triangles) 1289 dq1 = height_centroid_values[k1] - height_centroid_values[k0]; 1290 dq2 = height_centroid_values[k2] - height_centroid_values[k0]; 1291 1292 inv_area2 = 1.0/area2; 1293 // Calculate the gradient of height on the auxiliary triangle 1294 a = dy2*dq1 - dy1*dq2; 1295 a *= inv_area2; 1296 b = dx1*dq2 - dx2*dq1; 1297 b *= inv_area2; 1298 // Calculate provisional jumps in height from the centroid 1299 // of triangle k to its vertices, to be limited 1300 dqv[0] = a*dxv0 + b*dyv0; 1301 dqv[1] = a*dxv1 + b*dyv1; 1302 dqv[2] = a*dxv2 + b*dyv2; 1303 1304 // Now we want to find min and max of the centroid and the 1305 // vertices of the auxiliary triangle and compute jumps 1306 // from the centroid to the min and max 1307 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1308 1309 beta_tmp = beta_w_dry + (beta_w - beta_w_dry) * hfactor; 1310 //beta_tmp=beta_w; 1311 1312 // Limit the gradient 1313 limit_gradient(dqv, qmin, qmax, beta_tmp); 1314 1315 height_edge_values[k3+0] = height_centroid_values[k] + dqv[0]; 1316 height_edge_values[k3+1] = height_centroid_values[k] + dqv[1]; 1317 height_edge_values[k3+2] = height_centroid_values[k] + dqv[2]; 1318 1319 //----------------------------------- 1320 // xmomentum 1321 //----------------------------------- 1322 1323 // Calculate the difference between vertex 0 of the auxiliary 1324 // triangle and the centroid of triangle k 1325 dq0 = xmom_centroid_values[k0] - xmom_centroid_values[k]; 1326 1327 // Calculate differentials between the vertices 1328 // of the auxiliary triangle 1329 dq1 = xmom_centroid_values[k1] - xmom_centroid_values[k0]; 1330 dq2 = xmom_centroid_values[k2] - xmom_centroid_values[k0]; 1331 1332 // Calculate the gradient of xmom on the auxiliary triangle 1333 a = dy2*dq1 - dy1*dq2; 1334 a *= inv_area2; 1335 b = dx1*dq2 - dx2*dq1; 1336 b *= inv_area2; 1337 1338 // Calculate provisional jumps in stage from the centroid 1339 // of triangle k to its vertices, to be limited 1340 dqv[0] = a*dxv0+b*dyv0; 1341 dqv[1] = a*dxv1+b*dyv1; 1342 dqv[2] = a*dxv2+b*dyv2; 1343 1344 // Now we want to find min and max of the centroid and the 1345 // vertices of the auxiliary triangle and compute jumps 1346 // from the centroid to the min and max 1347 // 1348 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1349 1350 beta_tmp = beta_uh_dry + (beta_uh - beta_uh_dry) * hfactor; 1351 1352 // Limit the gradient 1353 //if((k!=k0)&(k!=k1)&(k!=k2)) 1354 //if(stagemin>=bedmax){ 1355 //if((count_wet_neighbours[k]>0)){ // && 1356 // (cell_wetness_scale[k]==1.0)){ 1357 //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){ 1358 1359 limit_gradient(dqv, qmin, qmax, beta_tmp); 1360 //}else{ 1361 // dqv[0]=0.; 1362 // dqv[1]=0.; 1363 // dqv[2]=0.; 1364 //// limit_gradient(dqv, qmin, qmax, 0.); 1365 //} 1366 //limit_gradient2(dqv, qmin, qmax, beta_tmp,r0scale); 1367 1368 1369 for (i=0; i < 3; i++) 1370 { 1371 xmom_edge_values[k3+i] = xmom_centroid_values[k] + dqv[i]; 1372 } 1373 1374 //----------------------------------- 1375 // ymomentum 1376 //----------------------------------- 1377 1378 // Calculate the difference between vertex 0 of the auxiliary 1379 // triangle and the centroid of triangle k 1380 dq0 = ymom_centroid_values[k0] - ymom_centroid_values[k]; 1381 1382 // Calculate differentials between the vertices 1383 // of the auxiliary triangle 1384 dq1 = ymom_centroid_values[k1] - ymom_centroid_values[k0]; 1385 dq2 = ymom_centroid_values[k2] - ymom_centroid_values[k0]; 1386 1387 // Calculate the gradient of xmom on the auxiliary triangle 1388 a = dy2*dq1 - dy1*dq2; 1389 a *= inv_area2; 1390 b = dx1*dq2 - dx2*dq1; 1391 b *= inv_area2; 1392 1393 // Calculate provisional jumps in stage from the centroid 1394 // of triangle k to its vertices, to be limited 1395 dqv[0] = a*dxv0 + b*dyv0; 1396 dqv[1] = a*dxv1 + b*dyv1; 1397 dqv[2] = a*dxv2 + b*dyv2; 1398 1399 // Now we want to find min and max of the centroid and the 1400 // vertices of the auxiliary triangle and compute jumps 1401 // from the centroid to the min and max 1402 // 1403 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1404 1405 beta_tmp = beta_vh_dry + (beta_vh - beta_vh_dry) * hfactor; 1406 1407 // Limit the gradient 1408 //if(stagemin>=bedmax){ 1409 //if((count_wet_neighbours[k]>0)){//&& 1410 //(cell_wetness_scale[k]==1.0)){ 1411 //(stage_centroid_values[k]>(minimum_allowed_height+elevation_centroid_values[k]))){ 1412 //if(stage_centroid_values[k]>(minimum_allowed_height+max_elevation_edgevalue[k])){ 1413 limit_gradient(dqv, qmin, qmax, beta_tmp); 1414 //}else{ 1415 // dqv[0]=0.; 1416 // dqv[1]=0.; 1417 // dqv[2]=0.; 1418 //} 1419 1420 for (i=0;i<3;i++) 1421 { 1422 ymom_edge_values[k3 + i] = ymom_centroid_values[k] + dqv[i]; 1423 } 1424 1425 } // End number_of_boundaries <=1 1426 else 1427 { 1428 1429 //============================================== 1430 // Number of boundaries == 2 1431 //============================================== 1432 1433 // One internal neighbour and gradient is in direction of the neighbour's centroid 1434 1435 // Find the only internal neighbour (k1?) 1436 for (k2 = k3; k2 < k3 + 3; k2++) 1437 { 1438 // Find internal neighbour of triangle k 1439 // k2 indexes the edges of triangle k 1440 1441 if (surrogate_neighbours[k2] != k) 1355 } 1356 1357 if ((k2 == k3 + 3)) 1358 { 1359 // If we didn't find an internal neighbour 1360 report_python_error(AT, "Internal neighbour not found"); 1361 return -1; 1362 } 1363 1364 k1 = surrogate_neighbours[k2]; 1365 1366 // The coordinates of the triangle are already (x,y). 1367 // Get centroid of the neighbour (x1,y1) 1368 coord_index = 2*k1; 1369 x1 = centroid_coordinates[coord_index]; 1370 y1 = centroid_coordinates[coord_index + 1]; 1371 1372 // Compute x- and y- distances between the centroid of 1373 // triangle k and that of its neighbour 1374 dx1 = x1 - x; 1375 dy1 = y1 - y; 1376 1377 // Set area2 as the square of the distance 1378 area2 = dx1*dx1 + dy1*dy1; 1379 1380 // Set dx2=(x1-x0)/((x1-x0)^2+(y1-y0)^2) 1381 // and dy2=(y1-y0)/((x1-x0)^2+(y1-y0)^2) which 1382 // respectively correspond to the x- and y- gradients 1383 // of the conserved quantities 1384 dx2 = 1.0/area2; 1385 dy2 = dx2*dy1; 1386 dx2 *= dx1; 1387 1388 1389 //----------------------------------- 1390 // stage 1391 //----------------------------------- 1392 1393 // Compute differentials 1394 dq1 = stage_centroid_values[k1] - stage_centroid_values[k]; 1395 1396 // Calculate the gradient between the centroid of triangle k 1397 // and that of its neighbour 1398 a = dq1*dx2; 1399 b = dq1*dy2; 1400 1401 // Calculate provisional edge jumps, to be limited 1402 dqv[0] = a*dxv0 + b*dyv0; 1403 dqv[1] = a*dxv1 + b*dyv1; 1404 dqv[2] = a*dxv2 + b*dyv2; 1405 1406 // Now limit the jumps 1407 if (dq1>=0.0) 1408 { 1409 qmin=0.0; 1410 qmax=dq1; 1411 } 1412 else 1413 { 1414 qmin = dq1; 1415 qmax = 0.0; 1416 } 1417 1418 // Limit the gradient 1419 limit_gradient(dqv, qmin, qmax, beta_w); 1420 1421 stage_edge_values[k3] = stage_centroid_values[k] + dqv[0]; 1422 stage_edge_values[k3 + 1] = stage_centroid_values[k] + dqv[1]; 1423 stage_edge_values[k3 + 2] = stage_centroid_values[k] + dqv[2]; 1424 1425 //----------------------------------- 1426 // height 1427 //----------------------------------- 1428 1429 // Compute differentials 1430 dq1 = height_centroid_values[k1] - height_centroid_values[k]; 1431 1432 // Calculate the gradient between the centroid of triangle k 1433 // and that of its neighbour 1434 a = dq1*dx2; 1435 b = dq1*dy2; 1436 1437 // Calculate provisional edge jumps, to be limited 1438 dqv[0] = a*dxv0 + b*dyv0; 1439 dqv[1] = a*dxv1 + b*dyv1; 1440 dqv[2] = a*dxv2 + b*dyv2; 1441 1442 // Now limit the jumps 1443 if (dq1>=0.0) 1444 { 1445 qmin=0.0; 1446 qmax=dq1; 1447 } 1448 else 1449 { 1450 qmin = dq1; 1451 qmax = 0.0; 1452 } 1453 1454 // Limit the gradient 1455 limit_gradient(dqv, qmin, qmax, beta_w); 1456 1457 height_edge_values[k3] = height_centroid_values[k] + dqv[0]; 1458 height_edge_values[k3 + 1] = height_centroid_values[k] + dqv[1]; 1459 height_edge_values[k3 + 2] = height_centroid_values[k] + dqv[2]; 1460 1461 //----------------------------------- 1462 // xmomentum 1463 //----------------------------------- 1464 1465 // Compute differentials 1466 dq1 = xmom_centroid_values[k1] - xmom_centroid_values[k]; 1467 1468 // Calculate the gradient between the centroid of triangle k 1469 // and that of its neighbour 1470 a = dq1*dx2; 1471 b = dq1*dy2; 1472 1473 // Calculate provisional edge jumps, to be limited 1474 dqv[0] = a*dxv0+b*dyv0; 1475 dqv[1] = a*dxv1+b*dyv1; 1476 dqv[2] = a*dxv2+b*dyv2; 1477 1478 // Now limit the jumps 1479 if (dq1 >= 0.0) 1480 { 1481 qmin = 0.0; 1482 qmax = dq1; 1483 } 1484 else 1485 { 1486 qmin = dq1; 1487 qmax = 0.0; 1488 } 1489 1490 // Limit the gradient 1491 limit_gradient(dqv, qmin, qmax, beta_w); 1492 1493 //for (i=0;i<3;i++) 1494 //xmom_edge_values[k3] = xmom_centroid_values[k] + dqv[0]; 1495 //xmom_edge_values[k3 + 1] = xmom_centroid_values[k] + dqv[1]; 1496 //xmom_edge_values[k3 + 2] = xmom_centroid_values[k] + dqv[2]; 1497 1498 for (i = 0; i < 3;i++) 1499 { 1500 xmom_edge_values[k3 + i] = xmom_centroid_values[k] + dqv[i]; 1501 } 1502 1503 //----------------------------------- 1504 // ymomentum 1505 //----------------------------------- 1506 1507 // Compute differentials 1508 dq1 = ymom_centroid_values[k1] - ymom_centroid_values[k]; 1509 1510 // Calculate the gradient between the centroid of triangle k 1511 // and that of its neighbour 1512 a = dq1*dx2; 1513 b = dq1*dy2; 1514 1515 // Calculate provisional edge jumps, to be limited 1516 dqv[0] = a*dxv0 + b*dyv0; 1517 dqv[1] = a*dxv1 + b*dyv1; 1518 dqv[2] = a*dxv2 + b*dyv2; 1519 1520 // Now limit the jumps 1521 if (dq1>=0.0) 1522 { 1523 qmin = 0.0; 1524 qmax = dq1; 1525 } 1526 else 1527 { 1528 qmin = dq1; 1529 qmax = 0.0; 1530 } 1531 1532 // Limit the gradient 1533 limit_gradient(dqv, qmin, qmax, beta_w); 1534 1535 for (i=0;i<3;i++) 1442 1536 { 1443 break;1537 ymom_edge_values[k3 + i] = ymom_centroid_values[k] + dqv[i]; 1444 1538 } 1445 } 1446 1447 if ((k2 == k3 + 3)) 1448 { 1449 // If we didn't find an internal neighbour 1450 report_python_error(AT, "Internal neighbour not found"); 1451 return -1; 1452 } 1453 1454 k1 = surrogate_neighbours[k2]; 1455 1456 // The coordinates of the triangle are already (x,y). 1457 // Get centroid of the neighbour (x1,y1) 1458 coord_index = 2*k1; 1459 x1 = centroid_coordinates[coord_index]; 1460 y1 = centroid_coordinates[coord_index + 1]; 1461 1462 // Compute x- and y- distances between the centroid of 1463 // triangle k and that of its neighbour 1464 dx1 = x1 - x; 1465 dy1 = y1 - y; 1466 1467 // Set area2 as the square of the distance 1468 area2 = dx1*dx1 + dy1*dy1; 1469 1470 // Set dx2=(x1-x0)/((x1-x0)^2+(y1-y0)^2) 1471 // and dy2=(y1-y0)/((x1-x0)^2+(y1-y0)^2) which 1472 // respectively correspond to the x- and y- gradients 1473 // of the conserved quantities 1474 dx2 = 1.0/area2; 1475 dy2 = dx2*dy1; 1476 dx2 *= dx1; 1477 1478 1479 //----------------------------------- 1480 // stage 1481 //----------------------------------- 1482 1483 // Compute differentials 1484 dq1 = stage_centroid_values[k1] - stage_centroid_values[k]; 1485 1486 // Calculate the gradient between the centroid of triangle k 1487 // and that of its neighbour 1488 a = dq1*dx2; 1489 b = dq1*dy2; 1490 1491 // Calculate provisional edge jumps, to be limited 1492 dqv[0] = a*dxv0 + b*dyv0; 1493 dqv[1] = a*dxv1 + b*dyv1; 1494 dqv[2] = a*dxv2 + b*dyv2; 1495 1496 // Now limit the jumps 1497 if (dq1>=0.0) 1498 { 1499 qmin=0.0; 1500 qmax=dq1; 1501 } 1502 else 1503 { 1504 qmin = dq1; 1505 qmax = 0.0; 1506 } 1507 1508 // Limit the gradient 1509 limit_gradient(dqv, qmin, qmax, beta_w); 1510 1511 stage_edge_values[k3] = stage_centroid_values[k] + dqv[0]; 1512 stage_edge_values[k3 + 1] = stage_centroid_values[k] + dqv[1]; 1513 stage_edge_values[k3 + 2] = stage_centroid_values[k] + dqv[2]; 1514 1515 //----------------------------------- 1516 // height 1517 //----------------------------------- 1518 1519 // Compute differentials 1520 dq1 = height_centroid_values[k1] - height_centroid_values[k]; 1521 1522 // Calculate the gradient between the centroid of triangle k 1523 // and that of its neighbour 1524 a = dq1*dx2; 1525 b = dq1*dy2; 1526 1527 // Calculate provisional edge jumps, to be limited 1528 dqv[0] = a*dxv0 + b*dyv0; 1529 dqv[1] = a*dxv1 + b*dyv1; 1530 dqv[2] = a*dxv2 + b*dyv2; 1531 1532 // Now limit the jumps 1533 if (dq1>=0.0) 1534 { 1535 qmin=0.0; 1536 qmax=dq1; 1537 } 1538 else 1539 { 1540 qmin = dq1; 1541 qmax = 0.0; 1542 } 1543 1544 // Limit the gradient 1545 limit_gradient(dqv, qmin, qmax, beta_w); 1546 1547 height_edge_values[k3] = height_centroid_values[k] + dqv[0]; 1548 height_edge_values[k3 + 1] = height_centroid_values[k] + dqv[1]; 1549 height_edge_values[k3 + 2] = height_centroid_values[k] + dqv[2]; 1550 1551 //----------------------------------- 1552 // xmomentum 1553 //----------------------------------- 1554 1555 // Compute differentials 1556 dq1 = xmom_centroid_values[k1] - xmom_centroid_values[k]; 1557 1558 // Calculate the gradient between the centroid of triangle k 1559 // and that of its neighbour 1560 a = dq1*dx2; 1561 b = dq1*dy2; 1562 1563 // Calculate provisional edge jumps, to be limited 1564 dqv[0] = a*dxv0+b*dyv0; 1565 dqv[1] = a*dxv1+b*dyv1; 1566 dqv[2] = a*dxv2+b*dyv2; 1567 1568 // Now limit the jumps 1569 if (dq1 >= 0.0) 1570 { 1571 qmin = 0.0; 1572 qmax = dq1; 1573 } 1574 else 1575 { 1576 qmin = dq1; 1577 qmax = 0.0; 1578 } 1579 1580 // Limit the gradient 1581 limit_gradient(dqv, qmin, qmax, beta_w); 1582 1583 //for (i=0;i<3;i++) 1584 //xmom_edge_values[k3] = xmom_centroid_values[k] + dqv[0]; 1585 //xmom_edge_values[k3 + 1] = xmom_centroid_values[k] + dqv[1]; 1586 //xmom_edge_values[k3 + 2] = xmom_centroid_values[k] + dqv[2]; 1587 1588 for (i = 0; i < 3;i++) 1589 { 1590 xmom_edge_values[k3 + i] = xmom_centroid_values[k] + dqv[i]; 1591 } 1592 1593 //----------------------------------- 1594 // ymomentum 1595 //----------------------------------- 1596 1597 // Compute differentials 1598 dq1 = ymom_centroid_values[k1] - ymom_centroid_values[k]; 1599 1600 // Calculate the gradient between the centroid of triangle k 1601 // and that of its neighbour 1602 a = dq1*dx2; 1603 b = dq1*dy2; 1604 1605 // Calculate provisional edge jumps, to be limited 1606 dqv[0] = a*dxv0 + b*dyv0; 1607 dqv[1] = a*dxv1 + b*dyv1; 1608 dqv[2] = a*dxv2 + b*dyv2; 1609 1610 // Now limit the jumps 1611 if (dq1>=0.0) 1612 { 1613 qmin = 0.0; 1614 qmax = dq1; 1615 } 1616 else 1617 { 1618 qmin = dq1; 1619 qmax = 0.0; 1620 } 1621 1622 // Limit the gradient 1623 limit_gradient(dqv, qmin, qmax, beta_w); 1624 1625 for (i=0;i<3;i++) 1626 { 1627 ymom_edge_values[k3 + i] = ymom_centroid_values[k] + dqv[i]; 1628 } 1629 } // else [number_of_boundaries==2] 1630 } // for k=0 to number_of_elements-1 1631 //} 1632 1633 //for(k=0;k<number_of_elements; k++){ 1634 // // Hack for 'dry' cells 1635 // // Make sure edge value is not greater than neighbour edge value 1636 // //if(stage_centroid_values[k] - elevation_centroid_values[k] < minimum_allowed_height+epsilon){ 1637 // if(cell_wetness_scale[k]==0.0){ 1638 // for(i=0; i<3;i++){ 1639 // if(surrogate_neighbours[3*k+i] >= 0){ 1640 // ktmp=3*surrogate_neighbours[3*k+i] + neighbour_edges[3*k+i]; 1641 // //if(cell_wetness_scale[surrogate_neighbours[3*k+i]]>0.){ 1642 // stage_edge_values[3*k+i] = min(stage_edge_values[3*k+i], stage_edge_values[ktmp]); 1643 // } 1644 // } 1645 // } 1646 //} 1539 } // else [number_of_boundaries==2] 1540 } // for k=0 to number_of_elements-1 1541 1647 1542 1648 1543 // Compute vertex values of quantities -
trunk/anuga_work/development/gareth/tests/dam_break/plotme.py
r9011 r9015 11 11 12 12 13 p_dev = util2.get_output('dam_break_20131 030_174145/dam_break.sww', 0.001)13 p_dev = util2.get_output('dam_break_20131103_204343/dam_break.sww', 0.001) 14 14 p2_dev=util2.get_centroids(p_dev, velocity_extrapolation=True) 15 15
Note: See TracChangeset
for help on using the changeset viewer.