Adding clarity to error message re: improperly sized strengths array

This commit is contained in:
Patrick Shriwise 2022-12-27 12:21:27 -06:00
parent f001d411ee
commit 60a2a0e1f8

View file

@ -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<double>(n_bins, 1.0);
if (check_for_node(node, "strengths")) {
strengths = get_node_array<double>(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")) {