1262{
1263 DM da = user->
da, fda = user->
fda;
1264 DMDALocalInfo info = user->
info;
1265 PetscInt xs = info.xs, xe = info.xs + info.xm;
1266 PetscInt ys = info.ys, ye = info.ys + info.ym;
1267 PetscInt zs = info.zs, ze = info.zs + info.zm;
1268 PetscInt mx = info.mx, my = info.my, mz = info.mz;
1269 PetscInt lxs, lxe, lys, lye, lzs, lze;
1270 PetscInt i, j, k;
1271
1272 PetscReal ***nvert,***lnvert;
1273
1274 PetscReal ***p,***lp;
1275 Cmpnts ***ucont, ***ubcs, ***ucat,***lucat, ***csi, ***eta, ***zet;
1276 Cmpnts ***cent,***centx,***centy,***centz,***coor;
1277 PetscScalar FluxIn, FluxOut,ratio;
1278 PetscScalar lArea, AreaSum;
1279
1280 PetscScalar FarFluxIn=0., FarFluxOut=0., FarFluxInSum, FarFluxOutSum;
1281 PetscScalar FarAreaIn=0., FarAreaOut=0., FarAreaInSum, FarAreaOutSum;
1282 PetscScalar FluxDiff, VelDiffIn, VelDiffOut;
1284
1285 PetscReal Un, nx,ny,nz,A;
1286
1288
1289 lxs = xs; lxe = xe;
1290 lys = ys; lye = ye;
1291 lzs = zs; lze = ze;
1292
1293 PetscInt gxs, gxe, gys, gye, gzs, gze;
1294
1295 gxs = info.gxs; gxe = gxs + info.gxm;
1296 gys = info.gys; gye = gys + info.gym;
1297 gzs = info.gzs; gze = gzs + info.gzm;
1298
1299 if (xs==0) lxs = xs+1;
1300 if (ys==0) lys = ys+1;
1301 if (zs==0) lzs = zs+1;
1302
1303 if (xe==mx ) lxe = xe-1;
1304 if (ye==my ) lye = ye-1;
1305 if (ze==mz ) lze = ze-1;
1306
1307
1308 DMDAVecGetArray(fda, user->
Bcs.
Ubcs, &ubcs);
1309
1310 DMDAVecGetArray(fda, user->
lCsi, &csi);
1311 DMDAVecGetArray(fda, user->
lEta, &eta);
1312 DMDAVecGetArray(fda, user->
lZet, &zet);
1313
1314 PetscInt ttemp;
1315 for (ttemp=0; ttemp<3; ttemp++) {
1316 DMDAVecGetArray(da, user->
Nvert, &nvert);
1317 DMDAVecGetArray(fda, user->
lUcat, &ucat);
1318 DMDAVecGetArray(fda, user->
Ucont, &ucont);
1319
1320
1321
1322
1323
1324
1325 FarFluxIn = 0.; FarFluxOut=0.;
1326 FarAreaIn = 0.; FarAreaOut=0.;
1327
1328 PetscReal lFlux_abs=0.0,FluxSum_abs=0.0,ratio=0.0;
1329
1333
1334
1335
1336 if (user->
bctype[0]==6) {
1337 if (xs == 0) {
1338 i= xs;
1339 for (k=lzs; k<lze; k++) {
1340 for (j=lys; j<lye; j++) {
1341 ubcs[k][j][i].
x = ucat[k][j][i+1].
x;
1342 ubcs[k][j][i].
y = ucat[k][j][i+1].
y;
1343 ubcs[k][j][i].
z = ucat[k][j][i+1].
z;
1344 ucont[k][j][i].
x = ubcs[k][j][i].
x * csi[k][j][i].
x;
1345 FarFluxIn += ucont[k][j][i].
x;
1346 lFlux_abs += fabs(ucont[k][j][i].x);
1347 FarAreaIn += csi[k][j][i].
x;
1348 }
1349 }
1350 }
1351 }
1352
1353 if (user->
bctype[1]==6) {
1354 if (xe==mx) {
1355 i= xe-1;
1356 for (k=lzs; k<lze; k++) {
1357 for (j=lys; j<lye; j++) {
1358 ubcs[k][j][i].
x = ucat[k][j][i-1].
x;
1359 ubcs[k][j][i].
y = ucat[k][j][i-1].
y;
1360 ubcs[k][j][i].
z = ucat[k][j][i-1].
z;
1361 ucont[k][j][i-1].
x = ubcs[k][j][i].
x * csi[k][j][i-1].
x;
1362 FarFluxOut += ucont[k][j][i-1].
x;
1363 lFlux_abs += fabs(ucont[k][j][i-1].x);
1364 FarAreaOut += csi[k][j][i-1].
x;
1365 }
1366 }
1367 }
1368 }
1369
1370 if (user->
bctype[2]==6) {
1371 if (ys==0) {
1372 j= ys;
1373 for (k=lzs; k<lze; k++) {
1374 for (i=lxs; i<lxe; i++) {
1375 ubcs[k][j][i].
x = ucat[k][j+1][i].
x;
1376 ubcs[k][j][i].
y = ucat[k][j+1][i].
y;
1377 ubcs[k][j][i].
z = ucat[k][j+1][i].
z;
1378 ucont[k][j][i].
y = ubcs[k][j][i].
y * eta[k][j][i].
y;
1379 FarFluxIn += ucont[k][j][i].
y;
1380 lFlux_abs += fabs(ucont[k][j][i].y);
1381 FarAreaIn += eta[k][j][i].
y;
1382 }
1383 }
1384 }
1385 }
1386
1387 if (user->
bctype[3]==6) {
1388 if (ye==my) {
1389 j=ye-1;
1390 for (k=lzs; k<lze; k++) {
1391 for (i=lxs; i<lxe; i++) {
1392 ubcs[k][j][i].
x = ucat[k][j-1][i].
x;
1393 ubcs[k][j][i].
y = ucat[k][j-1][i].
y;
1394 ubcs[k][j][i].
z = ucat[k][j-1][i].
z;
1395 ucont[k][j-1][i].
y = ubcs[k][j][i].
y * eta[k][j-1][i].
y;
1396 FarFluxOut += ucont[k][j-1][i].
y;
1397 lFlux_abs += fabs(ucont[k][j-1][i].y);
1398 FarAreaOut += eta[k][j-1][i].
y;
1399 }
1400 }
1401 }
1402 }
1403
1405 if (zs==0) {
1406 k = 0;
1407 for (j=lys; j<lye; j++) {
1408 for (i=lxs; i<lxe; i++) {
1409 ubcs[k][j][i].
x = ucat[k+1][j][i].
x;
1410 ubcs[k][j][i].
y = ucat[k+1][j][i].
y;
1411 ubcs[k][j][i].
z = ucat[k+1][j][i].
z;
1412 ucont[k][j][i].
z = ubcs[k][j][i].
z * zet[k][j][i].
z;
1413 FarFluxIn += ucont[k][j][i].
z;
1414 lFlux_abs += fabs(ucont[k][j][i].z);
1415 FarAreaIn += zet[k][j][i].
z;
1416 }
1417 }
1418 }
1419 }
1420
1422 if (ze==mz) {
1423 k = ze-1;
1424 for (j=lys; j<lye; j++) {
1425 for (i=lxs; i<lxe; i++) {
1426 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1427 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1428 ubcs[k][j][i].
z = ucat[k-1][j][i].
z;
1429 ucont[k-1][j][i].
z = ubcs[k][j][i].
z * zet[k-1][j][i].
z;
1430 FarFluxOut += ucont[k-1][j][i].
z;
1431 lFlux_abs += fabs(ucont[k-1][j][i].z);
1432 FarAreaOut += zet[k-1][j][i].
z;
1433 }
1434 }
1435 }
1436 }
1437
1438 MPI_Allreduce(&FarFluxIn,&FarFluxInSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1439 MPI_Allreduce(&FarFluxOut,&FarFluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1440 MPI_Allreduce(&lFlux_abs,&FluxSum_abs,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1441 MPI_Allreduce(&FarAreaIn,&FarAreaInSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1442 MPI_Allreduce(&FarAreaOut,&FarAreaOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1443
1445
1446 ratio=(FarFluxInSum - FarFluxOutSum)/FluxSum_abs;
1447 if (fabs(FluxSum_abs) <1.e-10) ratio = 0.;
1448
1450
1451 FluxDiff = 0.5*(FarFluxInSum - FarFluxOutSum) ;
1452 VelDiffIn = FluxDiff / FarAreaInSum ;
1453
1454 if (fabs(FarAreaInSum) <1.e-6) VelDiffIn = 0.;
1455
1456 VelDiffOut = FluxDiff / FarAreaOutSum ;
1457
1458 if (fabs(FarAreaOutSum) <1.e-6) VelDiffOut = 0.;
1459
1460 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);
1461
1462 }
1463
1464 if (user->
bctype[5]==10) {
1465 FluxDiff = simCtx->
FluxInSum -( FarFluxOutSum -FarFluxInSum) ;
1466 VelDiffIn = 1/3.*FluxDiff / (FarAreaInSum);
1467 if (fabs(FarAreaInSum) <1.e-6) VelDiffIn = 0.;
1468
1469 VelDiffOut = 2./3.* FluxDiff / (FarAreaOutSum) ;
1470
1471 if (fabs(FarAreaOutSum) <1.e-6) VelDiffOut = 0.;
1472
1473 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);
1474
1475 }
1476
1477
1478
1479
1481 if (ze==mz) {
1482 k = ze-1;
1483 for (j=lys; j<lye; j++) {
1484 for (i=lxs; i<lxe; i++) {
1485 ucont[k-1][j][i].
z += ratio*fabs(ucont[k-1][j][i].z);
1486 ubcs[k][j][i].
z = ucont[k-1][j][i].
z/zet[k-1][j][i].
z;
1487
1488
1489 }
1490 }
1491 }
1492 }
1493
1494 if (user->
bctype[3]==6) {
1495 if (ye==my) {
1496 j=ye-1;
1497 for (k=lzs; k<lze; k++) {
1498 for (i=lxs; i<lxe; i++) {
1499
1500 ucont[k][j-1][i].
y +=ratio*fabs(ucont[k][j-1][i].y);
1501 ubcs[k][j][i].
y = ucont[k][j-1][i].
y /eta[k][j-1][i].
y;
1502
1503
1504
1505 }
1506 }
1507 }
1508 }
1509
1510 if (user->
bctype[1]==6) {
1511 if (xe==mx) {
1512 i= xe-1;
1513 for (k=lzs; k<lze; k++) {
1514 for (j=lys; j<lye; j++) {
1515 ucont[k][j][i-1].
x +=ratio*fabs(ucont[k][j][i-1].x);
1516 ubcs[k][j][i].
x = ucont[k][j][i-1].
x / csi[k][j][i-1].
x ;
1517
1518
1519 }
1520 }
1521 }
1522 }
1523
1524
1525 if (user->
bctype[0]==6) {
1526 if (xs == 0) {
1527 i= xs;
1528 for (k=lzs; k<lze; k++) {
1529 for (j=lys; j<lye; j++) {
1530 ucont[k][j][i].
x -=ratio*fabs(ucont[k][j][i].x);
1531 ubcs[k][j][i].
x = ucont[k][j][i].
x / csi[k][j][i].
x;
1532
1533
1534 }
1535 }
1536 }
1537 }
1538
1539
1540 if (user->
bctype[2]==6) {
1541 if (ys==0) {
1542 j= ys;
1543 for (k=lzs; k<lze; k++) {
1544 for (i=lxs; i<lxe; i++) {
1545 ucont[k][j][i].
y -=ratio*fabs(ucont[k][j][i].y);
1546 ubcs[k][j][i].
y = ucont[k][j][i].
y / eta[k][j][i].
y;
1547
1548
1549 }
1550 }
1551 }
1552 }
1553
1554
1556 if (zs==0) {
1557 k = 0;
1558 for (j=lys; j<lye; j++) {
1559 for (i=lxs; i<lxe; i++) {
1560 ucont[k][j][i].
z -=ratio*fabs(ucont[k][j][i].z);
1561 ubcs[k][j][i].
z =ucont[k][j][i].
z / zet[k][j][i].
z;
1562
1563
1564
1565 }
1566 }
1567 }
1568 }
1569
1570
1571
1573 if (ys==0) {
1574 j= ys;
1575 for (k=lzs; k<lze; k++) {
1576 for (i=lxs; i<lxe; i++) {
1577 A=sqrt(eta[k][j][i].z*eta[k][j][i].z +
1578 eta[k][j][i].y*eta[k][j][i].y +
1579 eta[k][j][i].x*eta[k][j][i].x);
1580 nx=eta[k][j][i].
x/A;
1581 ny=eta[k][j][i].
y/A;
1582 nz=eta[k][j][i].
z/A;
1583 Un=ucat[k][j+1][i].
x*nx+ucat[k][j+1][i].
y*ny+ucat[k][j+1][i].
z*nz;
1584 ubcs[k][j][i].
x = 0.0;
1585 ubcs[k][j][i].
y = 0.0;
1586 ubcs[k][j][i].
z = 0.0;
1587 ucont[k][j][i].
y = 0.;
1588 }
1589 }
1590 }
1591 }
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1603 if (xs==0) {
1604 i= xs;
1605 for (k=lzs; k<lze; k++) {
1606 for (j=lys; j<lye; j++) {
1607 ubcs[k][j][i].
x = 0.0;
1608 ubcs[k][j][i].
y = 0.0;
1609 ubcs[k][j][i].
z = 0.0;
1610 ucont[k][j][i].
x = 0.0;
1611 }
1612 }
1613 }
1614}
1615
1616
1618 if (xe==mx) {
1619 i= xe-1;
1620 for (k=lzs; k<lze; k++) {
1621 for (j=lys; j<lye; j++) {
1622 ubcs[k][j][i].
x = 0.0;
1623 ubcs[k][j][i].
y = 0.0;
1624 ubcs[k][j][i].
z = 0.0;
1625
1626 ucont[k][j][i-1].
x = 0.0;
1627 }
1628 }
1629 }
1630}
1631
1632
1634 if (ys==0) {
1635 j= ys;
1636 for (k=lzs; k<lze; k++) {
1637 for (i=lxs; i<lxe; i++) {
1638 ubcs[k][j][i].
x = 0.0;
1639 ubcs[k][j][i].
y = 0.0;
1640 ubcs[k][j][i].
z = 0.0;
1641 ucont[k][j][i].
y = 0.0;
1642 }
1643 }
1644 }
1645}
1646
1647
1649 if (ye==my) {
1650 j= ye-1;
1651 for (k=lzs; k<lze; k++) {
1652 for (i=lxs; i<lxe; i++) {
1653 ubcs[k][j][i].
x = 0.0;
1654 ubcs[k][j][i].
y = 0.0;
1655 ubcs[k][j][i].
z = 0.0;
1656
1657 ucont[k][j-1][i].
y = 0.0;
1658 }
1659 }
1660 }
1661}
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672 if (user->
bctype[0]==3) {
1673 if (xs==0) {
1674 i= xs;
1675
1676 for (k=lzs; k<lze; k++) {
1677 for (j=lys; j<lye; j++) {
1678 A=sqrt(csi[k][j][i].z*csi[k][j][i].z +
1679 csi[k][j][i].y*csi[k][j][i].y +
1680 csi[k][j][i].x*csi[k][j][i].x);
1681 nx=csi[k][j][i].
x/A;
1682 ny=csi[k][j][i].
y/A;
1683 nz=csi[k][j][i].
z/A;
1684 Un=ucat[k][j][i+1].
x*nx+ucat[k][j][i+1].
y*ny+ucat[k][j][i+1].
z*nz;
1685 ubcs[k][j][i].
x = ucat[k][j][i+1].
x-Un*nx;
1686 ubcs[k][j][i].
y = ucat[k][j][i+1].
y-Un*ny;
1687 ubcs[k][j][i].
z = ucat[k][j][i+1].
z-Un*nz;
1688 ucont[k][j][i].
x = 0.;
1689 }
1690 }
1691 }
1692 }
1693
1694 if (user->
bctype[1]==3) {
1695 if (xe==mx) {
1696 i= xe-1;
1697
1698 for (k=lzs; k<lze; k++) {
1699 for (j=lys; j<lye; j++) {
1700 A=sqrt(csi[k][j][i-1].z*csi[k][j][i-1].z +
1701 csi[k][j][i-1].y*csi[k][j][i-1].y +
1702 csi[k][j][i-1].x*csi[k][j][i-1].x);
1703 nx=csi[k][j][i-1].
x/A;
1704 ny=csi[k][j][i-1].
y/A;
1705 nz=csi[k][j][i-1].
z/A;
1706 Un=ucat[k][j][i-1].
x*nx+ucat[k][j][i-1].
y*ny+ucat[k][j][i-1].
z*nz;
1707 ubcs[k][j][i].
x = ucat[k][j][i-1].
x-Un*nx;
1708 ubcs[k][j][i].
y = ucat[k][j][i-1].
y-Un*ny;
1709 ubcs[k][j][i].
z = ucat[k][j][i-1].
z-Un*nz;
1710 ucont[k][j][i-1].
x = 0.;
1711 }
1712 }
1713 }
1714 }
1715
1716 if (user->
bctype[2]==3) {
1717 if (ys==0) {
1718 j= ys;
1719
1720 for (k=lzs; k<lze; k++) {
1721 for (i=lxs; i<lxe; i++) {
1722 A=sqrt(eta[k][j][i].z*eta[k][j][i].z +
1723 eta[k][j][i].y*eta[k][j][i].y +
1724 eta[k][j][i].x*eta[k][j][i].x);
1725 nx=eta[k][j][i].
x/A;
1726 ny=eta[k][j][i].
y/A;
1727 nz=eta[k][j][i].
z/A;
1728 Un=ucat[k][j+1][i].
x*nx+ucat[k][j+1][i].
y*ny+ucat[k][j+1][i].
z*nz;
1729 ubcs[k][j][i].
x = ucat[k][j+1][i].
x-Un*nx;
1730 ubcs[k][j][i].
y = ucat[k][j+1][i].
y-Un*ny;
1731 ubcs[k][j][i].
z = ucat[k][j+1][i].
z-Un*nz;
1732 ucont[k][j][i].
y = 0.;
1733 }
1734 }
1735 }
1736 }
1737
1738 if (user->
bctype[3]==3) {
1739 if (ye==my) {
1740 j=ye-1;
1741
1742 for (k=lzs; k<lze; k++) {
1743 for (i=lxs; i<lxe; i++) {
1744 A=sqrt(eta[k][j-1][i].z*eta[k][j-1][i].z +
1745 eta[k][j-1][i].y*eta[k][j-1][i].y +
1746 eta[k][j-1][i].x*eta[k][j-1][i].x);
1747 nx=eta[k][j-1][i].
x/A;
1748 ny=eta[k][j-1][i].
y/A;
1749 nz=eta[k][j-1][i].
z/A;
1750 Un=ucat[k][j-1][i].
x*nx+ucat[k][j-1][i].
y*ny+ucat[k][j-1][i].
z*nz;
1751 ubcs[k][j][i].
x = ucat[k][j-1][i].
x-Un*nx;
1752 ubcs[k][j][i].
y = ucat[k][j-1][i].
y-Un*ny;
1753 ubcs[k][j][i].
z = ucat[k][j-1][i].
z-Un*nz;
1754 ucont[k][j-1][i].
y = 0.;
1755 }
1756 }
1757 }
1758 }
1759
1760
1761 if (user->
bctype[4]==3) {
1762 if (zs==0) {
1763 k = 0;
1764 for (j=lys; j<lye; j++) {
1765 for (i=lxs; i<lxe; i++) {
1766 A=sqrt(zet[k][j][i].z*zet[k][j][i].z +
1767 zet[k][j][i].y*zet[k][j][i].y +
1768 zet[k][j][i].x*zet[k][j][i].x);
1769 nx=zet[k][j][i].
x/A;
1770 ny=zet[k][j][i].
y/A;
1771 nz=zet[k][j][i].
z/A;
1772 Un=ucat[k+1][j][i].
x*nx+ucat[k+1][j][i].
y*ny+ucat[k+1][j][i].
z*nz;
1773 ubcs[k][j][i].
x = ucat[k+1][j][i].
x-Un*nx;
1774 ubcs[k][j][i].
y = ucat[k+1][j][i].
y-Un*ny;
1775 ubcs[k][j][i].
z = ucat[k+1][j][i].
z-Un*nz;
1776 ucont[k][j][i].
z = 0.;
1777 }
1778 }
1779 }
1780 }
1781
1782 if (user->
bctype[5]==3) {
1783 if (ze==mz) {
1784 k = ze-1;
1785 for (j=lys; j<lye; j++) {
1786 for (i=lxs; i<lxe; i++) {
1787 A=sqrt(zet[k-1][j][i].z*zet[k-1][j][i].z +
1788 zet[k-1][j][i].y*zet[k-1][j][i].y +
1789 zet[k-1][j][i].x*zet[k-1][j][i].x);
1790 nx=zet[k-1][j][i].
x/A;
1791 ny=zet[k-1][j][i].
y/A;
1792 nz=zet[k-1][j][i].
z/A;
1793 Un=ucat[k-1][j][i].
x*nx+ucat[k-1][j][i].
y*ny+ucat[k-1][j][i].
z*nz;
1794 ubcs[k][j][i].
x = ucat[k-1][j][i].
x-Un*nx;
1795 ubcs[k][j][i].
y = ucat[k-1][j][i].
y-Un*ny;
1796 ubcs[k][j][i].
z = ucat[k-1][j][i].
z-Un*nz;
1797 ucont[k-1][j][i].
z = 0.;
1798 }
1799 }
1800 }
1801 }
1802
1803
1804
1805
1806
1807 if (user->
bctype[5]==8) {
1808 if (ze == mz) {
1809 k = ze-2;
1810 FluxOut = 0;
1811 for (j=lys; j<lye; j++) {
1812 for (i=lxs; i<lxe; i++) {
1813 FluxOut += ucont[k][j][i].
z;
1814 }
1815 }
1816 }
1817 else {
1818 FluxOut = 0.;
1819 }
1820
1821 FluxIn = simCtx->
FluxInSum + FarFluxInSum;
1822
1823 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1824
1825
1826
1828 if (fabs(simCtx->
FluxOutSum) < 1.e-6) ratio = 1.;
1829
1830 if (fabs(FluxIn) <1.e-6) ratio = 0.;
1832
1833 if (ze==mz) {
1834 k = ze-1;
1835 for (j=lys; j<lye; j++) {
1836 for (i=lxs; i<lxe; i++) {
1837 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1838 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1839 if (simCtx->
step==0 || simCtx->
step==1)
1841 ubcs[k][j][i].
z = -1.;
1842 else if (user->
bctype[4]==6)
1843 ubcs[k][j][i].
z = 0.;
1844 else
1845 ubcs[k][j][i].
z = 1.;
1846
1847 else
1848 ucont[k-1][j][i].
z = ucont[k-1][j][i].
z*ratio;
1849
1850 ubcs[k][j][i].
z = ucont[k-1][j][i].
z / zet[k-1][j][i].
z;
1851 }
1852 }
1853 }
1854 }
1855
1856
1857
1858
1859
1860
1861
1863 lArea=0.;
1866 if (ze == mz) {
1867
1868 k=ze-1;
1869 FluxOut = 0;
1870 for (j=lys; j<lye; j++) {
1871 for (i=lxs; i<lxe; i++) {
1872
1873 if ((nvert[k-1][j][i])<0.1) {
1874 FluxOut += (ucat[k-1][j][i].
x * (zet[k-1][j][i].
x) +
1875 ucat[k-1][j][i].y * (zet[k-1][j][i].y) +
1876 ucat[k-1][j][i].
z * (zet[k-1][j][i].
z));
1877
1878 lArea += sqrt( (zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1879 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1880 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1881
1882 }
1883 }
1884 }
1885 }
1886 else {
1887 FluxOut = 0.;
1888 }
1889
1890 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1891 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1892
1894
1896
1899
1900 }
1901
1905 else
1906 ratio = (FluxIn - simCtx->
FluxOutSum) / AreaSum;
1907
1909
1910
1912 FluxOut=0.0;
1913 if (ze==mz) {
1914 k = ze-1;
1915 for (j=lys; j<lye; j++) {
1916 for (i=lxs; i<lxe; i++) {
1917 if ((nvert[k-1][j][i])<0.1) {
1918
1919 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1920 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1921 ubcs[k][j][i].
z = ucat[k-1][j][i].
z;
1922
1923
1925 ucont[k-1][j][i].
z = (ubcs[k][j][i].
x * (zet[k-1][j][i].
x ) +
1926 ubcs[k][j][i].y * (zet[k-1][j][i].y ) +
1927 ubcs[k][j][i].
z * (zet[k-1][j][i].
z ))*ratio;
1928
1929 else{
1930 ucont[k-1][j][i].
z = (ubcs[k][j][i].
x * (zet[k-1][j][i].
x ) +
1931 ubcs[k][j][i].y * (zet[k-1][j][i].y ) +
1932 ubcs[k][j][i].
z * (zet[k-1][j][i].
z ))
1933 + ratio * sqrt( (zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1934 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1935 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1936
1937 FluxOut += ucont[k-1][j][i].
z;
1938 }
1939 }
1940 }
1941 }
1942 }
1943
1944 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1946
1947 }
else if (user->
bctype[5]==2) {
1948
1949
1950 if (ze==mz) {
1951 k = ze-1;
1952 for (j=lys; j<lye; j++) {
1953 for (i=lxs; i<lxe; i++) {
1954 ubcs[k][j][i].
x = 0.;
1955 ubcs[k][j][i].
y = 1;
1956 ubcs[k][j][i].
z = 0.;
1957 }
1958 }
1959 }
1960 }
1961
1962
1963
1965 lArea=0.;
1966 if (zs == 0) {
1967 k = zs;
1968
1969 FluxOut = 0;
1970 for (j=lys; j<lye; j++) {
1971 for (i=lxs; i<lxe; i++) {
1972
1973
1974 FluxOut += ucat[k+1][j][i].
z * zet[k][j][i].
z ;
1975
1976 lArea += zet[k][j][i].
z;
1977
1978
1979
1980 }
1981 }
1982 }
1983 else {
1984 FluxOut = 0.;
1985 }
1986
1987 FluxIn = simCtx->
FluxInSum + FarFluxInSum;
1988
1989 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1990 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1991
1992
1995
1996 if (zs==0) {
1997 k = 0;
1998 for (j=lys; j<lye; j++) {
1999 for (i=lxs; i<lxe; i++) {
2000
2001 ubcs[k][j][i].
x = ucat[k+1][j][i].
x;
2002 ubcs[k][j][i].
y = ucat[k+1][j][i].
y;
2003 ubcs[k][j][i].
z = ucat[k+1][j][i].
z;
2004 ucont[k][j][i].
z = (ubcs[k][j][i].
z+ratio) * zet[k][j][i].z;
2005 }
2006 }
2007 }
2008 }
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2086 Vec Coor; DMGetCoordinatesLocal(da, &Coor);
2087 DMDAVecGetArray(fda,Coor,&coor);
2089 DMDAVecGetArray(fda, user->
Bcs.
Uch, &uch);
2090
2091 lArea=0.0;
2092
2093
2094 FluxIn=0.0;
2095
2096 double Fluxbcs=0.0, Fluxbcssum,ratiobcs;
2097
2098 if (zs==0) {
2099 k=0;
2100 Fluxbcs=0.0;
2101 for (j=lys; j<lye; j++) {
2102 for (i=lxs; i<lxe; i++) {
2103 if (nvert[k][j][i]<0.1){
2104 Fluxbcs += ucont[k][j][i].
z;
2105
2106 lArea += sqrt((zet[k][j][i].x) * (zet[k][j][i].x) +
2107 (zet[k][j][i].y) * (zet[k][j][i].y) +
2108 (zet[k][j][i].z) * (zet[k][j][i].z));
2109 }
2110 }
2111 }
2112 }
2113
2114
2115
2116
2117 for (k=zs;k<lze;k++){
2118 for (j=lys; j<lye; j++) {
2119 for (i=lxs; i<lxe; i++) {
2120 if (nvert[k][j][i]<0.1){
2121 FluxIn += ucont[k][j][i].
z /((mz)-1);
2122 }
2123 }
2124 }
2125 }
2126
2127
2128
2129
2130 MPI_Allreduce(&FluxIn,&simCtx->
Fluxsum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
2131 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
2132 MPI_Allreduce(&Fluxbcs,&Fluxbcssum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
2133
2137
2139 }
2140
2143 simCtx->
ratio=ratio;
2144 ratiobcs=(simCtx->
FluxInSum-Fluxbcssum)/AreaSum;
2145
2146 if (zs==0) {
2147 k=0;
2148 for (j=lys; j<lye; j++) {
2149 for (i=lxs; i<lxe; i++) {
2150 if (nvert[k+1][j][i]<0.1){
2152 ucont[k][j][i].
z+=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
2153 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
2154 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
2155 }
2156
2157 uch[k][j][i].
z=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
2158 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
2159 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
2160 }
2161 }
2162 }
2163 }
2164
2165 if (ze==mz) {
2166 k=mz-1;
2167 for (j=lys; j<lye; j++) {
2168 for (i=lxs; i<lxe; i++) {
2169 if (nvert[k-1][j][i]<0.1){
2171 ucont[k-1][j][i].
z+=ratiobcs * sqrt((zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
2172 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
2173 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
2174 }
2175 uch[k][j][i].
z=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
2176 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
2177 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
2178 }
2179 }
2180 }
2181 }
2182 DMDAVecRestoreArray(fda, user->
Bcs.
Uch, &uch);
2184 DMDAVecRestoreArray(fda,Coor,&coor);
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216 }
2217
2218
2219
2220
2221
2222
2223 if (user->
bctype[3]==12) {
2224
2225
2226 if (ye==my) {
2227 j = ye-1;
2228 for (k=lzs; k<lze; k++) {
2229 for (i=lxs; i<lxe; i++) {
2230 ubcs[k][j][i].
x = 0.;
2231 ubcs[k][j][i].
y = 0.;
2232 ubcs[k][j][i].
z = 1.;
2233 }
2234 }
2235 }
2236 }
2237
2238
2239
2240
2241 DMDAVecGetArray(fda, user->
Cent, ¢);
2242 if (user->
bctype[2]==11) {
2243 if (ys==0){
2244 j=0;
2245 for (k=lzs; k<lze; k++) {
2246 for (i=lxs; i<lxe; i++) {
2247
2248
2249
2250
2251
2252
2253 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);;
2254 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);
2255 ubcs[k][j][i].
z =0.0;
2256
2257 }
2258 }
2259 }
2260 }
2261
2262
2263
2264
2265
2266 PetscOptionsGetReal(NULL,NULL,
"-simCtx->U_bc", &(simCtx->
U_bc), NULL);
2267
2268
2269 if (user->
bctype[2]==13){
2270 if (ys==0){
2271 j=0;
2272 for (k=lzs; k<lze; k++) {
2273 for (i=lxs; i<lxe; i++) {
2274 ubcs[k][j][i].
x = 0.;
2275
2276 ubcs[k][j][i].
y = 0.;
2277 ubcs[k][j][i].
z = -simCtx->
U_bc;
2278
2279 }
2280 }
2281 }
2282 }
2283 if (user->
bctype[3]==13){
2284 if (ye==my){
2285 j=ye-1;
2286 for (k=lzs; k<lze; k++) {
2287 for (i=lxs; i<lxe; i++) {
2288 ubcs[k][j][i].
x = 0.;
2289
2290 ubcs[k][j][i].
y = 0.;
2291 ubcs[k][j][i].
z = simCtx->
U_bc;
2292
2293 }
2294 }
2295 }
2296 }
2297
2298 if (user->
bctype[4]==13){
2299 if (zs==0){
2300 k=0;
2301 for (j=lys; j<lye; j++) {
2302 for (i=lxs; i<lxe; i++) {
2303 ubcs[k][j][i].
x =-simCtx->
U_bc;
2304 ubcs[k][j][i].
y = 0.;
2305 ubcs[k][j][i].
z = 0.;
2306 }
2307 }
2308 }
2309 }
2310 if (user->
bctype[5]==13){
2311 if (ze==mz){
2312 k=ze-1;
2313 for (j=lys; j<lye; j++) {
2314 for (i=lxs; i<lxe; i++) {
2315 ubcs[k][j][i].
x = simCtx->
U_bc;
2316 ubcs[k][j][i].
y = 0.;
2317 ubcs[k][j][i].
z = 0.;
2318 }
2319 }
2320 }
2321 }
2322 DMDAVecRestoreArray(fda, user->
Cent, ¢);
2323 DMDAVecRestoreArray(fda, user->
lUcat, &ucat);
2324 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2325 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2326 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2327 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2328
2329
2330
2332
2333
2334
2335
2336
2338 PetscReal ***ustar, ***aj;
2339
2341 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2342 DMDAVecGetArray(fda, user->
Ucont, &ucont);
2343 DMDAVecGetArray(da, Aj, &aj);
2344
2345 DMDAVecGetArray(da, user->
lUstar, &ustar);
2346
2347
2348 for (k=lzs; k<lze; k++)
2349 for (j=lys; j<lye; j++)
2350 for (i=lxs; i<lxe; i++) {
2351
2352 if( nvert[k][j][i]<1.1 && user->
bctype[2]==-1 && j==1 )
2353 {
2354 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 );
2355 double sb, sc;
2356 double ni[3], nj[3], nk[3];
2358
2359 Ua.
x = Ua.
y = Ua.
z = 0;
2360 sb = 0.5/aj[k][j][i]/area;
2361
2362
2363 sc = 2*sb + 0.5/aj[k][j+1][i]/area;
2364 Uc = ucat[k][j+1][i];
2365
2366
2367
2368
2369
2370 double AA=sqrt(eta[k][j][i].z*eta[k][j][i].z +
2371 eta[k][j][i].y*eta[k][j][i].y +
2372 eta[k][j][i].x*eta[k][j][i].x);
2373 nj[0]=eta[k][j][i].
x/AA;
2374 nj[1]=eta[k][j][i].
y/AA;
2375 nj[2]=eta[k][j][i].
z/AA;
2376 noslip (user, sc, sb, Ua, Uc, &ucat[k][j][i], nj[0], nj[1], nj[2]);
2377 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]);
2378
2379
2380
2381
2382
2383 }
2384 }
2385 if (ys==0) {
2386 j= ys;
2387
2388 for (k=lzs; k<lze; k++) {
2389 for (i=lxs; i<lxe; i++) {
2390 ubcs[k][j][i].
x = 0.0;
2391 ubcs[k][j][i].
y = 0.0;
2392 ubcs[k][j][i].
z = 0.0;
2393 ucont[k][j][i].
y = 0.;
2394 }
2395 }
2396 }
2397
2398 DMDAVecRestoreArray(da, Aj, &aj);
2399 DMDAVecRestoreArray(da, user->
lUstar, &ustar);
2400 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2401 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2402
2403
2404
2405
2406 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2407 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2408
2409
2410
2411
2412 }
2413
2414
2415
2416 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2417
2418
2419
2420
2421 if (xs==0 && user->
bctype[0]!=7) {
2422 i = xs;
2423 for (k=lzs; k<lze; k++) {
2424 for (j=lys; j<lye; j++) {
2425 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j][i+1].
x;
2426 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j][i+1].
y;
2427 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j][i+1].
z;
2428 }
2429 }
2430 }
2431
2432 if (xe==mx && user->
bctype[0]!=7) {
2433 i = xe-1;
2434 for (k=lzs; k<lze; k++) {
2435 for (j=lys; j<lye; j++) {
2436 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j][i-1].
x;
2437 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j][i-1].
y;
2438 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j][i-1].
z;
2439 }
2440 }
2441 }
2442
2443
2444 if (ys==0 && user->
bctype[2]!=7) {
2445 j = ys;
2446 for (k=lzs; k<lze; k++) {
2447 for (i=lxs; i<lxe; i++) {
2448 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j+1][i].
x;
2449 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j+1][i].
y;
2450 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j+1][i].
z;
2451 }
2452 }
2453 }
2454
2455 if (ye==my && user->
bctype[2]!=7) {
2456 j = ye-1;
2457 for (k=lzs; k<lze; k++) {
2458 for (i=lxs; i<lxe; i++) {
2459 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j-1][i].
x;
2460 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j-1][i].
y;
2461 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j-1][i].
z;
2462 }
2463 }
2464 }
2465
2466 if (zs==0 && user->
bctype[4]!=7) {
2467 k = zs;
2468 for (j=lys; j<lye; j++) {
2469 for (i=lxs; i<lxe; i++) {
2470 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k+1][j][i].
x;
2471 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k+1][j][i].
y;
2472 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k+1][j][i].
z;
2473 }
2474 }
2475 }
2476
2477 if (ze==mz && user->
bctype[4]!=7) {
2478 k = ze-1;
2479 for (j=lys; j<lye; j++) {
2480 for (i=lxs; i<lxe; i++) {
2481 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k-1][j][i].
x;
2482 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k-1][j][i].
y;
2483 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k-1][j][i].
z;
2484 }
2485 }
2486 }
2487
2488 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2489
2490
2491
2493 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2494 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2495 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2496 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2497
2498
2499
2500 DMDAVecGetArray(da, user->
lP, &lp);
2501 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2502 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2503 DMDAVecGetArray(da, user->
P, &p);
2504 DMDAVecGetArray(da, user->
Nvert, &nvert);
2505 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2506
2508 if (xs==0){
2509 i=xs;
2510 for (k=zs; k<ze; k++) {
2511 for (j=ys; j<ye; j++) {
2512 if(j>0 && k>0 && j<user->JM && k<user->KM){
2513 ucat[k][j][i]=lucat[k][j][i-2];
2514 p[k][j][i]=lp[k][j][i-2];
2515 nvert[k][j][i]=lnvert[k][j][i-2];
2516 }
2517 }
2518 }
2519 }
2520 }
2522 if (ys==0){
2523 j=ys;
2524 for (k=zs; k<ze; k++) {
2525 for (i=xs; i<xe; i++) {
2526 if(i>0 && k>0 && i<user->IM && k<user->KM){
2527 ucat[k][j][i]=lucat[k][j-2][i];
2528 p[k][j][i]=lp[k][j-2][i];
2529 nvert[k][j][i]=lnvert[k][j-2][i];
2530 }
2531 }
2532 }
2533 }
2534 }
2536 if (zs==0){
2537 k=zs;
2538 for (j=ys; j<ye; j++) {
2539 for (i=xs; i<xe; i++) {
2540 if(i>0 && j>0 && i<user->IM && j<user->JM){
2541 ucat[k][j][i]=lucat[k-2][j][i];
2542 nvert[k][j][i]=lnvert[k-2][j][i];
2543
2544 p[k][j][i]=lp[k-2][j][i];
2545 }
2546 }
2547 }
2548 }
2549 }
2551 if (xe==mx){
2552 i=mx-1;
2553 for (k=zs; k<ze; k++) {
2554 for (j=ys; j<ye; j++) {
2555 if(j>0 && k>0 && j<user->JM && k<user->KM){
2556 ucat[k][j][i]=lucat[k][j][i+2];
2557 p[k][j][i]=lp[k][j][i+2];
2558 nvert[k][j][i]=lnvert[k][j][i+2];
2559 }
2560 }
2561 }
2562 }
2563 }
2565 if (ye==my){
2566 j=my-1;
2567 for (k=zs; k<ze; k++) {
2568 for (i=xs; i<xe; i++) {
2569 if(i>0 && k>0 && i<user->IM && k<user->KM){
2570 ucat[k][j][i]=lucat[k][j+2][i];
2571 p[k][j][i]=lp[k][j+2][i];
2572 nvert[k][j][i]=lnvert[k][j+2][i];
2573 }
2574 }
2575 }
2576 }
2577 }
2578
2580 if (ze==mz){
2581 k=mz-1;
2582 for (j=ys; j<ye; j++) {
2583 for (i=xs; i<xe; i++) {
2584 if(i>0 && j>0 && i<user->IM && j<user->JM){
2585 ucat[k][j][i]=lucat[k+2][j][i];
2586 nvert[k][j][i]=lnvert[k+2][j][i];
2587
2588 p[k][j][i]=lp[k+2][j][i];
2589 }
2590 }
2591 }
2592 }
2593 }
2594
2595
2596
2597
2598
2599 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2600 DMDAVecRestoreArray(da, user->
lP, &lp);
2601 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2602 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2603 DMDAVecRestoreArray(da, user->
P, &p);
2604 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2616 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2617
2618 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2619 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2620
2621 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2622 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2623 }
2624
2625
2626 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2627 DMDAVecGetArray(da, user->
P, &p);
2628
2629 if (zs==0) {
2630 k=0;
2631 if (xs==0) {
2632 i=0;
2633 for (j=ys; j<ye; j++) {
2634 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j][i+1].
x);
2635 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j][i+1].
y);
2636 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j][i+1].
z);
2637 p[k][j][i]= 0.5*(p[k+1][j][i]+p[k][j][i+1]);
2638 }
2639 }
2640 if (xe == mx) {
2641 i=mx-1;
2642 for (j=ys; j<ye; j++) {
2643 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j][i-1].
x);
2644 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j][i-1].
y);
2645 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j][i-1].
z);
2646 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j][i-1]);
2647 }
2648 }
2649
2650 if (ys==0) {
2651 j=0;
2652 for (i=xs; i<xe; i++) {
2653 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j+1][i].
x);
2654 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j+1][i].
y);
2655 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j+1][i].
z);
2656 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j+1][i]);
2657 }
2658 }
2659
2660 if (ye==my) {
2661 j=my-1;
2662 for (i=xs; i<xe; i++) {
2663 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j-1][i].
x);
2664 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j-1][i].
y);
2665 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j-1][i].
z);
2666 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j-1][i]);
2667 }
2668 }
2669 }
2670
2671 if (ze==mz) {
2672 k=mz-1;
2673 if (xs==0) {
2674 i=0;
2675 for (j=ys; j<ye; j++) {
2676 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j][i+1].
x);
2677 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j][i+1].
y);
2678 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j][i+1].
z);
2679 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j][i+1]);
2680 }
2681 }
2682 if (xe == mx) {
2683 i=mx-1;
2684 for (j=ys; j<ye; j++) {
2685 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j][i-1].
x);
2686 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j][i-1].
y);
2687 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j][i-1].
z);
2688 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j][i-1]);
2689 }
2690 }
2691
2692 if (ys==0) {
2693 j=0;
2694 for (i=xs; i<xe; i++) {
2695 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j+1][i].
x);
2696 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j+1][i].
y);
2697 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j+1][i].
z);
2698 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j+1][i]);
2699 }
2700 }
2701
2702 if (ye==my) {
2703 j=my-1;
2704 for (i=xs; i<xe; i++) {
2705 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j-1][i].
x);
2706 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j-1][i].
y);
2707 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j-1][i].
z);
2708 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j-1][i]);
2709 }
2710 }
2711 }
2712
2713 if (ys==0) {
2714 j=0;
2715 if (xs==0) {
2716 i=0;
2717 for (k=zs; k<ze; k++) {
2718 ucat[k][j][i].
x = 0.5*(ucat[k][j+1][i].
x+ucat[k][j][i+1].
x);
2719 ucat[k][j][i].
y = 0.5*(ucat[k][j+1][i].
y+ucat[k][j][i+1].
y);
2720 ucat[k][j][i].
z = 0.5*(ucat[k][j+1][i].
z+ucat[k][j][i+1].
z);
2721 p[k][j][i]= 0.5*(p[k][j+1][i]+p[k][j][i+1]);
2722 }
2723 }
2724
2725 if (xe==mx) {
2726 i=mx-1;
2727 for (k=zs; k<ze; k++) {
2728 ucat[k][j][i].
x = 0.5*(ucat[k][j+1][i].
x+ucat[k][j][i-1].
x);
2729 ucat[k][j][i].
y = 0.5*(ucat[k][j+1][i].
y+ucat[k][j][i-1].
y);
2730 ucat[k][j][i].
z = 0.5*(ucat[k][j+1][i].
z+ucat[k][j][i-1].
z);
2731 p[k][j][i] = 0.5*(p[k][j+1][i]+p[k][j][i-1]);
2732 }
2733 }
2734 }
2735
2736 if (ye==my) {
2737 j=my-1;
2738 if (xs==0) {
2739 i=0;
2740 for (k=zs; k<ze; k++) {
2741 ucat[k][j][i].
x = 0.5*(ucat[k][j-1][i].
x+ucat[k][j][i+1].
x);
2742 ucat[k][j][i].
y = 0.5*(ucat[k][j-1][i].
y+ucat[k][j][i+1].
y);
2743 ucat[k][j][i].
z = 0.5*(ucat[k][j-1][i].
z+ucat[k][j][i+1].
z);
2744 p[k][j][i] = 0.5*(p[k][j-1][i]+p[k][j][i+1]);
2745 }
2746 }
2747
2748 if (xe==mx) {
2749 i=mx-1;
2750 for (k=zs; k<ze; k++) {
2751 ucat[k][j][i].
x = 0.5*(ucat[k][j-1][i].
x+ucat[k][j][i-1].
x);
2752 ucat[k][j][i].
y = 0.5*(ucat[k][j-1][i].
y+ucat[k][j][i-1].
y);
2753 ucat[k][j][i].
z = 0.5*(ucat[k][j-1][i].
z+ucat[k][j][i-1].
z);
2754 p[k][j][i] = 0.5*(p[k][j-1][i]+p[k][j][i-1]);
2755 }
2756 }
2757 }
2758
2759 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2760 DMDAVecRestoreArray(da, user->
P, &p);
2761
2762 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2763 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2764
2765 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2766 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2767
2768
2769
2770
2772
2773
2774 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2775 DMDAVecGetArray(da, user->
lP, &lp);
2776 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2777 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2778 DMDAVecGetArray(da, user->
P, &p);
2779 DMDAVecGetArray(da, user->
Nvert, &nvert);
2780
2782 if (xs==0){
2783 i=xs;
2784 for (k=zs; k<ze; k++) {
2785 for (j=ys; j<ye; j++) {
2786 ucat[k][j][i]=lucat[k][j][i-2];
2787 p[k][j][i]=lp[k][j][i-2];
2788 nvert[k][j][i]=lnvert[k][j][i-2];
2789 }
2790 }
2791 }
2792 }
2794 if (xe==mx){
2795 i=xe-1;
2796 for (k=zs; k<ze; k++) {
2797 for (j=ys; j<ye; j++) {
2798 ucat[k][j][i].
x=lucat[k][j][i+2].
x;
2799 p[k][j][i]=lp[k][j][i+2];
2800 nvert[k][j][i]=lnvert[k][j][i+2];
2801 }
2802 }
2803 }
2804 }
2805 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2806 DMDAVecRestoreArray(da, user->
lP, &lp);
2807 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2808 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2809 DMDAVecRestoreArray(da, user->
P, &p);
2810 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2822 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2823
2824 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2825 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2826
2827 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2828 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2829
2830
2831 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2832 DMDAVecGetArray(da, user->
lP, &lp);
2833 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2834 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2835 DMDAVecGetArray(da, user->
P, &p);
2836 DMDAVecGetArray(da, user->
Nvert, &nvert);
2837
2839 if (ys==0){
2840 j=ys;
2841 for (k=zs; k<ze; k++) {
2842 for (i=xs; i<xe; i++) {
2843 ucat[k][j][i]=lucat[k][j-2][i];
2844 p[k][j][i]=lp[k][j-2][i];
2845 nvert[k][j][i]=lnvert[k][j-2][i];
2846 }
2847 }
2848 }
2849 }
2850
2852 if (ye==my){
2853 j=my-1;
2854 for (k=zs; k<ze; k++) {
2855 for (i=xs; i<xe; i++) {
2856 ucat[k][j][i]=lucat[k][j+2][i];
2857 p[k][j][i]=lp[k][j+2][i];
2858 nvert[k][j][i]=lnvert[k][j+2][i];
2859 }
2860 }
2861 }
2862 }
2863
2864 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2865 DMDAVecRestoreArray(da, user->
lP, &lp);
2866 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2867 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2868 DMDAVecRestoreArray(da, user->
P, &p);
2869 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2881 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2882
2883 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2884 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2885
2886 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2887 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2888
2889
2890 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2891 DMDAVecGetArray(da, user->
lP, &lp);
2892 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2893 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2894 DMDAVecGetArray(da, user->
P, &p);
2895 DMDAVecGetArray(da, user->
Nvert, &nvert);
2896
2898 if (zs==0){
2899 k=zs;
2900 for (j=ys; j<ye; j++) {
2901 for (i=xs; i<xe; i++) {
2902 ucat[k][j][i]=lucat[k-2][j][i];
2903 nvert[k][j][i]=lnvert[k-2][j][i];
2904
2905 p[k][j][i]=lp[k-2][j][i];
2906 }
2907 }
2908 }
2909 }
2911 if (ze==mz){
2912 k=mz-1;
2913 for (j=ys; j<ye; j++) {
2914 for (i=xs; i<xe; i++) {
2915 ucat[k][j][i]=lucat[k+2][j][i];
2916 nvert[k][j][i]=lnvert[k+2][j][i];
2917 p[k][j][i]=lp[k+2][j][i];
2918 }
2919 }
2920 }
2921 }
2922
2923 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2924 DMDAVecRestoreArray(da, user->
lP, &lp);
2925 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2926 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2927 DMDAVecRestoreArray(da, user->
P, &p);
2928 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2940 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2941
2942 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2943 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2944
2945 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2946 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2947 }
2948
2949
2950
2951
2952 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2953 DMDAVecGetArray(fda, user->
Ucont, &ucont);
2954 DMDAVecGetArray(fda, user->
Cent, ¢);
2955 DMDAVecGetArray(fda, user->
Centx, ¢x);
2956 DMDAVecGetArray(fda, user->
Centy, ¢y);
2957 DMDAVecGetArray(fda, user->
Centz, ¢z);
2958
2959 if (user->
bctype[0]==9) {
2960 if (xs==0) {
2961 i= xs;
2962 for (k=lzs; k<lze; k++) {
2963 for (j=lys; j<lye; j++) {
2964 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);
2965 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);
2966 ucat[k][j][i].
z =0.0;
2967
2968 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);
2969 }
2970 }
2971 if (ys==0) {
2972 j=ys;
2973 for (k=lzs; k<lze; k++) {
2974 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);
2975 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);
2976 ucat[k][j][i].
z =0.0;
2977 }
2978 }
2979 if (ye==my) {
2980 j=ye-1;
2981 for (k=lzs; k<lze; k++) {
2982 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);
2983 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);
2984 ucat[k][j][i].
z =0.0;
2985 }
2986 }
2987 }
2988 }
2989 if (user->
bctype[1]==9) {
2990 if (xe==mx) {
2991 i= xe-1;
2992 for (k=lzs; k<lze; k++) {
2993 for (j=lys; j<lye; j++) {
2994 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);
2995 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);
2996 ucat[k][j][i].
z =0.0;
2997
2998 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);
2999 }
3000 }
3001 if (ys==0) {
3002 j=ys;
3003 for (k=lzs; k<lze; k++) {
3004 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);
3005 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);
3006 ucat[k][j][i].
z =0.0;
3007 }
3008 }
3009 if (ye==my) {
3010 j=ye-1;
3011 for (k=lzs; k<lze; k++) {
3012 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);
3013 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);
3014 ucat[k][j][i].
z =0.0;
3015 }
3016 }
3017 }
3018 }
3019
3020 if (user->
bctype[2]==9) {
3021 if (ys==0) {
3022 j= ys;
3023 for (k=lzs; k<lze; k++) {
3024 for (i=lxs; i<lxe; i++) {
3025 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);
3026 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);
3027 ucat[k][j][i].
z =0.0;
3028
3029 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);
3030 }
3031 }
3032 }
3033 }
3034
3035
3036 if (user->
bctype[3]==9) {
3037 if (ye==my) {
3038 j= ye-1;
3039 for (k=lzs; k<lze; k++) {
3040 for (i=lxs; i<lxe; i++) {
3041 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);
3042 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);
3043 ucat[k][j][i].
z =0.0;
3044
3045 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);
3046 }
3047 }
3048 }
3049 }
3050 if (user->
bctype[4]==9) {
3051 if (zs==0) {
3052 k= zs;
3053 for (j=ys; j<ye; j++) {
3054 for (i=xs; i<xe; i++) {
3055 ucat[k][j][i].
x=ucat[k+1][j][i].
x;
3056 ucat[k][j][i].
y=ucat[k+1][j][i].
y;
3057 ucat[k][j][i].
z=ucat[k+1][j][i].
z;
3058
3059 ucont[k][j][i].
z=0.0;
3060 }
3061 }
3062 }
3063 }
3064 if (user->
bctype[5]==9) {
3065 if (ze==mz) {
3066 k= ze-1;
3067 for (j=ys; j<ye; j++) {
3068 for (i=xs; i<xe; i++) {
3069 ucat[k][j][i].
x=ucat[k-1][j][i].
x;
3070 ucat[k][j][i].
y=ucat[k-1][j][i].
y;
3071 ucat[k][j][i].
z=ucat[k-1][j][i].
z;
3072
3073 ucont[k-1][j][i].
z=0.0;
3074 }
3075 }
3076 }
3077 }
3078
3079 DMDAVecRestoreArray(fda, user->
Cent, ¢);
3080 DMDAVecRestoreArray(fda, user->
Centx, ¢x);
3081 DMDAVecRestoreArray(fda, user->
Centy, ¢y);
3082 DMDAVecRestoreArray(fda, user->
Centz, ¢z);
3083
3084 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
3085 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
3086
3087 }
3088
3089
3090 DMDAVecRestoreArray(fda, user->
Bcs.
Ubcs, &ubcs);
3091 DMDAVecRestoreArray(fda, user->
lCsi, &csi);
3092 DMDAVecRestoreArray(fda, user->
lEta, &eta);
3093 DMDAVecRestoreArray(fda, user->
lZet, &zet);
3094
3095 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
3096 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
3097 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
3098 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
3099 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
3100 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
3101
3102 return(0);
3103 }
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)