Changeset 6840
- Timestamp:
- Apr 20, 2009, 2:31:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r6778 r6840 133 133 134 134 phi=min(r*beta_w,1.0); 135 for (i=0;i<3;i++) 136 dqv[i]=dqv[i]*phi; 135 //for (i=0;i<3;i++) 136 dqv[0]=dqv[0]*phi; 137 dqv[1]=dqv[1]*phi; 138 dqv[2]=dqv[2]*phi; 137 139 138 140 return 0; … … 500 502 S = -g * eta[k]*eta[k] * sqrt((uh[k]*uh[k] + vh[k]*vh[k])); 501 503 S /= pow(h, 7.0/3); //Expensive (on Ole's home computer) 502 //S /= exp( 7.0/3.0*log(h)); //seems to save about 15% over manning_friction504 //S /= exp((7.0/3.0)*log(h)); //seems to save about 15% over manning_friction 503 505 //S /= h*h*(1 + h/3.0 - h*h/9.0); //FIXME: Could use a Taylor expansion 504 506 … … 1062 1064 // Computational routine 1063 1065 int _extrapolate_second_order_sw(int number_of_elements, 1064 double epsilon,1065 double minimum_allowed_height,1066 double beta_w,1067 double beta_w_dry,1068 double beta_uh,1069 double beta_uh_dry,1070 double beta_vh,1071 double beta_vh_dry,1072 long* surrogate_neighbours,1073 long* number_of_boundaries,1074 double* centroid_coordinates,1075 double* stage_centroid_values,1076 double* xmom_centroid_values,1077 double* ymom_centroid_values,1078 double* elevation_centroid_values,1079 double* vertex_coordinates,1080 double* stage_vertex_values,1081 double* xmom_vertex_values,1082 double* ymom_vertex_values,1083 double* elevation_vertex_values,1084 int optimise_dry_cells) {1066 double epsilon, 1067 double minimum_allowed_height, 1068 double beta_w, 1069 double beta_w_dry, 1070 double beta_uh, 1071 double beta_uh_dry, 1072 double beta_vh, 1073 double beta_vh_dry, 1074 long* surrogate_neighbours, 1075 long* number_of_boundaries, 1076 double* centroid_coordinates, 1077 double* stage_centroid_values, 1078 double* xmom_centroid_values, 1079 double* ymom_centroid_values, 1080 double* elevation_centroid_values, 1081 double* vertex_coordinates, 1082 double* stage_vertex_values, 1083 double* xmom_vertex_values, 1084 double* ymom_vertex_values, 1085 double* elevation_vertex_values, 1086 int optimise_dry_cells) { 1085 1087 1086 1088 … … 1088 1090 // Local variables 1089 1091 double a, b; // Gradient vector used to calculate vertex values from centroids 1090 int k, k0,k1,k2,k3,k6,coord_index,i;1091 double x, y,x0,y0,x1,y1,x2,y2,xv0,yv0,xv1,yv1,xv2,yv2; // Vertices of the auxiliary triangle1092 double dx1, dx2,dy1,dy2,dxv0,dxv1,dxv2,dyv0,dyv1,dyv2,dq0,dq1,dq2,area2;1092 int k, k0, k1, k2, k3, k6, coord_index, i; 1093 double x, y, x0, y0, x1, y1, x2, y2, xv0, yv0, xv1, yv1, xv2, yv2; // Vertices of the auxiliary triangle 1094 double dx1, dx2, dy1, dy2, dxv0, dxv1, dxv2, dyv0, dyv1, dyv2, dq0, dq1, dq2, area2, inv_area2; 1093 1095 double dqv[3], qmin, qmax, hmin, hmax; 1094 1096 double hc, h0, h1, h2, beta_tmp, hfactor; 1095 1097 1096 1098 1097 for (k=0; k<number_of_elements; k++) { 1099 for (k = 0; k < number_of_elements; k++) 1100 { 1098 1101 k3=k*3; 1099 1102 k6=k*6; 1100 1103 1101 1102 if (number_of_boundaries[k]==3){1104 if (number_of_boundaries[k]==3) 1105 { 1103 1106 // No neighbours, set gradient on the triangle to zero 1104 1107 … … 1115 1118 continue; 1116 1119 } 1117 else { 1120 else 1121 { 1118 1122 // Triangle k has one or more neighbours. 1119 1123 // Get centroid and vertex coordinates of the triangle 1120 1124 1121 1125 // Get the vertex coordinates 1122 xv0 = vertex_coordinates[k6]; yv0=vertex_coordinates[k6+1]; 1123 xv1 = vertex_coordinates[k6+2]; yv1=vertex_coordinates[k6+3]; 1124 xv2 = vertex_coordinates[k6+4]; yv2=vertex_coordinates[k6+5]; 1126 xv0 = vertex_coordinates[k6]; 1127 yv0 = vertex_coordinates[k6+1]; 1128 xv1 = vertex_coordinates[k6+2]; 1129 yv1 = vertex_coordinates[k6+3]; 1130 xv2 = vertex_coordinates[k6+4]; 1131 yv2 = vertex_coordinates[k6+5]; 1125 1132 1126 1133 // Get the centroid coordinates 1127 coord_index =2*k;1128 x =centroid_coordinates[coord_index];1129 y =centroid_coordinates[coord_index+1];1134 coord_index = 2*k; 1135 x = centroid_coordinates[coord_index]; 1136 y = centroid_coordinates[coord_index+1]; 1130 1137 1131 1138 // Store x- and y- differentials for the vertices of 1132 1139 // triangle k relative to the centroid 1133 dxv0=xv0-x; dxv1=xv1-x; dxv2=xv2-x; 1134 dyv0=yv0-y; dyv1=yv1-y; dyv2=yv2-y; 1140 dxv0 = xv0 - x; 1141 dxv1 = xv1 - x; 1142 dxv2 = xv2 - x; 1143 dyv0 = yv0 - y; 1144 dyv1 = yv1 - y; 1145 dyv2 = yv2 - y; 1135 1146 } 1136 1147 1137 1148 1138 1149 1139 if (number_of_boundaries[k]<=1) {1140 1150 if (number_of_boundaries[k]<=1) 1151 { 1141 1152 //============================================== 1142 1153 // Number of boundaries <= 1 … … 1149 1160 // from this centroid and its two neighbours 1150 1161 1151 k0 =surrogate_neighbours[k3];1152 k1 =surrogate_neighbours[k3+1];1153 k2 =surrogate_neighbours[k3+2];1162 k0 = surrogate_neighbours[k3]; 1163 k1 = surrogate_neighbours[k3 + 1]; 1164 k2 = surrogate_neighbours[k3 + 2]; 1154 1165 1155 1166 // Get the auxiliary triangle's vertex coordinates 1156 1167 // (really the centroids of neighbouring triangles) 1157 coord_index =2*k0;1158 x0 =centroid_coordinates[coord_index];1159 y0 =centroid_coordinates[coord_index+1];1160 1161 coord_index =2*k1;1162 x1 =centroid_coordinates[coord_index];1163 y1 =centroid_coordinates[coord_index+1];1164 1165 coord_index =2*k2;1166 x2 =centroid_coordinates[coord_index];1167 y2 =centroid_coordinates[coord_index+1];1168 coord_index = 2*k0; 1169 x0 = centroid_coordinates[coord_index]; 1170 y0 = centroid_coordinates[coord_index+1]; 1171 1172 coord_index = 2*k1; 1173 x1 = centroid_coordinates[coord_index]; 1174 y1 = centroid_coordinates[coord_index+1]; 1175 1176 coord_index = 2*k2; 1177 x2 = centroid_coordinates[coord_index]; 1178 y2 = centroid_coordinates[coord_index+1]; 1168 1179 1169 1180 // Store x- and y- differentials for the vertices 1170 1181 // of the auxiliary triangle 1171 dx1=x1-x0; dx2=x2-x0; 1172 dy1=y1-y0; dy2=y2-y0; 1182 dx1 = x1 - x0; 1183 dx2 = x2 - x0; 1184 dy1 = y1 - y0; 1185 dy2 = y2 - y0; 1173 1186 1174 1187 // Calculate 2*area of the auxiliary triangle … … 1178 1191 // If the mesh is 'weird' near the boundary, 1179 1192 // the triangle might be flat or clockwise: 1180 if (area2<=0) { 1181 PyErr_SetString(PyExc_RuntimeError, 1182 "shallow_water_ext.c: negative triangle area encountered"); 1183 return -1; 1193 if (area2 <= 0) 1194 { 1195 PyErr_SetString(PyExc_RuntimeError, 1196 "shallow_water_ext.c: negative triangle area encountered"); 1197 1198 return -1; 1184 1199 } 1185 1200 … … 1189 1204 h1 = stage_centroid_values[k1] - elevation_centroid_values[k1]; 1190 1205 h2 = stage_centroid_values[k2] - elevation_centroid_values[k2]; 1191 hmin = min(min(h0, min(h1,h2)),hc);1206 hmin = min(min(h0, min(h1, h2)), hc); 1192 1207 //hfactor = hc/(hc + 1.0); 1193 1208 1194 1209 hfactor = 0.0; 1195 if (hmin > 0.001 ) { 1196 hfactor = (hmin-0.001)/(hmin+0.004); 1197 } 1198 1199 if (optimise_dry_cells) { 1200 // Check if linear reconstruction is necessary for triangle k 1201 // This check will exclude dry cells. 1202 1203 hmax = max(h0,max(h1,h2)); 1204 if (hmax < epsilon) { 1205 continue; 1206 } 1207 } 1208 1209 1210 if (hmin > 0.001) 1211 { 1212 hfactor = (hmin - 0.001)/(hmin + 0.004); 1213 } 1214 1215 if (optimise_dry_cells) 1216 { 1217 // Check if linear reconstruction is necessary for triangle k 1218 // This check will exclude dry cells. 1219 1220 hmax = max(h0, max(h1, h2)); 1221 if (hmax < epsilon) 1222 { 1223 continue; 1224 } 1225 } 1226 1210 1227 //----------------------------------- 1211 1228 // stage … … 1214 1231 // Calculate the difference between vertex 0 of the auxiliary 1215 1232 // triangle and the centroid of triangle k 1216 dq0 =stage_centroid_values[k0]-stage_centroid_values[k];1233 dq0 = stage_centroid_values[k0] - stage_centroid_values[k]; 1217 1234 1218 1235 // Calculate differentials between the vertices 1219 1236 // of the auxiliary triangle (centroids of neighbouring triangles) 1220 dq1=stage_centroid_values[k1]-stage_centroid_values[k0]; 1221 dq2=stage_centroid_values[k2]-stage_centroid_values[k0]; 1222 1237 dq1 = stage_centroid_values[k1] - stage_centroid_values[k0]; 1238 dq2 = stage_centroid_values[k2] - stage_centroid_values[k0]; 1239 1240 inv_area2 = 1.0/area2; 1223 1241 // Calculate the gradient of stage on the auxiliary triangle 1224 1242 a = dy2*dq1 - dy1*dq2; 1225 a /=area2;1243 a *= inv_area2; 1226 1244 b = dx1*dq2 - dx2*dq1; 1227 b /=area2;1245 b *= inv_area2; 1228 1246 1229 1247 // Calculate provisional jumps in stage from the centroid 1230 1248 // of triangle k to its vertices, to be limited 1231 dqv[0] =a*dxv0+b*dyv0;1232 dqv[1] =a*dxv1+b*dyv1;1233 dqv[2] =a*dxv2+b*dyv2;1249 dqv[0] = a*dxv0 + b*dyv0; 1250 dqv[1] = a*dxv1 + b*dyv1; 1251 dqv[2] = a*dxv2 + b*dyv2; 1234 1252 1235 1253 // Now we want to find min and max of the centroid and the 1236 1254 // vertices of the auxiliary triangle and compute jumps 1237 1255 // from the centroid to the min and max 1238 find_qmin_and_qmax(dq0, dq1,dq2,&qmin,&qmax);1256 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1239 1257 1240 1258 // Playing with dry wet interface … … 1249 1267 //printf("beta_tmp = %f\n",beta_tmp); 1250 1268 // Limit the gradient 1251 limit_gradient(dqv,qmin,qmax,beta_tmp); 1252 1253 for (i=0;i<3;i++) 1254 stage_vertex_values[k3+i]=stage_centroid_values[k]+dqv[i]; 1269 limit_gradient(dqv, qmin, qmax, beta_tmp); 1270 1271 //for (i=0;i<3;i++) 1272 stage_vertex_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1273 stage_vertex_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1274 stage_vertex_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1255 1275 1256 1276 … … 1261 1281 // Calculate the difference between vertex 0 of the auxiliary 1262 1282 // triangle and the centroid of triangle k 1263 dq0 =xmom_centroid_values[k0]-xmom_centroid_values[k];1283 dq0 = xmom_centroid_values[k0] - xmom_centroid_values[k]; 1264 1284 1265 1285 // Calculate differentials between the vertices 1266 1286 // of the auxiliary triangle 1267 dq1 =xmom_centroid_values[k1]-xmom_centroid_values[k0];1268 dq2 =xmom_centroid_values[k2]-xmom_centroid_values[k0];1287 dq1 = xmom_centroid_values[k1] - xmom_centroid_values[k0]; 1288 dq2 = xmom_centroid_values[k2] - xmom_centroid_values[k0]; 1269 1289 1270 1290 // Calculate the gradient of xmom on the auxiliary triangle 1271 1291 a = dy2*dq1 - dy1*dq2; 1272 a /=area2;1292 a *= inv_area2; 1273 1293 b = dx1*dq2 - dx2*dq1; 1274 b /=area2;1294 b *= inv_area2; 1275 1295 1276 1296 // Calculate provisional jumps in stage from the centroid 1277 1297 // of triangle k to its vertices, to be limited 1278 dqv[0] =a*dxv0+b*dyv0;1279 dqv[1] =a*dxv1+b*dyv1;1280 dqv[2] =a*dxv2+b*dyv2;1298 dqv[0] = a*dxv0+b*dyv0; 1299 dqv[1] = a*dxv1+b*dyv1; 1300 dqv[2] = a*dxv2+b*dyv2; 1281 1301 1282 1302 // Now we want to find min and max of the centroid and the 1283 1303 // vertices of the auxiliary triangle and compute jumps 1284 1304 // from the centroid to the min and max 1285 find_qmin_and_qmax(dq0, dq1,dq2,&qmin,&qmax);1305 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1286 1306 //beta_tmp = beta_uh; 1287 1307 //if (hmin<minimum_allowed_height) … … 1290 1310 1291 1311 // Limit the gradient 1292 limit_gradient(dqv,qmin,qmax,beta_tmp); 1293 1294 for (i=0;i<3;i++) 1295 xmom_vertex_values[k3+i]=xmom_centroid_values[k]+dqv[i]; 1296 1312 limit_gradient(dqv, qmin, qmax, beta_tmp); 1313 1314 for (i=0; i < 3; i++) 1315 { 1316 xmom_vertex_values[k3+i] = xmom_centroid_values[k] + dqv[i]; 1317 } 1297 1318 1298 1319 //----------------------------------- … … 1302 1323 // Calculate the difference between vertex 0 of the auxiliary 1303 1324 // triangle and the centroid of triangle k 1304 dq0 =ymom_centroid_values[k0]-ymom_centroid_values[k];1325 dq0 = ymom_centroid_values[k0] - ymom_centroid_values[k]; 1305 1326 1306 1327 // Calculate differentials between the vertices 1307 1328 // of the auxiliary triangle 1308 dq1 =ymom_centroid_values[k1]-ymom_centroid_values[k0];1309 dq2 =ymom_centroid_values[k2]-ymom_centroid_values[k0];1329 dq1 = ymom_centroid_values[k1] - ymom_centroid_values[k0]; 1330 dq2 = ymom_centroid_values[k2] - ymom_centroid_values[k0]; 1310 1331 1311 1332 // Calculate the gradient of xmom on the auxiliary triangle 1312 1333 a = dy2*dq1 - dy1*dq2; 1313 a /=area2;1334 a *= inv_area2; 1314 1335 b = dx1*dq2 - dx2*dq1; 1315 b /=area2;1336 b *= inv_area2; 1316 1337 1317 1338 // Calculate provisional jumps in stage from the centroid 1318 1339 // of triangle k to its vertices, to be limited 1319 dqv[0] =a*dxv0+b*dyv0;1320 dqv[1] =a*dxv1+b*dyv1;1321 dqv[2] =a*dxv2+b*dyv2;1340 dqv[0] = a*dxv0 + b*dyv0; 1341 dqv[1] = a*dxv1 + b*dyv1; 1342 dqv[2] = a*dxv2 + b*dyv2; 1322 1343 1323 1344 // Now we want to find min and max of the centroid and the 1324 1345 // vertices of the auxiliary triangle and compute jumps 1325 1346 // from the centroid to the min and max 1326 find_qmin_and_qmax(dq0, dq1,dq2,&qmin,&qmax);1347 find_qmin_and_qmax(dq0, dq1, dq2, &qmin, &qmax); 1327 1348 1328 1349 //beta_tmp = beta_vh; … … 1333 1354 1334 1355 // Limit the gradient 1335 limit_gradient(dqv, qmin,qmax,beta_tmp);1356 limit_gradient(dqv, qmin, qmax, beta_tmp); 1336 1357 1337 1358 for (i=0;i<3;i++) 1338 ymom_vertex_values[k3+i]=ymom_centroid_values[k]+dqv[i]; 1339 1359 { 1360 ymom_vertex_values[k3 + i] = ymom_centroid_values[k] + dqv[i]; 1361 } 1340 1362 } // End number_of_boundaries <=1 1341 else{ 1363 else 1364 { 1342 1365 1343 1366 //============================================== … … 1348 1371 1349 1372 // Find the only internal neighbour (k1?) 1350 for (k2=k3;k2<k3+3;k2++){ 1351 // Find internal neighbour of triangle k 1352 // k2 indexes the edges of triangle k 1353 1354 if (surrogate_neighbours[k2]!=k) 1355 break; 1356 } 1357 1358 if ((k2==k3+3)) { 1359 // If we didn't find an internal neighbour 1360 PyErr_SetString(PyExc_RuntimeError, 1361 "shallow_water_ext.c: Internal neighbour not found"); 1362 return -1; 1363 } 1364 1365 k1=surrogate_neighbours[k2]; 1373 for (k2 = k3; k2 < k3 + 3; k2++) 1374 { 1375 // Find internal neighbour of triangle k 1376 // k2 indexes the edges of triangle k 1377 1378 if (surrogate_neighbours[k2] != k) 1379 { 1380 break; 1381 } 1382 } 1383 1384 if ((k2 == k3 + 3)) 1385 { 1386 // If we didn't find an internal neighbour 1387 PyErr_SetString(PyExc_RuntimeError, 1388 "shallow_water_ext.c: Internal neighbour not found"); 1389 return -1; 1390 } 1391 1392 k1 = surrogate_neighbours[k2]; 1366 1393 1367 1394 // The coordinates of the triangle are already (x,y). 1368 1395 // Get centroid of the neighbour (x1,y1) 1369 coord_index =2*k1;1370 x1 =centroid_coordinates[coord_index];1371 y1 =centroid_coordinates[coord_index+1];1396 coord_index = 2*k1; 1397 x1 = centroid_coordinates[coord_index]; 1398 y1 = centroid_coordinates[coord_index + 1]; 1372 1399 1373 1400 // Compute x- and y- distances between the centroid of 1374 1401 // triangle k and that of its neighbour 1375 dx1=x1-x; dy1=y1-y; 1402 dx1 = x1 - x; 1403 dy1 = y1 - y; 1376 1404 1377 1405 // Set area2 as the square of the distance 1378 area2 =dx1*dx1+dy1*dy1;1406 area2 = dx1*dx1 + dy1*dy1; 1379 1407 1380 1408 // Set dx2=(x1-x0)/((x1-x0)^2+(y1-y0)^2) … … 1382 1410 // respectively correspond to the x- and y- gradients 1383 1411 // of the conserved quantities 1384 dx2 =1.0/area2;1385 dy2 =dx2*dy1;1386 dx2 *=dx1;1412 dx2 = 1.0/area2; 1413 dy2 = dx2*dy1; 1414 dx2 *= dx1; 1387 1415 1388 1416 … … 1392 1420 1393 1421 // Compute differentials 1394 dq1 =stage_centroid_values[k1]-stage_centroid_values[k];1422 dq1 = stage_centroid_values[k1] - stage_centroid_values[k]; 1395 1423 1396 1424 // Calculate the gradient between the centroid of triangle k 1397 1425 // and that of its neighbour 1398 a =dq1*dx2;1399 b =dq1*dy2;1426 a = dq1*dx2; 1427 b = dq1*dy2; 1400 1428 1401 1429 // Calculate provisional vertex 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;1430 dqv[0] = a*dxv0 + b*dyv0; 1431 dqv[1] = a*dxv1 + b*dyv1; 1432 dqv[2] = a*dxv2 + b*dyv2; 1405 1433 1406 1434 // Now limit the jumps 1407 if (dq1>=0.0){ 1408 qmin=0.0; 1409 qmax=dq1; 1410 } 1411 else{ 1412 qmin=dq1; 1413 qmax=0.0; 1435 if (dq1>=0.0) 1436 { 1437 qmin=0.0; 1438 qmax=dq1; 1439 } 1440 else 1441 { 1442 qmin = dq1; 1443 qmax = 0.0; 1414 1444 } 1415 1445 1416 1446 // Limit the gradient 1417 limit_gradient(dqv,qmin,qmax,beta_w); 1418 1419 for (i=0;i<3;i++) 1420 stage_vertex_values[k3+i]=stage_centroid_values[k]+dqv[i]; 1421 1447 limit_gradient(dqv, qmin, qmax, beta_w); 1448 1449 //for (i=0; i < 3; i++) 1450 //{ 1451 stage_vertex_values[k3] = stage_centroid_values[k] + dqv[0]; 1452 stage_vertex_values[k3 + 1] = stage_centroid_values[k] + dqv[1]; 1453 stage_vertex_values[k3 + 2] = stage_centroid_values[k] + dqv[2]; 1454 //} 1422 1455 1423 1456 //----------------------------------- … … 1426 1459 1427 1460 // Compute differentials 1428 dq1 =xmom_centroid_values[k1]-xmom_centroid_values[k];1461 dq1 = xmom_centroid_values[k1] - xmom_centroid_values[k]; 1429 1462 1430 1463 // Calculate the gradient between the centroid of triangle k 1431 1464 // and that of its neighbour 1432 a =dq1*dx2;1433 b =dq1*dy2;1465 a = dq1*dx2; 1466 b = dq1*dy2; 1434 1467 1435 1468 // Calculate provisional vertex jumps, to be limited 1436 dqv[0] =a*dxv0+b*dyv0;1437 dqv[1] =a*dxv1+b*dyv1;1438 dqv[2] =a*dxv2+b*dyv2;1469 dqv[0] = a*dxv0+b*dyv0; 1470 dqv[1] = a*dxv1+b*dyv1; 1471 dqv[2] = a*dxv2+b*dyv2; 1439 1472 1440 1473 // Now limit the jumps 1441 if (dq1>=0.0){ 1442 qmin=0.0; 1443 qmax=dq1; 1444 } 1445 else{ 1446 qmin=dq1; 1447 qmax=0.0; 1474 if (dq1 >= 0.0) 1475 { 1476 qmin = 0.0; 1477 qmax = dq1; 1478 } 1479 else 1480 { 1481 qmin = dq1; 1482 qmax = 0.0; 1448 1483 } 1449 1484 1450 1485 // Limit the gradient 1451 limit_gradient(dqv,qmin,qmax,beta_w); 1452 1453 for (i=0;i<3;i++) 1454 xmom_vertex_values[k3+i]=xmom_centroid_values[k]+dqv[i]; 1455 1486 limit_gradient(dqv, qmin, qmax, beta_w); 1487 1488 //for (i=0;i<3;i++) 1489 //xmom_vertex_values[k3] = xmom_centroid_values[k] + dqv[0]; 1490 //xmom_vertex_values[k3 + 1] = xmom_centroid_values[k] + dqv[1]; 1491 //xmom_vertex_values[k3 + 2] = xmom_centroid_values[k] + dqv[2]; 1492 1493 for (i = 0; i < 3;i++) 1494 { 1495 xmom_vertex_values[k3 + i] = xmom_centroid_values[k] + dqv[i]; 1496 } 1456 1497 1457 1498 //----------------------------------- … … 1460 1501 1461 1502 // Compute differentials 1462 dq1 =ymom_centroid_values[k1]-ymom_centroid_values[k];1503 dq1 = ymom_centroid_values[k1] - ymom_centroid_values[k]; 1463 1504 1464 1505 // Calculate the gradient between the centroid of triangle k 1465 1506 // and that of its neighbour 1466 a =dq1*dx2;1467 b =dq1*dy2;1507 a = dq1*dx2; 1508 b = dq1*dy2; 1468 1509 1469 1510 // Calculate provisional vertex jumps, to be limited 1470 dqv[0] =a*dxv0+b*dyv0;1471 dqv[1] =a*dxv1+b*dyv1;1472 dqv[2] =a*dxv2+b*dyv2;1511 dqv[0] = a*dxv0 + b*dyv0; 1512 dqv[1] = a*dxv1 + b*dyv1; 1513 dqv[2] = a*dxv2 + b*dyv2; 1473 1514 1474 1515 // Now limit the jumps 1475 if (dq1>=0.0){ 1476 qmin=0.0; 1477 qmax=dq1; 1478 } 1479 else{ 1480 qmin=dq1; 1481 qmax=0.0; 1516 if (dq1>=0.0) 1517 { 1518 qmin = 0.0; 1519 qmax = dq1; 1520 } 1521 else 1522 { 1523 qmin = dq1; 1524 qmax = 0.0; 1482 1525 } 1483 1526 1484 1527 // Limit the gradient 1485 limit_gradient(dqv,qmin,qmax,beta_w); 1486 1487 for (i=0;i<3;i++) 1488 ymom_vertex_values[k3+i]=ymom_centroid_values[k]+dqv[i]; 1489 1528 limit_gradient(dqv, qmin, qmax, beta_w); 1529 1530 //for (i=0;i<3;i++) 1531 //ymom_vertex_values[k3] = ymom_centroid_values[k] + dqv[0]; 1532 //ymom_vertex_values[k3 + 1] = ymom_centroid_values[k] + dqv[1]; 1533 //ymom_vertex_values[k3 + 2] = ymom_centroid_values[k] + dqv[2]; 1534 1535 for (i=0;i<3;i++) 1536 { 1537 ymom_vertex_values[k3 + i] = ymom_centroid_values[k] + dqv[i]; 1538 } 1539 //ymom_vertex_values[k3] = ymom_centroid_values[k] + dqv[0]; 1540 //ymom_vertex_values[k3 + 1] = ymom_centroid_values[k] + dqv[1]; 1541 //ymom_vertex_values[k3 + 2] = ymom_centroid_values[k] + dqv[2]; 1490 1542 } // else [number_of_boundaries==2] 1491 1543 } // for k=0 to number_of_elements-1
Note: See TracChangeset
for help on using the changeset viewer.