Skip to content

Commit

Permalink
Some clang-tidy bugprone- fixes (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu authored Dec 13, 2024
1 parent 956a7d6 commit 1d5d9ca
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 120 deletions.
5 changes: 3 additions & 2 deletions src/ADT.C
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "codetypes.h"
#include "ADT.h"
#include "buildADTrecursion.h"
#include <limits>

void ADT::buildADT(int d, int nelements, double* elementBbox)
{
Expand Down Expand Up @@ -62,8 +63,8 @@ void ADT::buildADT(int d, int nelements, double* elementBbox)
*/
for (i = 0; i < ndim / 2; i++) {
i2 = 2 * i;
adtExtents[i2] = BIGVALUE;
adtExtents[i2 + 1] = -BIGVALUE;
adtExtents[i2] = std::numeric_limits<double>::max();
adtExtents[i2 + 1] = std::numeric_limits<double>::lowest();
}
for (j = 0; j < nelem; j++) {
j6 = 6 * j;
Expand Down
9 changes: 6 additions & 3 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "linCartInterp.h"
#include "linklist.h"
#include "tioga_utils.h"
#include <limits>

void CartBlock::registerData(int lid, TIOGA::AMRMeshInfo* minfo)
{
Expand Down Expand Up @@ -99,7 +100,7 @@ void CartBlock::getInterpolatedData(
listptr = interpList;
icount = 3 * nintold;
dcount = nrealold;
qq = (double*)malloc(sizeof(double) * (nvar_cell + nvar_node));
qq = (double*)calloc((nvar_cell + nvar_node), sizeof(double));
while (listptr != nullptr) {
(*intData)[icount++] = listptr->receptorInfo[0];
(*intData)[icount++] = -1 - listptr->receptorInfo[2];
Expand Down Expand Up @@ -471,7 +472,8 @@ void CartBlock::processIblank(HOLEMAP* holemap, int nmesh, bool isNodal)
// simplify logic here: the first one on the list is the
// best donor anyway, accept it if its not a mandatory
// receptor on the donor side
if (temp->donorRes < BIGVALUE) {
if (temp->donorRes <
std::numeric_limits<double>::max()) {
iblank[ibindex] = -1;
temp = temp->next;
}
Expand Down Expand Up @@ -636,7 +638,8 @@ void CartBlock::processIblank(
// simplify logic here: the first one on the list is the
// best donor anyway, accept it if its not a mandatory
// receptor on the donor side
if (temp->donorRes < BIGVALUE) {
if (temp->donorRes <
std::numeric_limits<double>::max()) {
iblank[ibindex] = -1;
temp = temp->next;
}
Expand Down
3 changes: 2 additions & 1 deletion src/CartGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <limits>

#include "tioga_gpu.h"
#include "TiogaMeshInfo.h"
Expand Down Expand Up @@ -153,7 +154,7 @@ void CartGrid::preprocess()
//
// find the global minimum coord location
//
xlosup[0] = xlosup[1] = xlosup[2] = BIGVALUE;
xlosup[0] = xlosup[1] = xlosup[2] = std::numeric_limits<double>::max();
maxlevel = -1;
for (i = 0; i < ngrids; i++) {
for (n = 0; n < 3; n++) {
Expand Down
64 changes: 35 additions & 29 deletions src/MeshBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "linklist.h"
#include "tioga_math.h"
#include "tioga_utils.h"
#include <limits>

void MeshBlock::setData(
int btag,
Expand Down Expand Up @@ -347,8 +348,8 @@ void MeshBlock::tagBoundary()
int idx[3];
itag = 0;
for (int j = 0; j < 3; j++) {
xmin[j] = BIGVALUE;
xmax[j] = -BIGVALUE;
xmin[j] = std::numeric_limits<double>::max();
xmax[j] = std::numeric_limits<double>::lowest();
}
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
Expand Down Expand Up @@ -387,7 +388,7 @@ void MeshBlock::tagBoundary()
if (itag != 0) {
for (m = 0; m < nvert; m++) {
// iflag[inode[m]]=1;
nodeRes[inode[m]] = BIGVALUE;
nodeRes[inode[m]] = std::numeric_limits<double>::max();
iextmp[inode[m]] = iextmp1[inode[m]] = 1;
}
}
Expand Down Expand Up @@ -420,11 +421,11 @@ void MeshBlock::tagBoundary()
inode[m] = vconn[n][nvert * i + m] - BASE;
if (iextmp[inode[m]] == 1) //(iflag[inode[m]])
{
cellRes[k] = BIGVALUE;
cellRes[k] = std::numeric_limits<double>::max();
break;
}
}
if (cellRes[k] == BIGVALUE) {
if (cellRes[k] == std::numeric_limits<double>::max()) {
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
if (iextmp[inode[m]] != 1) {
Expand Down Expand Up @@ -563,8 +564,10 @@ void MeshBlock::tagBoundaryFaces()
/* 2. COMPUTE LOCAL BOUNDING BOX (after adjusting iflagwbc) */
/* ======================================================== */
// bounding box of non-duplicate wall nodes
bboxLocalAHM[0] = bboxLocalAHM[1] = bboxLocalAHM[2] = BIGVALUE;
bboxLocalAHM[3] = bboxLocalAHM[4] = bboxLocalAHM[5] = -BIGVALUE;
bboxLocalAHM[0] = bboxLocalAHM[1] = bboxLocalAHM[2] =
std::numeric_limits<double>::max();
bboxLocalAHM[3] = bboxLocalAHM[4] = bboxLocalAHM[5] =
std::numeric_limits<double>::lowest();

for (i = 0; i < nwbc; i++) {
node = wbcnode[i] - BASE;
Expand Down Expand Up @@ -673,10 +676,11 @@ void MeshBlock::tagBoundaryFaces()

// initialize cell bounding box data
for (d = 0; d < 3; d++) {
bboxCell[d] = BIGVALUE;
bboxCell[d] = std::numeric_limits<double>::max();
}
for (d = 0; d < 3; d++) {
bboxCell[3 + d] = -BIGVALUE;
bboxCell[3 + d] =
std::numeric_limits<double>::lowest();
}

// get node indices and coordinates for this boundary
Expand Down Expand Up @@ -718,10 +722,11 @@ void MeshBlock::tagBoundaryFaces()

// initialize cell bounding box data
for (d = 0; d < 3; d++) {
bboxCell[d] = BIGVALUE;
bboxCell[d] = std::numeric_limits<double>::max();
}
for (d = 0; d < 3; d++) {
bboxCell[3 + d] = -BIGVALUE;
bboxCell[3 + d] =
std::numeric_limits<double>::lowest();
}

// get node indices and coordinates for this boundary
Expand Down Expand Up @@ -1015,8 +1020,8 @@ void MeshBlock::getWallBounds(int* mtag, int* existWall, double wbox[6])
int inode;

*mtag = meshtag + (1 - BASE);
wbox[0] = wbox[1] = wbox[2] = BIGVALUE;
wbox[3] = wbox[4] = wbox[5] = -BIGVALUE;
wbox[0] = wbox[1] = wbox[2] = std::numeric_limits<double>::max();
wbox[3] = wbox[4] = wbox[5] = std::numeric_limits<double>::lowest();

if (nwbc <= 0) {
*existWall = 0;
Expand Down Expand Up @@ -1098,8 +1103,9 @@ void MeshBlock::markWallBoundary(int* sam, int nx[3], const double extents[6])
// find the index bounds of each wall boundary cell
// bounding box
//
imin[0] = imin[1] = imin[2] = BIGINT;
imax[0] = imax[1] = imax[2] = -BIGINT;
imin[0] = imin[1] = imin[2] = std::numeric_limits<int>::max();
imax[0] = imax[1] = imax[2] =
std::numeric_limits<int>::lowest();
for (j = 0; j < nvert; j++) {
i3 = 3 * (vconn[n][nvert * i + j] - BASE);
for (k = 0; k < 3; k++) {
Expand Down Expand Up @@ -1547,14 +1553,14 @@ void MeshBlock::getReducedOBB(OBB* obc, double* realData)
return;
*/
for (j = 0; j < 3; j++) {
realData[j] = BIGVALUE;
realData[j + 3] = -BIGVALUE;
realData[j] = std::numeric_limits<double>::max();
realData[j + 3] = std::numeric_limits<double>::lowest();
}
for (n = 0; n < ntypes; n++) {
nvert = nv[n];
for (i = 0; i < nc[n]; i++) {
bbox[0] = bbox[1] = bbox[2] = BIGVALUE;
bbox[3] = bbox[4] = bbox[5] = -BIGVALUE;
bbox[0] = bbox[1] = bbox[2] = std::numeric_limits<double>::max();
bbox[3] = bbox[4] = bbox[5] = std::numeric_limits<double>::lowest();

for (m = 0; m < nvert; m++) {
i3 = 3 * (vconn[n][nvert * i + m] - BASE);
Expand Down Expand Up @@ -1628,8 +1634,8 @@ void MeshBlock::getReducedOBB2(OBB* obc, double* realData)

getobbcoords(obc->xc, obc->dxc, obc->vec, xv);
for (j = 0; j < 3; j++) {
xmin[j] = BIGVALUE;
xmax[j] = -BIGVALUE;
xmin[j] = std::numeric_limits<double>::max();
xmax[j] = std::numeric_limits<double>::lowest();
};
for (n = 0; n < 8; n++) {
transform2OBB(xv[n], obb->xc, obb->vec, xd);
Expand Down Expand Up @@ -1744,8 +1750,8 @@ void MeshBlock::getQueryPoints2(
*nints = *nreals = 0;
getobbcoords(obc->xc, obc->dxc, obc->vec, xv);
for (j = 0; j < 3; j++) {
xmin[j] = BIGVALUE;
xmax[j] = -BIGVALUE;
xmin[j] = std::numeric_limits<double>::max();
xmax[j] = std::numeric_limits<double>::lowest();
};
// writebbox(obc,1);
// writebbox(obb,2);
Expand Down Expand Up @@ -1774,8 +1780,8 @@ void MeshBlock::getQueryPoints2(
//
getobbcoords(obc->xc, mdx, obb->vec, xv);
for (j = 0; j < 3; j++) {
xmin[j] = BIGVALUE;
xmax[j] = -BIGVALUE;
xmin[j] = std::numeric_limits<double>::max();
xmax[j] = std::numeric_limits<double>::lowest();
}
for (m = 0; m < 8; m++) {
transform2OBB(xv[m], obc->xc, obc->vec, xd);
Expand Down Expand Up @@ -2166,8 +2172,8 @@ void MeshBlock::check_for_uniform_hex()
double xd[3];
double xmax[3];
double xmin[3];
xmax[0] = xmax[1] = xmax[2] = -BIGVALUE;
xmin[0] = xmin[1] = xmin[2] = BIGVALUE;
xmax[0] = xmax[1] = xmax[2] = std::numeric_limits<double>::lowest();
xmin[0] = xmin[1] = xmin[2] = std::numeric_limits<double>::max();
//
for (int i = 0; i < nnodes; i++) {
int const i3 = 3 * i;
Expand Down Expand Up @@ -2254,7 +2260,7 @@ void MeshBlock::checkOrphans()
// sprintf(fname,"nodeRes%d.dat",myid);
// FILE *fp=fopen(fname,"w");
for (int i = 0; i < nnodes; i++) {
if (nodeRes[i] >= BIGVALUE) {
if (nodeRes[i] >= std::numeric_limits<double>::max()) {
if (iblank[i] == 1) {
norphan++;
}
Expand All @@ -2275,7 +2281,7 @@ void MeshBlock::checkOrphans()
snprintf(fname, sizeof(fname), "orphan%s.dat", &(intstring[1]));
FILE* fp = fopen(fname, "w");
for (int i = 0; i < nnodes; i++) {
if (nodeRes[i] >= BIGVALUE) {
if (nodeRes[i] >= std::numeric_limits<double>::max()) {
if (iblank[i] == 1) {
fprintf(
fp, "%f %f %f %f\n", x[static_cast<int>(3 * i)],
Expand Down
14 changes: 8 additions & 6 deletions src/bookKeeping.C
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void MeshBlock::processDonors(
}
for (i = 0; i < nnodes; i++) {
if ((mtag1[i] != 0) && (iblank[i] != 0)) {
nodeRes[i] = BIGVALUE;
nodeRes[i] = std::numeric_limits<double>::max();
}
}
TIOGA_FREE(mtag);
Expand Down Expand Up @@ -525,7 +525,7 @@ void MeshBlock::processDonors(

for (i = 0; i < nnodes; i++) {
if ((mtag1[i] != 0) && (iblank[i] != 0)) {
nodeRes[i] = BIGVALUE;
nodeRes[i] = std::numeric_limits<double>::max();
}
}

Expand Down Expand Up @@ -690,7 +690,7 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
if (verbose != 0) TRACED(nodeRes[inode[m]])
i3 = 3 * inode[m];
if (iblank[inode[m]] <= 0 && receptorRes2 > 0.0) {
if (nodeRes[inode[m]] == BIGVALUE) {
if (nodeRes[inode[m]] == std::numeric_limits<double>::max()) {
acceptFlag = 0;
}
if (abs(iblank[inode[m]]) == meshtagrecv) {
Expand All @@ -703,7 +703,8 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
}
//
if (verbose != 0) TRACEI(acceptFlag);
if (receptorRes == BIGVALUE && resolutionScale == 1.0) {
if (receptorRes == std::numeric_limits<double>::max() &&
resolutionScale == 1.0) {
clist = cancelList;
//
// go to the end of the list
Expand All @@ -729,7 +730,8 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
TRACEI(irecord);
TRACEI(donorId[irecord]);
}
if (iblank[inode[m]] <= 0 && nodeRes[inode[m]] != BIGVALUE) {
if (iblank[inode[m]] <= 0 &&
nodeRes[inode[m]] != std::numeric_limits<double>::max()) {
if (iblank[inode[m]] < 0) {
iblank[inode[m]] = 1;
}
Expand Down Expand Up @@ -779,7 +781,7 @@ void MeshBlock::findInterpData(int* recid, int irecord, double receptorRes2)
}
interpList[*recid].inode[m] = donorId[irecord];
interpList[*recid].weights[m] = 0.0;
if (acceptFlag == 0 && receptorRes != BIGVALUE) {
if (acceptFlag == 0 && receptorRes != std::numeric_limits<double>::max()) {
interpList[*recid].cancel = 1;
}
(*recid)++;
Expand Down
6 changes: 4 additions & 2 deletions src/buildADTrecursion.C
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ void buildADTrecursion(
// contained in this leaf
//
for (i = 0; i < nd; i++) {
adtReals[ndim * (*adtCount) + i] = BIGVALUE;
adtReals[ndim * (*adtCount) + i + nd] = -BIGVALUE;
adtReals[ndim * (*adtCount) + i] =
std::numeric_limits<double>::max();
adtReals[ndim * (*adtCount) + i + nd] =
std::numeric_limits<double>::lowest();
}
//
for (i = 0; i < nav; i++) {
Expand Down
6 changes: 4 additions & 2 deletions src/cartOps.C
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ void MeshBlock::getUnresolvedMandatoryReceptors()
fcount = 0;
for (m = 0; m < nvert; m++) {
inode[m] = vconn[n][nvert * i + m] - BASE;
if (nodeRes[inode[m]] >= BIGVALUE) {
if (nodeRes[inode[m]] >=
std::numeric_limits<double>::max()) {
fcount++;
}
}
Expand Down Expand Up @@ -131,7 +132,8 @@ void MeshBlock::getUnresolvedMandatoryReceptors()

ntotalPointsCart = 0;
for (i = 0; i < nnodes; i++) {
if (nodeRes[i] >= BIGVALUE && iblank[i] == 1) {
if (nodeRes[i] >= std::numeric_limits<double>::max() &&
iblank[i] == 1) {
pickedCart[i] = 1;
ntotalPointsCart++;
}
Expand Down
3 changes: 2 additions & 1 deletion src/checkContainment.C
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ void MeshBlock::checkContainment(
cellIndex[0] = -1;
return;
}
if (fabs(frac[m]) < searchTol && cellRes[icell] == BIGVALUE) {
if (fabs(frac[m]) < searchTol &&
cellRes[icell] == std::numeric_limits<double>::max()) {
cellIndex[1] = 1;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/codetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <limits>
/*====================================================================*/
/* Floating point definition */
/*====================================================================*/
Expand All @@ -53,8 +54,6 @@ typedef int32_t qcoord_t;
// #define PI 3.1415926535897932e+00
// #define RAD2DEG (180.0/PI)
// #define DEG2RAD (PI/180.0)
#define BIGVALUE 1.0e+15
#define BIGINT 2147483647
#define TOL 1.0e-10
#define HOLEMAPSIZE 192
// #define NFRINGE 3
Expand Down
Loading

0 comments on commit 1d5d9ca

Please sign in to comment.