From 977ea5b602fe7b433b5ecf8b1fc02f7223d50e54 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 23 Apr 2020 09:23:34 -0500 Subject: [PATCH] Changes in filter_mesh.cpp from PullRequest Inc. review --- src/cross_sections.cpp | 3 +++ src/tallies/filter_mesh.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index 737d2a4aab..1d36b5cff4 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -282,6 +282,7 @@ read_ce_cross_sections(const std::vector>& nuc_temps, } } + // Perform final tasks -- reading S(a,b) tables, normalizing densities for (auto& mat : model::materials) { for (const auto& table : mat->thermal_tables_) { // Get name of S(a,b) table @@ -408,6 +409,8 @@ void read_ce_cross_sections_xml() } else { // If no directory is listed in cross_sections.xml, by default select the // directory in which the cross_sections.xml file resides + + // TODO: Use std::filesystem functionality when C++17 is adopted auto pos = filename.rfind("/"); if (pos == std::string::npos) { // no '/' found, probably a Windows directory diff --git a/src/tallies/filter_mesh.cpp b/src/tallies/filter_mesh.cpp index d2a240bcf1..60ab318cc1 100644 --- a/src/tallies/filter_mesh.cpp +++ b/src/tallies/filter_mesh.cpp @@ -1,6 +1,7 @@ #include "openmc/tallies/filter_mesh.h" #include +#include #include "openmc/capi.h" #include "openmc/constants.h" @@ -54,7 +55,7 @@ MeshFilter::to_statepoint(hid_t filter_group) const std::string MeshFilter::text_label(int bin) const { - auto& mesh = *model::meshes[mesh_]; + auto& mesh = *model::meshes.at(mesh_); return mesh.bin_label(bin); } @@ -72,6 +73,11 @@ MeshFilter::set_mesh(int32_t mesh) extern "C" int openmc_mesh_filter_get_mesh(int32_t index, int32_t* index_mesh) { + if (!index_mesh) { + set_errmsg("Mesh index argument is a null pointer."); + return OPENMC_E_INVALID_ARGUMENT; + } + // Make sure this is a valid index to an allocated filter. if (int err = verify_filter(index)) return err;