From d41b531d9019a04dd907b24bf4af41c354f025fd Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 25 Jul 2024 14:24:01 -0600 Subject: [PATCH] Fix misc-const-correctness. (#47) --- src/CartBlock.C | 54 ++++++++++++++++---------------- src/CartGrid.C | 4 +-- src/MeshBlock.C | 36 +++++++++++----------- src/bookKeeping.C | 9 +++--- src/buildADTrecursion.C | 2 +- src/dataUpdate.C | 4 +-- src/exchangeAMRDonors.C | 2 +- src/exchangeBoxes.C | 40 ++++++++++++------------ src/exchangeDonors.C | 40 ++++++++++++------------ src/exchangeSearchData.C | 22 +++++++------- src/getCartReceptors.C | 10 +++--- src/holeMap.C | 22 +++++++------- src/linCartInterp.C | 6 ++-- src/parallelComm.C | 16 +++++----- src/search.C | 2 +- src/tioga.C | 66 ++++++++++++++++++++-------------------- src/tioga.h | 6 ++-- src/tiogaInterface.C | 6 ++-- src/tioga_math.C | 2 +- src/tioga_utils.C | 26 ++++++++-------- src/tioga_utils.h | 6 ++-- 21 files changed, 193 insertions(+), 188 deletions(-) diff --git a/src/CartBlock.C b/src/CartBlock.C index 2fec289..0219a5b 100644 --- a/src/CartBlock.C +++ b/src/CartBlock.C @@ -110,7 +110,7 @@ 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], listptr->inode[3 * i + 1], listptr->inode[3 * i + 2]); for (n = 0; n < nvar_cell; n++) { @@ -118,8 +118,8 @@ void CartBlock::getInterpolatedData( 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]); @@ -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]), @@ -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 @@ -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) @@ -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; } @@ -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) @@ -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) { @@ -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 @@ -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) @@ -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) @@ -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) { diff --git a/src/CartGrid.C b/src/CartGrid.C index 85eeed2..b2545e5 100644 --- a/src/CartGrid.C +++ b/src/CartGrid.C @@ -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); }); diff --git a/src/MeshBlock.C b/src/MeshBlock.C index 3b508c3..8209c0d 100644 --- a/src/MeshBlock.C +++ b/src/MeshBlock.C @@ -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; @@ -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); } @@ -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 @@ -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 @@ -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& bcfacenode = (nodetype2tag == WALLNODETYPE) ? wbcfacenode : obcfacenode; std::vector& bcfacebox = @@ -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; @@ -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) && @@ -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& bcfacenode = (nodetype2tag == WALLNODETYPE) ? wbcfacenode : obcfacenode; std::vector& bcfacebox = @@ -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; @@ -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) && @@ -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 @@ -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++) { @@ -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]; } @@ -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; } @@ -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++) { diff --git a/src/bookKeeping.C b/src/bookKeeping.C index 6df5eb7..74ef0af 100644 --- a/src/bookKeeping.C +++ b/src/bookKeeping.C @@ -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; } @@ -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]; @@ -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; @@ -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; diff --git a/src/buildADTrecursion.C b/src/buildADTrecursion.C index fd40c00..8fb4aaa 100644 --- a/src/buildADTrecursion.C +++ b/src/buildADTrecursion.C @@ -36,7 +36,7 @@ void buildADTrecursion( int nav) { - int nd = ndim / 2; + int const nd = ndim / 2; double coordmid; int i, j; int dimcut; diff --git a/src/dataUpdate.C b/src/dataUpdate.C index 0f80003..3ae11ba 100644 --- a/src/dataUpdate.C +++ b/src/dataUpdate.C @@ -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; @@ -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 diff --git a/src/exchangeAMRDonors.C b/src/exchangeAMRDonors.C index f8e4499..3c130d1 100644 --- a/src/exchangeAMRDonors.C +++ b/src/exchangeAMRDonors.C @@ -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 { diff --git a/src/exchangeBoxes.C b/src/exchangeBoxes.C index 354f67a..dbb09ad 100644 --- a/src/exchangeBoxes.C +++ b/src/exchangeBoxes.C @@ -47,7 +47,8 @@ void tioga::exchangeBoxes() MPI_Allgather(&nblocks, 1, MPI_INT, nbPerProc.data(), 1, MPI_INT, scomm); // Total number mesh chunks across all procs - int ntotalblks = std::accumulate(nbPerProc.begin(), nbPerProc.end(), 0); + int const ntotalblks = + std::accumulate(nbPerProc.begin(), nbPerProc.end(), 0); std::vector alltags( ntotalblks); // Mesh tags for all blocks across all procs @@ -71,12 +72,12 @@ void tioga::exchangeBoxes() int maxtag = -1; // for (auto itag: alltags) for (int i = 0; i < ntotalblks; i++) { - int itag = abs(alltags[i]); + int const itag = abs(alltags[i]); if (maxtag < itag) { maxtag = itag; } } - int mxtgsqr = maxtag * maxtag; + int const mxtgsqr = maxtag * maxtag; displs[0] = 0; for (int i = 1; i <= numprocs; i++) { @@ -107,7 +108,7 @@ void tioga::exchangeBoxes() obSizePerProc.data(), displs.data(), MPI_DOUBLE, scomm); // Determine total number of OBBs received - int nobb = ntotalblks; + int const nobb = ntotalblks; // Store all received OBBs in a temporary list std::vector obbRecv(nobb); @@ -151,7 +152,7 @@ void tioga::exchangeBoxes() for (int ob = 0; ob < nobb; ob++) { for (int ib = 0; ib < nblocks; ib++) { auto& mb = mblocks[ib]; - int meshtag = mb->getMeshTag(); + int const meshtag = mb->getMeshTag(); if (abs(obbID[ob]) == meshtag) { continue; } @@ -177,7 +178,7 @@ void tioga::exchangeBoxes() } } } - int new_send = std::count(sendFlag.begin(), sendFlag.end(), true); + int const new_send = std::count(sendFlag.begin(), sendFlag.end(), true); assert(new_send <= nsend); // Populate send and recv maps std::map invMap; @@ -227,17 +228,18 @@ void tioga::exchangeBoxes() std::vector idxOffset(nsend, 0); for (size_t i = 0; i < intersectIDs.size(); i++) { auto ids = intersectIDs[i]; - int ib = ids.first; // Block ID of the local mesh block - int ob = ids.second; // Index of the intersected block in OBB list - int k = invMap[obbProc[ob]]; // Index in sndMap for this proc ID - auto& mb = mblocks[ib]; // Mesh block data object - int ip = obbProc[ob]; - - int ioff = idxOffset[k]; // Index to fill in sndPack - int roff = idxOffset[k] * 6; - - int key_recv = mxtgsqr * ip + maxtag * (mtags[ib] - 1) + obbID[ob] - 1; - int key_send = + int const ib = ids.first; // Block ID of the local mesh block + int const ob = ids.second; // Index of the intersected block in OBB list + int const k = invMap[obbProc[ob]]; // Index in sndMap for this proc ID + auto& mb = mblocks[ib]; // Mesh block data object + int const ip = obbProc[ob]; + + int const ioff = idxOffset[k]; // Index to fill in sndPack + int const roff = idxOffset[k] * 6; + + int const key_recv = + mxtgsqr * ip + maxtag * (mtags[ib] - 1) + obbID[ob] - 1; + int const key_send = mxtgsqr * myid + maxtag * (obbID[ob] - 1) + (mtags[ib] - 1); intBoxMap[key_recv] = i; ibProcMap[k][ioff] = i; @@ -272,8 +274,8 @@ void tioga::exchangeBoxes() int m = 0; for (int n = 0; n < rcvPack[k].nints; n += 3) { - int key = rcvPack[k].intData[n]; - int ii = intBoxMap[key]; + int const key = rcvPack[k].intData[n]; + int const ii = intBoxMap[key]; obblist[ii].iblk_remote = rcvPack[k].intData[n + 1]; obblist[ii].tag_remote = rcvPack[k].intData[n + 2]; diff --git a/src/exchangeDonors.C b/src/exchangeDonors.C index 57740da..479373a 100644 --- a/src/exchangeDonors.C +++ b/src/exchangeDonors.C @@ -90,12 +90,12 @@ void tioga::exchangeDonors() int m = 0; int l = 0; for (int i = 0; i < rcvPack[k].nints / 4; i++) { - int meshtag = rcvPack[k].intData[m++]; - int pointid = rcvPack[k].intData[m++]; - int remoteid = rcvPack[k].intData[m++]; - int ib = rcvPack[k].intData[m++]; - double donorRes = rcvPack[k].realData[l++]; - double receptorRes = rcvPack[k].realData[l++]; + int const meshtag = rcvPack[k].intData[m++]; + int const pointid = rcvPack[k].intData[m++]; + int const remoteid = rcvPack[k].intData[m++]; + int const ib = rcvPack[k].intData[m++]; + double const donorRes = rcvPack[k].realData[l++]; + double const receptorRes = rcvPack[k].realData[l++]; auto& mb = mblocks[ib]; mb->insertAndSort( pointid, k, meshtag, remoteid, donorRes, receptorRes); @@ -139,7 +139,7 @@ void tioga::exchangeDonors() for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].nints += 2; sndPack[k].nreals++; } @@ -153,7 +153,7 @@ void tioga::exchangeDonors() for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 1]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 2]; sndPack[k].realData[rxOffset[k]++] = receptorResolution[n][i]; @@ -170,7 +170,7 @@ void tioga::exchangeDonors() int m = 0; for (int j = 0; j < rcvPack[k].nints / 2; j++) { m++; // skip over point id - int ib = tag_iblk_map[rcvPack[k].intData[m++]]; + int const ib = tag_iblk_map[rcvPack[k].intData[m++]]; ninterp[ib]++; } } @@ -185,9 +185,9 @@ void tioga::exchangeDonors() int l = 0; int m = 0; for (int j = 0; j < rcvPack[k].nints / 2; j++) { - int recid = rcvPack[k].intData[m++]; - int ib = tag_iblk_map[rcvPack[k].intData[m++]]; - double receptorRes = rcvPack[k].realData[l++]; + int const recid = rcvPack[k].intData[m++]; + int const ib = tag_iblk_map[rcvPack[k].intData[m++]]; + double const receptorRes = rcvPack[k].realData[l++]; mblocks[ib]->findInterpData(&(ninterp[ib]), recid, receptorRes); } } @@ -213,7 +213,7 @@ void tioga::exchangeDonors() for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].nints += 2; } } @@ -223,7 +223,7 @@ void tioga::exchangeDonors() for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 1]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 2]; } @@ -236,8 +236,8 @@ void tioga::exchangeDonors() for (int k = 0; k < nrecv; k++) { int m = 0; for (int j = 0; j < rcvPack[k].nints / 2; j++) { - int recid = rcvPack[k].intData[m++]; - int ib = tag_iblk_map[rcvPack[k].intData[m++]]; + int const recid = rcvPack[k].intData[m++]; + int const ib = tag_iblk_map[rcvPack[k].intData[m++]]; mblocks[ib]->cancelDonor(recid); } } @@ -264,7 +264,7 @@ void tioga::exchangeDonors() std::fill(ixOffset.begin(), ixOffset.end(), 0); for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].nints += 2; } } @@ -273,7 +273,7 @@ void tioga::exchangeDonors() } for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 1]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 2]; } @@ -291,8 +291,8 @@ void tioga::exchangeDonors() for (int k = 0; k < nrecv; k++) { int m = 0; for (int j = 0; j < rcvPack[k].nints / 2; j++) { - int pointid = rcvPack[k].intData[m++]; - int ib = rcvPack[k].intData[m++]; + int const pointid = rcvPack[k].intData[m++]; + int const ib = rcvPack[k].intData[m++]; mblocks[ib]->setIblanks(pointid); } } diff --git a/src/exchangeSearchData.C b/src/exchangeSearchData.C index 195c5ac..ed66c5c 100644 --- a/src/exchangeSearchData.C +++ b/src/exchangeSearchData.C @@ -60,14 +60,14 @@ void tioga::exchangeSearchData(int at_points) // Process each intersection pair and determine the total data that needs to // be sent - int nobb = obblist.size(); + int const nobb = obblist.size(); std::vector nintsSend(nobb); std::vector nrealsSend(nobb); int** int_data = (int**)malloc(sizeof(int*) * nobb); double** real_data = (double**)malloc(sizeof(double*) * nobb); for (int ii = 0; ii < nobb; ii++) { - int ib = obblist[ii].iblk_local; + int const ib = obblist[ii].iblk_local; auto& mb = mblocks[ib]; if (at_points == 0) { mb->getQueryPoints2( @@ -86,7 +86,7 @@ void tioga::exchangeSearchData(int at_points) sndPack[k].nreals = 0; for (int i = 0; i < ibsPerProc[k]; i++) { - int ii = ibProcMap[k][i]; + int const ii = ibProcMap[k][i]; sndPack[k].nints += nintsSend[ii]; sndPack[k].nreals += nrealsSend[ii]; @@ -99,7 +99,7 @@ void tioga::exchangeSearchData(int at_points) int m = 0; for (int i = 0; i < ibsPerProc[k]; i++) { - int ii = ibProcMap[k][i]; + int const ii = ibProcMap[k][i]; sndPack[k].intData[n++] = obblist[ii].send_tag; sndPack[k].intData[n++] = nintsSend[ii]; @@ -153,7 +153,7 @@ void tioga::exchangeSearchData(int at_points) } #ifdef TIOGA_HAS_NODEGID - int nintsPerNode = 3; + int const nintsPerNode = 3; #else int nintsPerNode = 1; #endif @@ -166,9 +166,9 @@ void tioga::exchangeSearchData(int at_points) int m = 0; for (int i = 0; i < ibsPerProc[k]; i++) { - int key = rcvPack[k].intData[m++]; - int ii = intBoxMap[key]; - int ib = obblist[ii].iblk_local; + int const key = rcvPack[k].intData[m++]; + int const ii = intBoxMap[key]; + int const ib = obblist[ii].iblk_local; auto& mb = mblocks[ib]; nintsRecv[ii] = rcvPack[k].intData[m++]; @@ -217,9 +217,9 @@ void tioga::exchangeSearchData(int at_points) int m = 0; for (int i = 0; i < ibsPerProc[k]; i++) { - int key = rcvPack[k].intData[m++]; - int ii = intBoxMap[key]; - int ib = obblist[ii].iblk_local; + int const key = rcvPack[k].intData[m++]; + int const ii = intBoxMap[key]; + int const ib = obblist[ii].iblk_local; auto& mb = mblocks[ib]; int ioff = icOffset[ib]; diff --git a/src/getCartReceptors.C b/src/getCartReceptors.C index 398c2f2..2d9cfac 100644 --- a/src/getCartReceptors.C +++ b/src/getCartReceptors.C @@ -61,11 +61,11 @@ void MeshBlock::getCartReceptors(CartGrid* cg, parallelComm* pc) nsearch = 0; // for (int c = 0; c < cg->ngrids; c++) { - int cell_count = (cg->dims[3 * c] + 2 * cg->nf) * - (cg->dims[3 * c + 1] + 2 * cg->nf) * - (cg->dims[3 * c + 2] + 2 * cg->nf); + int const cell_count = (cg->dims[3 * c] + 2 * cg->nf) * + (cg->dims[3 * c + 1] + 2 * cg->nf) * + (cg->dims[3 * c + 2] + 2 * cg->nf); - int vol = cg->dx[3 * c] * cg->dx[3 * c + 1] * cg->dx[3 * c + 2]; + int const vol = cg->dx[3 * c] * cg->dx[3 * c + 1] * cg->dx[3 * c + 2]; for (int n = 0; n < 3; n++) { obcart->dxc[n] = cg->dx[3 * c + n] * (cg->dims[3 * c + n]) * 0.5; @@ -115,7 +115,7 @@ void MeshBlock::getCartReceptors(CartGrid* cg, parallelComm* pc) nsend++; } } - int nrecv = nsend; + int const nrecv = nsend; int* sndMap = (int*)malloc(sizeof(int) * nsend); int* rcvMap = (int*)malloc(sizeof(int) * nrecv); int m = 0; diff --git a/src/holeMap.C b/src/holeMap.C index 978f8d5..7c11d5c 100644 --- a/src/holeMap.C +++ b/src/holeMap.C @@ -228,7 +228,7 @@ void tioga::getAdaptiveHoleMap() maxtagLocal = -BIGINT; for (mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int mbtag = mb->getMeshTag(); + int const mbtag = mb->getMeshTag(); maxtagLocal = (maxtagLocal < mbtag) ? mbtag : maxtagLocal; } MPI_Allreduce(&maxtagLocal, &maxtag, 1, MPI_INT, MPI_MAX, scomm); @@ -427,7 +427,7 @@ void tioga::getAdaptiveHoleMap() nrefine++; } } - int nchildren = OCTANT_CHILDREN * nrefine; + int const nchildren = OCTANT_CHILDREN * nrefine; // allocate and fill next level level_id++; @@ -448,7 +448,7 @@ void tioga::getAdaptiveHoleMap() nrefine = 0; for (i = 0; i < lvl->elem_count; i++) { if (refineFlag[i] != 0) { - uint32_t newidx = OCTANT_CHILDREN * nrefine; + uint32_t const newidx = OCTANT_CHILDREN * nrefine; // set Morton code and filltype for new octants octant_children( @@ -470,7 +470,7 @@ void tioga::getAdaptiveHoleMap() nrefine = 0; for (i = 0; i < lvl->elem_count; i++) { if (refineFlag[i] != 0) { - int newidx = OCTANT_CHILDREN * nrefine; + int const newidx = OCTANT_CHILDREN * nrefine; // set neighbors for new octants octant_children_neighbors( @@ -538,24 +538,24 @@ void tioga::getAdaptiveHoleMap() /* ======================================================== */ for (int cb = 0; cb < ncomposite; cb++) { CompositeBody& Composite = compositeBody[cb]; - int nbodies = Composite.bodyids.size(); + int const nbodies = Composite.bodyids.size(); for (i = 0; i < nbodies; i++) { - int bodyi = Composite.bodyids[i] - BASE; + int const bodyi = Composite.bodyids[i] - BASE; ADAPTIVE_HOLEMAP_OCTANT& AHMOLocal = AHMO[bodyi]; // check if this rank contains this body char rankContainsBody = 0; for (mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int meshtag = mb->getMeshTag(); + int const meshtag = mb->getMeshTag(); if (meshtag - BASE == bodyi) { rankContainsBody = 1; break; } } - meshblockCompInfo& MBC = meshblockComposite[bodyi]; + meshblockCompInfo const& MBC = meshblockComposite[bodyi]; ADAPTIVE_HOLEMAP_COMPOSITE& AHMC = adaptiveHoleMapCOMPOSITE[bodyi]; ahm_meta_minimal_t& meta = AHMC.meta; @@ -720,7 +720,7 @@ void tioga::getAdaptiveHoleMap() for (mbi = 0; mbi < nblocks; mbi++) { ADAPTIVE_HOLEMAP_OCTANT& AHMOLocal = AHMO[mbi]; auto& mb = mblocks[mbi]; - int meshtag = mb->getMeshTag(); + int const meshtag = mb->getMeshTag(); ADAPTIVE_HOLEMAP& AHMLocal = adaptiveHoleMap[meshtag - BASE]; ahm_meta_t& meta = AHMLocal.meta; @@ -785,7 +785,7 @@ void tioga::getAdaptiveHoleMap() meta.elem_count = 0; if (AHME.existWall != 0u) { - meshblockCompInfo& MBC = meshblockComplement[i]; + meshblockCompInfo const& MBC = meshblockComplement[i]; // complement + master ranks only involved if (MBC.comm != MPI_COMM_NULL) { @@ -1066,7 +1066,7 @@ void tioga::outputAdaptiveHoleMap() if (myid == 0) { for (m = 0; m < nmesh; m++) { if (adaptiveHoleMap[m].existWall != 0u) { - ahm_meta_t& meta = adaptiveHoleMap[m].meta; + ahm_meta_t const& meta = adaptiveHoleMap[m].meta; ds[0] = meta.extents_hi[0] - meta.extents_lo[0]; ds[1] = meta.extents_hi[1] - meta.extents_lo[1]; diff --git a/src/linCartInterp.C b/src/linCartInterp.C index 9435320..4ccc583 100644 --- a/src/linCartInterp.C +++ b/src/linCartInterp.C @@ -28,9 +28,9 @@ void compute_1d_bases( std::vector& phi_y, std::vector& phi_z) { - double zeta = ref_coord[0]; - double mu = ref_coord[1]; - double eta = ref_coord[2]; + double const zeta = ref_coord[0]; + double const mu = ref_coord[1]; + double const eta = ref_coord[2]; phi_x[0] = (1 - zeta) / 2; phi_x[1] = (1 + zeta) / 2; diff --git a/src/parallelComm.C b/src/parallelComm.C index 3182278..0f5209e 100644 --- a/src/parallelComm.C +++ b/src/parallelComm.C @@ -49,8 +49,8 @@ void parallelComm::sendRecvPacketsAll(PACKET* sndPack, PACKET* rcvPack) const } // - int all_snd_nints = std::accumulate(sint, sint + numprocs, 0); - int all_rcv_nints = std::accumulate(rint, rint + numprocs, 0); + int const all_snd_nints = std::accumulate(sint, sint + numprocs, 0); + int const all_rcv_nints = std::accumulate(rint, rint + numprocs, 0); int *all_snd_intData, *all_rcv_intData; all_snd_intData = (int*)malloc(sizeof(int) * all_snd_nints); all_rcv_intData = (int*)malloc(sizeof(int) * all_rcv_nints); @@ -61,7 +61,7 @@ void parallelComm::sendRecvPacketsAll(PACKET* sndPack, PACKET* rcvPack) const rcv_int_displs[i] = rcv_int_displs[i - 1] + rint[i - 1]; } for (int i = 0; i < numprocs; i++) { - int displ = snd_int_displs[i]; + int const displ = snd_int_displs[i]; for (int j = 0; j < sint[i]; j++) { all_snd_intData[displ + j] = sndPack[i].intData[j]; } @@ -71,8 +71,8 @@ void parallelComm::sendRecvPacketsAll(PACKET* sndPack, PACKET* rcvPack) const all_snd_intData, sint, snd_int_displs.data(), MPI_INT, all_rcv_intData, rint, rcv_int_displs.data(), MPI_INT, scomm, &int_request); - int all_snd_nreals = std::accumulate(sreal, sreal + numprocs, 0); - int all_rcv_nreals = std::accumulate(rreal, rreal + numprocs, 0); + int const all_snd_nreals = std::accumulate(sreal, sreal + numprocs, 0); + int const all_rcv_nreals = std::accumulate(rreal, rreal + numprocs, 0); REAL *all_snd_realData, *all_rcv_realData; all_snd_realData = (REAL*)malloc(sizeof(REAL) * all_snd_nreals); all_rcv_realData = (REAL*)malloc(sizeof(REAL) * all_rcv_nreals); @@ -83,7 +83,7 @@ void parallelComm::sendRecvPacketsAll(PACKET* sndPack, PACKET* rcvPack) const rcv_real_displs[i] = rcv_real_displs[i - 1] + rreal[i - 1]; } for (int i = 0; i < numprocs; i++) { - int displ = snd_real_displs[i]; + int const displ = snd_real_displs[i]; for (int j = 0; j < sreal[i]; j++) { all_snd_realData[displ + j] = sndPack[i].realData[j]; } @@ -107,13 +107,13 @@ void parallelComm::sendRecvPacketsAll(PACKET* sndPack, PACKET* rcvPack) const MPI_Wait(&real_request, MPI_STATUS_IGNORE); for (int i = 0; i < numprocs; i++) { - int displ = rcv_int_displs[i]; + int const displ = rcv_int_displs[i]; for (int j = 0; j < rint[i]; j++) { rcvPack[i].intData[j] = all_rcv_intData[displ + j]; } } for (int i = 0; i < numprocs; i++) { - int displ = rcv_real_displs[i]; + int const displ = rcv_real_displs[i]; for (int j = 0; j < rreal[i]; j++) { rcvPack[i].realData[j] = all_rcv_realData[displ + j]; } diff --git a/src/search.C b/src/search.C index db0198b..eaea8c2 100644 --- a/src/search.C +++ b/src/search.C @@ -432,7 +432,7 @@ void MeshBlock::search_uniform_hex() idx[k]--; } } - int dtest = uindx + int const dtest = uindx [idx[2] * idims[1] * idims[0] + idx[1] * idims[0] + idx[0]]; dID[1] = (dtest > -1) diff --git a/src/tioga.C b/src/tioga.C index 0d37329..22530ee 100644 --- a/src/tioga.C +++ b/src/tioga.C @@ -106,12 +106,12 @@ void tioga::assembleCompositeMap() /* ================================= */ for (int mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int mbtag = mb->getMeshTag() - BASE; + int const mbtag = mb->getMeshTag() - BASE; for (int cb = 0; cb < ncomposite; cb++) { CompositeBody& Composite = compositeBody[cb]; - int nbodies = Composite.bodyids.size(); + int const nbodies = Composite.bodyids.size(); for (i = 0; i < nbodies; i++) { bodyi = Composite.bodyids[i] - BASE; if (bodyi == mbtag) { @@ -129,7 +129,7 @@ void tioga::assembleCompositeMap() int maxtagLocal = -BIGINT; for (int mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int mbtag = mb->getMeshTag(); + int const mbtag = mb->getMeshTag(); maxtagLocal = (maxtagLocal < mbtag) ? mbtag : maxtagLocal; } @@ -149,7 +149,7 @@ void tioga::assembleCompositeMap() compositeBodyMap[cb][i].resize(maxtag, 0); // fill 0 } - int nbodies = Composite.bodyids.size(); + int const nbodies = Composite.bodyids.size(); for (i = 0; i < nbodies; i++) { bodyi = Composite.bodyids[i] - BASE; for (j = i + 1; j < nbodies; j++) { @@ -191,7 +191,7 @@ void tioga::assembleCompositeComms() maxtagLocal = -BIGINT; for (int mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int mbtag = mb->getMeshTag(); + int const mbtag = mb->getMeshTag(); maxtagLocal = (maxtagLocal < mbtag) ? mbtag : maxtagLocal; } @@ -208,10 +208,10 @@ void tioga::assembleCompositeComms() /* ========================================= */ for (int cb = 0; cb < ncomposite; cb++) { CompositeBody& Composite = compositeBody[cb]; - int nbodies = Composite.bodyids.size(); + int const nbodies = Composite.bodyids.size(); for (int i = 0; i < nbodies; i++) { - int bodyi = Composite.bodyids[i] - BASE; + int const bodyi = Composite.bodyids[i] - BASE; meshblockCompInfo& MBC = meshblockComposite[bodyi]; // 1. set composite master rank ID (use complement info) @@ -223,11 +223,11 @@ void tioga::assembleCompositeComms() // 2. find if other ranks with mesh blocks in same composite body char foundFlag = 0; for (int j = 0; j < nbodies && foundFlag == 0; j++) { - int bodyj = Composite.bodyids[j] - BASE; + int const bodyj = Composite.bodyids[j] - BASE; for (int mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int mbtag = mb->getMeshTag(); + int const mbtag = mb->getMeshTag(); if (bodyj == mbtag - BASE) { foundFlag = 1; break; @@ -305,7 +305,7 @@ void tioga::assembleComplementComms() maxtagLocal = -BIGINT; for (int mbi = 0; mbi < nblocks; mbi++) { auto& mb = mblocks[mbi]; - int mbtag = mb->getMeshTag(); + int const mbtag = mb->getMeshTag(); maxtagLocal = (maxtagLocal < mbtag) ? mbtag : maxtagLocal; @@ -496,7 +496,7 @@ void tioga::register_unstructured_grid(TIOGA::MeshBlockInfo* minfo) void tioga::registerSolution(int btag, double* q) { auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; qblock[iblk] = q; } @@ -504,7 +504,7 @@ void tioga::register_unstructured_solution( int btag, double* q, int nvar, int interptype) { auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; qblock[iblk] = q; mblocks[iblk]->num_var() = nvar; mblocks[iblk]->set_interptype(interptype); @@ -783,7 +783,7 @@ void tioga::dataUpdate_AMR() for (i = 0; i < rcvPack[k].nints / 2; i++) { bid = rcvPack[k].intData[2 * i]; if (bid < 0) { - int inode = rcvPack[k].intData[2 * i + 1]; + int const inode = rcvPack[k].intData[2 * i + 1]; mblocks[-(bid + 1)]->updateSolnData( inode, &rcvPack[k].realData[m], qblock[-(bid + 1)]); } else { @@ -870,7 +870,7 @@ void tioga::dataUpdate(int nvar, int interptype, int at_points) // populate the packets // for (int i = 0; i < nints[ib]; i++) { - int k = integerRecords[ib][3 * i]; + int const k = integerRecords[ib][3 * i]; sndPack[k].nints += 2; sndPack[k].nreals += nvar; } @@ -886,7 +886,7 @@ void tioga::dataUpdate(int nvar, int interptype, int at_points) for (int ib = 0; ib < nblocks; ib++) { int m = 0; for (int i = 0; i < nints[ib]; i++) { - int k = integerRecords[ib][3 * i]; + int const k = integerRecords[ib][3 * i]; sndPack[k].intData[icount[k]++] = integerRecords[ib][3 * i + 1]; sndPack[k].intData[icount[k]++] = integerRecords[ib][3 * i + 2]; for (int j = 0; j < nvar; j++) { @@ -918,8 +918,8 @@ void tioga::dataUpdate(int nvar, int interptype, int at_points) int l = 0; int m = 0; for (int i = 0; i < rcvPack[k].nints / 2; i++) { - int pointid = rcvPack[k].intData[l++]; - int ib = rcvPack[k].intData[l++]; + int const pointid = rcvPack[k].intData[l++]; + int const ib = rcvPack[k].intData[l++]; auto& mb = mblocks[ib]; if (at_points == 0) { double* q = qblock[ib]; @@ -1028,7 +1028,7 @@ void tioga::getDonorCount(int btag, int* dcount, int* fcount) } auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; auto& mb = mblocks[iblk]; mb->getDonorCount(dcount, fcount); } @@ -1046,7 +1046,7 @@ void tioga::getDonorInfo( } auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; auto& mb = mblocks[iblk]; mb->getDonorInfo(receptors, indices, frac); // @@ -1110,7 +1110,7 @@ void tioga::getReceptorInfo(std::vector& receptors) std::vector& fringeData = fringeSend[ib]; for (int i = 0; i < (5 * dcount[ib]); i += 5) { - int k = fringeData[i]; + int const k = fringeData[i]; sndPack[k].nints += 4; } } @@ -1125,7 +1125,7 @@ void tioga::getReceptorInfo(std::vector& receptors) std::vector& fringeData = fringeSend[ib]; for (size_t i = 0; i < fringeData.size(); i += 5) { - int k = fringeData[i]; + int const k = fringeData[i]; sndPack[k].intData[ix[k]++] = fringeData[i + 1]; // nodeID sndPack[k].intData[ix[k]++] = fringeData[i + 2]; // local block index at receiver @@ -1331,7 +1331,7 @@ void tioga::reduce_fringes() // for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].nints += 2; } } @@ -1342,7 +1342,7 @@ void tioga::reduce_fringes() // for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 1]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 2]; } @@ -1355,8 +1355,8 @@ void tioga::reduce_fringes() for (int k = 0; k < nrecv; k++) { int m = 0; for (int j = 0; j < rcvPack[k].nints / 2; j++) { - int recid = rcvPack[k].intData[m++]; - int ib = tag_iblk_map[rcvPack[k].intData[m++]]; + int const recid = rcvPack[k].intData[m++]; + int const ib = tag_iblk_map[rcvPack[k].intData[m++]]; mblocks[ib]->cancelDonor(recid); } } @@ -1382,7 +1382,7 @@ void tioga::reduce_fringes() std::fill(ixOffset.begin(), ixOffset.end(), 0); for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].nints += 2; } } @@ -1391,7 +1391,7 @@ void tioga::reduce_fringes() } for (int n = 0; n < nblocks; n++) { for (int i = 0; i < nrecords[n]; i++) { - int k = donorRecords[n][3 * i]; + int const k = donorRecords[n][3 * i]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 1]; sndPack[k].intData[ixOffset[k]++] = donorRecords[n][3 * i + 2]; } @@ -1409,8 +1409,8 @@ void tioga::reduce_fringes() for (int k = 0; k < nrecv; k++) { int m = 0; for (int j = 0; j < rcvPack[k].nints / 2; j++) { - int pointid = rcvPack[k].intData[m++]; - int ib = rcvPack[k].intData[m++]; + int const pointid = rcvPack[k].intData[m++]; + int const ib = rcvPack[k].intData[m++]; mblocks[ib]->setIblanks(pointid); } } @@ -1484,9 +1484,9 @@ void tioga::preprocess_amr_data(int root) if (root == myid) { const auto* ainfo = cg->m_info; for (int pp = 0; pp < ngrids_global; ++pp) { - int i3 = pp * 3; - int i6 = pp * 6; - int iloc = nint_per_grid * pp; + int const i3 = pp * 3; + int const i6 = pp * 6; + int const iloc = nint_per_grid * pp; idata[iloc] = pp; idata[iloc + 1] = ainfo->level.hptr[pp]; @@ -1519,7 +1519,7 @@ void tioga::preprocess_amr_data(int root) // These MPI ranks don't have AMR mesh, but require patch information for // performing searches. So create appropriate data here. { - int nghost = idata.back(); + int const nghost = idata.back(); cg = new CartGrid[1]; cg->myid = myid; diff --git a/src/tioga.h b/src/tioga.h index 94b0597..d144e3d 100644 --- a/src/tioga.h +++ b/src/tioga.h @@ -254,7 +254,7 @@ class tioga void setResolutions(int btag, double* nres, double* cres) { auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; auto& mb = mblocks[iblk]; mb->setResolutions(nres, cres); } @@ -272,7 +272,7 @@ class tioga void set_uniform_hex_flag(int btag, int flag) { auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; auto& mb = mblocks[iblk]; mb->check_uniform_hex_flag = flag; } @@ -280,7 +280,7 @@ class tioga void set_cell_iblank(int btag, int* ib_cell) { auto idxit = tag_iblk_map.find(btag); - int iblk = idxit->second; + int const iblk = idxit->second; auto& mb = mblocks[iblk]; mb->set_cell_iblank(ib_cell); } diff --git a/src/tiogaInterface.C b/src/tiogaInterface.C index 888e4ec..84e85f2 100644 --- a/src/tiogaInterface.C +++ b/src/tiogaInterface.C @@ -94,7 +94,7 @@ void tioga_registergrid_data_( { va_list arguments; int i; - int iblk = 0; + int const iblk = 0; va_start(arguments, ntypes); if (idata[iblk].nv != nullptr) TIOGA_FREE(idata[iblk].nv); @@ -128,7 +128,7 @@ void tioga_registergrid_data_mb_( { va_list arguments; int i; - int iblk = *bid - BASE; + int const iblk = *bid - BASE; va_start(arguments, ntypes); @@ -244,7 +244,7 @@ void tioga_dataupdate_mb_(int* nvar, char* itype) void tioga_dataupdate_(double* q, int* nvar, char* itype) { int interptype; - int bid = 0; + int const bid = 0; tg->registerSolution(bid, q); tioga_dataupdate_mb_(nvar, itype); } diff --git a/src/tioga_math.C b/src/tioga_math.C index 9cf6c1e..7e20ff1 100644 --- a/src/tioga_math.C +++ b/src/tioga_math.C @@ -30,7 +30,7 @@ void solvec(double** a, double* b, int* iflag, int n) double fact; double temp; double sum; - double eps = 1e-8; + double const eps = 1e-8; for (i = 0; i < n; i++) { if (fabs(a[i][i]) < eps) { diff --git a/src/tioga_utils.C b/src/tioga_utils.C index 94e6dd2..1525c92 100644 --- a/src/tioga_utils.C +++ b/src/tioga_utils.C @@ -384,7 +384,7 @@ int obbIntersectCheck( int i1, i2, j1, j2; double r, r0, r1; double d1, d2; - double eps = 1e-12; + double const eps = 1e-12; double D[3]; double c[3][3]; // @@ -534,7 +534,7 @@ void writebboxdiv(OBB* obb, int bid) int ncells, npts; double xv[8][3], xc[3], xd[3]; int i, j, k, l, m, n; - int iorder[8] = {1, 2, 4, 3, 5, 6, 8, 7}; + int const iorder[8] = {1, 2, 4, 3, 5, 6, 8, 7}; FILE* fp; char intstring[12]; char fname[80]; @@ -609,12 +609,12 @@ void writePoints(double* x, int nsearch, int bid) */ void uniquenodes(double* x, int* meshtag, double* rtag, int* itag, int* nn) { - int NSUB = 101; + int const NSUB = 101; int i, j, k, m, ij, i3, jj, kk, ll, p1, p2, indx, jmax, kmax, lmax, nsblks, jkmax; double xmax[3], xmin[3], ds, dsi, dsx, dsxi, dsy, dsyi, dsz, dszi; int *cft, *numpts, *ilist; - int nnodes = *nn; + int const nnodes = *nn; for (j = 0; j < 3; j++) { xmax[j] = -1E15; @@ -732,7 +732,7 @@ void uniqNodesTree( int ndim, int nav) { - int nd = ndim; + int const nd = ndim; double coordmid; int i, j, ibox; int p1, p2; @@ -837,7 +837,7 @@ void uniqNodesTree( void uniquenodes_octree( double* x, int* meshtag, double* rtag, int* itag, int* nn) { - int nelem = *nn; + int const nelem = *nn; int* elementsAvailable; int i; @@ -894,12 +894,12 @@ uint8_t octant_filltype(octant_full_t* c, const qcoord_t inc) */ // returns (OUTSIDE_SB) if touching an octant boundary, (INSIDE_SB) // otherwise - uint8_t type = (((c->x == 0) || (c->y == 0) || (c->z == 0) || - ((c->x + inc) == OCTANT_ROOT_LEN) || - ((c->y + inc) == OCTANT_ROOT_LEN) || - ((c->z + inc) == OCTANT_ROOT_LEN))) - ? OUTSIDE_SB - : INSIDE_SB; + uint8_t const type = (((c->x == 0) || (c->y == 0) || (c->z == 0) || + ((c->x + inc) == OCTANT_ROOT_LEN) || + ((c->y + inc) == OCTANT_ROOT_LEN) || + ((c->z + inc) == OCTANT_ROOT_LEN))) + ? OUTSIDE_SB + : INSIDE_SB; return type; } @@ -1175,7 +1175,7 @@ void floodfill_octant(octant_full_t* o) /* recursive search in all directions */ void floodfill_level(level_octant_t* level) { - int nneig = 6; + int const nneig = 6; int j, n; for (j = 0; j < level->elem_count; j++) { diff --git a/src/tioga_utils.h b/src/tioga_utils.h index f1fe38a..b65767b 100644 --- a/src/tioga_utils.h +++ b/src/tioga_utils.h @@ -56,9 +56,9 @@ struct Node { size_t operator()(const Node& node) const { - size_t xHash = std::hash()(int(node.x)); - size_t yHash = std::hash()(int(node.y)) << 1; - size_t zHash = std::hash()(int(node.z)) << 2; + size_t const xHash = std::hash()(int(node.x)); + size_t const yHash = std::hash()(int(node.y)) << 1; + size_t const zHash = std::hash()(int(node.z)) << 2; return xHash ^ yHash ^ zHash; } };