Skip to content

Commit

Permalink
Replacing macros with enum definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu committed Dec 16, 2024
1 parent 100eb70 commit 0b98f9d
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 39 deletions.
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
4 changes: 1 addition & 3 deletions src/MeshBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ class CartGrid;
* 02/20/2014
*/

#define FRINGE (-1)
#define HOLE 0
#define FIELD 1
enum : int8_t { FRINGE = -1, HOLE = 0, FIELD = 1 };

class MeshBlock
{
Expand Down
4 changes: 2 additions & 2 deletions src/cartOps.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <cstdint>
#include "codetypes.h"
#include "MeshBlock.h"
#include "tioga_math.h"
#define ROW 0
#define COLUMN 1
enum : uint8_t { ROW = 0, COLUMN = 1 };

void MeshBlock::setCartIblanks()
{
Expand Down
42 changes: 21 additions & 21 deletions src/codetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ typedef int32_t qcoord_t;
/*====================================================================*/
/* Base for indexing (0 or 1) */
/*====================================================================*/
#define BASE 1

enum : uint8_t { BASE = 1 };
/*====================================================================*/
/* Define arithmetic constants */
/*====================================================================*/
Expand All @@ -55,22 +54,23 @@ typedef int32_t qcoord_t;
// #define RAD2DEG (180.0/PI)
// #define DEG2RAD (PI/180.0)
#define TOL 1.0e-10
#define HOLEMAPSIZE 192
// #define HOLEMAPSIZE 192

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
enum : uint8_t { HOLEMAPSIZE = 192 };
// #define NFRINGE 3
// #define NVAR 6
#define WALLNODETYPE 0
#define OUTERNODETYPE 1
// #define WALLNODETYPE 0
// #define OUTERNODETYPE 1
enum : uint8_t { WALLNODETYPE = 0, OUTERNODETYPE = 1 };
/*==================================================================*/
/* ADAPTIVE HOLE MAP OCTANT INFO */
/*==================================================================*/
#define INTERSECT_ALG \
1 // [0] point-box inclusion only
// [1] face-box intersection (water-tight)

#define NON_UNIQUE_NODES \
1 // [0] wbc nodes are NOT listed as obc nodes
// [1] wbc nodes may also be listed as obc nodes
// 1 // [0] point-box inclusion only
// // [1] face-box intersection (water-tight)
enum : uint8_t { INTERSECT_ALG = 1 };

// 1 // [0] wbc nodes are NOT listed as obc nodes
// // [1] wbc nodes may also be listed as obc nodes
enum : uint8_t { NON_UNIQUE_NODES };
/* Fixed Octree Constraints: Do Not Change */
#define OCTANT_MAXLEVEL 30 // 32-bit integer
#define OCTANT_CHILDREN 8
Expand All @@ -82,9 +82,7 @@ typedef int32_t qcoord_t;
/** Conversion from integer coordinates to double coordinates */
#define INT2DBL ((double)1.0 / (double)OCTANT_ROOT_LEN)

#define OUTSIDE_SB 0
#define INSIDE_SB 1
#define WALL_SB 2
enum : uint8_t { OUTSIDE_SB = 0, INSIDE_SB = 1, WALL_SB = 2 };
/*==================================================================*/
/* inline debugging tools */
/*==================================================================*/
Expand All @@ -109,12 +107,14 @@ typedef int32_t qcoord_t;
/*===================================================================*/
/* Code specific types */
/*===================================================================*/
#define XLO 0
#define XHI 1
#define YLO 2
#define YHI 3
#define ZLO 4
#define ZHI 5
// #define XLO 0
// #define XHI 1
// #define YLO 2
// #define YHI 3
// #define ZLO 4
// #define ZHI 5

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

enum : uint8_t { XLO = 0, XHI = 1, YLO = 2, YHI = 3, ZLO = 4, ZHI = 5 };

/* Mesh Block Complement/Composite Rank Data */
class meshblockCompInfo
Expand Down
5 changes: 3 additions & 2 deletions src/dataUpdate.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
#include "codetypes.h"
#include "MeshBlock.h"

#define ROW 0
#define COLUMN 1
// #define ROW 0
// #define COLUMN 1

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
enum : uint8_t { ROW = 0, COLUMN = 1 };

void MeshBlock::getInterpolatedSolution(
int* nints,
Expand Down
2 changes: 1 addition & 1 deletion src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "tioga.h"
using namespace TIOGA;
#define MAXBLOCKS 100
enum : uint8_t { MAXBLOCKS = 100 };
tioga* tg;
/*
** pointer storage for connectivity arrays that
Expand Down
5 changes: 2 additions & 3 deletions src/highOrder.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include "codetypes.h"
#include "MeshBlock.h"
#include "tioga_utils.h"
#include "tioga_math.h"

#define ROW 0
#define COLUMN 1
#define NFRAC 1331
enum : uint16_t { ROW = 0, COLUMN = 1, NFRAC = 1331 };

void MeshBlock::getCellIblanks2()
{
Expand Down
4 changes: 2 additions & 2 deletions src/kaiser.C
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "kaiser.h"
#include <cmath>
#include <cstdint>

#define NROWS 3
#define NCOLS 3
enum : uint8_t { NROWS = 3, NCOLS = 3 };

// This functions expects a 3x3 matrix
void kaiser(
Expand Down
5 changes: 2 additions & 3 deletions src/tioga.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
* meshes containing element and node IDs greater than what a 4-byte signed int
* can support
*/
#define TIOGA_HAS_UINT64T 1

enum : uint8_t { TIOGA_HAS_UINT64T = 1 };
/** Define a macro entry flagging whether TIOGA has hetereogenous execution
* space support, and uses the new API for registering mesh/solution data
*/
#define TIOGA_HAS_NGP_IFACE 1
enum : uint8_t { TIOGA_HAS_NGP_IFACE = 1 };

/**
* Topology Independent Overset Grid Assembler (TIOGA)
Expand Down

0 comments on commit 0b98f9d

Please sign in to comment.