Skip to content

Commit

Permalink
More readability-math-missing-parentheses fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu committed Dec 17, 2024
1 parent 272b244 commit 6d9e109
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 58 deletions.
43 changes: 22 additions & 21 deletions src/bookKeeping.C
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void MeshBlock::getDonorPacket(PACKET* sndPack, int nsend) const
for (i = 0; i < nsearch; i++) {
if (donorId[i] > -1) {
k = isearch[2 * i];
sndPack[k].intData[icount[k]++] = meshtag; // mesh tag
sndPack[k].intData[icount[k]++] = isearch[2 * i + 1]; // point id
sndPack[k].intData[icount[k]++] = meshtag; // mesh tag
sndPack[k].intData[icount[k]++] = isearch[(2 * i) + 1]; // point id
sndPack[k].intData[icount[k]++] = i; // point id on the donor side
sndPack[k].realData[dcount[k]++] =
cellRes[donorId[i]]; // donor resolution
Expand Down Expand Up @@ -97,10 +97,10 @@ void MeshBlock::getMBDonorPackets(
int& ix = ixOffset[k];
int& rx = rxOffset[k];

sndPack[k].intData[ix++] = meshtag; // Unique mesh tag
sndPack[k].intData[ix++] = isearch[3 * i + 1]; // point ID
sndPack[k].intData[ix++] = i; // point ID on donor side
sndPack[k].intData[ix++] = isearch[3 * i + 2]; // receptor block ID
sndPack[k].intData[ix++] = meshtag; // Unique mesh tag
sndPack[k].intData[ix++] = isearch[(3 * i) + 1]; // point ID
sndPack[k].intData[ix++] = i; // point ID on donor side
sndPack[k].intData[ix++] = isearch[(3 * i) + 2]; // receptor block ID
sndPack[k].realData[rx++] = cellRes[donorId[i]];
sndPack[k].realData[rx++] = res_search[xtag[i]];
}
Expand Down Expand Up @@ -180,7 +180,7 @@ void MeshBlock::processDonors(
if (verbose != 0) TRACEI(iblank[i]);
if (verbose != 0) TRACED(nodeRes[i]);
if (verbose != 0) {
printf("%f %f %f\n", x[3 * i], x[3 * i + 1], x[3 * i + 2]);
printf("%f %f %f\n", x[3 * i], x[(3 * i) + 1], x[(3 * i) + 2]);
}
if (donorList[i] == nullptr) {
if (verbose != 0) {
Expand Down Expand Up @@ -241,7 +241,8 @@ void MeshBlock::processDonors(
myid, wbcnode[i] - BASE, donorList[wbcnode[i] - BASE]);
ii = wbcnode[i] - BASE;
printf(
"xloc=%e %e %e\n", x[3 * ii], x[3 * ii + 1], x[3 * ii + 2]);
"xloc=%e %e %e\n", x[3 * ii], x[(3 * ii) + 1],
x[(3 * ii) + 2]);
printf(
"Computations will continue, but may suffer from accuracy "
"problems\n");
Expand Down Expand Up @@ -271,11 +272,11 @@ void MeshBlock::processDonors(
nvert = nv[n];
for (i = 0; i < nc[n]; i++) {
for (m = 0; m < nvert; m++) {
if (mtag[(vconn[n][nvert * i + m] - BASE)] == 1) {
if (mtag[(vconn[n][(nvert * i) + m] - BASE)] == 1) {
for (mm = 0; mm < nvert; mm++) {
if (m != mm &&
mtag[vconn[n][nvert * i + mm] - BASE] != 1) {
mtag1[vconn[n][nvert * i + mm] - BASE] = 1;
mtag[vconn[n][(nvert * i) + mm] - BASE] != 1) {
mtag1[vconn[n][(nvert * i) + mm] - BASE] = 1;
}
}
}
Expand Down Expand Up @@ -469,8 +470,8 @@ void MeshBlock::processDonors(
myid, wbcnode[i] - BASE, donorList[wbcnode[i] - BASE]);
ii = wbcnode[i] - BASE;
fprintf(
stderr, "xloc=%e %e %e\n", x[3 * ii], x[3 * ii + 1],
x[3 * ii + 2]);
stderr, "xloc=%e %e %e\n", x[3 * ii], x[(3 * ii) + 1],
x[(3 * ii) + 2]);
fprintf(
stderr,
"Computations will continue, but may suffer from accuracy "
Expand Down Expand Up @@ -501,11 +502,11 @@ void MeshBlock::processDonors(
nvert = nv[n];
for (i = 0; i < nc[n]; i++) {
for (m = 0; m < nvert; m++) {
if (mtag[(vconn[n][nvert * i + m] - BASE)] == 1) {
if (mtag[(vconn[n][(nvert * i) + m] - BASE)] == 1) {
for (mm = 0; mm < nvert; mm++) {
if (m != mm &&
mtag[vconn[n][nvert * i + mm] - BASE] != 1) {
mtag1[vconn[n][nvert * i + mm] - BASE] = 1;
mtag[vconn[n][(nvert * i) + mm] - BASE] != 1) {
mtag1[vconn[n][(nvert * i) + mm] - BASE] = 1;
}
}
}
Expand Down Expand Up @@ -651,8 +652,8 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
// if (myid==1 && irecord==158192 && meshtag==1) verbose=1;
receptorRes = fabs(receptorRes2);
procid = isearch[3 * irecord];
pointid = isearch[3 * irecord + 1];
blockid = isearch[3 * irecord + 2];
pointid = isearch[(3 * irecord) + 1];
blockid = isearch[(3 * irecord) + 2];
meshtagrecv = tagsearch[irecord];
if (verbose != 0) {
TRACEI(procid);
Expand Down Expand Up @@ -681,7 +682,7 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
if (verbose != 0) TRACEI(i)
if (verbose != 0) TRACED(nodeRes[241291]);
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
inode[m] = vconn[n][(nvert * i) + m] - BASE;
if (verbose != 0) TRACEI(inode[m]);
if (verbose != 0) TRACEI(iblank[inode[m]])
if (verbose != 0) TRACED(nodeRes[inode[m]])
Expand Down Expand Up @@ -714,7 +715,7 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
//
for (m = 0; m < nvert; m++) {
verbose = 0;
inode[m] = vconn[n][nvert * i + m] - BASE;
inode[m] = vconn[n][(nvert * i) + m] - BASE;
// if (myid==763 && inode[m]==9515) verbose=1;
// if (myid==1 && meshtag==2 && inode[m]==240304) verbose=1;
if (verbose != 0) TRACEI(inode[m]);
Expand Down Expand Up @@ -956,7 +957,7 @@ void MeshBlock::reduce_fringes()
verbose = 0;
ncount = 0;
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
inode[m] = vconn[n][(nvert * i) + m] - BASE;
ncount = ncount + static_cast<int>(
iblank_reduced[inode[m]] == 1 ||
iblank_reduced[inode[m]] < 0);
Expand Down
12 changes: 6 additions & 6 deletions src/buildADTrecursion.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void buildADTrecursion(
// collect coordinates along the dimension dimcut
//
for (i = 0; i < nav; i++) {
adtWork[i] = coord[ndim * elementsAvailable[i] + dimcut];
adtWork[i] = coord[(ndim * elementsAvailable[i]) + dimcut];
}
//
// reorder elements with nleft elements to
Expand Down Expand Up @@ -81,9 +81,9 @@ void buildADTrecursion(
// contained in this leaf
//
for (i = 0; i < nd; i++) {
adtReals[ndim * (*adtCount) + i] =
adtReals[(ndim * (*adtCount)) + i] =
std::numeric_limits<double>::max();
adtReals[ndim * (*adtCount) + i + nd] =
adtReals[(ndim * (*adtCount)) + i + nd] =
std::numeric_limits<double>::lowest();
}
//
Expand All @@ -103,7 +103,7 @@ void buildADTrecursion(
// unless root
//
if (side > 0) {
adtIntegers[4 * parent + side] = elementsAvailable[nleft - 1];
adtIntegers[(4 * parent) + side] = elementsAvailable[nleft - 1];
}
parentToChild = *adtCount;
//
Expand All @@ -129,10 +129,10 @@ void buildADTrecursion(
adtIntegers[ii + 2] = -1;
adtIntegers[ii + 3] = -1;
for (j = 0; j < ndim; j++) {
adtReals[jj + j] = coord[ndim * elementsAvailable[0] + j];
adtReals[jj + j] = coord[(ndim * elementsAvailable[0]) + j];
}
if (side > 0) {
adtIntegers[4 * parent + side] = elementsAvailable[0];
adtIntegers[(4 * parent) + side] = elementsAvailable[0];
}
}
}
12 changes: 6 additions & 6 deletions src/cartOps.C
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void MeshBlock::getUnresolvedMandatoryReceptors()
for (i = 0; i < nc[n]; i++) {
fcount = 0;
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
inode[m] = vconn[n][(nvert * i) + m] - BASE;
if (nodeRes[inode[m]] >=
std::numeric_limits<double>::max()) {
fcount++;
Expand Down Expand Up @@ -248,7 +248,7 @@ void MeshBlock::findInterpListCart()
}
nvert = nv[n];
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
inode[m] = vconn[n][(nvert * i) + m] - BASE;
i3 = 3 * inode[m];
for (j = 0; j < 3; j++) {
xv[m][j] = x[i3 + j];
Expand Down Expand Up @@ -362,7 +362,7 @@ void MeshBlock::getInterpolatedSolutionAMR(
printf("warning: weights are not convex 3\n");
}
for (k = 0; k < nvar; k++) {
qq[k] += q[inode * nvar + k] * weight;
qq[k] += q[(inode * nvar) + k] * weight;
}
}
(*intData)[icount++] = sndMap[interpList[i].receptorInfo[0]];
Expand All @@ -386,7 +386,7 @@ void MeshBlock::getInterpolatedSolutionAMR(
printf("warning: weights are not convex 4\n");
}
for (k = 0; k < nvar; k++) {
qq[k] += q[inode * nvar + k] * weight;
qq[k] += q[(inode * nvar) + k] * weight;
// if (myid==0 && dcount==0) {
// printf("nsu3d/interp: %d %d %f
// %f\n",k,inode,weight,q[inode*nvar+k]);
Expand All @@ -412,7 +412,7 @@ void MeshBlock::getInterpolatedSolutionAMR(
inode = interpList[i].inode[m];
weight = interpList[i].weights[m];
for (k = 0; k < nvar; k++) {
qq[k] += q[k * nnodes + inode] * weight;
qq[k] += q[(k * nnodes) + inode] * weight;
}
}
(*intData)[icount++] = sndMap[interpList[i].receptorInfo[0]];
Expand All @@ -432,7 +432,7 @@ void MeshBlock::getInterpolatedSolutionAMR(
inode = interpListCart[i].inode[m];
weight = interpListCart[i].weights[m];
for (k = 0; k < nvar; k++) {
qq[k] += q[k * nnodes + inode] * weight;
qq[k] += q[(k * nnodes) + inode] * weight;
}
}
(*intData)[icount++] = interpListCart[i].receptorInfo[0];
Expand Down
4 changes: 2 additions & 2 deletions src/cellVolume.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ double scalarProduct(
double c3)
{
return (
a1 * b2 * c3 - a1 * b3 * c2 + a2 * b3 * c1 - a2 * b1 * c3 +
a3 * b1 * c2 - a3 * b2 * c1);
(a1 * b2 * c3) - (a1 * b3 * c2) + (a2 * b3 * c1) - (a2 * b1 * c3) +
(a3 * b1 * c2) - (a3 * b2 * c1));
}

void cellVolume(
Expand Down
2 changes: 1 addition & 1 deletion src/checkContainment.C
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void MeshBlock::checkContainment(
//
nvert = nv[n];
for (m = 0; m < nvert; m++) {
i3 = 3 * (vconn[n][nvert * i + m] - BASE);
i3 = 3 * (vconn[n][(nvert * i) + m] - BASE);
for (j = 0; j < 3; j++) {
xv[m][j] = x[i3 + j];
}
Expand Down
8 changes: 4 additions & 4 deletions src/dataUpdate.C
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void MeshBlock::getInterpolatedSolution(
printf("warning: weights are not convex 1\n");
}
for (k = 0; k < nvar; k++) {
qq[k] += q[inode * nvar + k] * weight;
qq[k] += q[(inode * nvar) + k] * weight;
}
}
(*intData)[icount++] = interpList[i].receptorInfo[0];
Expand All @@ -94,7 +94,7 @@ void MeshBlock::getInterpolatedSolution(
inode = interpList[i].inode[m];
weight = interpList[i].weights[m];
for (k = 0; k < nvar; k++) {
qq[k] += q[k * nnodes + inode] * weight;
qq[k] += q[(k * nnodes) + inode] * weight;
}
}
(*intData)[icount++] = interpList[i].receptorInfo[0];
Expand All @@ -121,12 +121,12 @@ void MeshBlock::updateSolnData(int inode, const double* qvar, double* q) const
}
assert(inode < nnodes);
for (k = 0; k < nvar; k++) {
q[inode * nvar + k] = qvar[k];
q[(inode * nvar) + k] = qvar[k];
}
}
if (interptype == COLUMN) {
for (k = 0; k < nvar; k++) {
q[nnodes * k + inode] = qvar[k];
q[(nnodes * k) + inode] = qvar[k];
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/exchangeAMRDonors.C
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ void tioga::exchangeAMRDonors()
sndPack[procid].realData[realcount[procid]++] =
mb->rxyzCart[3 * i];
sndPack[procid].realData[realcount[procid]++] =
mb->rxyzCart[3 * i + 1];
mb->rxyzCart[(3 * i) + 1];
sndPack[procid].realData[realcount[procid]++] =
mb->rxyzCart[3 * i + 2];
mb->rxyzCart[(3 * i) + 2];
}
}
}
Expand All @@ -148,9 +148,9 @@ void tioga::exchangeAMRDonors()
if (mb->donorId[i] != -1) {
procid = imap[mb->isearch[3 * i]];
sndPack[procid].intData[intcount[procid]++] =
mb->isearch[3 * i + 1];
mb->isearch[(3 * i) + 1];
sndPack[procid].intData[intcount[procid]++] =
mb->isearch[3 * i + 2];
mb->isearch[(3 * i) + 2];
sndPack[procid].intData[intcount[procid]++] = mb->meshtag;
sndPack[procid].intData[intcount[procid]++] = i;
sndPack[procid].intData[intcount[procid]++] = ib;
Expand Down Expand Up @@ -258,9 +258,9 @@ void tioga::exchangeAMRDonors()
cb[i].getCancellationData(cancelledData, &ncancel);
for (j = 0; j < ncancel; j++) {
procid = cancelledData[4 * j];
ctype = cancelledData[4 * j + 1];
remoteid = cancelledData[4 * j + 2];
remoteblockid = cancelledData[4 * j + 3];
ctype = cancelledData[(4 * j) + 1];
remoteid = cancelledData[(4 * j) + 2];
remoteblockid = cancelledData[(4 * j) + 3];
sndPack[procid].intData[intcount[procid]++] = ctype;
sndPack[procid].intData[intcount[procid]++] = remoteid;
sndPack[procid].intData[intcount[procid]++] = remoteblockid;
Expand Down
8 changes: 4 additions & 4 deletions src/exchangeBoxes.C
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ void tioga::exchangeBoxes()
int const roff = idxOffset[k] * 6;

int const key_recv =
mxtgsqr * ip + maxtag * (mtags[ib] - 1) + obbID[ob] - 1;
(mxtgsqr * ip) + (maxtag * (mtags[ib] - 1)) + obbID[ob] - 1;
int const key_send =
mxtgsqr * myid + maxtag * (obbID[ob] - 1) + (mtags[ib] - 1);
(mxtgsqr * myid) + (maxtag * (obbID[ob] - 1)) + (mtags[ib] - 1);
intBoxMap[key_recv] = static_cast<int>(i);
ibProcMap[k][ioff] = static_cast<int>(i);
obblist[i].comm_idx = k;
Expand All @@ -252,8 +252,8 @@ void tioga::exchangeBoxes()

sndPack[k].intData[static_cast<int>(3 * ioff)] =
key_send; // mb->getMeshTag();
sndPack[k].intData[3 * ioff + 1] = ib;
sndPack[k].intData[3 * ioff + 2] = mb->getMeshTag();
sndPack[k].intData[(3 * ioff) + 1] = ib;
sndPack[k].intData[(3 * ioff) + 2] = mb->getMeshTag();
// mb->getReducedOBB2(&obbRecv[ob], &(sndPack[k].realData[roff]));
mb->getReducedOBB(&obbRecv[ob], &(sndPack[k].realData[roff]));

Expand Down
12 changes: 6 additions & 6 deletions src/exchangeDonors.C
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void tioga::exchangeDonors()
for (int n = 0; n < nblocks; n++) {
for (int i = 0; i < nrecords[n]; 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].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];
}
}
Expand Down Expand Up @@ -224,8 +224,8 @@ void tioga::exchangeDonors()
for (int n = 0; n < nblocks; n++) {
for (int i = 0; i < nrecords[n]; 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].intData[ixOffset[k]++] = donorRecords[n][(3 * i) + 1];
sndPack[k].intData[ixOffset[k]++] = donorRecords[n][(3 * i) + 2];
}
}
//
Expand Down Expand Up @@ -274,8 +274,8 @@ void tioga::exchangeDonors()
for (int n = 0; n < nblocks; n++) {
for (int i = 0; i < nrecords[n]; 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].intData[ixOffset[k]++] = donorRecords[n][(3 * i) + 1];
sndPack[k].intData[ixOffset[k]++] = donorRecords[n][(3 * i) + 2];
}
}
//
Expand Down
2 changes: 1 addition & 1 deletion src/exchangeSearchData.C
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void tioga::exchangeSearchData(int at_points)
mb->isearch[ioff++] = k;
mb->isearch[ioff++] = rcvPack[k].intData[m++];
mb->isearch[ioff++] = obblist[ii].iblk_remote;
mb->tagsearch[ioff / 3 - 1] = obblist[ii].tag_remote;
mb->tagsearch[(ioff / 3) - 1] = obblist[ii].tag_remote;

#ifdef TIOGA_HAS_NODEGID
std::memcpy(
Expand Down

0 comments on commit 6d9e109

Please sign in to comment.