402 DM swarm = user->
swarm;
404 PetscInt localNumParticles;
405 PetscReal *positions = NULL;
406 PetscInt64 *particleIDs = NULL;
407 PetscMPIInt *particleRanks = NULL;
408 PetscInt *cellIDs = NULL;
409 PetscReal *weights = NULL;
410 PetscReal *velocities = NULL;
413 ierr = MPI_Comm_rank(PETSC_COMM_WORLD, &rank); CHKERRQ(ierr);
416 ierr = DMSwarmGetLocalSize(swarm, &localNumParticles); CHKERRQ(ierr);
419 ierr = DMSwarmGetField(swarm,
"position", NULL, NULL, (
void**)&positions); CHKERRQ(ierr);
420 ierr = DMSwarmGetField(swarm,
"DMSwarm_pid", NULL, NULL, (
void**)&particleIDs); CHKERRQ(ierr);
421 ierr = DMSwarmGetField(swarm,
"DMSwarm_rank", NULL, NULL, (
void**)&particleRanks); CHKERRQ(ierr);
422 ierr = DMSwarmGetField(swarm,
"DMSwarm_CellID", NULL, NULL, (
void**)&cellIDs); CHKERRQ(ierr);
423 ierr = DMSwarmGetField(swarm,
"weight", NULL, NULL, (
void**)&weights); CHKERRQ(ierr);
424 ierr = DMSwarmGetField(swarm,
"velocity", NULL, NULL, (
void**)&velocities); CHKERRQ(ierr);
427 int wRank, wPID, wCell, wPos, wVel, wWt;
428 wRank = wPID = wCell = wPos = wVel = wWt = 0;
430 positions, velocities, weights,
431 &wRank, &wPID, &wCell, &wPos, &wVel, &wWt); CHKERRQ(ierr);
436 BuildHeaderString(headerFmt,
sizeof(headerFmt), wRank, wPID, wCell, wPos, wVel, wWt);
440 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"--------------------------------------------------------------------------------------------------------------\n"); CHKERRQ(ierr);
441 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"%s", headerFmt); CHKERRQ(ierr);
442 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"--------------------------------------------------------------------------------------------------------------\n"); CHKERRQ(ierr);
446 for (PetscInt i = 0; i < localNumParticles; i++) {
447 if (i % printInterval == 0) {
491 snprintf(rowStr,
sizeof(rowStr), rowFmt,
498 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"%s", rowStr); CHKERRQ(ierr);
503 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"--------------------------------------------------------------------------------------------------------------\n"); CHKERRQ(ierr);
504 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"\n"); CHKERRQ(ierr);
505 ierr = PetscSynchronizedFlush(PETSC_COMM_WORLD, PETSC_STDOUT); CHKERRQ(ierr);
510 ierr = DMSwarmRestoreField(swarm,
"position", NULL, NULL, (
void**)&positions); CHKERRQ(ierr);
511 ierr = DMSwarmRestoreField(swarm,
"DMSwarm_pid", NULL, NULL, (
void**)&particleIDs); CHKERRQ(ierr);
512 ierr = DMSwarmRestoreField(swarm,
"DMSwarm_rank", NULL, NULL, (
void**)&particleRanks); CHKERRQ(ierr);
513 ierr = DMSwarmRestoreField(swarm,
"DMSwarm_CellID", NULL, NULL, (
void**)&cellIDs); CHKERRQ(ierr);
514 ierr = DMSwarmRestoreField(swarm,
"weight", NULL, NULL, (
void**)&weights); CHKERRQ(ierr);
515 ierr = DMSwarmRestoreField(swarm,
"velocity", NULL, NULL, (
void**)&velocities); CHKERRQ(ierr);
1275 PetscErrorCode ierr;
1279 Vec fieldVec = NULL;
1282 char data_layout[20];
1284 PetscFunctionBeginUser;
1287 if (strcasecmp(fieldName,
"Ucat") == 0) {
1288 fieldVec = user->
Ucat; dm = user->
fda; dof = 3; strcpy(data_layout,
"Cell-Centered");
1289 }
else if (strcasecmp(fieldName,
"P") == 0) {
1290 fieldVec = user->
P; dm = user->
da; dof = 1; strcpy(data_layout,
"Cell-Centered");
1291 }
else if (strcasecmp(fieldName,
"Ucont") == 0) {
1292 fieldVec = user->
lUcont; dm = user->
fda; dof = 3; strcpy(data_layout,
"Face-Centered");
1293 }
else if (strcasecmp(fieldName,
"Coordinates") == 0) {
1294 ierr = DMGetCoordinates(user->
da, &fieldVec); CHKERRQ(ierr);
1295 dm = user->
fda; dof = 3; strcpy(data_layout,
"Node-Centered");
1296 }
else if (strcasecmp(fieldName,
"Psi") == 0) {
1297 fieldVec = user->
Psi; dm = user->
da; dof = 1; strcpy(data_layout,
"Cell-Centered");
1299 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE,
"Field %s not recognized.", fieldName);
1303 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
"Vector for field '%s' is NULL.", fieldName);
1306 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE,
"DM for field '%s' is NULL.", fieldName);
1309 ierr = DMDAGetLocalInfo(dm, &info); CHKERRQ(ierr);
1312 PetscInt i_start, i_end, j_start, j_end, k_start, k_end;
1314 if (strcmp(data_layout,
"Cell-Centered") == 0) {
1318 i_start = PetscMax(info.xs, 1); i_end = PetscMin(info.xs + info.xm, user->
IM);
1319 j_start = PetscMax(info.ys, 1); j_end = PetscMin(info.ys + info.ym, user->
JM);
1320 k_start = PetscMax(info.zs, 1); k_end = PetscMin(info.zs + info.zm, user->
KM);
1325 i_start = PetscMax(info.xs, 0); i_end = PetscMin(info.xs + info.xm, user->
IM);
1326 j_start = PetscMax(info.ys, 0); j_end = PetscMin(info.ys + info.ym, user->
JM);
1327 k_start = PetscMax(info.zs, 0); k_end = PetscMin(info.zs + info.zm, user->
KM);
1331 ierr = MPI_Barrier(PETSC_COMM_WORLD); CHKERRQ(ierr);
1333 PetscPrintf(PETSC_COMM_SELF,
"\n--- Field Ranges: [%s] (Layout: %s) ---\n", fieldName, data_layout);
1338 PetscReal localMin = PETSC_MAX_REAL, localMax = PETSC_MIN_REAL;
1339 PetscReal globalMin, globalMax;
1340 const PetscScalar ***array;
1342 ierr = DMDAVecGetArrayRead(dm, fieldVec, &array); CHKERRQ(ierr);
1343 for (k = k_start; k < k_end; k++) {
1344 for (j = j_start; j < j_end; j++) {
1345 for (i = i_start; i < i_end; i++) {
1346 localMin = PetscMin(localMin, array[k][j][i]);
1347 localMax = PetscMax(localMax, array[k][j][i]);
1351 ierr = DMDAVecRestoreArrayRead(dm, fieldVec, &array); CHKERRQ(ierr);
1353 ierr = MPI_Allreduce(&localMin, &globalMin, 1, MPIU_REAL, MPI_MIN, PETSC_COMM_WORLD); CHKERRQ(ierr);
1354 ierr = MPI_Allreduce(&localMax, &globalMax, 1, MPIU_REAL, MPI_MAX, PETSC_COMM_WORLD); CHKERRQ(ierr);
1356 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
" [Rank %d] Local Range: [ %11.4e , %11.4e ]\n", user->
simCtx->
rank, localMin, localMax);
1357 ierr = PetscSynchronizedFlush(PETSC_COMM_WORLD, PETSC_STDOUT); CHKERRQ(ierr);
1359 PetscPrintf(PETSC_COMM_SELF,
" Global Range: [ %11.4e , %11.4e ]\n", globalMin, globalMax);
1362 }
else if (dof == 3) {
1363 Cmpnts localMin = {PETSC_MAX_REAL, PETSC_MAX_REAL, PETSC_MAX_REAL};
1364 Cmpnts localMax = {PETSC_MIN_REAL, PETSC_MIN_REAL, PETSC_MIN_REAL};
1365 Cmpnts globalMin, globalMax;
1368 ierr = DMDAVecGetArrayRead(dm, fieldVec, &array); CHKERRQ(ierr);
1369 for (k = k_start; k < k_end; k++) {
1370 for (j = j_start; j < j_end; j++) {
1371 for (i = i_start; i < i_end; i++) {
1372 localMin.
x = PetscMin(localMin.
x, array[k][j][i].
x);
1373 localMin.
y = PetscMin(localMin.
y, array[k][j][i].
y);
1374 localMin.
z = PetscMin(localMin.
z, array[k][j][i].
z);
1375 localMax.
x = PetscMax(localMax.
x, array[k][j][i].
x);
1376 localMax.
y = PetscMax(localMax.
y, array[k][j][i].
y);
1377 localMax.
z = PetscMax(localMax.
z, array[k][j][i].
z);
1381 ierr = DMDAVecRestoreArrayRead(dm, fieldVec, &array); CHKERRQ(ierr);
1383 ierr = MPI_Allreduce(&localMin, &globalMin, 3, MPIU_REAL, MPI_MIN, PETSC_COMM_WORLD); CHKERRQ(ierr);
1384 ierr = MPI_Allreduce(&localMax, &globalMax, 3, MPIU_REAL, MPI_MAX, PETSC_COMM_WORLD); CHKERRQ(ierr);
1386 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
" [Rank %d] Local X-Range: [ %11.4e , %11.4e ]\n", user->
simCtx->
rank, localMin.
x, localMax.
x);
1387 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
" [Rank %d] Local Y-Range: [ %11.4e , %11.4e ]\n", user->
simCtx->
rank, localMin.
y, localMax.
y);
1388 ierr = PetscSynchronizedPrintf(PETSC_COMM_WORLD,
" [Rank %d] Local Z-Range: [ %11.4e , %11.4e ]\n", user->
simCtx->
rank, localMin.
z, localMax.
z);
1389 ierr = PetscSynchronizedFlush(PETSC_COMM_WORLD, PETSC_STDOUT); CHKERRQ(ierr);
1392 PetscPrintf(PETSC_COMM_SELF,
" [Global] X-Range: [ %11.4e , %11.4e ]\n", globalMin.
x, globalMax.
x);
1393 PetscPrintf(PETSC_COMM_SELF,
" [Global] Y-Range: [ %11.4e , %11.4e ]\n", globalMin.
y, globalMax.
y);
1394 PetscPrintf(PETSC_COMM_SELF,
" [Global] Z-Range: [ %11.4e , %11.4e ]\n", globalMin.
z, globalMax.
z);
1398 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
"LogFieldStatistics only supports fields with 1 or 3 components, but field '%s' has %D.", fieldName, dof);
1402 ierr = MPI_Barrier(PETSC_COMM_WORLD); CHKERRQ(ierr);
1404 PetscPrintf(PETSC_COMM_SELF,
"--------------------------------------------\n\n");
1407 PetscFunctionReturn(0);
1437 PetscErrorCode ierr;
1441 Vec vec_local = NULL;
1444 char data_layout[20];
1446 PetscFunctionBeginUser;
1447 ierr = MPI_Comm_rank(PETSC_COMM_WORLD, &rank); CHKERRQ(ierr);
1450 if (strcasecmp(field_name,
"Ucat") == 0) {
1451 vec_local = user->
lUcat; dm = user->
fda; dof = 3; strcpy(data_layout,
"Cell-Centered");
1452 }
else if (strcasecmp(field_name,
"P") == 0) {
1453 vec_local = user->
lP; dm = user->
da; dof = 1; strcpy(data_layout,
"Cell-Centered");
1454 }
else if (strcasecmp(field_name,
"Psi") == 0) {
1455 vec_local = user->
lPsi; dm = user->
da; dof = 1; strcpy(data_layout,
"Cell-Centered");
1456 }
else if (strcasecmp(field_name,
"Ucont") == 0) {
1457 vec_local = user->
lUcont; dm = user->
fda; dof = 3; strcpy(data_layout,
"Face-Centered");
1458 }
else if (strcasecmp(field_name,
"Coordinates") == 0) {
1459 ierr = DMGetCoordinatesLocal(user->
da, &vec_local); CHKERRQ(ierr);
1460 dm = user->
fda; dof = 3; strcpy(data_layout,
"Node-Centered");
1461 }
else if (strcasecmp(field_name,
"CornerField")== 0){
1462 vec_local = user->
lCellFieldAtCorner; dm = user->
fda; dof = 3; strcpy(data_layout,
"Node-Centered");
1464 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
"Unknown field name for LOG_FIELD_ANATOMY: %s", field_name);
1468 ierr = DMDAGetLocalInfo(dm, &info); CHKERRQ(ierr);
1471 ierr = PetscBarrier(NULL);
1472 PetscPrintf(PETSC_COMM_WORLD,
"\n--- Field Anatomy Log: [%s] | Stage: [%s] | Layout: [%s] ---\n", field_name, stage_name, data_layout);
1476 PetscInt im_phys = user->
IM;
1477 PetscInt jm_phys = user->
JM;
1478 PetscInt km_phys = user->
KM;
1480 PetscInt i_mid = (PetscInt)(info.xs + 0.5*info.xm);
1481 PetscInt j_mid = (PetscInt)(info.ys + 0.5*info.ym);
1482 PetscInt k_mid = (PetscInt)(info.zs + 0.5*info.zm);
1489 if (strcmp(data_layout,
"Cell-Centered") == 0) {
1491 ierr = DMDAVecGetArrayRead(dm, vec_local, (
void*)&l_arr); CHKERRQ(ierr);
1495 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Ghost for Cell 0) = ", rank, 0);
1496 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][j_mid][0]);
1497 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][j_mid][0].x, ((
const Cmpnts***)l_arr)[k_mid][j_mid][0].y, ((
const Cmpnts***)l_arr)[k_mid][j_mid][0].z);
1499 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Value for Cell 0) = ", rank, 1);
1500 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][j_mid][1]);
1501 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][j_mid][1].x, ((
const Cmpnts***)l_arr)[k_mid][j_mid][1].y, ((
const Cmpnts***)l_arr)[k_mid][j_mid][1].z);
1503 if (info.xs + info.xm == info.mx) {
1504 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Value for Cell %d) = ", rank, im_phys - 1, im_phys - 2);
1505 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][j_mid][im_phys - 1]);
1506 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][j_mid][im_phys - 1].x, ((
const Cmpnts***)l_arr)[k_mid][j_mid][im_phys - 1].y, ((
const Cmpnts***)l_arr)[k_mid][j_mid][im_phys - 1].z);
1508 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Ghost for Cell %d) = ", rank, im_phys, im_phys - 2);
1509 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][j_mid][im_phys]);
1510 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][j_mid][im_phys].x, ((
const Cmpnts***)l_arr)[k_mid][j_mid][im_phys].y, ((
const Cmpnts***)l_arr)[k_mid][j_mid][im_phys].z);
1515 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Ghost for Cell 0) = ", rank, 0);
1516 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][0][i_mid]);
1517 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][0][i_mid].x, ((
const Cmpnts***)l_arr)[k_mid][0][i_mid].y, ((
const Cmpnts***)l_arr)[k_mid][0][i_mid].z);
1519 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Value for Cell 0) = ", rank, 1);
1520 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][1][i_mid]);
1521 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][1][i_mid].x, ((
const Cmpnts***)l_arr)[k_mid][1][i_mid].y, ((
const Cmpnts***)l_arr)[k_mid][1][i_mid].z);
1524 if (info.ys + info.ym == info.my) {
1525 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Value for Cell %d) = ", rank, jm_phys - 1, jm_phys - 2);
1526 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][jm_phys - 1][i_mid]);
1527 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][jm_phys - 1][i_mid].x, ((
const Cmpnts***)l_arr)[k_mid][jm_phys - 1][i_mid].y, ((
const Cmpnts***)l_arr)[k_mid][jm_phys - 1][i_mid].z);
1529 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Ghost for Cell %d) = ", rank, jm_phys, jm_phys - 2);
1530 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[k_mid][jm_phys][i_mid]);
1531 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[k_mid][jm_phys][i_mid].x, ((
const Cmpnts***)l_arr)[k_mid][jm_phys][i_mid].y, ((
const Cmpnts***)l_arr)[k_mid][jm_phys][i_mid].z);
1536 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Ghost for Cell 0) = ", rank, 0);
1537 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[0][j_mid][i_mid]);
1538 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[0][j_mid][i_mid].x, ((
const Cmpnts***)l_arr)[0][j_mid][i_mid].y, ((
const Cmpnts***)l_arr)[0][j_mid][i_mid].z);
1539 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Value for Cell 0) = ", rank, 1);
1540 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[1][j_mid][i_mid]);
1541 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[1][j_mid][i_mid].x, ((
const Cmpnts***)l_arr)[1][j_mid][i_mid].y, ((
const Cmpnts***)l_arr)[1][j_mid][i_mid].z);
1543 if (info.zs + info.zm == info.mz) {
1544 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Value for Cell %d) = ", rank, km_phys - 1, km_phys - 2);
1545 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[km_phys - 1][j_mid][i_mid]);
1546 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[km_phys - 1][j_mid][i_mid].x, ((
const Cmpnts***)l_arr)[km_phys - 1][j_mid][i_mid].y, ((
const Cmpnts***)l_arr)[km_phys - 1][j_mid][i_mid].z);
1547 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Ghost for Cell %d) = ", rank, km_phys, km_phys - 2);
1548 if(dof==1) PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e)\n", ((
const PetscReal***)l_arr)[km_phys][j_mid][i_mid]);
1549 else PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"(%.3e, %.3e, %.3e)\n", ((
const Cmpnts***)l_arr)[km_phys][j_mid][i_mid].x, ((
const Cmpnts***)l_arr)[km_phys][j_mid][i_mid].y, ((
const Cmpnts***)l_arr)[km_phys][j_mid][i_mid].z);
1552 ierr = DMDAVecRestoreArrayRead(dm, vec_local, (
void*)&l_arr); CHKERRQ(ierr);
1557 else if (strcmp(data_layout,
"Face-Centered") == 0 || strcmp(data_layout,
"Node-Centered") == 0) {
1559 ierr = DMDAVecGetArrayRead(dm, vec_local, (
void*)&l_arr); CHKERRQ(ierr);
1563 if(strcmp(data_layout,
"Face-Centered")==0){
1564 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (First Physical Face) = (%.3e)\n", rank, 0,
1565 l_arr[k_mid][j_mid][0].x);
1566 }
else if(strcmp(data_layout,
"Node-Centered")==0){
1567 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (First Physical Face/Node) = (%.3e, %.3e, %.3e)\n", rank, 0,
1568 l_arr[k_mid][j_mid][0].x, l_arr[k_mid][j_mid][0].y, l_arr[k_mid][j_mid][0].z);
1571 if (info.xs + info.xm == info.mx) {
1572 if(strcmp(data_layout,
"Face-Centered")==0){
1573 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Last Physical Face) = (%.3e)\n", rank, im_phys - 1,
1574 l_arr[k_mid][j_mid][im_phys - 1].x);
1575 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Unused/Ghost Location) = (%.3e)\n", rank, im_phys,
1576 l_arr[k_mid][j_mid][im_phys].x);
1577 }
else if(strcmp(data_layout,
"Node-Centered")==0){
1578 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Last Physical Face/Node) = (%.3e, %.3e, %.3e)\n", rank, im_phys - 1,
1579 l_arr[k_mid][j_mid][im_phys - 1].x, l_arr[k_mid][j_mid][im_phys - 1].y, l_arr[k_mid][j_mid][im_phys - 1].z);
1581 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, I-DIR]: Idx %2d (Unused/Ghost Location) = (%.3e, %.3e, %.3e)\n", rank, im_phys,
1582 l_arr[k_mid][j_mid][im_phys].x, l_arr[k_mid][j_mid][im_phys].y, l_arr[k_mid][j_mid][im_phys].z);
1589 if(strcmp(data_layout,
"Face-Centered")==0){
1590 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (First Physical Face) = (%.3e)\n", rank, 0,
1591 l_arr[k_mid][0][i_mid].y);
1592 }
else if(strcmp(data_layout,
"Node-Centered")==0){
1593 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (First Physical Face/Node) = (%.3e, %.3e, %.3e)\n", rank, 0,
1594 l_arr[k_mid][0][i_mid].x, l_arr[k_mid][0][i_mid].y, l_arr[k_mid][0][i_mid].z);
1597 if (info.ys + info.ym == info.my) {
1598 if(strcmp(data_layout,
"Face-Centered")==0){
1599 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Last Physical Face) = (%.3e)\n", rank, jm_phys - 1,
1600 l_arr[k_mid][jm_phys - 1][i_mid].y);
1601 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Unused/Ghost Location) = (%.3e)\n", rank, jm_phys,
1602 l_arr[k_mid][jm_phys][i_mid].y);
1603 }
else if(strcmp(data_layout,
"Node-Centered")==0){
1604 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Last Physical Face/Node) = (%.3e, %.3e, %.3e)\n", rank, jm_phys - 1,
1605 l_arr[k_mid][jm_phys - 1][i_mid].x, l_arr[k_mid][jm_phys - 1][i_mid].y, l_arr[k_mid][jm_phys - 1][i_mid].z);
1607 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, J-DIR]: Idx %2d (Unused/Ghost Location) = (%.3e, %.3e, %.3e)\n", rank, jm_phys,
1608 l_arr[k_mid][jm_phys][i_mid].x, l_arr[k_mid][jm_phys][i_mid].y, l_arr[k_mid][jm_phys][i_mid].z);
1613 if(strcmp(data_layout,
"Face-Centered")==0){
1614 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (First Physical Face) = (%.3e)\n", rank, 0,
1615 l_arr[0][j_mid][i_mid].z);
1616 }
else if(strcmp(data_layout,
"Node-Centered")==0){
1617 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (First Physical Face/Node) = (%.3e, %.3e, %.3e)\n", rank, 0,
1618 l_arr[0][j_mid][i_mid].x, l_arr[0][j_mid][i_mid].y, l_arr[0][j_mid][i_mid].z);
1621 if(info.zs + info.zm == info.mz) {
1622 if(strcmp(data_layout,
"Face-Centered")==0){
1623 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Last Physical Face) = (%.3e)\n", rank, km_phys - 1,
1624 l_arr[km_phys - 1][j_mid][i_mid].z);
1625 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Unused/Ghost Location) = (%.3e)\n", rank, km_phys,
1626 l_arr[km_phys][j_mid][i_mid].z);
1627 }
else if(strcmp(data_layout,
"Node-Centered")==0){
1628 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Last Physical Face/Node) = (%.3e, %.3e, %.3e)\n", rank, km_phys - 1,
1629 l_arr[km_phys - 1][j_mid][i_mid].x, l_arr[km_phys - 1][j_mid][i_mid].y, l_arr[km_phys - 1][j_mid][i_mid].z);
1631 PetscSynchronizedPrintf(PETSC_COMM_WORLD,
"[Rank %d, K-DIR]: Idx %2d (Unused/Ghost Location) = (%.3e, %.3e, %.3e)\n", rank, km_phys,
1632 l_arr[km_phys][j_mid][i_mid].x, l_arr[km_phys][j_mid][i_mid].y, l_arr[km_phys][j_mid][i_mid].z);
1636 ierr = DMDAVecRestoreArrayRead(dm, vec_local, (
void*)&l_arr); CHKERRQ(ierr);
1639 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
"LOG_FIELD_ANATOMY only supports fields with 1 or 3 components & certain data-layouts, but field '%s' has %D components and an unsupported data-layout %s \n", field_name, dof,data_layout);
1641 ierr = PetscSynchronizedFlush(PETSC_COMM_WORLD, PETSC_STDOUT); CHKERRQ(ierr);
1642 ierr = PetscBarrier(NULL);
1643 PetscFunctionReturn(0);