Skip to content

Commit

Permalink
More clang-tidy fixes (#64)
Browse files Browse the repository at this point in the history
* uint8_t underlying type for enum

* Changing the argument int nx to const int in markWallBoundary()

* Removed redundant boolean literal

* Changing void return type to void const

* Changing clang version from 17 to 19 for CI

* Updating .clang-tidy to eliminate outdated option

* Replacing macros with enum definitions

* Changing void const to void

* Removing redundant explicit casting

* Addressing the readability-math-missing-parentheses warning

* More readability-math-missing-parentheses fixes

* static_cast<ptrdiff_t>

* static_cast<unsigned long>

* Removing inline specifiers from implicitly inlined functions to eliminate the warning readability-redundant-inline-specifier

* static_cast<ptrdiff_t>() instances in MeshBlock.C

* Changing enum to define in tioga.h

* Fixing enum declarations
  • Loading branch information
itopcuoglu authored Dec 30, 2024
1 parent 02b0a92 commit b4f7aa9
Show file tree
Hide file tree
Showing 28 changed files with 362 additions and 339 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Checks: 'bugprone-*,
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
AnalyzeTemporaryDtors: false
FormatStyle: none
User: user
CheckOptions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
echo "CCACHE_EXTRAFILES=${{github.workspace}}/.clang-tidy" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
echo "CTCACHE_DIR=~/.cache/ctcache" >> $GITHUB_ENV
echo "CLANG_TIDY_VERSION=17" >> $GITHUB_ENV
echo "CLANG_TIDY_VERSION=19" >> $GITHUB_ENV
- name: Install clang-tidy
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
Expand Down
6 changes: 4 additions & 2 deletions src/ADT.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ADT.h"
#include "buildADTrecursion.h"
#include <limits>
#include <cstddef>

void ADT::buildADT(int d, int nelements, double* elementBbox)
{
Expand Down Expand Up @@ -74,7 +75,8 @@ void ADT::buildADT(int d, int nelements, double* elementBbox)
}
for (i = 0; i < ndim / 2; i++) {
i2 = 2 * i + 1;
adtExtents[i2] = std::max(adtExtents[i2], coord[j6 + i + ndim / 2]);
adtExtents[i2] =
std::max(adtExtents[i2], coord[j6 + i + (ndim / 2)]);
}
}
//
Expand Down Expand Up @@ -112,7 +114,7 @@ void ADT::buildADT(int d, int nelements, double* elementBbox)
// fp=fopen("adtReals.dat","w");
// fp1=fopen("adtInts.dat","w");
for (i = 0; i < nelem; i++) {
i4 = 4 * adtIntegers[static_cast<int>(4 * i)];
i4 = 4 * adtIntegers[static_cast<ptrdiff_t>(4 * i)];
adtIntegers[i4 + 3] = i;
}
// for(i=0;i<nelem;i++)
Expand Down
44 changes: 23 additions & 21 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 @@ -111,14 +112,13 @@ void CartBlock::getInterpolatedData(
}

for (i = 0; i < listptr->nweights; i++) {
int const cell_index =
static_cast<int>(cart_utils::get_cell_index(
dims[0], dims[1], nf,
listptr->inode[static_cast<int>(3 * i)],
listptr->inode[3 * i + 1], listptr->inode[3 * i + 2]));
int const cell_index = (cart_utils::get_cell_index(
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];
qq[n] += qcell[cell_index + ncell_nf * n] * weight;
qq[n] += qcell[cell_index + (ncell_nf * n)] * weight;
}

int const ind_offset = 3 * (listptr->nweights + i);
Expand All @@ -129,7 +129,7 @@ void CartBlock::getInterpolatedData(
for (n = 0; n < nvar_node; n++) {
weight = listptr->weights[listptr->nweights + i];
qq[nvar_cell + n] +=
qnode[node_index + nnode_nf * n] * weight;
qnode[node_index + (nnode_nf * n)] * weight;
}
}

Expand All @@ -150,14 +150,14 @@ void CartBlock::update(const double* qval, int index)
return;
}
for (int i = 0; i < nvar_node; i++) {
qnode[index - ncell_nf + nnode_nf * i] = qval[nvar_cell + i];
qnode[index - ncell_nf + (nnode_nf * i)] = qval[nvar_cell + i];
}
} else {
if (nvar_cell == 0) {
return;
}
for (int i = 0; i < nvar_cell; i++) {
qcell[index + ncell_nf * i] = qval[i];
qcell[index + (ncell_nf * i)] = qval[i];
}
}
}
Expand All @@ -166,15 +166,15 @@ void CartBlock::preprocess(CartGrid* cg)
{
int nfrac;
for (int n = 0; n < 3; n++) {
xlo[n] = cg->xlo[3 * global_id + n];
xlo[n] = cg->xlo[(3 * global_id) + n];
}
for (int n = 0; n < 3; n++) {
dx[n] = cg->dx[3 * global_id + n];
dx[n] = cg->dx[(3 * global_id) + n];
}
dims[0] = cg->ihi[static_cast<int>(3 * global_id)] -
cg->ilo[static_cast<int>(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;
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;
myid = cg->myid;
donor_frac = cg->donor_frac;
Expand Down Expand Up @@ -261,9 +261,11 @@ void CartBlock::insertInInterpList(
if (donor_frac == nullptr) {
listptr->nweights = 8;
listptr->weights = (double*)malloc(
sizeof(double) * (static_cast<int>(listptr->nweights * 2)));
sizeof(double) *
(static_cast<unsigned long>(listptr->nweights * 2)));
listptr->inode = (int*)malloc(
sizeof(int) * (static_cast<int>(listptr->nweights * 2 * 3)));
sizeof(int) *
(static_cast<unsigned long>(listptr->nweights * 2 * 3)));

cart_interp::linear_interpolation(
nf, ix, dims, rst, &(listptr->nweights), listptr->inode,
Expand Down Expand Up @@ -758,21 +760,21 @@ void CartBlock::writeCellFile(int bid)
for (k = 0; k < dims[2] + 1; k++) {
for (j = 0; j < dims[1] + 1; j++) {
for (i = 0; i < dims[0] + 1; i++) {
fprintf(fp, "%lf\n", xlo[0] + dx[0] * i);
fprintf(fp, "%lf\n", xlo[0] + (dx[0] * i));
}
}
}
for (k = 0; k < dims[2] + 1; k++) {
for (j = 0; j < dims[1] + 1; j++) {
for (i = 0; i < dims[0] + 1; i++) {
fprintf(fp, "%lf\n", xlo[1] + dx[1] * j);
fprintf(fp, "%lf\n", xlo[1] + (dx[1] * j));
}
}
}
for (k = 0; k < dims[2] + 1; k++) {
for (j = 0; j < dims[1] + 1; j++) {
for (i = 0; i < dims[0] + 1; i++) {
fprintf(fp, "%lf\n", xlo[2] + dx[2] * k);
fprintf(fp, "%lf\n", xlo[2] + (dx[2] * k));
}
}
}
Expand Down
37 changes: 22 additions & 15 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 @@ -159,7 +160,8 @@ void CartGrid::preprocess()
for (i = 0; i < ngrids; i++) {
for (n = 0; n < 3; n++) {
xlosup[n] =
((xlosup[n] <= xlo[3 * i + n]) ? xlosup[n] : xlo[3 * i + n]);
((xlosup[n] <= xlo[(3 * i) + n]) ? xlosup[n]
: xlo[(3 * i) + n]);
}
maxlevel = ((maxlevel >= level_num[i]) ? maxlevel : level_num[i]);
}
Expand All @@ -172,7 +174,7 @@ void CartGrid::preprocess()
for (i = 0; i < ngrids; i++) {
lcount[level_num[i]]++;
for (n = 0; n < 3; n++) {
dxlvl[3 * level_num[i] + n] = dx[3 * i + n];
dxlvl[(3 * level_num[i]) + n] = dx[(3 * i) + n];
}
}
}
Expand All @@ -191,7 +193,8 @@ void CartGrid::search(double* x, int* donorid, int npts)
donorid[i] = -1;
for (l = maxlevel - 1; l >= 0 && static_cast<int>(flag) == 0; l--) {
for (n = 0; n < 3; n++) {
il[n] = floor((x[3 * i + n] - xlosup[n]) / dxlvl[3 * l + n]);
il[n] =
floor((x[(3 * i) + n] - xlosup[n]) / dxlvl[(3 * l) + n]);
}
for (j = 0; j < ngrids && static_cast<int>(flag) == 0; j++) {
if (level_num[j] == l) {
Expand All @@ -202,13 +205,15 @@ void CartGrid::search(double* x, int* donorid, int npts)
// for(n=0;n<3;n++) flag = flag && (il[n] >=ilo[3*j+n]);
// for(n=0;n<3;n++) flag = flag && (il[n] <=ihi[3*j+n]);
for (n = 0; n < 3; n++) {
flag = flag && ((x[3 * i + n] - xlo[3 * j + n]) > -TOL);
flag = flag &&
((x[(3 * i) + n] - xlo[(3 * j) + n]) > -TOL);
}
for (n = 0; n < 3; n++) {
flag = flag &&
((x[3 * i + n] -
(xlo[3 * j + n] +
dx[3 * j + n] * (dims[3 * j + n]))) < TOL);
flag =
flag &&
((x[(3 * i) + n] -
(xlo[(3 * j) + n] +
dx[(3 * j) + n] * (dims[(3 * j) + n]))) < TOL);
}
if (flag) {
dcount++;
Expand All @@ -217,17 +222,19 @@ void CartGrid::search(double* x, int* donorid, int npts)
}
}
}
if (myid == 2 && abs(x[static_cast<int>(3 * i)] - 0.739573) < 1e-5 &&
abs(x[3 * i + 1] + 0.259310) < 1e-5 &&
abs(x[3 * i + 2] + 0.639614) < 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[static_cast<int>(3 * i)],
x[3 * i + 1], x[3 * i + 2], donorid[i]);
"%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[static_cast<int>(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
Loading

0 comments on commit b4f7aa9

Please sign in to comment.