Skip to content
5 changes: 5 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ Checks: "*,
-cert-*,
-clang-analyzer-optin.mpi.MPI-Checker,
-bugprone-easily-swappable-parameters,
-bugprone-std-namespace-modification,
-bugprone-derived-method-shadowing-base-method,
-bugprone-throwing-static-initialization,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-use-default-member-init,
Expand All @@ -33,6 +37,7 @@ Checks: "*,
-misc-include-cleaner,
-misc-const-correctness,
-misc-no-recursion,
-misc-multiple-inheritance,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-use-nodiscard,
Expand Down
6 changes: 6 additions & 0 deletions framework/data_types/dense_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ Determinant(const DenseMatrix<TYPE>& A)
auto rows = A.Rows();

if (rows == 1)
{
return A(0, 0);
}
else if (rows == 2)
{
return A(0, 0) * A(1, 1) - A(0, 1) * A(1, 0);
Expand Down Expand Up @@ -506,7 +508,9 @@ Inverse(const DenseMatrix<TYPE>& A)
}

if (rows == 1)
{
M(0, 0) = f;
}
else if (rows == 2)
{
M(0, 0) = A(1, 1);
Expand Down Expand Up @@ -585,7 +589,9 @@ Inverse(const DenseMatrix<TYPE>& A)
Scale(M, f);
}
else
{
M = InverseGEPivoting(A);
}

return M;
}
Expand Down
4 changes: 4 additions & 0 deletions framework/data_types/matrix3x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,13 @@ struct Matrix3x3
Vector3 khat(0.0, 0.0, 1.0);

if (n.Dot(khat) > 0.9999999)
{
R.SetDiagonalVec(1.0, 1.0, 1.0);
}
else if (n.Dot(khat) < -0.9999999)
{
R.SetDiagonalVec(1.0, 1.0, -1.0);
}
else
{
auto tangent = n.Cross(khat).Normalized();
Expand Down
6 changes: 1 addition & 5 deletions framework/data_types/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NDArray
using conjunction = std::is_same<bool_pack<true, U::value...>, bool_pack<U::value..., true>>;

template <typename... U>
using AllIntegral = typename conjunction<std::is_integral<U>...>::type;
using AllIntegral = conjunction<std::is_integral<U>...>::type;

public:
/**
Expand Down Expand Up @@ -461,15 +461,11 @@ class NDArray
else if constexpr (sizeof...(args) == 3)
return indices[0] * strides_[0] + indices[1] * strides_[1] + indices[2] * strides_[2];
else if constexpr (sizeof...(args) == 4)
{
return indices[0] * strides_[0] + indices[1] * strides_[1] + indices[2] * strides_[2] +
indices[3] * strides_[3];
}
else if constexpr (sizeof...(args) == 5)
{
return indices[0] * strides_[0] + indices[1] * strides_[1] + indices[2] * strides_[2] +
indices[3] * strides_[3] + indices[4] * strides_[4];
}

size_t index = 0;
for (int i = 0; i < D; ++i)
Expand Down
24 changes: 13 additions & 11 deletions framework/data_types/varying.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ class Varying
};

template <typename T>
using BoolType = typename std::enable_if_t<IsBool<T>::value, T>;
using BoolType = std::enable_if_t<IsBool<T>::value, T>;
template <typename T>
using FloatType = typename std::enable_if_t<IsFloat<T>::value, T>;
using FloatType = std::enable_if_t<IsFloat<T>::value, T>;
template <typename T>
using IntegerType = typename std::enable_if_t<IsInteger<T>::value, T>;
using IntegerType = std::enable_if_t<IsInteger<T>::value, T>;

template <typename T>
using BoolStorageType = typename std::enable_if_t<IsBool<T>::value, bool>;
using BoolStorageType = std::enable_if_t<IsBool<T>::value, bool>;
template <typename T>
using FloatStorageType = typename std::enable_if_t<IsFloat<T>::value, double>;
using FloatStorageType = std::enable_if_t<IsFloat<T>::value, double>;
template <typename T>
using IntegerStorageType = typename std::enable_if_t<IsInteger<T>::value, int64_t>;
using IntegerStorageType = std::enable_if_t<IsInteger<T>::value, int64_t>;
template <typename T>
using UserDataStorageType = typename std::enable_if_t<IsUserData<T>::value, T>;
using UserDataStorageType = std::enable_if_t<IsUserData<T>::value, T>;

template <typename T>
BoolStorageType<T> CastValue(const T& value)
Expand Down Expand Up @@ -309,7 +309,9 @@ class Varying
type_ = VaryingDataType::INTEGER;
}
else
{
type_ = VaryingDataType::USER_DATA;
}

data_ = Helper(CastValue(value));
}
Expand Down Expand Up @@ -405,13 +407,13 @@ class Varying
};

template <typename T>
using StringType = typename std::enable_if_t<IsString<T>::value, T>;
using StringType = std::enable_if_t<IsString<T>::value, T>;
template <typename T>
using SignedIntegerType = typename std::enable_if_t<IsSignedInteger<T>::value, T>;
using SignedIntegerType = std::enable_if_t<IsSignedInteger<T>::value, T>;
template <typename T>
using UnsignedIntegerType = typename std::enable_if_t<IsUnsignedInteger<T>::value, T>;
using UnsignedIntegerType = std::enable_if_t<IsUnsignedInteger<T>::value, T>;
template <typename T>
using UserDataType = typename std::enable_if_t<IsUserData<T>::value, T>;
using UserDataType = std::enable_if_t<IsUserData<T>::value, T>;

/// Returns values of type bool if able.
template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ VectorGhostCommunicator::MapGhostToLocal(const uint64_t ghost_id) const
return local_size_ + k;
}
else
{
return std::nullopt;
}
}

void
Expand Down
2 changes: 2 additions & 0 deletions framework/field_functions/interpolation/ffinter_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ FieldFunctionInterpolationLine::Execute()
}

if (op_type_ == FieldFunctionInterpolationOperation::OP_SUM)
{
mpi_comm.all_reduce(local_sum, op_value_, mpi::op::sum<double>());
}
else if (op_type_ == FieldFunctionInterpolationOperation::OP_AVG)
{
size_t global_size = 0;
Expand Down
2 changes: 2 additions & 0 deletions framework/field_functions/interpolation/ffinterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class FieldFunctionInterpolation
field_function_ = std::move(gbff);
}
else
{
throw std::runtime_error("Expected FieldFunctionGridBased field function");
}
}

FieldFunctionInterpolationType Type() const { return type_; }
Expand Down
2 changes: 2 additions & 0 deletions framework/graphs/linear_graph_partitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ LinearGraphPartitioner::Partition(const std::vector<std::vector<uint64_t>>& grap
pids[n++] = k;
}
else
{
pids.assign(graph.size(), all_to_rank_);
}

log.Log0Verbose1() << "Done partitioning with LinearGraphPartitioner";
return pids;
Expand Down
14 changes: 14 additions & 0 deletions framework/logging/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cout;
}
else
{
use_dummy = true;
}
break;
}
case LOG_0WARNING:
Expand All @@ -51,7 +53,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cout;
}
else
{
use_dummy = true;
}
break;
}
case LOG_0ERROR:
Expand All @@ -62,7 +66,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cerr;
}
else
{
use_dummy = true;
}
break;
}
case LOG_0VERBOSE_1:
Expand All @@ -73,7 +79,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cout;
}
else
{
use_dummy = true;
}
break;
}
case LOG_0VERBOSE_2:
Expand All @@ -84,7 +92,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cout;
}
else
{
use_dummy = true;
}
break;
}
case LOG_ALL:
Expand Down Expand Up @@ -114,7 +124,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cout;
}
else
{
use_dummy = true;
}
break;
}
case LOG_ALLVERBOSE_2:
Expand All @@ -125,7 +137,9 @@ Logger::Log(LOG_LVL level)
stream = &std::cout;
}
else
{
use_dummy = true;
}
break;
}
default:
Expand Down
1 change: 1 addition & 0 deletions framework/logging/log_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct DummyStream : public std::ostream
{
struct DummyStreamBuffer : std::streambuf
{
protected:
int overflow(int c) override { return c; };
} buffer;

Expand Down
2 changes: 2 additions & 0 deletions framework/materials/multi_group_xs/multi_group_xs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ MultiGroupXS::ComputeDiffusionParameters()
diffusion_coeff_[g] = diffusion_coeff_max;
}
else
{
diffusion_coeff_[g] = 1.0 / 3.0 / sigma_tr_[g];
}

// Determine within group scattering
if (not S.empty())
Expand Down
4 changes: 2 additions & 2 deletions framework/math/math.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ InvertMatrix(const std::vector<std::vector<double>>& matrix)
char jobu = 'A';
char jobvt = 'A';
auto n_blas = static_cast<PetscBLASInt>(n);
PetscBLASInt lwork = std::max(PetscBLASInt(1), 5 * n_blas);
PetscBLASInt lwork = std::max(PetscBLASInt{1}, 5 * n_blas);
std::vector<double> work(lwork);
PetscBLASInt info_svd = 0;

Expand Down Expand Up @@ -254,7 +254,7 @@ InvertMatrix(const NDArray<double, 2>& matrix)
char jobu = 'A';
char jobvt = 'A';
auto n_blas = static_cast<PetscBLASInt>(n);
PetscBLASInt lwork = std::max(PetscBLASInt(1), 5 * n_blas);
PetscBLASInt lwork = std::max(PetscBLASInt{1}, 5 * n_blas);
std::vector<double> work(lwork);
PetscBLASInt info_svd = 0;

Expand Down
4 changes: 4 additions & 0 deletions framework/math/petsc_utils/petsc_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ CopyVecToSTLvector(Vec x, std::vector<double>& data, size_t N, bool resize_STL)
data.assign(N, 0.0);
}
else
{
OpenSnLogicalErrorIf(data.size() < N,
"data.size() < N, " + std::to_string(data.size()) + " < " +
std::to_string(N));
}

const PetscScalar* x_ref = nullptr;
OpenSnPETScCall(VecGetArrayRead(x, &x_ref));
Expand All @@ -293,9 +295,11 @@ CopyVecToSTLvectorWithGhosts(Vec x, std::vector<double>& data, size_t N, bool re
data.assign(N, 0.0);
}
else
{
OpenSnLogicalErrorIf(data.size() != N,
"data.size() != N, " + std::to_string(data.size()) + " < " +
std::to_string(N));
}

auto info = GetGhostVectorLocalViewRead(x);
const PetscScalar* x_ref = info.x_localized_raw;
Expand Down
14 changes: 8 additions & 6 deletions framework/math/quadratures/angular/angular_quadrature.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct QuadraturePointPhiTheta;
/// Angular quadrature type identifier.
enum class AngularQuadratureType
{
INVALID = 0,
PRODUCT_QUADRATURE = 1,
SLDFE_SQ = 2,
LEBEDEV_QUADRATURE = 3,
Expand Down Expand Up @@ -62,6 +63,13 @@ class AngularQuadrature
}
};

/// Quadrature-specific order parameter used by harmonic-selection rules.
virtual unsigned int GetQuadratureOrder() const { return 0; }
/// Number of polar angles used by harmonic-selection rules.
virtual unsigned int GetNumPolarAngles() const { return 0; }
/// Number of azimuthal angles used by harmonic-selection rules.
virtual unsigned int GetNumAzimuthalAngles() const { return 0; }

protected:
explicit AngularQuadrature(
AngularQuadratureType type,
Expand All @@ -83,12 +91,6 @@ class AngularQuadrature

/// Populate the map of moment index to spherical harmonic indices.
void MakeHarmonicIndices();
/// Quadrature-specific order parameter used by harmonic-selection rules.
virtual unsigned int GetQuadratureOrder() const { return 0; }
/// Number of polar angles used by harmonic-selection rules.
virtual unsigned int GetNumPolarAngles() const { return 0; }
/// Number of azimuthal angles used by harmonic-selection rules.
virtual unsigned int GetNumAzimuthalAngles() const { return 0; }

/// Discrete-to-moment operator matrix.
/// OpenSn storage is indexed [angle][moment].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ GLProductQuadrature1DSpherical::Initialize(unsigned int Npolar, const bool verbo
w *= fac;
}
else
{
throw std::invalid_argument("GLProductQuadrature1DSpherical: "
"Polar quadrature weights sum to zero.");
}

// Defined on range [-1;+1]
if (std::abs(polar_quad.GetRange().first - polar_quad_span.first) > eps or
Expand Down Expand Up @@ -258,8 +260,10 @@ GLCProductQuadrature2DRZ::Initialize(const GaussQuadrature& quad_polar,
w *= fac;
}
else
{
throw std::invalid_argument("GLCProductQuadrature2DRZ: "
"Polar quadrature weights sum to zero.");
}

// Defined on range [-1;+1]
if (std::abs(polar_quad.GetRange().first - polar_quad_span.first) > eps or
Expand All @@ -283,8 +287,10 @@ GLCProductQuadrature2DRZ::Initialize(const GaussQuadrature& quad_polar,
w *= fac;
}
else
{
throw std::invalid_argument("GLCProductQuadrature2DRZ: "
"Azimuthal quadrature weights sum to zero.");
}

// Defined on range [-1;+1]
if (std::abs(azimu_quad.GetRange().first - azimu_quad_span.first) > eps or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ HarmonicSelectionRules::SelectHarmonics(const SelectionParameters& params)
return SelectSLDFESQ(params);

default:
throw std::logic_error("`quadrature_type` was not set in SelectionParameters");
break;
}

Expand Down
Loading
Loading