Skip to content

Commit

Permalink
static_cast<ptrdiff_t>
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu committed Dec 17, 2024
1 parent 6d9e109 commit 923fe25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <limits>
#include "TiogaMeshInfo.h"
#include "codetypes.h"
#include "CartBlock.h"
Expand All @@ -30,7 +32,6 @@
#include "linCartInterp.h"
#include "linklist.h"
#include "tioga_utils.h"
#include <limits>

void CartBlock::registerData(int lid, TIOGA::AMRMeshInfo* minfo)
{
Expand Down Expand Up @@ -112,7 +113,8 @@ void CartBlock::getInterpolatedData(

for (i = 0; i < listptr->nweights; i++) {
int const cell_index = (cart_utils::get_cell_index(
dims[0], dims[1], nf, listptr->inode[3 * i],
dims[0], dims[1], nf,
listptr->inode[static_cast<ptrdiff_t>(3 * i)],
listptr->inode[(3 * i) + 1], listptr->inode[(3 * i) + 2]));
for (n = 0; n < nvar_cell; n++) {
weight = listptr->weights[i];
Expand Down Expand Up @@ -169,7 +171,8 @@ void CartBlock::preprocess(CartGrid* cg)
for (int n = 0; n < 3; n++) {
dx[n] = cg->dx[(3 * global_id) + n];
}
dims[0] = cg->ihi[3 * global_id] - cg->ilo[3 * global_id] + 1;
dims[0] = cg->ihi[static_cast<ptrdiff_t>(3 * global_id)] -
cg->ilo[static_cast<ptrdiff_t>(3 * global_id)] + 1;
dims[1] = cg->ihi[(3 * global_id) + 1] - cg->ilo[(3 * global_id) + 1] + 1;
dims[2] = cg->ihi[(3 * global_id) + 2] - cg->ilo[(3 * global_id) + 2] + 1;
nf = cg->nf;
Expand Down
11 changes: 7 additions & 4 deletions src/CartGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cmath>
#include <numeric>
#include <limits>
#include <cstddef>

#include "tioga_gpu.h"
#include "TiogaMeshInfo.h"
Expand Down Expand Up @@ -221,17 +222,19 @@ void CartGrid::search(double* x, int* donorid, int npts)
}
}
}
if (myid == 2 && abs(x[3 * i] - 0.739573) < 1e-5 &&
if (myid == 2 &&
abs(x[static_cast<ptrdiff_t>(3 * i)] - 0.739573) < 1e-5 &&
abs(x[(3 * i) + 1] + 0.259310) < 1e-5 &&
abs(x[(3 * i) + 2] + 0.639614) < 1e-5) {
printf(
"%d %d %f %f %f %d\n", myid, i, x[3 * i], x[(3 * i) + 1],
"%d %d %f %f %f %d\n", myid, i,
x[static_cast<ptrdiff_t>(3 * i)], x[(3 * i) + 1],
x[(3 * i) + 2], donorid[i]);
}
if (donorid[i] == -1) {
printf(
"%d %f %f %f\n", myid, x[3 * i], x[(3 * i) + 1],
x[(3 * i) + 2]);
"%d %f %f %f\n", myid, x[static_cast<ptrdiff_t>(3 * i)],
x[(3 * i) + 1], x[(3 * i) + 2]);
}
}
// printf("CartGrid::search Processor %d located %d of %d
Expand Down
9 changes: 6 additions & 3 deletions src/MeshBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,8 @@ void MeshBlock::writeFlowFile(int bid, double* q, int nvar, int type)
for (i = 0; i < nc[n]; i++) {
if (nvert == 4) {
fprintf(
fp, "%d %d %d %d %d %d %d %d\n", vconn[n][nvert * i] + ba,
fp, "%d %d %d %d %d %d %d %d\n",
vconn[n][static_cast<ptrdiff_t>(nvert * i)] + ba,
vconn[n][(nvert * i) + 1] + ba,
vconn[n][(nvert * i) + 2] + ba,
vconn[n][(nvert * i) + 2] + ba,
Expand All @@ -1008,7 +1009,8 @@ void MeshBlock::writeFlowFile(int bid, double* q, int nvar, int type)
vconn[n][(nvert * i) + 4] + ba);
} else if (nvert == 6) {
fprintf(
fp, "%d %d %d %d %d %d %d %d\n", vconn[n][nvert * i] + ba,
fp, "%d %d %d %d %d %d %d %d\n",
vconn[n][static_cast<ptrdiff_t>(nvert * i)] + ba,
vconn[n][(nvert * i) + 1] + ba,
vconn[n][(nvert * i) + 2] + ba,
vconn[n][(nvert * i) + 2] + ba,
Expand All @@ -1018,7 +1020,8 @@ void MeshBlock::writeFlowFile(int bid, double* q, int nvar, int type)
vconn[n][(nvert * i) + 5] + ba);
} else if (nvert == 8) {
fprintf(
fp, "%d %d %d %d %d %d %d %d\n", vconn[n][nvert * i] + ba,
fp, "%d %d %d %d %d %d %d %d\n",
vconn[n][static_cast<ptrdiff_t>(nvert * i)] + ba,
vconn[n][(nvert * i) + 1] + ba,
vconn[n][(nvert * i) + 2] + ba,
vconn[n][(nvert * i) + 3] + ba,
Expand Down

0 comments on commit 923fe25

Please sign in to comment.