From 7334febda503277137ba1e7ed47f339a5c1ded7a Mon Sep 17 00:00:00 2001 From: David Andrs Date: Thu, 11 Jun 2026 12:38:25 -0600 Subject: [PATCH 01/11] Avoid c-style casts --- framework/math/math.cc | 4 ++-- .../angular/legendre_poly/assoc_legendrepoly.cc | 3 ++- .../quadratures/gausschebyshev_quadrature.cc | 2 +- .../math/quadratures/gausslegendre_quadrature.cc | 4 ++-- framework/mesh/mesh_continuum/grid_vtk_utils.cc | 2 +- framework/mesh/mesh_continuum/mesh_continuum.cc | 14 ++++++++------ framework/mesh/mesh_generator/mesh_generator.cc | 3 ++- framework/utils/utils.cc | 6 +++--- framework/utils/utils.h | 6 ++++-- .../sweep/fluds/aahd_structs.h | 16 ++++++++-------- .../sweep/fluds/cbcd_structs.h | 8 ++++---- .../sweep/fluds/fluds_structs.h | 4 ++-- .../lbs_problem/lbs_problem.cc | 4 +++- python/lib/solver.cc | 2 +- 14 files changed, 43 insertions(+), 35 deletions(-) diff --git a/framework/math/math.cc b/framework/math/math.cc index a79e75923d..4416263d2c 100644 --- a/framework/math/math.cc +++ b/framework/math/math.cc @@ -157,7 +157,7 @@ InvertMatrix(const std::vector>& matrix) char jobu = 'A'; char jobvt = 'A'; auto n_blas = static_cast(n); - PetscBLASInt lwork = std::max(PetscBLASInt(1), 5 * n_blas); + PetscBLASInt lwork = std::max(PetscBLASInt{1}, 5 * n_blas); std::vector work(lwork); PetscBLASInt info_svd = 0; @@ -254,7 +254,7 @@ InvertMatrix(const NDArray& matrix) char jobu = 'A'; char jobvt = 'A'; auto n_blas = static_cast(n); - PetscBLASInt lwork = std::max(PetscBLASInt(1), 5 * n_blas); + PetscBLASInt lwork = std::max(PetscBLASInt{1}, 5 * n_blas); std::vector work(lwork); PetscBLASInt info_svd = 0; diff --git a/framework/math/quadratures/angular/legendre_poly/assoc_legendrepoly.cc b/framework/math/quadratures/angular/legendre_poly/assoc_legendrepoly.cc index bbe7f9eac2..2a7dc90e7d 100644 --- a/framework/math/quadratures/angular/legendre_poly/assoc_legendrepoly.cc +++ b/framework/math/quadratures/angular/legendre_poly/assoc_legendrepoly.cc @@ -36,7 +36,8 @@ AssocLegendre(unsigned int ell, int m, double x) double Pmlp1 = 0.0; if (std::cmp_equal(ell, m)) { - Pmlp1 = -(2.0 * ell - 1.0) * sqrt(1.0 - x * x) * AssocLegendre(ell - 1, int(ell) - 1, x); + Pmlp1 = + -(2.0 * ell - 1.0) * sqrt(1.0 - x * x) * AssocLegendre(ell - 1, static_cast(ell) - 1, x); } else { diff --git a/framework/math/quadratures/gausschebyshev_quadrature.cc b/framework/math/quadratures/gausschebyshev_quadrature.cc index 91be3b6480..65e2620e03 100644 --- a/framework/math/quadratures/gausschebyshev_quadrature.cc +++ b/framework/math/quadratures/gausschebyshev_quadrature.cc @@ -10,7 +10,7 @@ namespace opensn { GaussChebyshevQuadrature::GaussChebyshevQuadrature(unsigned int N, bool verbose) - : GaussQuadrature((QuadratureOrder)(2 * N - 1)) + : GaussQuadrature(static_cast(2 * N - 1)) { Initialize(N); } diff --git a/framework/math/quadratures/gausslegendre_quadrature.cc b/framework/math/quadratures/gausslegendre_quadrature.cc index 1869c8b80c..0d93faf63d 100644 --- a/framework/math/quadratures/gausslegendre_quadrature.cc +++ b/framework/math/quadratures/gausslegendre_quadrature.cc @@ -17,7 +17,7 @@ GaussLegendreQuadrature::GaussLegendreQuadrature(QuadratureOrder order, double tol) : GaussQuadrature(order) { - const unsigned int N = std::ceil(((int)order_ + 1) / 2.0); + const unsigned int N = std::ceil((static_cast(order_) + 1) / 2.0); Initialize(N, verbose, max_iters, tol); } @@ -25,7 +25,7 @@ GaussLegendreQuadrature::GaussLegendreQuadrature(unsigned int N, bool verbose, unsigned int max_iters, double tol) - : GaussQuadrature((QuadratureOrder)(2 * N - 1)) + : GaussQuadrature(static_cast(2 * N - 1)) { Initialize(N, verbose, max_iters, tol); } diff --git a/framework/mesh/mesh_continuum/grid_vtk_utils.cc b/framework/mesh/mesh_continuum/grid_vtk_utils.cc index 2d8691246c..4b046f120b 100644 --- a/framework/mesh/mesh_continuum/grid_vtk_utils.cc +++ b/framework/mesh/mesh_continuum/grid_vtk_utils.cc @@ -517,7 +517,7 @@ BuildCellBlockIDsFromField(vtkUGridPtr& ugrid, { std::vector cell_id_vec(1); cell_id_array_ptr->GetTuple(c, cell_id_vec.data()); - const auto mat_id = (int)cell_id_vec.front(); + const auto mat_id = static_cast(cell_id_vec.front()); block_ids[c] = mat_id; } diff --git a/framework/mesh/mesh_continuum/mesh_continuum.cc b/framework/mesh/mesh_continuum/mesh_continuum.cc index b47e6eac33..e471c7c2c9 100644 --- a/framework/mesh/mesh_continuum/mesh_continuum.cc +++ b/framework/mesh/mesh_continuum/mesh_continuum.cc @@ -254,7 +254,8 @@ MeshContinuum::MakeGridFaceHistogram(double master_tolerance, double slave_toler size_t smallest_face = face_size_histogram.front(); size_t largest_face = face_size_histogram.back(); size_t total_num_faces = face_size_histogram.size(); - double average_dofs_per_face = (double)total_face_dofs_count / (double)total_num_faces; + double average_dofs_per_face = + static_cast(total_face_dofs_count) / static_cast(total_num_faces); std::stringstream outstr; outstr << "\nSmallest face = " << smallest_face; @@ -262,12 +263,12 @@ MeshContinuum::MakeGridFaceHistogram(double master_tolerance, double slave_toler outstr << "\nTotal face dofs = " << total_face_dofs_count; outstr << "\nTotal faces = " << face_size_histogram.size(); outstr << "\nAverage dofs/face = " << average_dofs_per_face; - outstr << "\nMax to avg ratio = " << (double)largest_face / average_dofs_per_face; + outstr << "\nMax to avg ratio = " << static_cast(largest_face) / average_dofs_per_face; log.LogAllVerbose2() << outstr.str(); // Determine number of bins size_t last_bin_num_faces = total_num_faces; - if (((double)largest_face / average_dofs_per_face) > master_tolerance) + if ((static_cast(largest_face) / average_dofs_per_face) > master_tolerance) { log.LogAllVerbose2() << "The ratio of max face dofs to average face dofs " << "is larger than " << master_tolerance @@ -283,7 +284,7 @@ MeshContinuum::MakeGridFaceHistogram(double master_tolerance, double slave_toler for (size_t f = 0; f < total_num_faces; ++f) { - if (((double)face_size_histogram[f] / running_average) > slave_tolerance) + if ((static_cast(face_size_histogram[f]) / running_average) > slave_tolerance) { face_categories_list.emplace_back(running_face_size, running_face_count); running_total_face_dofs = 0; @@ -293,7 +294,8 @@ MeshContinuum::MakeGridFaceHistogram(double master_tolerance, double slave_toler running_face_size = face_size_histogram[f]; running_total_face_dofs += face_size_histogram[f]; running_face_count++; - running_average = (double)running_total_face_dofs / double(running_face_count); + running_average = + static_cast(running_total_face_dofs) / static_cast(running_face_count); last_bin_num_faces = running_face_count; } } @@ -725,7 +727,7 @@ MeshContinuum::ComputeCentroidFromListOfNodes(const std::vector& list) for (auto node_id : list) centroid = centroid + vertices[node_id]; - return centroid / double(list.size()); + return centroid / static_cast(list.size()); } std::array, 4> diff --git a/framework/mesh/mesh_generator/mesh_generator.cc b/framework/mesh/mesh_generator/mesh_generator.cc index 5b1798c139..3ee377bb2b 100644 --- a/framework/mesh/mesh_generator/mesh_generator.cc +++ b/framework/mesh/mesh_generator/mesh_generator.cc @@ -270,7 +270,8 @@ MeshGenerator::ComputeAndPrintStats(const std::shared_ptr& grid) const size_t avg_num_local_cells = num_global_cells / mpi_comm.size(); const size_t num_local_ghosts = grid->cells.GhostCellCount(); - const double local_ghost_to_local_cell_ratio = double(num_local_ghosts) / double(num_local_cells); + const double local_ghost_to_local_cell_ratio = + static_cast(num_local_ghosts) / static_cast(num_local_cells); double average_ghost_ratio = 0.0; mpi_comm.all_reduce(local_ghost_to_local_cell_ratio, average_ghost_ratio, mpi::op::sum()); diff --git a/framework/utils/utils.cc b/framework/utils/utils.cc index 84aa4b4938..feee41056a 100644 --- a/framework/utils/utils.cc +++ b/framework/utils/utils.cc @@ -124,14 +124,14 @@ PrintIterationProgress(const size_t current_iteration, return output.str(); } - const double dI = std::ceil(double(N) / I); // Interval size + const double dI = std::ceil(static_cast(N) / I); // Interval size // std::modf is used to get the integral part // of a real value double x1 = 0.0; - std::modf(double(i - 1) / dI, &x1); + std::modf(static_cast(i - 1) / dI, &x1); double x2 = 0.0; - std::modf(double(i) / dI, &x2); + std::modf(static_cast(i) / dI, &x2); if (static_cast(x2) != static_cast(x1)) { diff --git a/framework/utils/utils.h b/framework/utils/utils.h index acbf9d948a..333feb226e 100644 --- a/framework/utils/utils.h +++ b/framework/utils/utils.h @@ -109,7 +109,8 @@ template void WriteBinaryValue(std::ofstream& output_file, const T& value) { - output_file.write((char*)&value, sizeof(T)); + const void* address = &value; + output_file.write(static_cast(address), sizeof(T)); } template <> @@ -125,7 +126,8 @@ T ReadBinaryValue(std::ifstream& input_file) { T value; - input_file.read((char*)&value, sizeof(T)); + void* address = &value; + input_file.read(static_cast(address), sizeof(T)); return value; } diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h index dd73ce383a..386b762418 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h @@ -47,7 +47,7 @@ class AAHD_NodeIndex : public NodeIndex bool is_local_or_reflecting, bool is_delayed_or_angle_dependent) { - if (index >= (std::uint64_t(1) << 60) - 1) + if (index >= (std::uint64_t{1} << 60) - 1) throw std::runtime_error("Cannot hold an index greater than 2^60."); SetInOut(is_outgoing); SetBoundary(is_boundary); @@ -76,7 +76,7 @@ class AAHD_NodeIndex : public NodeIndex /// \name Delayed/angle-dependent bit /// \{ /// Third bit mask (``001`` followed by 61 zeros) - Bit 61 - static constexpr std::uint64_t delayed_or_angle_dependent_bit_mask = std::uint64_t(1) << (64 - 3); + static constexpr std::uint64_t delayed_or_angle_dependent_bit_mask = std::uint64_t{1} << (64 - 3); /// Encode the value as delayed or angle dependent boundary. constexpr void SetDelayedOrAngleDependent(bool is_delayed_or_angle_dependent) noexcept { @@ -90,7 +90,7 @@ class AAHD_NodeIndex : public NodeIndex /// \name Local/reflecting bit /// \{ /// Fourth bit mask (``0001`` followed by 60 zeros) - Bit 60 - static constexpr std::uint64_t local_or_reflecting_bit_mask = std::uint64_t(1) << (64 - 4); + static constexpr std::uint64_t local_or_reflecting_bit_mask = std::uint64_t{1} << (64 - 4); /// Encode the value as local. constexpr void SetLocalOrReflecting(bool is_local_or_reflecting) noexcept { @@ -104,7 +104,7 @@ class AAHD_NodeIndex : public NodeIndex /// \name Index bits /// \{ /// Index bit mask (``1`` at the last 60 bits). - static constexpr std::uint64_t index_bit_mask = (std::uint64_t(1) << (64 - 4)) - 1; + static constexpr std::uint64_t index_bit_mask = (std::uint64_t{1} << (64 - 4)) - 1; /// Encode the index. constexpr void SetIndex(const std::uint64_t& index) noexcept { @@ -146,22 +146,22 @@ class AAHD_NonLocalFaceNode std::uint16_t neighbor_face_node_idx) : node(cell_local_idx, face_idx, face_node_idx) { - std::uint32_t packed_cell_idx = (std::uint32_t(face_idx) << 16) | face_node_idx; + std::uint32_t packed_cell_idx = (std::uint32_t{face_idx} << 16) | face_node_idx; std::uint32_t packed_neighbor_idx = - (std::uint32_t(neighbor_face_idx) << 16) | neighbor_face_node_idx; + (std::uint32_t{neighbor_face_idx} << 16) | neighbor_face_node_idx; if (cell_global_idx < neighbor_global_idx) { global_ordering_ = std::make_tuple(cell_global_idx, neighbor_global_idx, - (std::uint64_t(packed_cell_idx) << 32) | packed_neighbor_idx); + (std::uint64_t{packed_cell_idx} << 32) | packed_neighbor_idx); } else if (neighbor_global_idx < cell_global_idx) { global_ordering_ = std::make_tuple(neighbor_global_idx, cell_global_idx, - (std::uint64_t(packed_neighbor_idx) << 32) | packed_cell_idx); + (std::uint64_t{packed_neighbor_idx} << 32) | packed_cell_idx); } else throw std::runtime_error("Non local face node requires cell with different global index.\n"); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_structs.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_structs.h index ff61072456..b18f9c355c 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_structs.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_structs.h @@ -33,7 +33,7 @@ class CBCD_NodeIndex : public NodeIndex */ CBCD_NodeIndex(std::uint64_t index, bool is_outgoing, bool is_local) { - if (index >= (std::uint64_t(1) << 61) - 1) + if (index >= (std::uint64_t{1} << 61) - 1) throw std::runtime_error("Cannot hold an index greater than 2^61."); SetInOut(is_outgoing); SetLocal(is_local); @@ -48,7 +48,7 @@ class CBCD_NodeIndex : public NodeIndex */ CBCD_NodeIndex(std::uint64_t index, bool is_outgoing) { - if (index >= (std::uint64_t(1) << 61) - 1) + if (index >= (std::uint64_t{1} << 61) - 1) throw std::runtime_error("Cannot hold an index greater than 2^61."); SetInOut(is_outgoing); SetLocal(true); @@ -66,7 +66,7 @@ class CBCD_NodeIndex : public NodeIndex /// \name Local bit /// \{ /// Third bit mask (``001`` followed by 61 zeros) - Bit 61. - static constexpr std::uint64_t local_bit_mask = std::uint64_t(1) << (64 - 3); + static constexpr std::uint64_t local_bit_mask = std::uint64_t{1} << (64 - 3); /// Encode the value as local. constexpr void SetLocal(bool is_local) noexcept { @@ -80,7 +80,7 @@ class CBCD_NodeIndex : public NodeIndex /// \name Index bits /// \{ /// Index bit mask (``1`` at the last 61 bits). - static constexpr std::uint64_t index_bit_mask = (std::uint64_t(1) << (64 - 3)) - 1; + static constexpr std::uint64_t index_bit_mask = (std::uint64_t{1} << (64 - 3)) - 1; /// Encode the index. constexpr void SetIndex(std::uint64_t index) noexcept { diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds_structs.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds_structs.h index 524fecf412..d8d45ee52c 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds_structs.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds_structs.h @@ -48,7 +48,7 @@ class NodeIndex /// \name Incoming/outgoing bit /// \{ /// First bit mask (``1`` followed by 63 zeros). - static constexpr std::uint64_t inout_bit_mask = std::uint64_t(1) << (64 - 1); + static constexpr std::uint64_t inout_bit_mask = std::uint64_t{1} << (64 - 1); /// Encode the value as incoming or outgoing. constexpr void SetInOut(bool is_outgoing) noexcept { @@ -62,7 +62,7 @@ class NodeIndex /// \name Boundary bit /// \{ /// Second bit mask (``01`` followed by 62 zeros). - static constexpr std::uint64_t boundary_bit_mask = std::uint64_t(1) << (64 - 2); + static constexpr std::uint64_t boundary_bit_mask = std::uint64_t{1} << (64 - 2); /// Encode the value as boundary. constexpr void SetBoundary(bool is_boundary) noexcept { diff --git a/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc b/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc index 3e1db93612..0d58a62c5c 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc @@ -1054,7 +1054,9 @@ LBSProblem::ComputeUnitIntegrals() opensn::mpi_comm.barrier(); log.Log() << program_timer.GetTimeString() << " Ghost cell unit cell-matrix ratio: " - << (double)num_global_ucms[1] * 100 / (double)num_global_ucms[0] << "%"; + << static_cast(num_global_ucms[1]) * 100 / + static_cast(num_global_ucms[0]) + << "%"; log.Log() << program_timer.GetTimeString() << " Cell matrices computed."; } diff --git a/python/lib/solver.cc b/python/lib/solver.cc index 18acb4148d..2ec32a10ac 100644 --- a/python/lib/solver.cc +++ b/python/lib/solver.cc @@ -1210,7 +1210,7 @@ WrapLBS(py::module& slv) continue; // construct numpy array and copy contents const auto& grp_wise_leakage = it->second; - py::array_t np_vector(py::ssize_t(grp_wise_leakage.size())); + py::array_t np_vector(static_cast(grp_wise_leakage.size())); auto buffer = np_vector.request(); auto *np_vector_data = static_cast(buffer.ptr); std::copy(grp_wise_leakage.begin(), grp_wise_leakage.end(), np_vector_data); From c393931a41a96cd7a54c02cfc12652b06ba61676 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Thu, 11 Jun 2026 12:45:41 -0600 Subject: [PATCH 02/11] Use `py::overload_cast` instead of `static_cast` Fixing clang-tidy warning --- python/lib/solver.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/lib/solver.cc b/python/lib/solver.cc index 2ec32a10ac..71e0d265d6 100644 --- a/python/lib/solver.cc +++ b/python/lib/solver.cc @@ -1717,8 +1717,7 @@ WrapTransient(py::module& slv) )"); transient_solver.def( "SetPreAdvanceCallback", - static_cast( - &TransientSolver::SetPreAdvanceCallback), + py::overload_cast(&TransientSolver::SetPreAdvanceCallback), "Clear the PreAdvance callback by passing None."); transient_solver.def( "SetPostAdvanceCallback", @@ -1734,8 +1733,7 @@ WrapTransient(py::module& slv) )"); transient_solver.def( "SetPostAdvanceCallback", - static_cast( - &TransientSolver::SetPostAdvanceCallback), + py::overload_cast(&TransientSolver::SetPostAdvanceCallback), "Clear the PostAdvance callback by passing None."); transient_solver.def( "ComputeBalanceTable", From 5c0d5f0e27af2b124566037df6bc07b91ad25d0c Mon Sep 17 00:00:00 2001 From: David Andrs Date: Thu, 11 Jun 2026 12:53:53 -0600 Subject: [PATCH 03/11] Fixing initialization of an enum with an non-existing value --- framework/math/quadratures/angular/angular_quadrature.h | 1 + framework/math/quadratures/angular/harmonic_selection_rules.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/framework/math/quadratures/angular/angular_quadrature.h b/framework/math/quadratures/angular/angular_quadrature.h index 98872259b9..f1f1bce25f 100644 --- a/framework/math/quadratures/angular/angular_quadrature.h +++ b/framework/math/quadratures/angular/angular_quadrature.h @@ -16,6 +16,7 @@ struct QuadraturePointPhiTheta; /// Angular quadrature type identifier. enum class AngularQuadratureType { + INVALID = 0, PRODUCT_QUADRATURE = 1, SLDFE_SQ = 2, LEBEDEV_QUADRATURE = 3, diff --git a/framework/math/quadratures/angular/harmonic_selection_rules.cc b/framework/math/quadratures/angular/harmonic_selection_rules.cc index f6ae667bdb..2289845c03 100644 --- a/framework/math/quadratures/angular/harmonic_selection_rules.cc +++ b/framework/math/quadratures/angular/harmonic_selection_rules.cc @@ -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; } From 3c50cc2ffca13233ab375df8c09521c05f6d2575 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Fri, 12 Jun 2026 10:05:02 -0600 Subject: [PATCH 04/11] Replacing `std::atoi` with `std::strtol` `std::atoi` provides no error handling at all; if the string is completely invalid, it just returns 0, and if the number overflows, the behavior is undefined. --- python/lib/context.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/lib/context.cc b/python/lib/context.cc index fad346671f..80c3ccb62b 100644 --- a/python/lib/context.cc +++ b/python/lib/context.cc @@ -168,8 +168,13 @@ WrapSysArgv(py::module& context) if (arg == "-v" || arg == "--verbose") { auto next_arg = sys_argv[++i_arg].cast(); - log.SetVerbosity(std::atoi(next_arg.c_str())); - continue; + char* endptr = nullptr; + const char* str_ptr = next_arg.c_str(); + auto parsed_val = std::strtol(str_ptr, &endptr, 10); + if (endptr != str_ptr && *endptr == '\0') { + log.SetVerbosity(static_cast(parsed_val)); + continue; + } } // caliper if (arg == "--caliper") From ed7182139e3832b5d23307cea55878deb91b1269 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Fri, 12 Jun 2026 10:11:01 -0600 Subject: [PATCH 05/11] Removing redundant parentheses clang-tidy-22 reports that as an error now. --- framework/mesh/io/gmsh_io_v22.cc | 2 +- framework/mesh/io/gmsh_io_v41.cc | 4 ++-- framework/mesh/raytrace/raytracer.cc | 2 +- .../sweep/boundary/isotropic_boundary.cc | 2 +- .../sweep/boundary/reflecting_boundary.cc | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/mesh/io/gmsh_io_v22.cc b/framework/mesh/io/gmsh_io_v22.cc index 5d7a752f3e..d386abb5c4 100644 --- a/framework/mesh/io/gmsh_io_v22.cc +++ b/framework/mesh/io/gmsh_io_v22.cc @@ -348,7 +348,7 @@ MeshIO::FromGmshV22(const UnpartitionedMesh::Options& options) file.close(); // create boundary names and IDs - unsigned int dimension = (mesh_is_2D) ? 2 : 3; + unsigned int dimension = mesh_is_2D ? 2 : 3; for (auto& [id, e] : physical_names) { if (std::get<0>(e) == dimension - 1) diff --git a/framework/mesh/io/gmsh_io_v41.cc b/framework/mesh/io/gmsh_io_v41.cc index dc56a7da1f..9af472fb05 100644 --- a/framework/mesh/io/gmsh_io_v41.cc +++ b/framework/mesh/io/gmsh_io_v41.cc @@ -570,7 +570,7 @@ MeshIO::FromGmshV41ASCII(const UnpartitionedMesh::Options& options) file.close(); // create boundary names and IDs - unsigned int dimension = (mesh_is_2D) ? 2 : 3; + unsigned int dimension = mesh_is_2D ? 2 : 3; mesh->SetDimension(dimension); for (auto& [id, e] : physical_names) { @@ -1045,7 +1045,7 @@ MeshIO::FromGmshV41Binary(const UnpartitionedMesh::Options& options, int data_si } // create boundary names and IDs - const unsigned int dimension = (mesh_is_2D) ? 2 : 3; + const unsigned int dimension = mesh_is_2D ? 2 : 3; mesh->SetDimension(dimension); for (const auto& [id, data] : physical_names) { diff --git a/framework/mesh/raytrace/raytracer.cc b/framework/mesh/raytrace/raytracer.cc index 9ee7456334..865d7487dc 100644 --- a/framework/mesh/raytrace/raytracer.cc +++ b/framework/mesh/raytrace/raytracer.cc @@ -130,7 +130,7 @@ RayTracer::TraceRay(const Cell& cell, Vector3& pos_i, Vector3& omega_i, int func std::stringstream outstr; outstr << "Intersection not found at function level " << function_depth << "." - << ((backward_tolerance_hit) ? " Backward tolerance hit. " : "") + << (backward_tolerance_hit ? " Backward tolerance hit. " : "") << "For particle xyz=" << pos_i.PrintStr() << " uvw=" << omega_i.PrintStr() << " " << (pos_i + extension_distance_ * omega_i).PrintStr() << " " << extension_distance_ << " in cell " << cell.global_id << " with vertices: \n"; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc index a65b9fdba5..5ca9c93f87 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc @@ -38,7 +38,7 @@ IsotropicBoundary::UpdateBoundaryFlux(const std::vector& groupsets) double* boundary_flux = GetBoundaryFlux(groupset.id); for (unsigned int g = 0; g < groupset.GetNumGroups(); ++g) { - boundary_flux[g] = ((is_active) ? active_boundary_flux_[groupset.first_group + g] : 0.0); + boundary_flux[g] = (is_active ? active_boundary_flux_[groupset.first_group + g] : 0.0); } } current_state_ = is_active; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc index c121df12ec..6598d0a2f8 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc @@ -25,7 +25,7 @@ ReflectingBoundary::TransformGroupset(int groupset_id, Fn&& fn) auto&& f = std::forward(fn); const auto& extra_data = extra_data_[groupset_id]; const auto old_stride = extra_data.old_stride; - double* flux = GetBoundaryFlux(groupset_id, (ApplyOnOldFlux) ? old_stride : 0); + double* flux = GetBoundaryFlux(groupset_id, ApplyOnOldFlux ? old_stride : 0); std::size_t size = old_stride * bank_[groupset_id].groupset_size; std::span flux_view(flux, size); f(flux_view); @@ -40,7 +40,7 @@ ReflectingBoundary::TransformGroupset(int groupset_id, Fn&& fn) const auto&& f = std::forward(fn); const auto& extra_data = extra_data_[groupset_id]; const auto old_stride = extra_data.old_stride; - const double* flux = GetBoundaryFlux(groupset_id, (ApplyOnOldFlux) ? old_stride : 0); + const double* flux = GetBoundaryFlux(groupset_id, ApplyOnOldFlux ? old_stride : 0); std::size_t size = old_stride * bank_[groupset_id].groupset_size; std::span flux_view(flux, size); f(flux_view); @@ -55,7 +55,7 @@ ReflectingBoundary::ForEachDelayedAngularFlux(int groupset_id, Fn&& fn) auto&& f = std::forward(fn); const auto& extra_data = extra_data_[groupset_id]; const auto old_stride = extra_data.old_stride; - double* flux = GetBoundaryFlux(groupset_id, (ApplyOnOldFlux) ? old_stride : 0); + double* flux = GetBoundaryFlux(groupset_id, ApplyOnOldFlux ? old_stride : 0); std::size_t size = old_stride * bank_[groupset_id].groupset_size; std::for_each_n(flux, size, f); } @@ -69,7 +69,7 @@ ReflectingBoundary::ForEachDelayedAngularFlux(int groupset_id, Fn&& fn) const auto&& f = std::forward(fn); const auto& extra_data = extra_data_[groupset_id]; const auto old_stride = extra_data.old_stride; - const double* flux = GetBoundaryFlux(groupset_id, (ApplyOnOldFlux) ? old_stride : 0); + const double* flux = GetBoundaryFlux(groupset_id, ApplyOnOldFlux ? old_stride : 0); std::size_t size = old_stride * bank_[groupset_id].groupset_size; std::for_each_n(flux, size, f); } From edc5c89bfe20b61493d5769b6e67c383a2c82d82 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Fri, 12 Jun 2026 11:33:59 -0600 Subject: [PATCH 06/11] Patching warnings produced by `readability-inconsistent-ifelse-braces` --- framework/data_types/dense_matrix.h | 6 ++++++ framework/data_types/matrix3x3.h | 4 ++++ framework/data_types/ndarray.h | 4 ---- framework/data_types/varying.h | 2 ++ .../vector_ghost_communicator.cc | 2 ++ .../field_functions/interpolation/ffinter_line.cc | 2 ++ .../interpolation/ffinterpolation.h | 2 ++ framework/graphs/linear_graph_partitioner.cc | 2 ++ framework/logging/log.cc | 14 ++++++++++++++ .../materials/multi_group_xs/multi_group_xs.cc | 2 ++ framework/math/petsc_utils/petsc_utils.cc | 4 ++++ .../angular/curvilinear_product_quadrature.cc | 6 ++++++ .../quadratures/angular/sldfe_sq_quadrature.cc | 6 ++++++ .../piecewise_linear_continuous.cc | 10 ++++++---- framework/math/unknown_manager/unknown_manager.cc | 2 ++ framework/mesh/io/foam_io.cc | 6 ++++++ framework/mesh/io/gmsh_io_v22.cc | 2 ++ framework/mesh/io/gmsh_io_v41.cc | 3 ++- framework/mesh/io/vtk_io.cc | 6 ++++++ framework/mesh/mesh_continuum/grid_vtk_utils.cc | 2 ++ .../mesh/mesh_generator/extruder_mesh_generator.cc | 2 ++ framework/mesh/mesh_generator/mesh_generator.cc | 2 ++ framework/mesh/raytrace/raytracer.cc | 4 ++++ .../mesh/unpartitioned_mesh/unpartitioned_mesh.cc | 2 ++ framework/object_factory.cc | 2 ++ framework/parameters/input_parameters.cc | 8 ++++++++ framework/utils/hdf_utils.h | 2 ++ modules/diffusion/diffusion.cc | 4 ++++ modules/diffusion/diffusion_mip_solver.cc | 10 ++++++++++ modules/diffusion/diffusion_pwlc_solver.cc | 2 ++ .../sweep_chunks/aah_sweep_chunk_rz.cc | 4 ++++ .../acceleration/cmfd_acceleration.cc | 8 ++++++++ .../discrete_ordinates_problem.cc | 14 ++++++++++++++ .../iterative_methods/ags_linear_solver.cc | 4 ++++ .../iterative_methods/classic_richardson.cc | 2 ++ .../iterative_methods/sweep_wgs_context.cc | 2 ++ .../sweep/angle_set/aah_angle_set.cc | 4 ++++ .../sweep/boundary/reflecting_boundary.cc | 2 ++ .../sweep/communicators/cbc_async_comm.cc | 2 ++ .../sweep/fluds/aahd_structs.h | 2 ++ .../sweep/fluds/cbc_fluds.cc | 2 ++ .../sweep/scheduler/sweep_scheduler.cc | 2 ++ .../discrete_ordinates_problem/sweep/spds/aah.cc | 2 ++ .../discrete_ordinates_problem/sweep/spds/spds.cc | 2 ++ .../sweep_chunks/aah_avx_sweep_chunk.cc | 2 ++ .../sweep_chunks/cbc_avx_sweep_chunk.cc | 2 ++ .../sweep_chunks/cbc_sweep_kernels.h | 2 ++ .../lbs_problem/io/restart_io.cc | 2 ++ .../lbs_problem/lbs_problem.cc | 4 ++++ .../postprocessors/volume_postprocessor.cc | 2 ++ .../volumetric_source/volumetric_source.cc | 4 ++++ .../response_evaluator/response_evaluator.cc | 2 ++ .../uncollided_problem/uncollided_problem.cc | 2 ++ python/lib/py_app.cc | 2 ++ python/lib/solver.cc | 14 ++++++++++++++ 55 files changed, 206 insertions(+), 9 deletions(-) diff --git a/framework/data_types/dense_matrix.h b/framework/data_types/dense_matrix.h index 5952b16d53..e34a46522d 100644 --- a/framework/data_types/dense_matrix.h +++ b/framework/data_types/dense_matrix.h @@ -356,7 +356,9 @@ Determinant(const DenseMatrix& 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); @@ -506,7 +508,9 @@ Inverse(const DenseMatrix& A) } if (rows == 1) + { M(0, 0) = f; + } else if (rows == 2) { M(0, 0) = A(1, 1); @@ -585,7 +589,9 @@ Inverse(const DenseMatrix& A) Scale(M, f); } else + { M = InverseGEPivoting(A); + } return M; } diff --git a/framework/data_types/matrix3x3.h b/framework/data_types/matrix3x3.h index 04d301de06..7a29e8414f 100644 --- a/framework/data_types/matrix3x3.h +++ b/framework/data_types/matrix3x3.h @@ -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(); diff --git a/framework/data_types/ndarray.h b/framework/data_types/ndarray.h index 60cfcf2af1..bdabe5b7cb 100644 --- a/framework/data_types/ndarray.h +++ b/framework/data_types/ndarray.h @@ -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) diff --git a/framework/data_types/varying.h b/framework/data_types/varying.h index 02cff748a1..18703651b2 100644 --- a/framework/data_types/varying.h +++ b/framework/data_types/varying.h @@ -309,7 +309,9 @@ class Varying type_ = VaryingDataType::INTEGER; } else + { type_ = VaryingDataType::USER_DATA; + } data_ = Helper(CastValue(value)); } diff --git a/framework/data_types/vector_ghost_communicator/vector_ghost_communicator.cc b/framework/data_types/vector_ghost_communicator/vector_ghost_communicator.cc index 0b0424f29b..198157d1c8 100644 --- a/framework/data_types/vector_ghost_communicator/vector_ghost_communicator.cc +++ b/framework/data_types/vector_ghost_communicator/vector_ghost_communicator.cc @@ -144,7 +144,9 @@ VectorGhostCommunicator::MapGhostToLocal(const uint64_t ghost_id) const return local_size_ + k; } else + { return std::nullopt; + } } void diff --git a/framework/field_functions/interpolation/ffinter_line.cc b/framework/field_functions/interpolation/ffinter_line.cc index 9f0c615226..917ea42048 100644 --- a/framework/field_functions/interpolation/ffinter_line.cc +++ b/framework/field_functions/interpolation/ffinter_line.cc @@ -137,7 +137,9 @@ FieldFunctionInterpolationLine::Execute() } if (op_type_ == FieldFunctionInterpolationOperation::OP_SUM) + { mpi_comm.all_reduce(local_sum, op_value_, mpi::op::sum()); + } else if (op_type_ == FieldFunctionInterpolationOperation::OP_AVG) { size_t global_size = 0; diff --git a/framework/field_functions/interpolation/ffinterpolation.h b/framework/field_functions/interpolation/ffinterpolation.h index 097e7d52ae..385f92c40c 100644 --- a/framework/field_functions/interpolation/ffinterpolation.h +++ b/framework/field_functions/interpolation/ffinterpolation.h @@ -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_; } diff --git a/framework/graphs/linear_graph_partitioner.cc b/framework/graphs/linear_graph_partitioner.cc index 5b6e1b7aa8..d86f508753 100644 --- a/framework/graphs/linear_graph_partitioner.cc +++ b/framework/graphs/linear_graph_partitioner.cc @@ -64,7 +64,9 @@ LinearGraphPartitioner::Partition(const std::vector>& grap pids[n++] = k; } else + { pids.assign(graph.size(), all_to_rank_); + } log.Log0Verbose1() << "Done partitioning with LinearGraphPartitioner"; return pids; diff --git a/framework/logging/log.cc b/framework/logging/log.cc index 5d05367800..7d0aa6abe2 100644 --- a/framework/logging/log.cc +++ b/framework/logging/log.cc @@ -40,7 +40,9 @@ Logger::Log(LOG_LVL level) stream = &std::cout; } else + { use_dummy = true; + } break; } case LOG_0WARNING: @@ -51,7 +53,9 @@ Logger::Log(LOG_LVL level) stream = &std::cout; } else + { use_dummy = true; + } break; } case LOG_0ERROR: @@ -62,7 +66,9 @@ Logger::Log(LOG_LVL level) stream = &std::cerr; } else + { use_dummy = true; + } break; } case LOG_0VERBOSE_1: @@ -73,7 +79,9 @@ Logger::Log(LOG_LVL level) stream = &std::cout; } else + { use_dummy = true; + } break; } case LOG_0VERBOSE_2: @@ -84,7 +92,9 @@ Logger::Log(LOG_LVL level) stream = &std::cout; } else + { use_dummy = true; + } break; } case LOG_ALL: @@ -114,7 +124,9 @@ Logger::Log(LOG_LVL level) stream = &std::cout; } else + { use_dummy = true; + } break; } case LOG_ALLVERBOSE_2: @@ -125,7 +137,9 @@ Logger::Log(LOG_LVL level) stream = &std::cout; } else + { use_dummy = true; + } break; } default: diff --git a/framework/materials/multi_group_xs/multi_group_xs.cc b/framework/materials/multi_group_xs/multi_group_xs.cc index d6d579d01b..bcf90b321b 100644 --- a/framework/materials/multi_group_xs/multi_group_xs.cc +++ b/framework/materials/multi_group_xs/multi_group_xs.cc @@ -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()) diff --git a/framework/math/petsc_utils/petsc_utils.cc b/framework/math/petsc_utils/petsc_utils.cc index 93becbccc1..c613a1b9f7 100644 --- a/framework/math/petsc_utils/petsc_utils.cc +++ b/framework/math/petsc_utils/petsc_utils.cc @@ -272,9 +272,11 @@ CopyVecToSTLvector(Vec x, std::vector& 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)); @@ -293,9 +295,11 @@ CopyVecToSTLvectorWithGhosts(Vec x, std::vector& 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; diff --git a/framework/math/quadratures/angular/curvilinear_product_quadrature.cc b/framework/math/quadratures/angular/curvilinear_product_quadrature.cc index 329eb596fc..e3ca6b436d 100644 --- a/framework/math/quadratures/angular/curvilinear_product_quadrature.cc +++ b/framework/math/quadratures/angular/curvilinear_product_quadrature.cc @@ -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 @@ -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 @@ -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 diff --git a/framework/math/quadratures/angular/sldfe_sq_quadrature.cc b/framework/math/quadratures/angular/sldfe_sq_quadrature.cc index d031e12fbf..b2e42dd63b 100644 --- a/framework/math/quadratures/angular/sldfe_sq_quadrature.cc +++ b/framework/math/quadratures/angular/sldfe_sq_quadrature.cc @@ -330,9 +330,13 @@ SLDFEsqQuadrature::DevelopSQLDFEValues(SphericalQuadrilateral& sq, } } else if (qp_optimization_type == QuadraturePointOptimization::EMPIRICAL) + { EmpiricalQPOptimization(sq, legendre, sq_tilde_center, vctoi, SA_i); + } else if (qp_optimization_type == QuadraturePointOptimization::ISOLATED) + { IsolatedQPOptimization(sq, legendre, sq_tilde_center, vctoi, SA_i); + } } double @@ -806,7 +810,9 @@ SLDFEsqQuadrature::LocallyRefine(const Vector3& ref_dir, sq_to_be_split = std::fabs(sq.centroid_xyz.Dot(ref_dir_n)) < (sin(cone_size)); if (not sq_to_be_split) + { new_deployment.push_back(sq); + } else { auto new_sqs = SplitSQ(sq, legendre); diff --git a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc index 7153289168..958bdb1780 100644 --- a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc +++ b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc @@ -108,7 +108,9 @@ PieceWiseLinearContinuous::OrderNodes() for (const uint64_t node_id : node_list) if (node_mapping_.count(node_id) == 0) + { throw std::logic_error("PieceWiseLinearContinuous: Error mapping query node"); + } else { const int64_t mapping = node_mapping_.at(node_id); @@ -446,7 +448,9 @@ PieceWiseLinearContinuous::MapDOF(const Cell& cell, } } else if (storage == UnknownStorageType::NODAL) + { address = global_id * static_cast(num_unknowns) + static_cast(block_id); + } return address; } @@ -474,9 +478,7 @@ PieceWiseLinearContinuous::MapDOFLocal(const Cell& cell, if (is_local) { if (storage == UnknownStorageType::BLOCK) - { address = static_cast(local_base_block_size_ * block_id) + local_id; - } else if (storage == UnknownStorageType::NODAL) address = local_id * static_cast(num_unknowns) + static_cast(block_id); } // if is_local @@ -495,9 +497,7 @@ PieceWiseLinearContinuous::MapDOFLocal(const Cell& cell, ++counter; } if (storage == UnknownStorageType::BLOCK) - { address = static_cast(ghost_node_mapping_.size() * block_id) + ghost_local_node_id; - } else if (storage == UnknownStorageType::NODAL) address = ghost_local_node_id * static_cast(num_unknowns) + static_cast(block_id); @@ -553,8 +553,10 @@ PieceWiseLinearContinuous::GetGhostDOFIndices(const UnknownManager& unknown_mana } } else if (storage == UnknownStorageType::NODAL) + { address = global_id * static_cast(num_unknown_comps) + static_cast(block_id); + } dof_ids.push_back(address); } // for c diff --git a/framework/math/unknown_manager/unknown_manager.cc b/framework/math/unknown_manager/unknown_manager.cc index 1996195939..db82cdd0ea 100644 --- a/framework/math/unknown_manager/unknown_manager.cc +++ b/framework/math/unknown_manager/unknown_manager.cc @@ -43,8 +43,10 @@ UnknownManager::AddUnknown(UnknownType unk_type, unsigned int dimension) unknowns.back().name = "Unknown_" + std::to_string(unknowns.size() - 1); } else + { throw std::runtime_error( "UnknownManager: Invalid call to AddUnknown. Unknown type not supported."); + } return unknowns.size(); } diff --git a/framework/mesh/io/foam_io.cc b/framework/mesh/io/foam_io.cc index 3eaa617caa..b70a5f7e10 100644 --- a/framework/mesh/io/foam_io.cc +++ b/framework/mesh/io/foam_io.cc @@ -230,7 +230,9 @@ ReadFoamList(std::istream& in, // find closing ')' SkipWSAndComments(in); if (in.peek() == ')') + { in.get(); + } else { // catch to parse for ')' if earlier statement failed @@ -272,7 +274,9 @@ ReadFoamList(std::istream& in, // catch closure char ' } ' SkipWSAndComments(in); if (in.peek() == '}') + { in.get(); + } else { // catch for ' } ' in event that comments or extra whitespace exists @@ -418,7 +422,9 @@ ReadBoundaryFile(const std::filesystem::path& path, const std::string& fname) const auto key_l = LowerCase(key); if (key_l == "type") + { patch.type = value; + } else if (key_l == "nfaces") { patch.n_faces = std::stoi(value); diff --git a/framework/mesh/io/gmsh_io_v22.cc b/framework/mesh/io/gmsh_io_v22.cc index d386abb5c4..e307f5e7f1 100644 --- a/framework/mesh/io/gmsh_io_v22.cc +++ b/framework/mesh/io/gmsh_io_v22.cc @@ -341,7 +341,9 @@ MeshIO::FromGmshV22(const UnpartitionedMesh::Options& options) cell.faces.push_back(lw_face); } else + { throw std::runtime_error(fname + ": Unsupported cell type"); + } } // for elements diff --git a/framework/mesh/io/gmsh_io_v41.cc b/framework/mesh/io/gmsh_io_v41.cc index 9af472fb05..32c99ce62b 100644 --- a/framework/mesh/io/gmsh_io_v41.cc +++ b/framework/mesh/io/gmsh_io_v41.cc @@ -563,8 +563,9 @@ MeshIO::FromGmshV41ASCII(const UnpartitionedMesh::Options& options) cell.faces.push_back(lw_face); } else + { throw std::runtime_error(fname + ": Unsupported cell type."); - + } } // for elements file.close(); diff --git a/framework/mesh/io/vtk_io.cc b/framework/mesh/io/vtk_io.cc index f66c2f90d0..2e9875e9f3 100644 --- a/framework/mesh/io/vtk_io.cc +++ b/framework/mesh/io/vtk_io.cc @@ -950,7 +950,9 @@ MeshIO::ToExodusII(const std::shared_ptr& grid, { const auto blk_id = static_cast(cell.block_id); if (block_id_map.count(blk_id) == 0) + { block_id_map[blk_id] = cell.GetSubType(); + } else { if (cell.GetSubType() != block_id_map.at(blk_id)) @@ -1040,9 +1042,13 @@ MeshIO::ToExodusII(const std::shared_ptr& grid, const size_t num_faces = cell.faces.size(); std::vector face_mapping(num_faces, 0); if (cell.GetSubType() == CellType::WEDGE) + { face_mapping = {2, 3, 4, 0, 1}; + } else if (cell.GetSubType() == CellType::HEXAHEDRON) + { face_mapping = {2, 1, 3, 0, 4, 5}; + } else { for (size_t f = 0; f < cell.faces.size(); ++f) diff --git a/framework/mesh/mesh_continuum/grid_vtk_utils.cc b/framework/mesh/mesh_continuum/grid_vtk_utils.cc index 4b046f120b..4364d65a42 100644 --- a/framework/mesh/mesh_continuum/grid_vtk_utils.cc +++ b/framework/mesh/mesh_continuum/grid_vtk_utils.cc @@ -554,7 +554,9 @@ PrepareVtkUnstructuredGrid(const std::shared_ptr grid, bool disco for (const auto& cell : grid->local_cells) { if (discontinuous) + { UploadCellGeometryDiscontinuous(grid, cell, node_count, points, ugrid); + } else { for (uint64_t vid : cell.vertex_ids) diff --git a/framework/mesh/mesh_generator/extruder_mesh_generator.cc b/framework/mesh/mesh_generator/extruder_mesh_generator.cc index 0fc4aca4bf..4f89fc384c 100644 --- a/framework/mesh/mesh_generator/extruder_mesh_generator.cc +++ b/framework/mesh/mesh_generator/extruder_mesh_generator.cc @@ -33,7 +33,9 @@ ExtruderMeshGenerator::ExtruderMeshGenerator(const InputParameters& params) double h = 0.0; const auto n = valid_params.GetParamValue("n"); if (layer_block.Has("h")) + { h = valid_params.GetParamValue("h"); + } else { const auto z = valid_params.GetParamValue("z"); diff --git a/framework/mesh/mesh_generator/mesh_generator.cc b/framework/mesh/mesh_generator/mesh_generator.cc index 3ee377bb2b..69bace856d 100644 --- a/framework/mesh/mesh_generator/mesh_generator.cc +++ b/framework/mesh/mesh_generator/mesh_generator.cc @@ -24,7 +24,9 @@ MeshGenerator::MeshGenerator(const InputParameters& params) // Set partitioner if (params.IsParameterValid("partitioner")) + { partitioner_ = params.GetSharedPtrParam("partitioner"); + } else { const auto& factory = ObjectFactory::GetInstance(); diff --git a/framework/mesh/raytrace/raytracer.cc b/framework/mesh/raytrace/raytracer.cc index 865d7487dc..8b8dafdf3f 100644 --- a/framework/mesh/raytrace/raytracer.cc +++ b/framework/mesh/raytrace/raytracer.cc @@ -259,7 +259,9 @@ RayTracer::TraceIncidentRay(const Cell& cell, const Vector3& pos_i, const Vector oi.particle_lost = false; } else + { oi.particle_lost = true; + } return oi; } @@ -364,7 +366,9 @@ RayTracer::TracePolygon(const Cell& cell, // Determine closest intersection if (not perform_concavity_checks_ and not face_intersections.empty()) + { oi = face_intersections.back(); + } else if (perform_concavity_checks_ and not face_intersections.empty()) { auto* closest_intersection = &face_intersections.back(); diff --git a/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc b/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc index 99fe00be9e..dbfdab3b7e 100644 --- a/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc +++ b/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc @@ -28,7 +28,9 @@ UnpartitionedMesh::ComputeBoundingBox() { const auto& vertex = vertices_[p]; if (p == 0) + { bound_box_ = {vertex.x, vertex.x, vertex.y, vertex.y, vertex.z, vertex.z}; + } else { bound_box_.xmin = std::min(bound_box_.xmin, vertex.x); diff --git a/framework/object_factory.cc b/framework/object_factory.cc index f6b0f68258..41eb1e9414 100644 --- a/framework/object_factory.cc +++ b/framework/object_factory.cc @@ -53,7 +53,9 @@ ObjectFactory::DumpRegister() const log.Log() << "OBJECT_BEGIN " << key; if (entry.get_in_params_func == nullptr) + { log.Log() << "NOT_CONSTRUCTIBLE"; + } else { const auto in_params = entry.get_in_params_func(); diff --git a/framework/parameters/input_parameters.cc b/framework/parameters/input_parameters.cc index 7683f6d8ab..b0c04491f3 100644 --- a/framework/parameters/input_parameters.cc +++ b/framework/parameters/input_parameters.cc @@ -260,7 +260,9 @@ InputParameters::AssignParameters(const ParameterBlock& params) if (IsParameterIgnored(param_name)) continue; if (not this->Has(param_name)) + { err_stream << "Invalid param \"" << param_name << "\" supplied.\n"; + } else if (renamed_error_tags_.count(param_name) > 0) { err_stream << "Invalid param \"" << param_name << "\" supplied. "; @@ -405,7 +407,9 @@ InputParameters::ConstrainParameterRange(const std::string& param_name, constraint_tags_[param_name] = allowable_range; } else + { throw std::logic_error(ParamNotPresentErrorStr(__PRETTY_FUNCTION__, param_name)); + } } void @@ -441,7 +445,9 @@ InputParameters::DumpParameters() const { log.Log() << sp4 << "TAG OPTIONAL"; if (type != ParameterBlockType::BLOCK and type != ParameterBlockType::ARRAY) + { log.Log() << sp4 << "DEFAULT_VALUE " << param.GetValue().PrintStr(); + } else if (type == ParameterBlockType::ARRAY) { std::stringstream outstr; @@ -455,7 +461,9 @@ InputParameters::DumpParameters() const } } else + { log.Log() << sp4 << "TAG REQUIRED"; + } if (constraint_tags_.count(param_name) != 0) log.Log() << sp4 << "CONSTRAINTS " << constraint_tags_.at(param_name)->PrintRange(); diff --git a/framework/utils/hdf_utils.h b/framework/utils/hdf_utils.h index e95639498c..f0204bcce8 100644 --- a/framework/utils/hdf_utils.h +++ b/framework/utils/hdf_utils.h @@ -197,7 +197,9 @@ H5WriteDataset1D(hid_t id, const std::string& name, const std::vector& data) if (dataset != H5I_INVALID_HID) { if (data.empty()) + { success = true; + } else { if (H5Dwrite(dataset, get_datatype(), H5S_ALL, H5S_ALL, H5P_DEFAULT, data.data()) >= 0) diff --git a/modules/diffusion/diffusion.cc b/modules/diffusion/diffusion.cc index ad6548012a..b5e8070b91 100644 --- a/modules/diffusion/diffusion.cc +++ b/modules/diffusion/diffusion.cc @@ -174,7 +174,9 @@ DiffusionSolver::Initialize() // Create RHS if (not requires_ghosts_) + { rhs_ = CreateVector(num_local_dofs_, num_global_dofs_); + } else { auto ghost_ids = sdm_.GetGhostDOFIndices(uk_man_); @@ -296,7 +298,9 @@ DiffusionSolver::Solve(std::vector& solution, bool use_initial_guess) sdm_.LocalizePETScVectorWithGhosts(x_, solution, uk_man_); } else + { sdm_.LocalizePETScVector(x_, solution, uk_man_); + } } void diff --git a/modules/diffusion/diffusion_mip_solver.cc b/modules/diffusion/diffusion_mip_solver.cc index 1f98c4b2e5..abdf06a131 100644 --- a/modules/diffusion/diffusion_mip_solver.cc +++ b/modules/diffusion/diffusion_mip_solver.cc @@ -427,6 +427,7 @@ DiffusionMIPSolver::Assemble_b_wQpoints(const std::vector& q_vector) { double entry_rhs_i = 0.0; // entry may accumulate over j if (not source_function_) + { for (size_t j = 0; j < num_nodes; ++j) { for (size_t qp : fe_vol_data.GetQuadraturePointIndices()) @@ -435,6 +436,7 @@ DiffusionMIPSolver::Assemble_b_wQpoints(const std::vector& q_vector) fe_vol_data.JxW(qp) * qg[j]; } // for qp } // for j + } else { for (size_t qp : fe_vol_data.GetQuadraturePointIndices()) @@ -1212,15 +1214,21 @@ DiffusionMIPSolver::HPerpendicular(const Cell& cell, unsigned int f) else if (cell.GetType() == CellType::POLYGON) { if (num_faces == 3) + { hp = 2.0 * volume / face_area; + } else if (num_faces == 4) + { hp = volume / face_area; + } else // Nv > 4 { const auto surface_area = ComputeSurfaceArea(); if (num_faces % 2 == 0) + { hp = 4.0 * volume / surface_area; + } else { hp = 2.0 * volume / surface_area; @@ -1242,8 +1250,10 @@ DiffusionMIPSolver::HPerpendicular(const Cell& cell, unsigned int f) hp = 6 * volume / surface_area; } // Polyhedron else + { throw std::logic_error("acceleration::DiffusionMIPSolver::HPerpendicular: " "Unsupported cell type in call to HPerpendicular"); + } return hp; } diff --git a/modules/diffusion/diffusion_pwlc_solver.cc b/modules/diffusion/diffusion_pwlc_solver.cc index 6b9928fe2d..51f3be631f 100644 --- a/modules/diffusion/diffusion_pwlc_solver.cc +++ b/modules/diffusion/diffusion_pwlc_solver.cc @@ -121,7 +121,9 @@ DiffusionPWLCSolver::AssembleAand_b(const std::vector& q_vector) Dg * intV_gradshapeI_gradshapeJ(i, j) + sigr_g * intV_shapeI_shapeJ(i, j); if (not node_is_dirichlet[j].first) + { cell_A(i, j) += entry_aij; + } else { const double bcvalue = node_is_dirichlet[j].second; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/sweep_chunks/aah_sweep_chunk_rz.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/sweep_chunks/aah_sweep_chunk_rz.cc index aa924644cf..854c570dcd 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/sweep_chunks/aah_sweep_chunk_rz.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/sweep_chunks/aah_sweep_chunk_rz.cc @@ -179,9 +179,13 @@ AAHSweepChunkRZ::Sweep(AngleSet& angle_set) const double* psi = nullptr; if (is_local_face) + { psi = fluds.UpwindPsi(spls_index, in_face_counter, fj, 0, as_ss_idx); + } else if (not is_boundary_face) + { psi = fluds.NLUpwindPsi(preloc_face_counter, fj, 0, as_ss_idx); + } else { // Determine whether incoming direction is incident on the point diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc index 54a4e9a148..be13859ecb 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc @@ -465,12 +465,14 @@ CMFDAcceleration::ProbeAutomaticClosure(const double k_eff, << ", partial coarse k = " << partial_coarse_k_eff << "."; } else if (verbose_ and (outer_iteration_ < 5 or outer_iteration_ % 25 == 0)) + { log.Log() << no_wrap << program_timer.GetTimeString() << " CMFD auto closure probe kept net" << ": net residual = " << net_l2 << ", partial residual = " << partial_l2 << ", net coarse k = " << net_coarse_k_eff << ", partial coarse k = " << partial_coarse_k_eff << ", selected blend = " << selected_blend << ", probe = " << automatic_closure_probe_iterations_ << "."; + } } void @@ -694,6 +696,7 @@ CMFDAcceleration::PostPowerIteration() } } else + { k_eff = ApplyFluxCorrectionWithDamping(phi_new_local_, coarse_phi, cmfd_reference_fission_production, @@ -703,6 +706,7 @@ CMFDAcceleration::PostPowerIteration() correction_diagnostics, skipped_correction, correction_skip_reason); + } if (skipped_correction) { ++consecutive_skipped_corrections_; @@ -710,7 +714,9 @@ CMFDAcceleration::PostPowerIteration() k_eff = raw_transport_k_eff; } else + { consecutive_skipped_corrections_ = 0; + } last_correction_skipped_ = skipped_correction; last_correction_skip_reason_ = skipped_correction ? correction_skip_reason : std::string(); last_update_allows_convergence_ = transport_balance_allows_convergence and not skipped_correction; @@ -1665,7 +1671,9 @@ CMFDAcceleration::ComputeTransportCurrentBalanceResidual( { const auto& face = coarse_cell.faces[f]; if (face.has_neighbor) + { lhs += ComputeOutwardCurrent(coarse_cell, f, cg); + } else { const auto bc_it = do_problem_.GetBoundaryDefinitions().find(face.neighbor_id); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.cc index 6ad697b0bd..8ced602400 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.cc @@ -228,7 +228,9 @@ DiscreteOrdinatesProblem::DiscreteOrdinatesProblem(const InputParameters& params SetSweepChunkMode(SweepChunkMode::TIME_DEPENDENT); } else + { SetSweepChunkMode(SweepChunkMode::STEADY_STATE); + } if (params.Has("boundary_conditions")) { @@ -942,7 +944,9 @@ DiscreteOrdinatesProblem::ResetMode(SweepChunkMode target_mode) SetSweepChunkMode(SweepChunkMode::TIME_DEPENDENT); } else + { SetSweepChunkMode(SweepChunkMode::STEADY_STATE); + } } if (switching_modes or default_to_transient) @@ -1054,7 +1058,9 @@ DiscreteOrdinatesProblem::UpdateAngularFluxStorage() psi_new.assign(num_ang_unknowns, 0.0); } else + { std::vector().swap(psi_new); + } if (save_old) { @@ -1062,7 +1068,9 @@ DiscreteOrdinatesProblem::UpdateAngularFluxStorage() psi_old.assign(num_ang_unknowns, 0.0); } else + { std::vector().swap(psi_old); + } } } @@ -1520,7 +1528,9 @@ DiscreteOrdinatesProblem::InitializeSweepDataStructures() } } else + { OpenSnInvalidArgument("Unsupported sweep type \"" + sweep_type_ + "\""); + } opensn::mpi_comm.barrier(); @@ -1992,7 +2002,9 @@ DiscreteOrdinatesProblem::InitFluxDataStructures(LBSGroupset& groupset) groupset.angle_agg->GetAngleSetGroups().push_back(angle_set); } else + { OpenSnInvalidArgument("Unsupported sweeptype \"" + sweep_type_ + "\""); + } } // for an_ss } // for so_grouping @@ -2026,7 +2038,9 @@ DiscreteOrdinatesProblem::SetSweepChunk(LBSGroupset& groupset) return std::make_shared(*this, groupset); } else + { OpenSnLogicalError("Unsupported sweep_type_ \"" + sweep_type_ + "\""); + } } void diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/ags_linear_solver.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/ags_linear_solver.cc index 218c4c5281..f0b80e8884 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/ags_linear_solver.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/ags_linear_solver.cc @@ -108,9 +108,13 @@ AGSLinearSolver::Solve() break; } else if (converged) + { break; + } else + { phi_old_ = lbs_problem_.GetPhiNewLocal(); + } } CALI_CXX_MARK_LOOP_END(ags_iteration); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/classic_richardson.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/classic_richardson.cc index 594843aa4c..ff09061380 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/classic_richardson.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/classic_richardson.cc @@ -118,7 +118,9 @@ ClassicRichardson::Solve() converged = true; } else + { SyncLaggedStateToLatestIterate(*gs_context_ptr); + } if (verbose_) { diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/sweep_wgs_context.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/sweep_wgs_context.cc index 7757adca71..cdda13bd51 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/sweep_wgs_context.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/iterative_methods/sweep_wgs_context.cc @@ -40,7 +40,9 @@ GetSchedulingAlgorithm(const std::string& sweep_type, bool use_gpu) return SchedulingAlgorithm::FIRST_IN_FIRST_OUT; } else + { throw std::runtime_error("Unsupported sweep scheduling algorithm: " + sweep_type + "\n"); + } } } // namespace diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/aah_angle_set.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/aah_angle_set.cc index 23c8f2513e..a2e3d9e995 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/aah_angle_set.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/aah_angle_set.cc @@ -48,7 +48,9 @@ AAH_AngleSet::AngleSetAdvance(SweepChunk& sweep_chunk, AngleSetStatus permission } if (status == AngleSetStatus::RECEIVING) + { return status; + } else if (status == AngleSetStatus::READY_TO_EXECUTE and permission == AngleSetStatus::EXECUTE) { async_comm_.InitializeLocalAndDownstreamBuffers(); @@ -70,7 +72,9 @@ AAH_AngleSet::AngleSetAdvance(SweepChunk& sweep_chunk, AngleSetStatus permission return AngleSetStatus::FINISHED; } else + { return AngleSetStatus::READY_TO_EXECUTE; + } } AngleSetStatus diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc index 6598d0a2f8..aa172367dd 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.cc @@ -136,7 +136,9 @@ ReflectingBoundary::InitializeReflectingMap(const std::vector& grou { // left, top and bottom are regular reflecting if (std::fabs(normal_.Dot(jhat)) > 0.999999 or normal_.Dot(ihat) < -0.999999) + { omega_reflected = omega_n - 2.0 * normal_ * omega_n.Dot(normal_); + } // right derives normal from omega_n else if (normal_.Dot(ihat) > 0.999999) { diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/communicators/cbc_async_comm.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/communicators/cbc_async_comm.cc index 1b310d82af..15a06d6ff8 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/communicators/cbc_async_comm.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/communicators/cbc_async_comm.cc @@ -147,7 +147,9 @@ CBC_AsynchronousCommunicator::SendData() send_requests_.pop_back(); } else + { ++i; + } } std::fill( open_send_buffer_indices_.begin(), open_send_buffer_indices_.end(), INVALID_BUFFER_INDEX); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h index 386b762418..a74c0a66f6 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h @@ -164,7 +164,9 @@ class AAHD_NonLocalFaceNode (std::uint64_t{packed_neighbor_idx} << 32) | packed_cell_idx); } else + { throw std::runtime_error("Non local face node requires cell with different global index.\n"); + } } /// Comparison operator for ordering. diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds.cc index 69babed388..c369fcd15b 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds.cc @@ -108,7 +108,9 @@ CBC_FLUDS::ClearLocalAndReceivePsi() current_psi_epoch_ = 1; } else + { ++current_psi_epoch_; + } } CBC_FLUDS::IncomingNonlocalPsi diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/scheduler/sweep_scheduler.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/scheduler/sweep_scheduler.cc index 5aeaf3aca4..4bce391b17 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/scheduler/sweep_scheduler.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/scheduler/sweep_scheduler.cc @@ -157,7 +157,9 @@ SweepScheduler::InitializeAlgoDOG() rule_values_.push_back(new_rule_vals); } else + { throw std::runtime_error("InitializeAlgoDOG: Failed to find location depth"); + } } // for anglesets std::stable_sort( diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc index 1a1a22ac4d..b0d82a1250 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc @@ -228,7 +228,9 @@ AAH_SPDS::BuildGlobalSweepTDG() { auto loc = global_linear_sweep_order[k]; if (global_dependencies_[loc].empty()) + { global_sweep_order_rank[k] = 0; + } else { int max_rank = -1; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc index 138143c110..7d03c96227 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc @@ -485,7 +485,9 @@ SPDS::PopulateCellRelationships( std::make_pair(face_info[cell.local_id][f].neighbor_local_id, weight)); } else + { location_successors.insert(face_info[cell.local_id][f].neighbor_partition_id); + } } } // If not outgoing determine what it is dependent on diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/aah_avx_sweep_chunk.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/aah_avx_sweep_chunk.cc index e7dd0fd860..cebf879cbb 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/aah_avx_sweep_chunk.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/aah_avx_sweep_chunk.cc @@ -331,7 +331,9 @@ AAH_Sweep_FixedN(AAHSweepData& data, AngleSet& angle_set) cell_psi_data[imap + gsg] = inv_theta * (psi_sol + (theta - 1.0) * psi_old_val); } else + { cell_psi_data[imap + gsg] = psi_sol; + } } } } diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_avx_sweep_chunk.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_avx_sweep_chunk.cc index 46d5983f1f..969c19cd52 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_avx_sweep_chunk.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_avx_sweep_chunk.cc @@ -333,7 +333,9 @@ CBC_Sweep_FixedN(SweepChunkT& sweep_chunk, AngleSet& angle_set) psi_new[imap + gsg] = inv_theta * (psi_sol + (theta - 1.0) * psi_old_val); } else + { psi_new[imap + gsg] = psi_sol; + } } } } diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h index 073eb1e5d5..46bbfe3b46 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h @@ -321,7 +321,9 @@ CBC_Sweep_Generic(SweepChunkT& sweep_chunk, AngleSet& angle_set) psi_new[imap + gsg] = inv_theta * (psi_sol + (theta - 1.0) * psi_old_val); } else + { psi_new[imap + gsg] = psi_sol; + } } } } diff --git a/modules/linear_boltzmann_solvers/lbs_problem/io/restart_io.cc b/modules/linear_boltzmann_solvers/lbs_problem/io/restart_io.cc index 8b9e2f58d6..5063e7d94a 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/io/restart_io.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/io/restart_io.cc @@ -214,7 +214,9 @@ LBSProblem::WriteRestartData(const RestartDataHook& extra_writer) log.Log() << "Successfully wrote restart data." << std::endl; } else + { log.Log() << "Failed to write restart data." << std::endl; + } return success; } diff --git a/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc b/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc index 0d58a62c5c..a84f2e5ecb 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc @@ -327,7 +327,9 @@ LBSProblem::SetBlockID2XSMap(const BlockID2XSMap& xs_map) precursor_new_local_ = std::move(remapped_precursors); } else + { precursor_new_local_.clear(); + } ResetGPUCarriers(); InitializeGPUExtras(); @@ -709,9 +711,11 @@ LBSProblem::ParseOptions(const InputParameters& input) GetName() + ": Failed to create restart directory " + dir.string()); } else + { OpenSnLogicalErrorIf(not std::filesystem::is_directory(dir), GetName() + ": Restart path exists but is not a directory " + dir.string()); + } } opensn::mpi_comm.barrier(); options_.restart.MarkWriteComplete(); diff --git a/modules/linear_boltzmann_solvers/lbs_problem/postprocessors/volume_postprocessor.cc b/modules/linear_boltzmann_solvers/lbs_problem/postprocessors/volume_postprocessor.cc index 1ccb5719b5..d58a361682 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/postprocessors/volume_postprocessor.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/postprocessors/volume_postprocessor.cc @@ -170,7 +170,9 @@ VolumePostprocessor::CreateMultipliers() // computation } else + { throw std::logic_error("Can specify either 'multiplier' or 'group_multipliers', not both."); + } } std::vector diff --git a/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc b/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc index fd8fdd9395..0fa4dcfc0b 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc @@ -156,7 +156,9 @@ VolumetricSource::Evaluate(const Cell& cell, const double time) const { if (std::count(subscribers_.begin(), subscribers_.end(), cell.local_id) == 0) + { return std::vector(num_groups, 0.0); // NOLINT + } else if (not function_) { if (strength_function_) @@ -169,7 +171,9 @@ VolumetricSource::Evaluate(const Cell& cell, return strength_; } else + { return (*function_)(xyz, num_groups); + } } bool diff --git a/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc b/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc index da7590ba57..df34f26bb9 100644 --- a/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc +++ b/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc @@ -310,7 +310,9 @@ ResponseEvaluator::SetBoundarySourceOptions(const InputParameters& params) boundary_sources_[bid] = {LBSBoundaryType::ISOTROPIC, values}; } else + { log.Log0Warning() << "Unsupported boundary type. Skipping the entry."; + } } void diff --git a/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.cc b/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.cc index 04e875f447..662bd73d7b 100644 --- a/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.cc +++ b/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.cc @@ -580,7 +580,9 @@ UncollidedProblem::BuildSweepOrdering(const SourcePoint& source_point) cell_regions_[cell_id] = CellRegion::NEAR_SOURCE; } else + { bulk_spls_.push_back(cell_id); + } } } diff --git a/python/lib/py_app.cc b/python/lib/py_app.cc index 27a59b5d40..a8a9d3f37e 100644 --- a/python/lib/py_app.cc +++ b/python/lib/py_app.cc @@ -97,7 +97,9 @@ PyApp::Run(int argc, char** argv) } } else + { return EXIT_FAILURE; + } if (opensn::use_caliper and opensn::mpi_comm.rank() == 0) std::cout << std::endl; diff --git a/python/lib/solver.cc b/python/lib/solver.cc index 71e0d265d6..c20b238af1 100644 --- a/python/lib/solver.cc +++ b/python/lib/solver.cc @@ -467,7 +467,9 @@ WrapLBS(py::module& slv) { auto c_key = key.cast(); if (c_key == "clear_point_sources") + { self.ClearPointSources(); + } else if (c_key == "point_sources") { auto sources = value.cast(); @@ -477,7 +479,9 @@ WrapLBS(py::module& slv) } } else + { throw std::runtime_error("Invalid argument provided to SetPointSources.\n"); + } } }, R"( @@ -499,7 +503,9 @@ WrapLBS(py::module& slv) { auto c_key = key.cast(); if (c_key == "clear_volumetric_sources") + { self.ClearVolumetricSources(); + } else if (c_key == "volumetric_sources") { auto sources = value.cast(); @@ -509,7 +515,9 @@ WrapLBS(py::module& slv) } } else + { throw std::runtime_error("Invalid argument provided to SetVolumetricSources.\n"); + } } }, R"( @@ -546,7 +554,9 @@ WrapLBS(py::module& slv) } } else + { throw std::runtime_error("Invalid argument provided to SetXSMap.\n"); + } } self.SetBlockID2XSMap(xs_map); }, @@ -977,7 +987,9 @@ WrapLBS(py::module& slv) { auto c_key = key.cast(); if (c_key == "clear_boundary_conditions") + { clear_boundary_conditions = value.cast(); + } else if (c_key == "boundary_conditions") { auto boundaries = value.cast(); @@ -989,7 +1001,9 @@ WrapLBS(py::module& slv) } } else + { throw std::runtime_error("Invalid argument provided to SetBoundaryOptions.\n"); + } } if (clear_boundary_conditions or not boundary_params.empty()) self.SetBoundaryOptions(boundary_params, clear_boundary_conditions); From e70572e2d9b8b9a286bfed2eec13b0ae0185a619 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Wed, 17 Jun 2026 11:28:13 -0600 Subject: [PATCH 07/11] Removing redundant `typename` --- framework/data_types/ndarray.h | 2 +- framework/data_types/varying.h | 22 +++++++++---------- .../angle_aggregation/angle_aggregation.h | 4 ++-- .../sweep_chunks/avx_sweep_chunk_utils.h | 6 ++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/framework/data_types/ndarray.h b/framework/data_types/ndarray.h index bdabe5b7cb..facaa90d3c 100644 --- a/framework/data_types/ndarray.h +++ b/framework/data_types/ndarray.h @@ -31,7 +31,7 @@ class NDArray using conjunction = std::is_same, bool_pack>; template - using AllIntegral = typename conjunction...>::type; + using AllIntegral = conjunction...>::type; public: /** diff --git a/framework/data_types/varying.h b/framework/data_types/varying.h index 18703651b2..b3334b0e6b 100644 --- a/framework/data_types/varying.h +++ b/framework/data_types/varying.h @@ -79,20 +79,20 @@ class Varying }; template - using BoolType = typename std::enable_if_t::value, T>; + using BoolType = std::enable_if_t::value, T>; template - using FloatType = typename std::enable_if_t::value, T>; + using FloatType = std::enable_if_t::value, T>; template - using IntegerType = typename std::enable_if_t::value, T>; + using IntegerType = std::enable_if_t::value, T>; template - using BoolStorageType = typename std::enable_if_t::value, bool>; + using BoolStorageType = std::enable_if_t::value, bool>; template - using FloatStorageType = typename std::enable_if_t::value, double>; + using FloatStorageType = std::enable_if_t::value, double>; template - using IntegerStorageType = typename std::enable_if_t::value, int64_t>; + using IntegerStorageType = std::enable_if_t::value, int64_t>; template - using UserDataStorageType = typename std::enable_if_t::value, T>; + using UserDataStorageType = std::enable_if_t::value, T>; template BoolStorageType CastValue(const T& value) @@ -407,13 +407,13 @@ class Varying }; template - using StringType = typename std::enable_if_t::value, T>; + using StringType = std::enable_if_t::value, T>; template - using SignedIntegerType = typename std::enable_if_t::value, T>; + using SignedIntegerType = std::enable_if_t::value, T>; template - using UnsignedIntegerType = typename std::enable_if_t::value, T>; + using UnsignedIntegerType = std::enable_if_t::value, T>; template - using UserDataType = typename std::enable_if_t::value, T>; + using UserDataType = std::enable_if_t::value, T>; /// Returns values of type bool if able. template diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h index c2f2e83aab..0b73003b62 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h @@ -52,8 +52,8 @@ class AngleAggregation std::shared_ptr& quadrature, std::shared_ptr& grid); - using iterator = typename std::vector>::iterator; - using const_iterator = typename std::vector>::const_iterator; + using iterator = std::vector>::iterator; + using const_iterator = std::vector>::const_iterator; iterator begin() { return angle_set_groups_.begin(); } iterator end() { return angle_set_groups_.end(); } const_iterator begin() const { return angle_set_groups_.begin(); } diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h index 804300c92f..ebb8547a74 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h @@ -138,7 +138,7 @@ struct AVX2Ops template struct GatherIndexBuilder { - static typename Ops::avx_index Build(int row) = delete; + static Ops::avx_index Build(int row) = delete; }; #if __AVX512F__ @@ -172,7 +172,7 @@ namespace { template -inline typename Ops::avx_index +inline Ops::avx_index MakeGatherIndex(int row) { return GatherIndexBuilder::Build(row); @@ -182,7 +182,7 @@ template inline void SimdBatchSolve(const double* Am, const double* Mm, const double* sigma_t, double* __restrict b) { - using avx_vec = typename Ops::avx_vec; + using avx_vec = Ops::avx_vec; avx_vec rhs[N]; PRAGMA_UNROLL From 4ba9be5bb2ea2c665edc63f5d69538f819642572 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Wed, 17 Jun 2026 11:35:13 -0600 Subject: [PATCH 08/11] Fixing overrides with different visibility --- framework/logging/log_stream.h | 1 + .../math/quadratures/angular/angular_quadrature.h | 13 +++++++------ .../mesh/mesh_generator/extruder_mesh_generator.h | 2 +- .../mesh/mesh_generator/from_file_mesh_generator.h | 2 +- .../mesh/mesh_generator/orthogonal_mesh_generator.h | 2 +- .../discrete_ordinates_curvilinear_problem.h | 3 +-- .../discrete_ordinates_problem.h | 4 ++-- .../uncollided_problem/uncollided_problem.h | 4 ++-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/framework/logging/log_stream.h b/framework/logging/log_stream.h index 51128ac625..09655993e3 100644 --- a/framework/logging/log_stream.h +++ b/framework/logging/log_stream.h @@ -174,6 +174,7 @@ struct DummyStream : public std::ostream { struct DummyStreamBuffer : std::streambuf { + protected: int overflow(int c) override { return c; }; } buffer; diff --git a/framework/math/quadratures/angular/angular_quadrature.h b/framework/math/quadratures/angular/angular_quadrature.h index f1f1bce25f..040281d78e 100644 --- a/framework/math/quadratures/angular/angular_quadrature.h +++ b/framework/math/quadratures/angular/angular_quadrature.h @@ -63,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, @@ -84,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]. diff --git a/framework/mesh/mesh_generator/extruder_mesh_generator.h b/framework/mesh/mesh_generator/extruder_mesh_generator.h index 6389e86356..756c962418 100644 --- a/framework/mesh/mesh_generator/extruder_mesh_generator.h +++ b/framework/mesh/mesh_generator/extruder_mesh_generator.h @@ -21,10 +21,10 @@ class ExtruderMeshGenerator : public MeshGenerator public: explicit ExtruderMeshGenerator(const InputParameters& params); -protected: std::shared_ptr GenerateUnpartitionedMesh(std::shared_ptr input_umesh) override; +protected: const std::string top_boundary_name_; const std::string bottom_boundary_name_; diff --git a/framework/mesh/mesh_generator/from_file_mesh_generator.h b/framework/mesh/mesh_generator/from_file_mesh_generator.h index aa25ee7346..05a8ffcac4 100644 --- a/framework/mesh/mesh_generator/from_file_mesh_generator.h +++ b/framework/mesh/mesh_generator/from_file_mesh_generator.h @@ -13,10 +13,10 @@ class FromFileMeshGenerator : public MeshGenerator public: explicit FromFileMeshGenerator(const InputParameters& params); -protected: std::shared_ptr GenerateUnpartitionedMesh(std::shared_ptr input_umesh) override; +protected: const std::string filename_; const std::string block_id_fieldname_; const std::string boundary_id_fieldname_; diff --git a/framework/mesh/mesh_generator/orthogonal_mesh_generator.h b/framework/mesh/mesh_generator/orthogonal_mesh_generator.h index 799bbbacce..fefac361fe 100644 --- a/framework/mesh/mesh_generator/orthogonal_mesh_generator.h +++ b/framework/mesh/mesh_generator/orthogonal_mesh_generator.h @@ -13,10 +13,10 @@ class OrthogonalMeshGenerator : public MeshGenerator public: explicit OrthogonalMeshGenerator(const InputParameters& params); -protected: std::shared_ptr GenerateUnpartitionedMesh(std::shared_ptr input_umesh) override; +protected: const CoordinateSystemType coord_sys_; std::vector> node_sets_; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/discrete_ordinates_curvilinear_problem.h b/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/discrete_ordinates_curvilinear_problem.h index 03c0fa48b4..7280a40807 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/discrete_ordinates_curvilinear_problem.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_curvilinear_problem/discrete_ordinates_curvilinear_problem.h @@ -25,10 +25,9 @@ class DiscreteOrdinatesCurvilinearProblem : public DiscreteOrdinatesProblem void PerformInputChecks(); void InitializeSpatialDiscretization() override; void ComputeSecondaryUnitIntegrals(); - -private: std::shared_ptr SetSweepChunk(LBSGroupset& groupset) override; +private: /** * Discretization pointer to matrices of the secondary cell view (matrices of the primary cell * view forwarded to the base class). diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.h index 861dffb4a7..e7247de673 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.h @@ -116,8 +116,6 @@ class DiscreteOrdinatesProblem : public LBSProblem void ComputeBalance(double scaling_factor = 1.0); - void PrintSimHeader() override; - /// Returns the sweep boundaries as a read-only reference. const std::map>& GetSweepBoundaries() const; @@ -197,6 +195,8 @@ class DiscreteOrdinatesProblem : public LBSProblem void InitializeBoundaries() override; /** @} */ + void PrintSimHeader() override; + /** * @name Solver and sweep state * @{ diff --git a/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.h b/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.h index 9f59906438..d07c294bb9 100644 --- a/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.h +++ b/modules/linear_boltzmann_solvers/uncollided_problem/uncollided_problem.h @@ -37,6 +37,8 @@ class UncollidedProblem : public LBSProblem ~UncollidedProblem() override; + void ClearBoundaries() override {} + protected: friend class UncollidedSolver; @@ -78,8 +80,6 @@ class UncollidedProblem : public LBSProblem void InitializeSpatialDiscretization() override; - void ClearBoundaries() override {} - static Vector3 ComputeOmega(const Vector3& point0, const Vector3& point1) { double norm = (point1 - point0).Norm(); From 6ef6a2044acff70dab2009ee00c13ab8995eea7f Mon Sep 17 00:00:00 2001 From: David Andrs Date: Wed, 17 Jun 2026 12:19:54 -0600 Subject: [PATCH 09/11] Patching `RandomNumberGenerator` class - default ctor gives truly random behavior - ctor with seed should be used for reproducible results (for example in a test suite) --- .../random_number_generator.cc | 11 +++++++---- .../random_number_generator.h | 5 +++-- .../framework/tutorials/tutorial_93_raytracing.cc | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/framework/math/random_number_generation/random_number_generator.cc b/framework/math/random_number_generation/random_number_generator.cc index 9a369e6a84..a22afb6c10 100644 --- a/framework/math/random_number_generation/random_number_generator.cc +++ b/framework/math/random_number_generation/random_number_generator.cc @@ -5,15 +5,18 @@ namespace opensn { +namespace +{ +std::random_device rd; +} -RandomNumberGenerator::RandomNumberGenerator() : distribution_(0.0, 1.0) +RandomNumberGenerator::RandomNumberGenerator() : mt1993764_generator_(rd()), distribution_(0.0, 1.0) { - mt1993764_generator_.seed(0); } -RandomNumberGenerator::RandomNumberGenerator(int seed) : distribution_(0.0, 1.0) +RandomNumberGenerator::RandomNumberGenerator(int seed) + : mt1993764_generator_(seed), distribution_(0.0, 1.0) { - mt1993764_generator_.seed(seed); } double diff --git a/framework/math/random_number_generation/random_number_generator.h b/framework/math/random_number_generation/random_number_generator.h index 4ea797a069..933b3db90f 100644 --- a/framework/math/random_number_generation/random_number_generator.h +++ b/framework/math/random_number_generation/random_number_generator.h @@ -12,10 +12,11 @@ namespace opensn class RandomNumberGenerator { public: - /// Default constructor. Seeds the generator with a zero. + /// Default constructor. Use this to get truly random behavior. RandomNumberGenerator(); - /// Constructor where a seed is supplied. + /// Constructor where a seed is supplied. Use this here you need to replicate results, as in + /// tests. RandomNumberGenerator(int seed); /// Generates a random number with the default distribution. diff --git a/test/unit/framework/tutorials/tutorial_93_raytracing.cc b/test/unit/framework/tutorials/tutorial_93_raytracing.cc index 9ba6f4b384..34c3b99ab0 100644 --- a/test/unit/framework/tutorials/tutorial_93_raytracing.cc +++ b/test/unit/framework/tutorials/tutorial_93_raytracing.cc @@ -99,7 +99,7 @@ SimTest93_RayTracing(std::shared_ptr grid) const uint64_t source_cell_id = source_cell_ptr->global_id; // Define lambdas - RandomNumberGenerator rng; + RandomNumberGenerator rng(0); auto SampleRandomDirection = [&rng]() { double costheta = 2.0 * rng.Rand() - 1.0; From 886188f496bb11db300ded71bc8349d460d81815 Mon Sep 17 00:00:00 2001 From: David Andrs Date: Thu, 18 Jun 2026 09:56:25 -0600 Subject: [PATCH 10/11] Patch to fix clang-tidy's `misc-anonymous-namespace-in-header` --- .../sweep_chunks/avx_sweep_chunk_utils.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h index ebb8547a74..6da6e091ca 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/avx_sweep_chunk_utils.h @@ -168,9 +168,6 @@ struct GatherIndexBuilder }; #endif -namespace -{ - template inline Ops::avx_index MakeGatherIndex(int row) @@ -234,8 +231,6 @@ SimdBatchSolve(const double* Am, const double* Mm, const double* sigma_t, double Ops::Scatter(MakeGatherIndex(row), b, rhs[row]); } -} // namespace - } // namespace detail } // namespace opensn From 92ceb4af4224f8709de8625177b7a046e426cbcb Mon Sep 17 00:00:00 2001 From: David Andrs Date: Thu, 18 Jun 2026 10:12:34 -0600 Subject: [PATCH 11/11] Updating .clang-tidy for clang-tidy-22 --- .clang-tidy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index e03b768ca2..d4a615145e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,6 +16,9 @@ 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, @@ -23,6 +26,7 @@ Checks: "*, -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, @@ -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,