From 4b2130712868401142ad08e948ce67b9fe13d1be Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 10 Nov 2020 14:09:44 -0600 Subject: [PATCH 1/2] Make sure is specified on a mesh --- src/mesh.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/mesh.cpp b/src/mesh.cpp index 53279cc57a..64d2c269ba 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -525,18 +525,21 @@ RegularMesh::RegularMesh(pugi::xml_node node) : StructuredMesh {node} { // Determine number of dimensions for mesh - if (check_for_node(node, "dimension")) { - shape_ = get_node_xarray(node, "dimension"); - int n = n_dimension_ = shape_.size(); - if (n != 1 && n != 2 && n != 3) { - fatal_error("Mesh must be one, two, or three dimensions."); - } + if (!check_for_node(node, "dimension")) { + fatal_error("Must specify on a regular mesh."); + } - // Check that dimensions are all greater than zero - if (xt::any(shape_ <= 0)) { - fatal_error("All entries on the element for a tally " - "mesh must be positive."); - } + + shape_ = get_node_xarray(node, "dimension"); + int n = n_dimension_ = shape_.size(); + if (n != 1 && n != 2 && n != 3) { + fatal_error("Mesh must be one, two, or three dimensions."); + } + + // Check that dimensions are all greater than zero + if (xt::any(shape_ <= 0)) { + fatal_error("All entries on the element for a tally " + "mesh must be positive."); } // Check for lower-left coordinates @@ -587,23 +590,19 @@ RegularMesh::RegularMesh(pugi::xml_node node) } // Set width - if (shape_.size() > 0) { - width_ = xt::eval((upper_right_ - lower_left_) / shape_); - } + width_ = xt::eval((upper_right_ - lower_left_) / shape_); } else { fatal_error("Must specify either and on a mesh."); } // Make sure lower_left and dimension match - if (shape_.size() > 0) { - if (shape_.size() != lower_left_.size()) { - fatal_error("Number of entries on must be the same " - "as the number of entries on ."); - } - - // Set volume fraction - volume_frac_ = 1.0/xt::prod(shape_)(); + if (shape_.size() != lower_left_.size()) { + fatal_error("Number of entries on must be the same " + "as the number of entries on ."); } + + // Set volume fraction + volume_frac_ = 1.0/xt::prod(shape_)(); } int RegularMesh::get_index_in_direction(double r, int i) const From d05bf7789db0d42f5240696e1141e6fd441afff9 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 10 Nov 2020 21:43:13 -0600 Subject: [PATCH 2/2] Move check for consistent shape/lower_left on regular mesh --- src/mesh.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesh.cpp b/src/mesh.cpp index 64d2c269ba..a5409f05a0 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -550,6 +550,12 @@ RegularMesh::RegularMesh(pugi::xml_node node) fatal_error("Must specify on a mesh."); } + // Make sure lower_left and dimension match + if (shape_.size() != lower_left_.size()) { + fatal_error("Number of entries on must be the same " + "as the number of entries on ."); + } + if (check_for_node(node, "width")) { // Make sure both upper-right or width were specified if (check_for_node(node, "upper_right")) { @@ -595,12 +601,6 @@ RegularMesh::RegularMesh(pugi::xml_node node) fatal_error("Must specify either and on a mesh."); } - // Make sure lower_left and dimension match - if (shape_.size() != lower_left_.size()) { - fatal_error("Number of entries on must be the same " - "as the number of entries on ."); - } - // Set volume fraction volume_frac_ = 1.0/xt::prod(shape_)(); }