Skip to content

Commit

Permalink
Merge pull request #1253 from LLNL/feature/kweiss/odds-and-ends
Browse files Browse the repository at this point in the history
Addresses some odds and ends
  • Loading branch information
kennyweiss committed Jan 8, 2024
2 parents cb18e47 + 030edb3 commit 65dfc3a
Show file tree
Hide file tree
Showing 50 changed files with 180 additions and 144 deletions.
8 changes: 6 additions & 2 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Checks: '-*,readability-braces-around-statements'
# Adds some checks to the code
# the following might also be useful:
# modernize-use-nullptr
# readability-static-definition-in-anonymous-namespace
Checks: '-*,readability-braces-around-statements,modernize-use-using'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFilterRegex: "^.*.hpp$|^.*.cpp$"
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
10 changes: 5 additions & 5 deletions src/axom/core/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,22 +730,22 @@ class Array : public ArrayBase<T, DIM, Array<T, DIM, SPACE>>
"Cannot call Array<T>::resize() when T is non-trivially-"
"constructible. Use Array<T>::reserve() and emplace_back()"
"instead.");
const StackArray<IndexType, DIM> dims {static_cast<IndexType>(args)...};
const StackArray<IndexType, DIM> dims {{static_cast<IndexType>(args)...}};
resizeImpl(dims, true);
}

/// \overload
template <typename... Args, typename Enable = std::enable_if_t<sizeof...(Args) == DIM>>
void resize(ArrayOptions::Uninitialized, Args... args)
{
const StackArray<IndexType, DIM> dims {static_cast<IndexType>(args)...};
const StackArray<IndexType, DIM> dims {{static_cast<IndexType>(args)...}};
resizeImpl(dims, false);
}

template <int Dims = DIM, typename Enable = std::enable_if_t<Dims == 1>>
void resize(IndexType size, const T& value)
{
resizeImpl({size}, true, &value);
resizeImpl({{size}}, true, &value);
}

void resize(const StackArray<IndexType, DIM>& size, const T& value)
Expand Down Expand Up @@ -911,7 +911,7 @@ template <typename T, int DIM, MemorySpace SPACE>
template <typename... Args, typename Enable>
Array<T, DIM, SPACE>::Array(Args... args)
: ArrayBase<T, DIM, Array<T, DIM, SPACE>>(
StackArray<IndexType, DIM> {static_cast<IndexType>(args)...})
StackArray<IndexType, DIM> {{static_cast<IndexType>(args)...}})
, m_allocator_id(axom::detail::getAllocatorID<SPACE>())
{
static_assert(sizeof...(Args) == DIM,
Expand All @@ -927,7 +927,7 @@ template <typename T, int DIM, MemorySpace SPACE>
template <typename... Args, typename Enable>
Array<T, DIM, SPACE>::Array(ArrayOptions::Uninitialized, Args... args)
: ArrayBase<T, DIM, Array<T, DIM, SPACE>>(
StackArray<IndexType, DIM> {static_cast<IndexType>(args)...})
StackArray<IndexType, DIM> {{static_cast<IndexType>(args)...}})
, m_allocator_id(axom::detail::getAllocatorID<SPACE>())
{
static_assert(sizeof...(Args) == DIM,
Expand Down
6 changes: 3 additions & 3 deletions src/axom/core/ArrayBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class ArrayBase
static_assert(sizeof...(Args) <= DIM,
"Index dimensions different from array dimensions");
constexpr int UDim = sizeof...(Args);
const StackArray<IndexType, UDim> indices {static_cast<IndexType>(args)...};
const StackArray<IndexType, UDim> indices {{static_cast<IndexType>(args)...}};
return (*this)[indices];
}
/// \overload
Expand All @@ -255,14 +255,14 @@ class ArrayBase
*/
AXOM_HOST_DEVICE SliceType<1> operator[](const IndexType idx)
{
const StackArray<IndexType, 1> slice {idx};
const StackArray<IndexType, 1> slice {{idx}};
return (*this)[slice];
}

/// \overload
AXOM_HOST_DEVICE ConstSliceType<1> operator[](const IndexType idx) const
{
const StackArray<IndexType, 1> slice {idx};
const StackArray<IndexType, 1> slice {{idx}};
return (*this)[slice];
}

Expand Down
3 changes: 2 additions & 1 deletion src/axom/core/ArrayView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ using MCArrayView = ArrayView<T, 2>;
template <typename T, int DIM, MemorySpace SPACE>
template <typename... Args, typename Enable>
ArrayView<T, DIM, SPACE>::ArrayView(T* data, Args... args)
: ArrayView(data, StackArray<IndexType, DIM> {static_cast<IndexType>(args)...})
: ArrayView(data,
StackArray<IndexType, DIM> {{static_cast<IndexType>(args)...}})
{
static_assert(sizeof...(Args) == DIM,
"Array size must match number of dimensions");
Expand Down
2 changes: 1 addition & 1 deletion src/axom/core/examples/core_numerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void demoMatrix()
// _eigs_start
// Solve for eigenvectors and values using the power method
// The power method calls rand(), so we need to initialize it with srand().
std::srand(std::time(0));
std::srand(std::time(nullptr));
double eigvec[nrows * ncols];
double eigval[nrows];
int res = numerics::eigen_solve(A, nrows, eigvec, eigval);
Expand Down
4 changes: 2 additions & 2 deletions src/axom/core/tests/core_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ void test_resize_with_stackarray(DataType value)
const int K_DIMS = 7;
axom::Array<DataType, 2> arr2;

axom::StackArray<axom::IndexType, 2> dims2 = {I_DIMS, J_DIMS};
axom::StackArray<axom::IndexType, 2> dims2 = {{I_DIMS, J_DIMS}};
arr2.resize(dims2, value);
EXPECT_EQ(arr2.size(), I_DIMS * J_DIMS);
EXPECT_EQ(arr2.shape()[0], I_DIMS);
Expand All @@ -2234,7 +2234,7 @@ void test_resize_with_stackarray(DataType value)

axom::Array<DataType, 3> arr3;

axom::StackArray<axom::IndexType, 3> dims3 = {I_DIMS, J_DIMS, K_DIMS};
axom::StackArray<axom::IndexType, 3> dims3 = {{I_DIMS, J_DIMS, K_DIMS}};
arr3.resize(dims3, value);
EXPECT_EQ(arr3.size(), I_DIMS * J_DIMS * K_DIMS);
EXPECT_EQ(arr3.shape()[0], I_DIMS);
Expand Down
6 changes: 2 additions & 4 deletions src/axom/core/utilities/nvtx/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ namespace axom
{
namespace nvtx
{
/*!
* \brief Predefined set of NVTX colors to use with NVTXRange.
*/
enum class Color : uint32_t
/// \brief Predefined set of NVTX colors to use with NVTXRange
enum class Color : std::uint32_t
{
BLACK = 0x00000000,
GREEN = 0x0000FF00,
Expand Down
8 changes: 3 additions & 5 deletions src/axom/mint/examples/mint_heat_equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,8 @@ const std::string help_string =
"-d INT, -dumpPeriod INT\n"
"\tThe number of cycles to wait between writing a dump file.\n";

/*!
* \brief A structure that holds the command line arguments.
*/
typedef struct
/// A structure that holds the command line arguments.
struct Arguments
{
double h;
double lower_bound[2];
Expand All @@ -379,7 +377,7 @@ typedef struct
double t_max;
int period;
std::string path;
} Arguments;
};

/*!
* \brief Parses and validates the command line arguments.
Expand Down
8 changes: 4 additions & 4 deletions src/axom/mint/fem/FiniteElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class FiniteElement
/// \name Reference Element Attributes
/// @{

typedef void (*ShapeFunctionPtr)(const double* lc, double* phi);
using ShapeFunctionPtr = void (*)(const double* lc, double* phi);
ShapeFunctionPtr m_shapeFunction; /*! shape function functor */
ShapeFunctionPtr m_shapeFunctionDerivatives; /*! derivatives functor */

Expand All @@ -517,7 +517,7 @@ class FiniteElement
DISABLE_MOVE_AND_ASSIGNMENT(FiniteElement);
};

} /* namespace mint */
} // namespace mint
} // namespace axom

//------------------------------------------------------------------------------
Expand All @@ -534,8 +534,8 @@ void bind_basis(FiniteElement& fe)
SLIC_ASSERT(fe.m_reference_center != nullptr);
SLIC_ASSERT(fe.m_reference_coords != nullptr);

typedef mint::FEBasis<BasisType, CELLTYPE> FEBasisType;
typedef typename FEBasisType::ShapeFunctionType ShapeType;
using FEBasisType = mint::FEBasis<BasisType, CELLTYPE>;
using ShapeType = typename FEBasisType::ShapeFunctionType;

if(CELLTYPE != fe.getCellType())
{
Expand Down
4 changes: 2 additions & 2 deletions src/axom/mint/mesh/CellTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ constexpr int NUM_CELL_TYPES = static_cast<int>(CellType::NUM_CELL_TYPES);
*
* \brief Holds information associated with a given cell type.
*/
typedef struct
struct CellInfo
{
CellType cell_type; /*!< cell type, e.g. mint::QUAD, mint::HEX */
const char* name; /*!< the name associated with the cell */
Expand All @@ -119,7 +119,7 @@ typedef struct
int face_nodecount[MAX_CELL_FACES]; /*!< number of nodes for each of cell's faces */
CellType face_types[MAX_CELL_FACES]; /*!< face type, e.g. mint::SEGMENT, mint::QUAD */
IndexType face_nodes[MAX_ALL_FACES_NODES]; /*!< nodes for each of cell's faces */
} CellInfo;
};

// This construct lets us pass literal arrays to function-like macros.
// AR stands for ARray.
Expand Down
3 changes: 2 additions & 1 deletion src/axom/mint/mesh/internal/MeshHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ bool initFaces(Mesh* mesh,
f2noffsets[facecount] = faceNodeOffset;

// Step 4. Now that we have face IDs, record cell-to-face relation.
typedef std::unordered_map<IndexType, std::vector<IndexType>> CellFaceBuilderType;
using CellFaceBuilderType =
std::unordered_map<IndexType, std::vector<IndexType>>;

CellFaceBuilderType cell_to_face;
int cellFaceCount = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/axom/mint/tests/mint_fem_shape_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace
template <int BasisType, mint::CellType CELLTYPE>
void reference_element(double TOL = std::numeric_limits<double>::epsilon())
{
typedef typename mint::FEBasis<BasisType, CELLTYPE> FEMType;
typedef typename FEMType::ShapeFunctionType ShapeFunctionType;
using FEMType = typename mint::FEBasis<BasisType, CELLTYPE>;
using ShapeFunctionType = typename FEMType::ShapeFunctionType;
ShapeFunctionType sf;

SLIC_INFO("checking " << mint::basis_name[BasisType] << " / "
Expand Down Expand Up @@ -84,8 +84,8 @@ void reference_element(double TOL = std::numeric_limits<double>::epsilon())
template <int BasisType, mint::CellType CELLTYPE>
void kronecker_delta()
{
typedef typename mint::FEBasis<BasisType, CELLTYPE> FEMType;
typedef typename FEMType::ShapeFunctionType ShapeFunctionType;
using FEMType = typename mint::FEBasis<BasisType, CELLTYPE>;
using ShapeFunctionType = typename FEMType::ShapeFunctionType;
ShapeFunctionType sf;

SLIC_INFO("checking " << mint::basis_name[BasisType] << " / "
Expand Down Expand Up @@ -122,8 +122,8 @@ void kronecker_delta()
template <int BasisType, mint::CellType CELLTYPE>
void partition_of_unity()
{
typedef typename mint::FEBasis<BasisType, CELLTYPE> FEMType;
typedef typename FEMType::ShapeFunctionType ShapeFunctionType;
using FEMType = typename mint::FEBasis<BasisType, CELLTYPE>;
using ShapeFunctionType = typename FEMType::ShapeFunctionType;
ShapeFunctionType sf;

SLIC_INFO("checking " << mint::basis_name[BasisType] << " / "
Expand Down
46 changes: 38 additions & 8 deletions src/axom/primal/geometry/BezierPatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1896,14 +1896,20 @@ class BezierPatch
VectorType::scalar_triple_product(v1, v2, v3),
0.0,
tol))
{
return false;
}

// Find three points that produce a nonzero normal
Vector3D plane_normal = VectorType::cross_product(v1, v2);
if(axom::utilities::isNearlyEqual(plane_normal.norm(), 0.0, tol))
{
plane_normal = VectorType::cross_product(v1, v3);
}
if(axom::utilities::isNearlyEqual(plane_normal.norm(), 0.0, tol))
{
plane_normal = VectorType::cross_product(v2, v3);
}
plane_normal = plane_normal.unitVector();

double sqDist = 0.0;
Expand Down Expand Up @@ -1936,18 +1942,42 @@ class BezierPatch
const int ord_u = getOrder_u();
const int ord_v = getOrder_v();

if(ord_u <= 0 && ord_v <= 0) return true;
if(ord_u == 1 && ord_v == 0) return true;
if(ord_u == 0 && ord_v == 1) return true;
if(ord_u <= 0 && ord_v <= 0)
{
return true;
}
if(ord_u == 1 && ord_v == 0)
{
return true;
}
if(ord_u == 0 && ord_v == 1)
{
return true;
}

// Check if the patch is planar
if(!isPlanar(tol)) return false;
if(!isPlanar(tol))
{
return false;
}

// Check if each bounding curve is linear
if(!isocurve_u(0).isLinear(tol)) return false;
if(!isocurve_v(0).isLinear(tol)) return false;
if(!isocurve_u(1).isLinear(tol)) return false;
if(!isocurve_v(1).isLinear(tol)) return false;
if(!isocurve_u(0).isLinear(tol))
{
return false;
}
if(!isocurve_v(0).isLinear(tol))
{
return false;
}
if(!isocurve_u(1).isLinear(tol))
{
return false;
}
if(!isocurve_v(1).isLinear(tol))
{
return false;
}

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/axom/primal/geometry/NumericArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,21 @@ std::ostream& operator<<(std::ostream& os, const NumericArray<T, SIZE>& arr);
template <typename T>
struct NonChar
{
typedef T type; /** The non-char type to return */
using type = T; // The non-char type to return
};

template <>
struct NonChar<char>
{
/** A non-char signed type to which we can cast a char for output */
typedef int type;
using type = int;
};

template <>
struct NonChar<unsigned char>
{
/** A non-char unsigned type to which we can cast a char for output */
typedef unsigned int type;
using type = unsigned int;
};

/*!
Expand Down
10 changes: 5 additions & 5 deletions src/axom/primal/geometry/OrientedBoundingBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ template <typename T, int NDIMS>
class OrientedBoundingBox
{
public:
typedef T CoordType;
typedef Point<T, NDIMS> PointType;
typedef Vector<T, NDIMS> VectorType;
typedef OrientedBoundingBox<T, NDIMS> OrientedBoxType;
typedef BoundingBox<T, NDIMS> BoxType;
using CoordType = T;
using PointType = Point<T, NDIMS>;
using VectorType = Vector<T, NDIMS>;
using OrientedBoxType = OrientedBoundingBox<T, NDIMS>;
using BoxType = BoundingBox<T, NDIMS>;

public:
/*!
Expand Down
4 changes: 2 additions & 2 deletions src/axom/primal/geometry/Point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ class Point
/// \name Pre-defined point types
/// @{

typedef Point<double, 2> Point2D;
typedef Point<double, 3> Point3D;
using Point2D = Point<double, 2>;
using Point3D = Point<double, 3>;

/// @}

Expand Down
4 changes: 2 additions & 2 deletions src/axom/primal/geometry/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ class Vector
/// \name Pre-defined Vector types
/// @{

typedef Vector<double, 2> Vector2D;
typedef Vector<double, 3> Vector3D;
using Vector2D = Vector<double, 2>;
using Vector3D = Vector<double, 3>;

/// @}

Expand Down

0 comments on commit 65dfc3a

Please sign in to comment.