1023{
1024 DM da = user->
da, fda = user->
fda;
1025 DMDALocalInfo info = user->
info;
1026 PetscInt xs = info.xs, xe = info.xs + info.xm;
1027 PetscInt ys = info.ys, ye = info.ys + info.ym;
1028 PetscInt zs = info.zs, ze = info.zs + info.zm;
1029 PetscInt mx = info.mx, my = info.my, mz = info.mz;
1030 PetscInt lxs, lxe, lys, lye, lzs, lze;
1031 PetscInt i, j, k;
1032
1033 PetscReal ***nvert,***lnvert;
1034
1035 PetscReal ***p,***lp;
1036 Cmpnts ***ucont, ***ubcs, ***ucat,***lucat, ***csi, ***eta, ***zet;
1037 Cmpnts ***cent,***centx,***centy,***centz,***coor;
1038 PetscScalar FluxIn, FluxOut,ratio;
1039 PetscScalar lArea, AreaSum;
1040
1041 PetscScalar FarFluxIn=0., FarFluxOut=0., FarFluxInSum, FarFluxOutSum;
1042 PetscScalar FarAreaIn=0., FarAreaOut=0., FarAreaInSum, FarAreaOutSum;
1043 PetscScalar FluxDiff, VelDiffIn, VelDiffOut;
1045
1046 PetscReal Un, nx,ny,nz,A;
1047
1049
1050 lxs = xs; lxe = xe;
1051 lys = ys; lye = ye;
1052 lzs = zs; lze = ze;
1053
1054 PetscInt gxs, gxe, gys, gye, gzs, gze;
1055
1056 gxs = info.gxs; gxe = gxs + info.gxm;
1057 gys = info.gys; gye = gys + info.gym;
1058 gzs = info.gzs; gze = gzs + info.gzm;
1059
1060 if (xs==0) lxs = xs+1;
1061 if (ys==0) lys = ys+1;
1062 if (zs==0) lzs = zs+1;
1063
1064 if (xe==mx ) lxe = xe-1;
1065 if (ye==my ) lye = ye-1;
1066 if (ze==mz ) lze = ze-1;
1067
1068 PetscFunctionBeginUser;
1069
1071
1072 DMDAVecGetArray(fda, user->
Bcs.
Ubcs, &ubcs);
1073
1074 DMDAVecGetArray(fda, user->
lCsi, &csi);
1075 DMDAVecGetArray(fda, user->
lEta, &eta);
1076 DMDAVecGetArray(fda, user->
lZet, &zet);
1077
1078 PetscInt ttemp;
1079 for (ttemp=0; ttemp<3; ttemp++) {
1080 DMDAVecGetArray(da, user->
Nvert, &nvert);
1081 DMDAVecGetArray(fda, user->
lUcat, &ucat);
1082 DMDAVecGetArray(fda, user->
Ucont, &ucont);
1083
1084
1085
1086
1087
1088
1089 FarFluxIn = 0.; FarFluxOut=0.;
1090 FarAreaIn = 0.; FarAreaOut=0.;
1091
1092 PetscReal lFlux_abs=0.0,FluxSum_abs=0.0,ratio=0.0;
1093
1097
1098
1099
1100 if (user->
bctype[0]==6) {
1101 if (xs == 0) {
1102 i= xs;
1103 for (k=lzs; k<lze; k++) {
1104 for (j=lys; j<lye; j++) {
1105 ubcs[k][j][i].
x = ucat[k][j][i+1].
x;
1106 ubcs[k][j][i].
y = ucat[k][j][i+1].
y;
1107 ubcs[k][j][i].
z = ucat[k][j][i+1].
z;
1108 ucont[k][j][i].
x = ubcs[k][j][i].
x * csi[k][j][i].
x;
1109 FarFluxIn += ucont[k][j][i].
x;
1110 lFlux_abs += fabs(ucont[k][j][i].x);
1111 FarAreaIn += csi[k][j][i].
x;
1112 }
1113 }
1114 }
1115 }
1116
1117 if (user->
bctype[1]==6) {
1118 if (xe==mx) {
1119 i= xe-1;
1120 for (k=lzs; k<lze; k++) {
1121 for (j=lys; j<lye; j++) {
1122 ubcs[k][j][i].
x = ucat[k][j][i-1].
x;
1123 ubcs[k][j][i].
y = ucat[k][j][i-1].
y;
1124 ubcs[k][j][i].
z = ucat[k][j][i-1].
z;
1125 ucont[k][j][i-1].
x = ubcs[k][j][i].
x * csi[k][j][i-1].
x;
1126 FarFluxOut += ucont[k][j][i-1].
x;
1127 lFlux_abs += fabs(ucont[k][j][i-1].x);
1128 FarAreaOut += csi[k][j][i-1].
x;
1129 }
1130 }
1131 }
1132 }
1133
1134 if (user->
bctype[2]==6) {
1135 if (ys==0) {
1136 j= ys;
1137 for (k=lzs; k<lze; k++) {
1138 for (i=lxs; i<lxe; i++) {
1139 ubcs[k][j][i].
x = ucat[k][j+1][i].
x;
1140 ubcs[k][j][i].
y = ucat[k][j+1][i].
y;
1141 ubcs[k][j][i].
z = ucat[k][j+1][i].
z;
1142 ucont[k][j][i].
y = ubcs[k][j][i].
y * eta[k][j][i].
y;
1143 FarFluxIn += ucont[k][j][i].
y;
1144 lFlux_abs += fabs(ucont[k][j][i].y);
1145 FarAreaIn += eta[k][j][i].
y;
1146 }
1147 }
1148 }
1149 }
1150
1151 if (user->
bctype[3]==6) {
1152 if (ye==my) {
1153 j=ye-1;
1154 for (k=lzs; k<lze; k++) {
1155 for (i=lxs; i<lxe; i++) {
1156 ubcs[k][j][i].
x = ucat[k][j-1][i].
x;
1157 ubcs[k][j][i].
y = ucat[k][j-1][i].
y;
1158 ubcs[k][j][i].
z = ucat[k][j-1][i].
z;
1159 ucont[k][j-1][i].
y = ubcs[k][j][i].
y * eta[k][j-1][i].
y;
1160 FarFluxOut += ucont[k][j-1][i].
y;
1161 lFlux_abs += fabs(ucont[k][j-1][i].y);
1162 FarAreaOut += eta[k][j-1][i].
y;
1163 }
1164 }
1165 }
1166 }
1167
1169 if (zs==0) {
1170 k = 0;
1171 for (j=lys; j<lye; j++) {
1172 for (i=lxs; i<lxe; i++) {
1173 ubcs[k][j][i].
x = ucat[k+1][j][i].
x;
1174 ubcs[k][j][i].
y = ucat[k+1][j][i].
y;
1175 ubcs[k][j][i].
z = ucat[k+1][j][i].
z;
1176 ucont[k][j][i].
z = ubcs[k][j][i].
z * zet[k][j][i].
z;
1177 FarFluxIn += ucont[k][j][i].
z;
1178 lFlux_abs += fabs(ucont[k][j][i].z);
1179 FarAreaIn += zet[k][j][i].
z;
1180 }
1181 }
1182 }
1183 }
1184
1186 if (ze==mz) {
1187 k = ze-1;
1188 for (j=lys; j<lye; j++) {
1189 for (i=lxs; i<lxe; i++) {
1190 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1191 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1192 ubcs[k][j][i].
z = ucat[k-1][j][i].
z;
1193 ucont[k-1][j][i].
z = ubcs[k][j][i].
z * zet[k-1][j][i].
z;
1194 FarFluxOut += ucont[k-1][j][i].
z;
1195 lFlux_abs += fabs(ucont[k-1][j][i].z);
1196 FarAreaOut += zet[k-1][j][i].
z;
1197 }
1198 }
1199 }
1200 }
1201
1202 MPI_Allreduce(&FarFluxIn,&FarFluxInSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1203 MPI_Allreduce(&FarFluxOut,&FarFluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1204 MPI_Allreduce(&lFlux_abs,&FluxSum_abs,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1205 MPI_Allreduce(&FarAreaIn,&FarAreaInSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1206 MPI_Allreduce(&FarAreaOut,&FarAreaOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1207
1209
1210 ratio=(FarFluxInSum - FarFluxOutSum)/FluxSum_abs;
1211 if (fabs(FluxSum_abs) <1.e-10) ratio = 0.;
1212
1214
1215 FluxDiff = 0.5*(FarFluxInSum - FarFluxOutSum) ;
1216 VelDiffIn = FluxDiff / FarAreaInSum ;
1217
1218 if (fabs(FarAreaInSum) <1.e-6) VelDiffIn = 0.;
1219
1220 VelDiffOut = FluxDiff / FarAreaOutSum ;
1221
1222 if (fabs(FarAreaOutSum) <1.e-6) VelDiffOut = 0.;
1223
1224 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"Far Flux Diff %d %le %le %le %le %le %le %le\n", simCtx->
step, FarFluxInSum, FarFluxOutSum, FluxDiff, FarAreaInSum, FarAreaOutSum, VelDiffIn, VelDiffOut);
1225
1226 }
1227
1228 if (user->
bctype[5]==10) {
1229 FluxDiff = simCtx->
FluxInSum -( FarFluxOutSum -FarFluxInSum) ;
1230 VelDiffIn = 1/3.*FluxDiff / (FarAreaInSum);
1231 if (fabs(FarAreaInSum) <1.e-6) VelDiffIn = 0.;
1232
1233 VelDiffOut = 2./3.* FluxDiff / (FarAreaOutSum) ;
1234
1235 if (fabs(FarAreaOutSum) <1.e-6) VelDiffOut = 0.;
1236
1237 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"Far Flux Diff %d %le %le %le %le %le %le %le\n", simCtx->
step, FarFluxInSum, FarFluxOutSum, FluxDiff, FarAreaInSum, FarAreaOutSum, VelDiffIn, VelDiffOut);
1238
1239 }
1240
1241
1242
1243
1245 if (ze==mz) {
1246 k = ze-1;
1247 for (j=lys; j<lye; j++) {
1248 for (i=lxs; i<lxe; i++) {
1249 ucont[k-1][j][i].
z += ratio*fabs(ucont[k-1][j][i].z);
1250 ubcs[k][j][i].
z = ucont[k-1][j][i].
z/zet[k-1][j][i].
z;
1251
1252
1253 }
1254 }
1255 }
1256 }
1257
1258 if (user->
bctype[3]==6) {
1259 if (ye==my) {
1260 j=ye-1;
1261 for (k=lzs; k<lze; k++) {
1262 for (i=lxs; i<lxe; i++) {
1263
1264 ucont[k][j-1][i].
y +=ratio*fabs(ucont[k][j-1][i].y);
1265 ubcs[k][j][i].
y = ucont[k][j-1][i].
y /eta[k][j-1][i].
y;
1266
1267
1268
1269 }
1270 }
1271 }
1272 }
1273
1274 if (user->
bctype[1]==6) {
1275 if (xe==mx) {
1276 i= xe-1;
1277 for (k=lzs; k<lze; k++) {
1278 for (j=lys; j<lye; j++) {
1279 ucont[k][j][i-1].
x +=ratio*fabs(ucont[k][j][i-1].x);
1280 ubcs[k][j][i].
x = ucont[k][j][i-1].
x / csi[k][j][i-1].
x ;
1281
1282
1283 }
1284 }
1285 }
1286 }
1287
1288
1289 if (user->
bctype[0]==6) {
1290 if (xs == 0) {
1291 i= xs;
1292 for (k=lzs; k<lze; k++) {
1293 for (j=lys; j<lye; j++) {
1294 ucont[k][j][i].
x -=ratio*fabs(ucont[k][j][i].x);
1295 ubcs[k][j][i].
x = ucont[k][j][i].
x / csi[k][j][i].
x;
1296
1297
1298 }
1299 }
1300 }
1301 }
1302
1303
1304 if (user->
bctype[2]==6) {
1305 if (ys==0) {
1306 j= ys;
1307 for (k=lzs; k<lze; k++) {
1308 for (i=lxs; i<lxe; i++) {
1309 ucont[k][j][i].
y -=ratio*fabs(ucont[k][j][i].y);
1310 ubcs[k][j][i].
y = ucont[k][j][i].
y / eta[k][j][i].
y;
1311
1312
1313 }
1314 }
1315 }
1316 }
1317
1318
1320 if (zs==0) {
1321 k = 0;
1322 for (j=lys; j<lye; j++) {
1323 for (i=lxs; i<lxe; i++) {
1324 ucont[k][j][i].
z -=ratio*fabs(ucont[k][j][i].z);
1325 ubcs[k][j][i].
z =ucont[k][j][i].
z / zet[k][j][i].
z;
1326
1327
1328
1329 }
1330 }
1331 }
1332 }
1333
1334
1335
1337 if (ys==0) {
1338 j= ys;
1339 for (k=lzs; k<lze; k++) {
1340 for (i=lxs; i<lxe; i++) {
1341 A=sqrt(eta[k][j][i].z*eta[k][j][i].z +
1342 eta[k][j][i].y*eta[k][j][i].y +
1343 eta[k][j][i].x*eta[k][j][i].x);
1344 nx=eta[k][j][i].
x/A;
1345 ny=eta[k][j][i].
y/A;
1346 nz=eta[k][j][i].
z/A;
1347 Un=ucat[k][j+1][i].
x*nx+ucat[k][j+1][i].
y*ny+ucat[k][j+1][i].
z*nz;
1348 ubcs[k][j][i].
x = 0.0;
1349 ubcs[k][j][i].
y = 0.0;
1350 ubcs[k][j][i].
z = 0.0;
1351 ucont[k][j][i].
y = 0.;
1352 }
1353 }
1354 }
1355 }
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1367 if (xs==0) {
1368 i= xs;
1369 for (k=lzs; k<lze; k++) {
1370 for (j=lys; j<lye; j++) {
1371 ubcs[k][j][i].
x = 0.0;
1372 ubcs[k][j][i].
y = 0.0;
1373 ubcs[k][j][i].
z = 0.0;
1374 ucont[k][j][i].
x = 0.0;
1375 }
1376 }
1377 }
1378}
1379
1380
1382 if (xe==mx) {
1383 i= xe-1;
1384 for (k=lzs; k<lze; k++) {
1385 for (j=lys; j<lye; j++) {
1386 ubcs[k][j][i].
x = 0.0;
1387 ubcs[k][j][i].
y = 0.0;
1388 ubcs[k][j][i].
z = 0.0;
1389
1390 ucont[k][j][i-1].
x = 0.0;
1391 }
1392 }
1393 }
1394}
1395
1396
1398 if (ys==0) {
1399 j= ys;
1400 for (k=lzs; k<lze; k++) {
1401 for (i=lxs; i<lxe; i++) {
1402 ubcs[k][j][i].
x = 0.0;
1403 ubcs[k][j][i].
y = 0.0;
1404 ubcs[k][j][i].
z = 0.0;
1405 ucont[k][j][i].
y = 0.0;
1406 }
1407 }
1408 }
1409}
1410
1411
1413 if (ye==my) {
1414 j= ye-1;
1415 for (k=lzs; k<lze; k++) {
1416 for (i=lxs; i<lxe; i++) {
1417 ubcs[k][j][i].
x = 0.0;
1418 ubcs[k][j][i].
y = 0.0;
1419 ubcs[k][j][i].
z = 0.0;
1420
1421 ucont[k][j-1][i].
y = 0.0;
1422 }
1423 }
1424 }
1425}
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436 if (user->
bctype[0]==3) {
1437 if (xs==0) {
1438 i= xs;
1439
1440 for (k=lzs; k<lze; k++) {
1441 for (j=lys; j<lye; j++) {
1442 A=sqrt(csi[k][j][i].z*csi[k][j][i].z +
1443 csi[k][j][i].y*csi[k][j][i].y +
1444 csi[k][j][i].x*csi[k][j][i].x);
1445 nx=csi[k][j][i].
x/A;
1446 ny=csi[k][j][i].
y/A;
1447 nz=csi[k][j][i].
z/A;
1448 Un=ucat[k][j][i+1].
x*nx+ucat[k][j][i+1].
y*ny+ucat[k][j][i+1].
z*nz;
1449 ubcs[k][j][i].
x = ucat[k][j][i+1].
x-Un*nx;
1450 ubcs[k][j][i].
y = ucat[k][j][i+1].
y-Un*ny;
1451 ubcs[k][j][i].
z = ucat[k][j][i+1].
z-Un*nz;
1452 ucont[k][j][i].
x = 0.;
1453 }
1454 }
1455 }
1456 }
1457
1458 if (user->
bctype[1]==3) {
1459 if (xe==mx) {
1460 i= xe-1;
1461
1462 for (k=lzs; k<lze; k++) {
1463 for (j=lys; j<lye; j++) {
1464 A=sqrt(csi[k][j][i-1].z*csi[k][j][i-1].z +
1465 csi[k][j][i-1].y*csi[k][j][i-1].y +
1466 csi[k][j][i-1].x*csi[k][j][i-1].x);
1467 nx=csi[k][j][i-1].
x/A;
1468 ny=csi[k][j][i-1].
y/A;
1469 nz=csi[k][j][i-1].
z/A;
1470 Un=ucat[k][j][i-1].
x*nx+ucat[k][j][i-1].
y*ny+ucat[k][j][i-1].
z*nz;
1471 ubcs[k][j][i].
x = ucat[k][j][i-1].
x-Un*nx;
1472 ubcs[k][j][i].
y = ucat[k][j][i-1].
y-Un*ny;
1473 ubcs[k][j][i].
z = ucat[k][j][i-1].
z-Un*nz;
1474 ucont[k][j][i-1].
x = 0.;
1475 }
1476 }
1477 }
1478 }
1479
1480 if (user->
bctype[2]==3) {
1481 if (ys==0) {
1482 j= ys;
1483
1484 for (k=lzs; k<lze; k++) {
1485 for (i=lxs; i<lxe; i++) {
1486 A=sqrt(eta[k][j][i].z*eta[k][j][i].z +
1487 eta[k][j][i].y*eta[k][j][i].y +
1488 eta[k][j][i].x*eta[k][j][i].x);
1489 nx=eta[k][j][i].
x/A;
1490 ny=eta[k][j][i].
y/A;
1491 nz=eta[k][j][i].
z/A;
1492 Un=ucat[k][j+1][i].
x*nx+ucat[k][j+1][i].
y*ny+ucat[k][j+1][i].
z*nz;
1493 ubcs[k][j][i].
x = ucat[k][j+1][i].
x-Un*nx;
1494 ubcs[k][j][i].
y = ucat[k][j+1][i].
y-Un*ny;
1495 ubcs[k][j][i].
z = ucat[k][j+1][i].
z-Un*nz;
1496 ucont[k][j][i].
y = 0.;
1497 }
1498 }
1499 }
1500 }
1501
1502 if (user->
bctype[3]==3) {
1503 if (ye==my) {
1504 j=ye-1;
1505
1506 for (k=lzs; k<lze; k++) {
1507 for (i=lxs; i<lxe; i++) {
1508 A=sqrt(eta[k][j-1][i].z*eta[k][j-1][i].z +
1509 eta[k][j-1][i].y*eta[k][j-1][i].y +
1510 eta[k][j-1][i].x*eta[k][j-1][i].x);
1511 nx=eta[k][j-1][i].
x/A;
1512 ny=eta[k][j-1][i].
y/A;
1513 nz=eta[k][j-1][i].
z/A;
1514 Un=ucat[k][j-1][i].
x*nx+ucat[k][j-1][i].
y*ny+ucat[k][j-1][i].
z*nz;
1515 ubcs[k][j][i].
x = ucat[k][j-1][i].
x-Un*nx;
1516 ubcs[k][j][i].
y = ucat[k][j-1][i].
y-Un*ny;
1517 ubcs[k][j][i].
z = ucat[k][j-1][i].
z-Un*nz;
1518 ucont[k][j-1][i].
y = 0.;
1519 }
1520 }
1521 }
1522 }
1523
1524
1525 if (user->
bctype[4]==3) {
1526 if (zs==0) {
1527 k = 0;
1528 for (j=lys; j<lye; j++) {
1529 for (i=lxs; i<lxe; i++) {
1530 A=sqrt(zet[k][j][i].z*zet[k][j][i].z +
1531 zet[k][j][i].y*zet[k][j][i].y +
1532 zet[k][j][i].x*zet[k][j][i].x);
1533 nx=zet[k][j][i].
x/A;
1534 ny=zet[k][j][i].
y/A;
1535 nz=zet[k][j][i].
z/A;
1536 Un=ucat[k+1][j][i].
x*nx+ucat[k+1][j][i].
y*ny+ucat[k+1][j][i].
z*nz;
1537 ubcs[k][j][i].
x = ucat[k+1][j][i].
x-Un*nx;
1538 ubcs[k][j][i].
y = ucat[k+1][j][i].
y-Un*ny;
1539 ubcs[k][j][i].
z = ucat[k+1][j][i].
z-Un*nz;
1540 ucont[k][j][i].
z = 0.;
1541 }
1542 }
1543 }
1544 }
1545
1546 if (user->
bctype[5]==3) {
1547 if (ze==mz) {
1548 k = ze-1;
1549 for (j=lys; j<lye; j++) {
1550 for (i=lxs; i<lxe; i++) {
1551 A=sqrt(zet[k-1][j][i].z*zet[k-1][j][i].z +
1552 zet[k-1][j][i].y*zet[k-1][j][i].y +
1553 zet[k-1][j][i].x*zet[k-1][j][i].x);
1554 nx=zet[k-1][j][i].
x/A;
1555 ny=zet[k-1][j][i].
y/A;
1556 nz=zet[k-1][j][i].
z/A;
1557 Un=ucat[k-1][j][i].
x*nx+ucat[k-1][j][i].
y*ny+ucat[k-1][j][i].
z*nz;
1558 ubcs[k][j][i].
x = ucat[k-1][j][i].
x-Un*nx;
1559 ubcs[k][j][i].
y = ucat[k-1][j][i].
y-Un*ny;
1560 ubcs[k][j][i].
z = ucat[k-1][j][i].
z-Un*nz;
1561 ucont[k-1][j][i].
z = 0.;
1562 }
1563 }
1564 }
1565 }
1566
1567
1568
1569
1570
1571 if (user->
bctype[5]==8) {
1572 if (ze == mz) {
1573 k = ze-2;
1574 FluxOut = 0;
1575 for (j=lys; j<lye; j++) {
1576 for (i=lxs; i<lxe; i++) {
1577 FluxOut += ucont[k][j][i].
z;
1578 }
1579 }
1580 }
1581 else {
1582 FluxOut = 0.;
1583 }
1584
1585 FluxIn = simCtx->
FluxInSum + FarFluxInSum;
1586
1587 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1588
1589
1590
1592 if (fabs(simCtx->
FluxOutSum) < 1.e-6) ratio = 1.;
1593
1594 if (fabs(FluxIn) <1.e-6) ratio = 0.;
1596
1597 if (ze==mz) {
1598 k = ze-1;
1599 for (j=lys; j<lye; j++) {
1600 for (i=lxs; i<lxe; i++) {
1601 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1602 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1603 if (simCtx->
step==0 || simCtx->
step==1)
1605 ubcs[k][j][i].
z = -1.;
1606 else if (user->
bctype[4]==6)
1607 ubcs[k][j][i].
z = 0.;
1608 else
1609 ubcs[k][j][i].
z = 1.;
1610
1611 else
1612 ucont[k-1][j][i].
z = ucont[k-1][j][i].
z*ratio;
1613
1614 ubcs[k][j][i].
z = ucont[k-1][j][i].
z / zet[k-1][j][i].
z;
1615 }
1616 }
1617 }
1618 }
1619
1620
1621
1622
1623
1624
1625
1627 lArea=0.;
1630 if (ze == mz) {
1631
1632 k=ze-1;
1633 FluxOut = 0;
1634 for (j=lys; j<lye; j++) {
1635 for (i=lxs; i<lxe; i++) {
1636
1637 if ((nvert[k-1][j][i])<0.1) {
1638 FluxOut += (ucat[k-1][j][i].
x * (zet[k-1][j][i].
x) +
1639 ucat[k-1][j][i].y * (zet[k-1][j][i].y) +
1640 ucat[k-1][j][i].
z * (zet[k-1][j][i].
z));
1641
1642 lArea += sqrt( (zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1643 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1644 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1645
1646 }
1647 }
1648 }
1649 }
1650 else {
1651 FluxOut = 0.;
1652 }
1653
1654 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1655 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1656
1658
1660
1663
1664 }
1665
1669 else
1670 ratio = (FluxIn - simCtx->
FluxOutSum) / AreaSum;
1671
1673
1674
1676 FluxOut=0.0;
1677 if (ze==mz) {
1678 k = ze-1;
1679 for (j=lys; j<lye; j++) {
1680 for (i=lxs; i<lxe; i++) {
1681 if ((nvert[k-1][j][i])<0.1) {
1682
1683 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1684 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1685 ubcs[k][j][i].
z = ucat[k-1][j][i].
z;
1686
1687
1689 ucont[k-1][j][i].
z = (ubcs[k][j][i].
x * (zet[k-1][j][i].
x ) +
1690 ubcs[k][j][i].y * (zet[k-1][j][i].y ) +
1691 ubcs[k][j][i].
z * (zet[k-1][j][i].
z ))*ratio;
1692
1693 else{
1694 ucont[k-1][j][i].
z = (ubcs[k][j][i].
x * (zet[k-1][j][i].
x ) +
1695 ubcs[k][j][i].y * (zet[k-1][j][i].y ) +
1696 ubcs[k][j][i].
z * (zet[k-1][j][i].
z ))
1697 + ratio * sqrt( (zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1698 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1699 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1700
1701 FluxOut += ucont[k-1][j][i].
z;
1702 }
1703 }
1704 }
1705 }
1706 }
1707
1708 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1710
1711 }
else if (user->
bctype[5]==2) {
1712
1713
1714 if (ze==mz) {
1715 k = ze-1;
1716 for (j=lys; j<lye; j++) {
1717 for (i=lxs; i<lxe; i++) {
1718 ubcs[k][j][i].
x = 0.;
1719 ubcs[k][j][i].
y = 1;
1720 ubcs[k][j][i].
z = 0.;
1721 }
1722 }
1723 }
1724 }
1725
1726
1727
1729 lArea=0.;
1730 if (zs == 0) {
1731 k = zs;
1732
1733 FluxOut = 0;
1734 for (j=lys; j<lye; j++) {
1735 for (i=lxs; i<lxe; i++) {
1736
1737
1738 FluxOut += ucat[k+1][j][i].
z * zet[k][j][i].
z ;
1739
1740 lArea += zet[k][j][i].
z;
1741
1742
1743
1744 }
1745 }
1746 }
1747 else {
1748 FluxOut = 0.;
1749 }
1750
1751 FluxIn = simCtx->
FluxInSum + FarFluxInSum;
1752
1753 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1754 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1755
1756
1759
1760 if (zs==0) {
1761 k = 0;
1762 for (j=lys; j<lye; j++) {
1763 for (i=lxs; i<lxe; i++) {
1764 ubcs[k][j][i].
x = ucat[k+1][j][i].
x;
1765 ubcs[k][j][i].
y = ucat[k+1][j][i].
y;
1766 ubcs[k][j][i].
z = ucat[k+1][j][i].
z;
1767 ucont[k][j][i].
z = (ubcs[k][j][i].
z+ratio) * zet[k][j][i].z;
1768 }
1769 }
1770 }
1771 }
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1849 Vec Coor; DMGetCoordinatesLocal(da, &Coor);
1850 DMDAVecGetArray(fda,Coor,&coor);
1852 DMDAVecGetArray(fda, user->
Bcs.
Uch, &uch);
1853
1854 lArea=0.0;
1855
1856
1857 FluxIn=0.0;
1858
1859 double Fluxbcs=0.0, Fluxbcssum,ratiobcs;
1860
1861 if (zs==0) {
1862 k=0;
1863 Fluxbcs=0.0;
1864 for (j=lys; j<lye; j++) {
1865 for (i=lxs; i<lxe; i++) {
1866 if (nvert[k][j][i]<0.1){
1867 Fluxbcs += ucont[k][j][i].
z;
1868
1869 lArea += sqrt((zet[k][j][i].x) * (zet[k][j][i].x) +
1870 (zet[k][j][i].y) * (zet[k][j][i].y) +
1871 (zet[k][j][i].z) * (zet[k][j][i].z));
1872 }
1873 }
1874 }
1875 }
1876
1877
1878
1879
1880 for (k=zs;k<lze;k++){
1881 for (j=lys; j<lye; j++) {
1882 for (i=lxs; i<lxe; i++) {
1883 if (nvert[k][j][i]<0.1){
1884 FluxIn += ucont[k][j][i].
z /((mz)-1);
1885 }
1886 }
1887 }
1888 }
1889
1890
1891
1892
1893 MPI_Allreduce(&FluxIn,&simCtx->
Fluxsum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1894 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1895 MPI_Allreduce(&Fluxbcs,&Fluxbcssum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1896
1900
1902 }
1903
1906 simCtx->
ratio=ratio;
1907 ratiobcs=(simCtx->
FluxInSum-Fluxbcssum)/AreaSum;
1908
1909 if (zs==0) {
1910 k=0;
1911 for (j=lys; j<lye; j++) {
1912 for (i=lxs; i<lxe; i++) {
1913 if (nvert[k+1][j][i]<0.1){
1915 ucont[k][j][i].
z+=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
1916 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
1917 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
1918 }
1919
1920 uch[k][j][i].
z=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
1921 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
1922 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
1923 }
1924 }
1925 }
1926 }
1927
1928 if (ze==mz) {
1929 k=mz-1;
1930 for (j=lys; j<lye; j++) {
1931 for (i=lxs; i<lxe; i++) {
1932 if (nvert[k-1][j][i]<0.1){
1934 ucont[k-1][j][i].
z+=ratiobcs * sqrt((zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1935 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1936 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1937 }
1938 uch[k][j][i].
z=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
1939 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
1940 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
1941 }
1942 }
1943 }
1944 }
1945 DMDAVecRestoreArray(fda, user->
Bcs.
Uch, &uch);
1947 DMDAVecRestoreArray(fda,Coor,&coor);
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979 }
1980
1981
1982
1983
1984
1985
1986 if (user->
bctype[3]==12) {
1987
1988
1989 if (ye==my) {
1990 j = ye-1;
1991 for (k=lzs; k<lze; k++) {
1992 for (i=lxs; i<lxe; i++) {
1993 ubcs[k][j][i].
x = 0.;
1994 ubcs[k][j][i].
y = 0.;
1995 ubcs[k][j][i].
z = 1.;
1996 }
1997 }
1998 }
1999 }
2000
2001
2002
2003
2004 DMDAVecGetArray(fda, user->
Cent, ¢);
2005 if (user->
bctype[2]==11) {
2006 if (ys==0){
2007 j=0;
2008 for (k=lzs; k<lze; k++) {
2009 for (i=lxs; i<lxe; i++) {
2010
2011
2012
2013
2014
2015
2016 ubcs[k][j][i].
x = cent[k][j+1][i].
y/sqrt(cent[k][j+1][i].x*cent[k][j+1][i].x+cent[k][j+1][i].y*cent[k][j+1][i].y);;
2017 ubcs[k][j][i].
y =-cent[k][j+1][i].
x/sqrt(cent[k][j+1][i].x*cent[k][j+1][i].x+cent[k][j+1][i].y*cent[k][j+1][i].y);
2018 ubcs[k][j][i].
z =0.0;
2019
2020 }
2021 }
2022 }
2023 }
2024
2025
2026
2027
2030 }
2031
2032 if (user->
bctype[2]==13){
2033 if (ys==0){
2034 j=0;
2035 for (k=lzs; k<lze; k++) {
2036 for (i=lxs; i<lxe; i++) {
2037 ubcs[k][j][i].
x = 0.;
2038
2039 ubcs[k][j][i].
y = 0.;
2040 ubcs[k][j][i].
z = -simCtx->
U_bc;
2041
2042 }
2043 }
2044 }
2045 }
2046 if (user->
bctype[3]==13){
2047 if (ye==my){
2048 j=ye-1;
2049 for (k=lzs; k<lze; k++) {
2050 for (i=lxs; i<lxe; i++) {
2051 ubcs[k][j][i].
x = 0.;
2052
2053 ubcs[k][j][i].
y = 0.;
2054 ubcs[k][j][i].
z = simCtx->
U_bc;
2055
2056 }
2057 }
2058 }
2059 }
2060
2061 if (user->
bctype[4]==13){
2062 if (zs==0){
2063 k=0;
2064 for (j=lys; j<lye; j++) {
2065 for (i=lxs; i<lxe; i++) {
2066 ubcs[k][j][i].
x =-simCtx->
U_bc;
2067 ubcs[k][j][i].
y = 0.;
2068 ubcs[k][j][i].
z = 0.;
2069 }
2070 }
2071 }
2072 }
2073 if (user->
bctype[5]==13){
2074 if (ze==mz){
2075 k=ze-1;
2076 for (j=lys; j<lye; j++) {
2077 for (i=lxs; i<lxe; i++) {
2078 ubcs[k][j][i].
x = simCtx->
U_bc;
2079 ubcs[k][j][i].
y = 0.;
2080 ubcs[k][j][i].
z = 0.;
2081 }
2082 }
2083 }
2084 }
2085 DMDAVecRestoreArray(fda, user->
Cent, ¢);
2086 DMDAVecRestoreArray(fda, user->
lUcat, &ucat);
2087 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2088 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2089 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2090 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2091
2092
2093
2095
2096
2097
2098
2099
2101 PetscReal ***ustar, ***aj;
2102
2104 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2105 DMDAVecGetArray(fda, user->
Ucont, &ucont);
2106 DMDAVecGetArray(da, Aj, &aj);
2107
2108 DMDAVecGetArray(da, user->
lUstar, &ustar);
2109
2110
2111 for (k=lzs; k<lze; k++)
2112 for (j=lys; j<lye; j++)
2113 for (i=lxs; i<lxe; i++) {
2114
2115 if( nvert[k][j][i]<1.1 && user->
bctype[2]==-1 && j==1 )
2116 {
2117 double area = sqrt( eta[k][j][i].x*eta[k][j][i].x + eta[k][j][i].y*eta[k][j][i].y + eta[k][j][i].z*eta[k][j][i].z );
2118 double sb, sc;
2119 double ni[3], nj[3], nk[3];
2121
2122 Ua.
x = Ua.
y = Ua.
z = 0;
2123 sb = 0.5/aj[k][j][i]/area;
2124
2125
2126 sc = 2*sb + 0.5/aj[k][j+1][i]/area;
2127 Uc = ucat[k][j+1][i];
2128
2129
2130
2131
2132
2133 double AA=sqrt(eta[k][j][i].z*eta[k][j][i].z +
2134 eta[k][j][i].y*eta[k][j][i].y +
2135 eta[k][j][i].x*eta[k][j][i].x);
2136 nj[0]=eta[k][j][i].
x/AA;
2137 nj[1]=eta[k][j][i].
y/AA;
2138 nj[2]=eta[k][j][i].
z/AA;
2139 noslip (user, sc, sb, Ua, Uc, &ucat[k][j][i], nj[0], nj[1], nj[2]);
2140 wall_function_loglaw(user, 1.e-16, sc, sb, Ua, Uc, &ucat[k][j][i], &ustar[k][j][i], nj[0], nj[1], nj[2]);
2141
2142
2143
2144
2145
2146 }
2147 }
2148 if (ys==0) {
2149 j= ys;
2150
2151 for (k=lzs; k<lze; k++) {
2152 for (i=lxs; i<lxe; i++) {
2153 ubcs[k][j][i].
x = 0.0;
2154 ubcs[k][j][i].
y = 0.0;
2155 ubcs[k][j][i].
z = 0.0;
2156 ucont[k][j][i].
y = 0.;
2157 }
2158 }
2159 }
2160
2161 DMDAVecRestoreArray(da, Aj, &aj);
2162 DMDAVecRestoreArray(da, user->
lUstar, &ustar);
2163 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2164 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2165
2166
2167
2168
2169 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2170 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2171
2172
2173
2174
2175 }
2176
2177
2178
2179 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2180
2181
2182
2183
2184 if (xs==0 && user->
bctype[0]!=7) {
2185 i = xs;
2186 for (k=lzs; k<lze; k++) {
2187 for (j=lys; j<lye; j++) {
2188 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j][i+1].
x;
2189 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j][i+1].
y;
2190 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j][i+1].
z;
2191 }
2192 }
2193 }
2194
2195 if (xe==mx && user->
bctype[0]!=7) {
2196 i = xe-1;
2197 for (k=lzs; k<lze; k++) {
2198 for (j=lys; j<lye; j++) {
2199 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j][i-1].
x;
2200 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j][i-1].
y;
2201 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j][i-1].
z;
2202 }
2203 }
2204 }
2205
2206
2207 if (ys==0 && user->
bctype[2]!=7) {
2208 j = ys;
2209 for (k=lzs; k<lze; k++) {
2210 for (i=lxs; i<lxe; i++) {
2211 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j+1][i].
x;
2212 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j+1][i].
y;
2213 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j+1][i].
z;
2214 }
2215 }
2216 }
2217
2218 if (ye==my && user->
bctype[2]!=7) {
2219 j = ye-1;
2220 for (k=lzs; k<lze; k++) {
2221 for (i=lxs; i<lxe; i++) {
2222 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j-1][i].
x;
2223 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j-1][i].
y;
2224 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j-1][i].
z;
2225 }
2226 }
2227 }
2228
2229 if (zs==0 && user->
bctype[4]!=7) {
2230 k = zs;
2231 for (j=lys; j<lye; j++) {
2232 for (i=lxs; i<lxe; i++) {
2233 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k+1][j][i].
x;
2234 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k+1][j][i].
y;
2235 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k+1][j][i].
z;
2236 }
2237 }
2238 }
2239
2240 if (ze==mz && user->
bctype[4]!=7) {
2241 k = ze-1;
2242 for (j=lys; j<lye; j++) {
2243 for (i=lxs; i<lxe; i++) {
2244 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k-1][j][i].
x;
2245 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k-1][j][i].
y;
2246 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k-1][j][i].
z;
2247 }
2248 }
2249 }
2250
2251 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2252
2253
2254
2256 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2257 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2258 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2259 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2260
2261
2262
2263 DMDAVecGetArray(da, user->
lP, &lp);
2264 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2265 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2266 DMDAVecGetArray(da, user->
P, &p);
2267 DMDAVecGetArray(da, user->
Nvert, &nvert);
2268 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2269
2271 if (xs==0){
2272 i=xs;
2273 for (k=zs; k<ze; k++) {
2274 for (j=ys; j<ye; j++) {
2275 if(j>0 && k>0 && j<user->JM && k<user->KM){
2276 ucat[k][j][i]=lucat[k][j][i-2];
2277 p[k][j][i]=lp[k][j][i-2];
2278 nvert[k][j][i]=lnvert[k][j][i-2];
2279 }
2280 }
2281 }
2282 }
2283 }
2285 if (ys==0){
2286 j=ys;
2287 for (k=zs; k<ze; k++) {
2288 for (i=xs; i<xe; i++) {
2289 if(i>0 && k>0 && i<user->IM && k<user->KM){
2290 ucat[k][j][i]=lucat[k][j-2][i];
2291 p[k][j][i]=lp[k][j-2][i];
2292 nvert[k][j][i]=lnvert[k][j-2][i];
2293 }
2294 }
2295 }
2296 }
2297 }
2299 if (zs==0){
2300 k=zs;
2301 for (j=ys; j<ye; j++) {
2302 for (i=xs; i<xe; i++) {
2303 if(i>0 && j>0 && i<user->IM && j<user->JM){
2304 ucat[k][j][i]=lucat[k-2][j][i];
2305 nvert[k][j][i]=lnvert[k-2][j][i];
2306
2307 p[k][j][i]=lp[k-2][j][i];
2308 }
2309 }
2310 }
2311 }
2312 }
2314 if (xe==mx){
2315 i=mx-1;
2316 for (k=zs; k<ze; k++) {
2317 for (j=ys; j<ye; j++) {
2318 if(j>0 && k>0 && j<user->JM && k<user->KM){
2319 ucat[k][j][i]=lucat[k][j][i+2];
2320 p[k][j][i]=lp[k][j][i+2];
2321 nvert[k][j][i]=lnvert[k][j][i+2];
2322 }
2323 }
2324 }
2325 }
2326 }
2328 if (ye==my){
2329 j=my-1;
2330 for (k=zs; k<ze; k++) {
2331 for (i=xs; i<xe; i++) {
2332 if(i>0 && k>0 && i<user->IM && k<user->KM){
2333 ucat[k][j][i]=lucat[k][j+2][i];
2334 p[k][j][i]=lp[k][j+2][i];
2335 nvert[k][j][i]=lnvert[k][j+2][i];
2336 }
2337 }
2338 }
2339 }
2340 }
2341
2343 if (ze==mz){
2344 k=mz-1;
2345 for (j=ys; j<ye; j++) {
2346 for (i=xs; i<xe; i++) {
2347 if(i>0 && j>0 && i<user->IM && j<user->JM){
2348 ucat[k][j][i]=lucat[k+2][j][i];
2349 nvert[k][j][i]=lnvert[k+2][j][i];
2350
2351 p[k][j][i]=lp[k+2][j][i];
2352 }
2353 }
2354 }
2355 }
2356 }
2357
2358
2359
2360
2361
2362 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2363 DMDAVecRestoreArray(da, user->
lP, &lp);
2364 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2365 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2366 DMDAVecRestoreArray(da, user->
P, &p);
2367 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2379 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2380
2381 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2382 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2383
2384 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2385 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2386}
2387
2388
2389 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2390 DMDAVecGetArray(da, user->
P, &p);
2391
2392 if (zs==0) {
2393 k=0;
2394 if (xs==0) {
2395 i=0;
2396 for (j=ys; j<ye; j++) {
2397 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j][i+1].
x);
2398 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j][i+1].
y);
2399 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j][i+1].
z);
2400 p[k][j][i]= 0.5*(p[k+1][j][i]+p[k][j][i+1]);
2401 }
2402 }
2403 if (xe == mx) {
2404 i=mx-1;
2405 for (j=ys; j<ye; j++) {
2406 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j][i-1].
x);
2407 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j][i-1].
y);
2408 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j][i-1].
z);
2409 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j][i-1]);
2410 }
2411 }
2412
2413 if (ys==0) {
2414 j=0;
2415 for (i=xs; i<xe; i++) {
2416 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j+1][i].
x);
2417 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j+1][i].
y);
2418 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j+1][i].
z);
2419 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j+1][i]);
2420 }
2421 }
2422
2423 if (ye==my) {
2424 j=my-1;
2425 for (i=xs; i<xe; i++) {
2426 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j-1][i].
x);
2427 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j-1][i].
y);
2428 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j-1][i].
z);
2429 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j-1][i]);
2430 }
2431 }
2432 }
2433
2434 if (ze==mz) {
2435 k=mz-1;
2436 if (xs==0) {
2437 i=0;
2438 for (j=ys; j<ye; j++) {
2439 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j][i+1].
x);
2440 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j][i+1].
y);
2441 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j][i+1].
z);
2442 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j][i+1]);
2443 }
2444 }
2445 if (xe == mx) {
2446 i=mx-1;
2447 for (j=ys; j<ye; j++) {
2448 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j][i-1].
x);
2449 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j][i-1].
y);
2450 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j][i-1].
z);
2451 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j][i-1]);
2452 }
2453 }
2454
2455 if (ys==0) {
2456 j=0;
2457 for (i=xs; i<xe; i++) {
2458 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j+1][i].
x);
2459 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j+1][i].
y);
2460 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j+1][i].
z);
2461 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j+1][i]);
2462 }
2463 }
2464
2465 if (ye==my) {
2466 j=my-1;
2467 for (i=xs; i<xe; i++) {
2468 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j-1][i].
x);
2469 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j-1][i].
y);
2470 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j-1][i].
z);
2471 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j-1][i]);
2472 }
2473 }
2474 }
2475
2476 if (ys==0) {
2477 j=0;
2478 if (xs==0) {
2479 i=0;
2480 for (k=zs; k<ze; k++) {
2481 ucat[k][j][i].
x = 0.5*(ucat[k][j+1][i].
x+ucat[k][j][i+1].
x);
2482 ucat[k][j][i].
y = 0.5*(ucat[k][j+1][i].
y+ucat[k][j][i+1].
y);
2483 ucat[k][j][i].
z = 0.5*(ucat[k][j+1][i].
z+ucat[k][j][i+1].
z);
2484 p[k][j][i]= 0.5*(p[k][j+1][i]+p[k][j][i+1]);
2485 }
2486 }
2487
2488 if (xe==mx) {
2489 i=mx-1;
2490 for (k=zs; k<ze; k++) {
2491 ucat[k][j][i].
x = 0.5*(ucat[k][j+1][i].
x+ucat[k][j][i-1].
x);
2492 ucat[k][j][i].
y = 0.5*(ucat[k][j+1][i].
y+ucat[k][j][i-1].
y);
2493 ucat[k][j][i].
z = 0.5*(ucat[k][j+1][i].
z+ucat[k][j][i-1].
z);
2494 p[k][j][i] = 0.5*(p[k][j+1][i]+p[k][j][i-1]);
2495 }
2496 }
2497 }
2498
2499 if (ye==my) {
2500 j=my-1;
2501 if (xs==0) {
2502 i=0;
2503 for (k=zs; k<ze; k++) {
2504 ucat[k][j][i].
x = 0.5*(ucat[k][j-1][i].
x+ucat[k][j][i+1].
x);
2505 ucat[k][j][i].
y = 0.5*(ucat[k][j-1][i].
y+ucat[k][j][i+1].
y);
2506 ucat[k][j][i].
z = 0.5*(ucat[k][j-1][i].
z+ucat[k][j][i+1].
z);
2507 p[k][j][i] = 0.5*(p[k][j-1][i]+p[k][j][i+1]);
2508 }
2509 }
2510
2511 if (xe==mx) {
2512 i=mx-1;
2513 for (k=zs; k<ze; k++) {
2514 ucat[k][j][i].
x = 0.5*(ucat[k][j-1][i].
x+ucat[k][j][i-1].
x);
2515 ucat[k][j][i].
y = 0.5*(ucat[k][j-1][i].
y+ucat[k][j][i-1].
y);
2516 ucat[k][j][i].
z = 0.5*(ucat[k][j-1][i].
z+ucat[k][j][i-1].
z);
2517 p[k][j][i] = 0.5*(p[k][j-1][i]+p[k][j][i-1]);
2518 }
2519 }
2520 }
2521
2522 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2523 DMDAVecRestoreArray(da, user->
P, &p);
2524
2525 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2526 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2527
2528 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2529 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2530
2531
2532
2533
2535
2536
2537 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2538 DMDAVecGetArray(da, user->
lP, &lp);
2539 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2540 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2541 DMDAVecGetArray(da, user->
P, &p);
2542 DMDAVecGetArray(da, user->
Nvert, &nvert);
2543
2545 if (xs==0){
2546 i=xs;
2547 for (k=zs; k<ze; k++) {
2548 for (j=ys; j<ye; j++) {
2549 ucat[k][j][i]=lucat[k][j][i-2];
2550 p[k][j][i]=lp[k][j][i-2];
2551 nvert[k][j][i]=lnvert[k][j][i-2];
2552 }
2553 }
2554 }
2555 }
2557 if (xe==mx){
2558 i=xe-1;
2559 for (k=zs; k<ze; k++) {
2560 for (j=ys; j<ye; j++) {
2561 ucat[k][j][i].
x=lucat[k][j][i+2].
x;
2562 p[k][j][i]=lp[k][j][i+2];
2563 nvert[k][j][i]=lnvert[k][j][i+2];
2564 }
2565 }
2566 }
2567 }
2568 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2569 DMDAVecRestoreArray(da, user->
lP, &lp);
2570 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2571 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2572 DMDAVecRestoreArray(da, user->
P, &p);
2573 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2585 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2586
2587 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2588 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2589
2590 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2591 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2592
2593
2594 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2595 DMDAVecGetArray(da, user->
lP, &lp);
2596 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2597 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2598 DMDAVecGetArray(da, user->
P, &p);
2599 DMDAVecGetArray(da, user->
Nvert, &nvert);
2600
2602 if (ys==0){
2603 j=ys;
2604 for (k=zs; k<ze; k++) {
2605 for (i=xs; i<xe; i++) {
2606 ucat[k][j][i]=lucat[k][j-2][i];
2607 p[k][j][i]=lp[k][j-2][i];
2608 nvert[k][j][i]=lnvert[k][j-2][i];
2609 }
2610 }
2611 }
2612 }
2613
2615 if (ye==my){
2616 j=my-1;
2617 for (k=zs; k<ze; k++) {
2618 for (i=xs; i<xe; i++) {
2619 ucat[k][j][i]=lucat[k][j+2][i];
2620 p[k][j][i]=lp[k][j+2][i];
2621 nvert[k][j][i]=lnvert[k][j+2][i];
2622 }
2623 }
2624 }
2625 }
2626
2627 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2628 DMDAVecRestoreArray(da, user->
lP, &lp);
2629 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2630 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2631 DMDAVecRestoreArray(da, user->
P, &p);
2632 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2644 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2645
2646 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2647 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2648
2649 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2650 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2651
2652
2653 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2654 DMDAVecGetArray(da, user->
lP, &lp);
2655 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2656 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2657 DMDAVecGetArray(da, user->
P, &p);
2658 DMDAVecGetArray(da, user->
Nvert, &nvert);
2659
2661 if (zs==0){
2662 k=zs;
2663 for (j=ys; j<ye; j++) {
2664 for (i=xs; i<xe; i++) {
2665 ucat[k][j][i]=lucat[k-2][j][i];
2666 nvert[k][j][i]=lnvert[k-2][j][i];
2667
2668 p[k][j][i]=lp[k-2][j][i];
2669 }
2670 }
2671 }
2672 }
2674 if (ze==mz){
2675 k=mz-1;
2676 for (j=ys; j<ye; j++) {
2677 for (i=xs; i<xe; i++) {
2678 ucat[k][j][i]=lucat[k+2][j][i];
2679 nvert[k][j][i]=lnvert[k+2][j][i];
2680 p[k][j][i]=lp[k+2][j][i];
2681 }
2682 }
2683 }
2684 }
2685
2686 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2687 DMDAVecRestoreArray(da, user->
lP, &lp);
2688 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2689 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2690 DMDAVecRestoreArray(da, user->
P, &p);
2691 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2703 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2704
2705 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2706 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2707
2708 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2709 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2710 }
2711
2712
2713
2714
2715 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2716 DMDAVecGetArray(fda, user->
Ucont, &ucont);
2717 DMDAVecGetArray(fda, user->
Cent, ¢);
2718 DMDAVecGetArray(fda, user->
Centx, ¢x);
2719 DMDAVecGetArray(fda, user->
Centy, ¢y);
2720 DMDAVecGetArray(fda, user->
Centz, ¢z);
2721
2722 if (user->
bctype[0]==9) {
2723 if (xs==0) {
2724 i= xs;
2725 for (k=lzs; k<lze; k++) {
2726 for (j=lys; j<lye; j++) {
2727 ucat[k][j][i].
x=-cos(cent[k][j][i+1].x)*sin(cent[k][j][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2728 ucat[k][j][i].
y=-sin(cent[k][j][i+1].x)*cos(cent[k][j][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2729 ucat[k][j][i].
z =0.0;
2730
2731 ucont[k][j][i].
x =-(cos(centx[k][j][i].x)*sin(centx[k][j][i].y)*csi[k][j][i].
x)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2732 }
2733 }
2734 if (ys==0) {
2735 j=ys;
2736 for (k=lzs; k<lze; k++) {
2737 ucat[k][j][i].
x=cos(cent[k][j+1][i+1].x)*sin(cent[k][j+1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2738 ucat[k][j][i].
y=-sin(cent[k][j+1][i+1].x)*cos(cent[k][j+1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2739 ucat[k][j][i].
z =0.0;
2740 }
2741 }
2742 if (ye==my) {
2743 j=ye-1;
2744 for (k=lzs; k<lze; k++) {
2745 ucat[k][j][i].
x=cos(cent[k][j-1][i+1].x)*sin(cent[k][j-1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2746 ucat[k][j][i].
y=-sin(cent[k][j-1][i+1].x)*cos(cent[k][j-1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2747 ucat[k][j][i].
z =0.0;
2748 }
2749 }
2750 }
2751 }
2752 if (user->
bctype[1]==9) {
2753 if (xe==mx) {
2754 i= xe-1;
2755 for (k=lzs; k<lze; k++) {
2756 for (j=lys; j<lye; j++) {
2757 ucat[k][j][i].
x=-cos(cent[k][j][i-1].x)*sin(cent[k][j][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2758 ucat[k][j][i].
y=-sin(cent[k][j][i-1].x)*cos(cent[k][j][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2759 ucat[k][j][i].
z =0.0;
2760
2761 ucont[k][j][i-1].
x =(-cos(centx[k][j][i-1].x)*sin(centx[k][j][i-1].y)*csi[k][j][i-1].
x)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2762 }
2763 }
2764 if (ys==0) {
2765 j=ys;
2766 for (k=lzs; k<lze; k++) {
2767 ucat[k][j][i].
x=cos(cent[k][j+1][i-1].x)*sin(cent[k][j+1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2768 ucat[k][j][i].
y=-sin(cent[k][j+1][i-1].x)*cos(cent[k][j+1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2769 ucat[k][j][i].
z =0.0;
2770 }
2771 }
2772 if (ye==my) {
2773 j=ye-1;
2774 for (k=lzs; k<lze; k++) {
2775 ucat[k][j][i].
x=cos(cent[k][j-1][i-1].x)*sin(cent[k][j-1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2776 ucat[k][j][i].
y=-sin(cent[k][j-1][i-1].x)*cos(cent[k][j-1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2777 ucat[k][j][i].
z =0.0;
2778 }
2779 }
2780 }
2781 }
2782
2783 if (user->
bctype[2]==9) {
2784 if (ys==0) {
2785 j= ys;
2786 for (k=lzs; k<lze; k++) {
2787 for (i=lxs; i<lxe; i++) {
2788 ucat[k][j][i].
x=cos(cent[k][j+1][i].x)*sin(cent[k][j+1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2789 ucat[k][j][i].
y=sin(cent[k][j+1][i].x)*cos(cent[k][j+1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2790 ucat[k][j][i].
z =0.0;
2791
2792 ucont[k][j][i].
y=(sin(centy[k][j][i].x)*cos(centy[k][j][i].y)*eta[k][j][i].
y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2793 }
2794 }
2795 }
2796 }
2797
2798
2799 if (user->
bctype[3]==9) {
2800 if (ye==my) {
2801 j= ye-1;
2802 for (k=lzs; k<lze; k++) {
2803 for (i=lxs; i<lxe; i++) {
2804 ucat[k][j][i].
x=cos(cent[k][j-1][i].x)*sin(cent[k][j-1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2805 ucat[k][j][i].
y=sin(cent[k][j-1][i].x)*cos(cent[k][j-1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2806 ucat[k][j][i].
z =0.0;
2807
2808 ucont[k][j-1][i].
y=(sin(centy[k][j-1][i].x)*cos(centy[k][j-1][i].y)*eta[k][j-1][i].
y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2809 }
2810 }
2811 }
2812 }
2813 if (user->
bctype[4]==9) {
2814 if (zs==0) {
2815 k= zs;
2816 for (j=ys; j<ye; j++) {
2817 for (i=xs; i<xe; i++) {
2818 ucat[k][j][i].
x=ucat[k+1][j][i].
x;
2819 ucat[k][j][i].
y=ucat[k+1][j][i].
y;
2820 ucat[k][j][i].
z=ucat[k+1][j][i].
z;
2821
2822 ucont[k][j][i].
z=0.0;
2823 }
2824 }
2825 }
2826 }
2827 if (user->
bctype[5]==9) {
2828 if (ze==mz) {
2829 k= ze-1;
2830 for (j=ys; j<ye; j++) {
2831 for (i=xs; i<xe; i++) {
2832 ucat[k][j][i].
x=ucat[k-1][j][i].
x;
2833 ucat[k][j][i].
y=ucat[k-1][j][i].
y;
2834 ucat[k][j][i].
z=ucat[k-1][j][i].
z;
2835
2836 ucont[k-1][j][i].
z=0.0;
2837 }
2838 }
2839 }
2840 }
2841
2842 DMDAVecRestoreArray(fda, user->
Cent, ¢);
2843 DMDAVecRestoreArray(fda, user->
Centx, ¢x);
2844 DMDAVecRestoreArray(fda, user->
Centy, ¢y);
2845 DMDAVecRestoreArray(fda, user->
Centz, ¢z);
2846
2847 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2848 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2849
2850 }
2851
2852
2853 DMDAVecRestoreArray(fda, user->
Bcs.
Ubcs, &ubcs);
2854 DMDAVecRestoreArray(fda, user->
lCsi, &csi);
2855 DMDAVecRestoreArray(fda, user->
lEta, &eta);
2856 DMDAVecRestoreArray(fda, user->
lZet, &zet);
2857
2858 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2859 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2860 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2861 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2862 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2863 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2864
2866
2867 PetscFunctionReturn(0);
2868 }
PetscErrorCode Contra2Cart(UserCtx *user)
Reconstructs Cartesian velocity (Ucat) at cell centers from contravariant velocity (Ucont) defined on...
Vec Uch
Characteristic velocity for boundary conditions.
void noslip(UserCtx *user, double sc, double sb, Cmpnts Ua, Cmpnts Uc, Cmpnts *Ub, double nx, double ny, double nz)
void wall_function_loglaw(UserCtx *user, double ks, double sc, double sb, Cmpnts Ua, Cmpnts Uc, Cmpnts *Ub, PetscReal *ustar, double nx, double ny, double nz)