From 60a2a0e1f80a6438e0cbda436effdf9174d4fafc Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 27 Dec 2022 12:21:27 -0600 Subject: [PATCH] Adding clarity to error message re: improperly sized strengths array --- src/distribution_spatial.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/distribution_spatial.cpp b/src/distribution_spatial.cpp index 7418b483a..89fef6155 100644 --- a/src/distribution_spatial.cpp +++ b/src/distribution_spatial.cpp @@ -204,7 +204,6 @@ MeshSpatial::MeshSpatial(pugi::xml_node node) mesh_CDF_.resize(n_bins+1); mesh_CDF_[0] = {0.0}; total_strength_ = 0.0; - mesh_strengths_.resize(n_bins); // Create cdfs for sampling for an element over a mesh // Volume scheme is weighted by the volume of each tet @@ -212,10 +211,13 @@ MeshSpatial::MeshSpatial(pugi::xml_node node) mesh_strengths_ = std::vector(n_bins, 1.0); if (check_for_node(node, "strengths")) { strengths = get_node_array(node, "strengths"); - if (strengths.size() != mesh_strengths_.size()){ - fatal_error("Number of entries in the strength matrix does not match the number of mesh entities"); + if (strengths.size() != n_bins) { + fatal_error( + fmt::format("Number of entries in the source strengths array {} does " + "not match the number of entities in mesh {} ({}).", + strengths.size(), mesh_id, n_bins)); } - mesh_strengths_ = strengths; + mesh_strengths_ = std::move(strengths); } if (get_node_value_bool(node, "volume_normalized")) {