Skip to content

Commit

Permalink
Fix misc-const-correctness. (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrood-nrel authored Jul 25, 2024
1 parent 7ee3fad commit d41b531
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 188 deletions.
54 changes: 28 additions & 26 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ void CartBlock::getInterpolatedData(
}

for (i = 0; i < listptr->nweights; i++) {
int cell_index = cart_utils::get_cell_index(
int const cell_index = cart_utils::get_cell_index(
dims[0], dims[1], nf, listptr->inode[3 * i],

Check warning on line 114 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result]
listptr->inode[3 * i + 1], listptr->inode[3 * i + 2]);
for (n = 0; n < nvar_cell; n++) {
weight = listptr->weights[i];
qq[n] += qcell[cell_index + ncell_nf * n] * weight;
}

int ind_offset = 3 * (listptr->nweights + i);
int node_index = cart_utils::get_node_index(
int const ind_offset = 3 * (listptr->nweights + i);
int const node_index = cart_utils::get_node_index(
dims[0], dims[1], nf, listptr->inode[ind_offset],
listptr->inode[ind_offset + 1],
listptr->inode[ind_offset + 2]);
Expand Down Expand Up @@ -265,7 +265,7 @@ void CartBlock::insertInInterpList(
nf, ix, dims, rst, &(listptr->nweights), listptr->inode,
listptr->weights, false);

int ind_offset = 3 * listptr->nweights;
int const ind_offset = 3 * listptr->nweights;
cart_interp::linear_interpolation(
nf, ix, dims, rst, &(listptr->nweights),
&(listptr->inode[ind_offset]),
Expand Down Expand Up @@ -367,9 +367,9 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
// set variables based on isNodal flag
int idof = isNodal ? (ncell - 1) : -1;
int* iblank = isNodal ? ibl_node : ibl_cell;
int nX = isNodal ? (dims[0] + 1) : dims[0];
int nY = isNodal ? (dims[1] + 1) : dims[1];
int nZ = isNodal ? (dims[2] + 1) : dims[2];
int const nX = isNodal ? (dims[0] + 1) : dims[0];
int const nY = isNodal ? (dims[1] + 1) : dims[1];
int const nZ = isNodal ? (dims[2] + 1) : dims[2];

//
// first mark hole points
Expand All @@ -395,7 +395,7 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
if (checkHoleMap(
xtmp, holemap[h].nx, holemap[h].sam,
holemap[h].extents) != 0) {
int ibindex =
int const ibindex =
isNodal
? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
Expand All @@ -412,7 +412,7 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
iflag[h] = 0;
}
while (temp != nullptr) {
int meshtagdonor = temp->donorData[1] - BASE;
int const meshtagdonor = temp->donorData[1] - BASE;
iflag[meshtagdonor] = 1;
temp = temp->next;
}
Expand All @@ -422,7 +422,7 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
if (checkHoleMap(
xtmp, holemap[h].nx, holemap[h].sam,
holemap[h].extents) != 0) {
int ibindex =
int const ibindex =
isNodal
? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
Expand All @@ -448,10 +448,11 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
for (int j = 0; j < nY; j++) {
for (int i = 0; i < nX; i++) {
idof++;
int ibindex = isNodal ? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
: cart_utils::get_cell_index(
dims[0], dims[1], nf, i, j, k);
int const ibindex = isNodal
? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
: cart_utils::get_cell_index(
dims[0], dims[1], nf, i, j, k);

if (iblank[ibindex] == 0) {
if (donorList[idof] != nullptr) {
Expand Down Expand Up @@ -530,9 +531,9 @@ void CartBlock::processIblank(
// set variables based on isNodal flag
int idof = isNodal ? (ncell - 1) : -1;
int* iblank = isNodal ? ibl_node : ibl_cell;
int nX = isNodal ? (dims[0] + 1) : dims[0];
int nY = isNodal ? (dims[1] + 1) : dims[1];
int nZ = isNodal ? (dims[2] + 1) : dims[2];
int const nX = isNodal ? (dims[0] + 1) : dims[0];
int const nY = isNodal ? (dims[1] + 1) : dims[1];
int const nZ = isNodal ? (dims[2] + 1) : dims[2];

//
// first mark hole points
Expand All @@ -555,10 +556,10 @@ void CartBlock::processIblank(
if (donorList[idof] == nullptr) {
for (int h = 0; h < nmesh; h++) {
if (holemap[h].existWall != 0u) {
int SB_val =
int const SB_val =
checkAdaptiveHoleMap(&xtmp[0], &holemap[h]);
if (SB_val != OUTSIDE_SB) {
int ibindex =
int const ibindex =
isNodal
? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
Expand All @@ -575,17 +576,17 @@ void CartBlock::processIblank(
iflag[h] = 0;
}
while (temp != nullptr) {
int meshtagdonor = temp->donorData[1] - BASE;
int const meshtagdonor = temp->donorData[1] - BASE;
iflag[meshtagdonor] = 1;
temp = temp->next;
}
for (int h = 0; h < nmesh; h++) {
if (holemap[h].existWall != 0u) {
if (iflag[h] == 0) {
int SB_val =
int const SB_val =
checkAdaptiveHoleMap(&xtmp[0], &holemap[h]);
if (SB_val != OUTSIDE_SB) {
int ibindex =
int const ibindex =
isNodal
? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
Expand All @@ -611,10 +612,11 @@ void CartBlock::processIblank(
for (int j = 0; j < nY; j++) {
for (int i = 0; i < nX; i++) {
idof++;
int ibindex = isNodal ? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
: cart_utils::get_cell_index(
dims[0], dims[1], nf, i, j, k);
int const ibindex = isNodal
? cart_utils::get_node_index(
dims[0], dims[1], nf, i, j, k)
: cart_utils::get_cell_index(
dims[0], dims[1], nf, i, j, k);

if (iblank[ibindex] == 0) {
if (donorList[idof] != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions src/CartGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ void CartGrid::create_mesh_info()
create_view(m_info->xlo, xlo, ngrids * 3);
create_view(m_info->dx, dx, ngrids * 3);

int iproc = myid;
int nplocal = std::accumulate(
int const iproc = myid;
int const nplocal = std::accumulate(
proc_id, proc_id + ngrids, 0,
[iproc](int x, int y) -> int { return x + ((iproc == y) ? 1 : 0); });

Expand Down
36 changes: 18 additions & 18 deletions src/MeshBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void MeshBlock::tagBoundary()
}
idx[j] = xd[j] / mapdx[j];
}
int indx =
int const indx =
idx[2] * mapdims[1] * mapdims[0] + idx[1] * mapdims[0] + idx[0];
iptr[i] = icft[indx + 1];
icft[indx + 1] = i;
Expand Down Expand Up @@ -1162,9 +1162,9 @@ void MeshBlock::writeBCnodes(char nodetype2tag, int bodyid)
i3 = 3 * ii;

// boundary point coordinates
double xc = x[i3 + 0];
double yc = x[i3 + 1];
double zc = x[i3 + 2];
double const xc = x[i3 + 0];
double const yc = x[i3 + 1];
double const zc = x[i3 + 2];

fprintf(fp, "%f %f %f\n", xc, yc, zc);
}
Expand Down Expand Up @@ -1200,7 +1200,7 @@ void MeshBlock::markBoundaryAdaptiveMap(
OCTANT_LEN(level->level_id); // integer length of octant

// set node type data
int nbc = (nodetype2tag == WALLNODETYPE) ? nwbc : nobc;
int const nbc = (nodetype2tag == WALLNODETYPE) ? nwbc : nobc;
int* bcnode = (nodetype2tag == WALLNODETYPE) ? wbcnode : obcnode;

// octree physical lengths
Expand Down Expand Up @@ -1238,7 +1238,7 @@ void MeshBlock::markBoundaryAdaptiveMap(
continue;
}

octant_full_t& oct = level->octants[j];
octant_full_t const& oct = level->octants[j];

/* check intersection */
// x octant bounds
Expand Down Expand Up @@ -1288,7 +1288,7 @@ void MeshBlock::markBoundaryAdaptiveMapSurfaceIntersect(
OCTANT_LEN(level->level_id); // integer length of octant

// set node type data
int nbcface = (nodetype2tag == WALLNODETYPE) ? nwbcface : nobcface;
int const nbcface = (nodetype2tag == WALLNODETYPE) ? nwbcface : nobcface;
std::vector<int>& bcfacenode =
(nodetype2tag == WALLNODETYPE) ? wbcfacenode : obcfacenode;
std::vector<box_t>& bcfacebox =
Expand Down Expand Up @@ -1323,7 +1323,7 @@ void MeshBlock::markBoundaryAdaptiveMapSurfaceIntersect(
}

// get octant since it hasn't been tagged
octant_full_t& oct = level->octants[j];
octant_full_t const& oct = level->octants[j];

// octant bounds: x
xlo[0] = extents_lo[0] + ds[0] * oct.x;
Expand All @@ -1346,7 +1346,7 @@ void MeshBlock::markBoundaryAdaptiveMapSurfaceIntersect(
for (i = 0; i < nbcface; i++) {

// box of face
box_t& box1 = bcfacebox[i];
box_t const& box1 = bcfacebox[i];

// test bounds of octant
if ((overlapping1D(box1.x, box2.x) != 0) &&
Expand Down Expand Up @@ -1406,7 +1406,7 @@ void MeshBlock::markBoundaryAdaptiveMapSurfaceIntersect(
const qcoord_t levelh = OCTANT_LEN(level_id); // integer length of octant

// set node type data
int nbcface = (nodetype2tag == WALLNODETYPE) ? nwbcface : nobcface;
int const nbcface = (nodetype2tag == WALLNODETYPE) ? nwbcface : nobcface;
std::vector<int>& bcfacenode =
(nodetype2tag == WALLNODETYPE) ? wbcfacenode : obcfacenode;
std::vector<box_t>& bcfacebox =
Expand Down Expand Up @@ -1441,7 +1441,7 @@ void MeshBlock::markBoundaryAdaptiveMapSurfaceIntersect(
}

// get octant since it hasn't been tagged
octant_coordinates_t& oct = octants[j];
octant_coordinates_t const& oct = octants[j];

// octant bounds: x
xlo[0] = extents_lo[0] + ds[0] * oct.x;
Expand All @@ -1464,7 +1464,7 @@ void MeshBlock::markBoundaryAdaptiveMapSurfaceIntersect(
for (i = 0; i < nbcface; i++) {

// box of face
box_t& box1 = bcfacebox[i];
box_t const& box1 = bcfacebox[i];

// test bounds of octant
if ((overlapping1D(box1.x, box2.x) != 0) &&
Expand Down Expand Up @@ -1870,7 +1870,7 @@ void MeshBlock::getQueryPoints2(
// MPI_Abort(MPI_COMM_WORLD,ierr);
//
#ifdef TIOGA_HAS_NODEGID
int nintsPerNode = 3;
int const nintsPerNode = 3;
#else
int nintsPerNode = 1;
#endif
Expand Down Expand Up @@ -2055,7 +2055,7 @@ void MeshBlock::check_for_uniform_hex()
return;
}
for (int n = 0; n < ntypes; n++) {
int nvert = nv[n];
int const nvert = nv[n];
if (nvert == 8) {
hex_present = 1;
for (int i = 0; i < nc[n]; i++) {
Expand All @@ -2065,7 +2065,7 @@ void MeshBlock::check_for_uniform_hex()
return; // degenerated hex are not uniform
}
vold = vconn[n][nvert * i + m];
int i3 = 3 * (vconn[n][nvert * i + m] - BASE);
int const i3 = 3 * (vconn[n][nvert * i + m] - BASE);
for (int k = 0; k < 3; k++) {
xv[m][k] = x[i3 + k];
}
Expand Down Expand Up @@ -2160,7 +2160,7 @@ void MeshBlock::check_for_uniform_hex()
xmin[0] = xmin[1] = xmin[2] = BIGVALUE;
//
for (int i = 0; i < nnodes; i++) {
int i3 = 3 * i;
int const i3 = 3 * i;
for (int j = 0; j < 3; j++) {
xd[j] = 0;
}
Expand Down Expand Up @@ -2223,8 +2223,8 @@ void MeshBlock::create_hex_cell_map()
double xd[3];
int idx[3];
for (int j = 0; j < 3; j++) {
int lnode = vconn[0][8 * i] - BASE;
int tnode = vconn[0][8 * i + 6] - BASE;
int const lnode = vconn[0][8 * i] - BASE;
int const tnode = vconn[0][8 * i + 6] - BASE;
xc[j] = 0.5 * (x[3 * lnode + j] + x[3 * tnode + j]);
}
for (int j = 0; j < 3; j++) {
Expand Down
9 changes: 5 additions & 4 deletions src/bookKeeping.C
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void MeshBlock::getMBDonorPktSizes(
{
for (int i = 0; i < nsearch; i++) {
if (donorId[i] > -1) {
int ii = isearch[3 * i];
int const ii = isearch[3 * i];
nints[ii] += 4;
nreals[ii] += 2;
}
Expand All @@ -93,7 +93,7 @@ void MeshBlock::getMBDonorPackets(
continue;
}

int k = isearch[3 * i];
int const k = isearch[3 * i];
int& ix = ixOffset[k];
int& rx = rxOffset[k];

Expand Down Expand Up @@ -405,7 +405,8 @@ void MeshBlock::processDonors(

for (j = 0; j < nmesh; j++) {
if (j != (meshtag - BASE) && (holemap[j].existWall != 0u)) {
int SB_val = checkAdaptiveHoleMap(&x[3 * i], &holemap[j]);
int const SB_val =
checkAdaptiveHoleMap(&x[3 * i], &holemap[j]);
if (SB_val != OUTSIDE_SB) {
iblank[i] = 0;
break;
Expand Down Expand Up @@ -442,7 +443,7 @@ void MeshBlock::processDonors(
if (iflag[j] == 0) {
// body{j} does NOT have candidate so check if point is
// INSIDE SB
int SB_val =
int const SB_val =
checkAdaptiveHoleMap(&x[3 * i], &holemap[j]);
if (SB_val != OUTSIDE_SB) {
iblank[i] = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/buildADTrecursion.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void buildADTrecursion(
int nav)
{

int nd = ndim / 2;
int const nd = ndim / 2;
double coordmid;
int i, j;
int dimcut;
Expand Down
4 changes: 2 additions & 2 deletions src/dataUpdate.C
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void MeshBlock::getDonorCount(int* dcount, int* fcount)
void MeshBlock::getDonorInfo(int* receptors, int* indices, double* frac)
{
int i, j, k, m;
int dcount = 0;
int const dcount = 0;

j = 0;
k = 0;
Expand Down Expand Up @@ -178,7 +178,7 @@ void MeshBlock::getReceptorInfo(int* receptors)
receptors[k++] = interpList[i].receptorInfo[1];
receptors[k++] = interpList[i].receptorInfo[2];

int donID = interpList[i].inode[interpList[i].nweights];
int const donID = interpList[i].inode[interpList[i].nweights];

// Copy the contents of uint64_t (8 bytes) into 2 4-byte locations in
// the array
Expand Down
2 changes: 1 addition & 1 deletion src/exchangeAMRDonors.C
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void tioga::exchangeAMRDonors()
for (j = 0; j < rcvPack[i].nints / 3; j++) {
ctype = rcvPack[i].intData[m++];
id = rcvPack[i].intData[m++];
int ib = rcvPack[i].intData[m++];
int const ib = rcvPack[i].intData[m++];
if (ctype == 0) {
mblocks[ib]->donorIdCart[id] = -1;
} else {
Expand Down
Loading

0 comments on commit d41b531

Please sign in to comment.