From 115be68953b30e64aa886c55db13b0e9d212f3c5 Mon Sep 17 00:00:00 2001 From: NybergWISC Date: Mon, 15 Aug 2022 09:30:57 -0500 Subject: [PATCH] Small refactor of distribution_spatial.cpp and change default of volume_normalized to True --- openmc/stats/multivariate.py | 2 +- src/distribution_spatial.cpp | 33 ++++++++----------- .../unstructured_mesh/source_sampling/test.py | 4 ++- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/openmc/stats/multivariate.py b/openmc/stats/multivariate.py index 9aa03b2d7f..88beea2f7e 100644 --- a/openmc/stats/multivariate.py +++ b/openmc/stats/multivariate.py @@ -643,7 +643,7 @@ class MeshSpatial(Spatial): """ - def __init__(self, mesh, strengths=None, volume_normalized=False): + def __init__(self, mesh, strengths=None, volume_normalized=True): self.mesh = mesh self.strengths = strengths self.volume_normalized = volume_normalized diff --git a/src/distribution_spatial.cpp b/src/distribution_spatial.cpp index 6d00739b06..b47b85281d 100644 --- a/src/distribution_spatial.cpp +++ b/src/distribution_spatial.cpp @@ -212,34 +212,27 @@ MeshSpatial::MeshSpatial(pugi::xml_node node) // Volume scheme is weighted by the volume of each tet // File scheme is weighted by an array given in the xml file + mesh_strengths_ = std::vector(tot_bins_, 1.0); if (check_for_node(node, "strengths")) { - mesh_strengths_ = get_node_array(node, "strengths"); - if (mesh_strengths_.size() != tot_bins_){ - fatal_error("The size of the strengths array from the xml file does not equal the number of elements in the mesh."); - } if (get_node_value_bool(node, "volume_normalized")){ - for (int i = 0; i < tot_bins_; i++){ - strengths[i] = mesh_strengths_[i]*mesh_ptr_->volume(i); - } - } else if (!get_node_value_bool(node, "volume_normalized")){ - for (int i = 0; i < tot_bins_; i++){ - strengths[i] = mesh_strengths_[i]; + 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"); } - } - } else if (get_node_value_bool(node, "volume_normalized")){ - for (int i = 0; ivolume(i); - } - } else { - for (int i = 0; ivolume(i); } } + for (int i = 0; i