From 6ad771b332d09e12017e517e7e212309bf129b92 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Sun, 4 Aug 2019 17:45:51 -0700 Subject: [PATCH] Calculate number of fissionable cells in the OpenMC model to aid in ensuring correct mappings. Refs #55 --- include/enrico/openmc_driver.h | 1 + src/openmc_driver.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/enrico/openmc_driver.h b/include/enrico/openmc_driver.h index 98e26d2d..7c0ca3f6 100644 --- a/include/enrico/openmc_driver.h +++ b/include/enrico/openmc_driver.h @@ -49,6 +49,7 @@ class OpenmcDriver : public NeutronicsDriver { openmc::Tally* tally_; //!< Fission energy deposition tally int32_t index_filter_; //!< Index in filters arrays for material filter std::vector cells_; //!< Array of cell instances + int n_fissionable_cells_; //!< Number of fissionable cells in model }; } // namespace enrico diff --git a/src/openmc_driver.cpp b/src/openmc_driver.cpp index 2c2cf530..7f05f8a8 100644 --- a/src/openmc_driver.cpp +++ b/src/openmc_driver.cpp @@ -5,7 +5,6 @@ #include "openmc/capi.h" #include "openmc/constants.h" -#include "openmc/tallies/tally.h" #include "xtensor/xadapt.hpp" #include "xtensor/xarray.hpp" #include "xtensor/xview.hpp" @@ -21,6 +20,31 @@ OpenmcDriver::OpenmcDriver(MPI_Comm comm) err_chk(openmc_init(0, nullptr, &comm)); } MPI_Barrier(MPI_COMM_WORLD); + + // determine number of fissionable cells in model to aid in catching + // improperly mapped problems + n_fissionable_cells_ = 0; + for (int i = 0; i < cells_size(); ++i) { + int type; + int32_t* indices; + int32_t n; + err_chk(openmc_cell_get_fill(i, &type, &indices, &n)); + + // only check for cells filled with type FILL_MATERIAL (evaluated to '1' enum) + if (type == 1) { + for (int j = 0; j < n; ++j) { + int material_index = indices[j]; + + // skip cells filled with type MATERIAL_VOID (evaluated to '-1' enum) + if (material_index != -1) { + bool fissionable; + err_chk(openmc_material_get_fissionable(material_index, &fissionable)); + + if (fissionable) n_fissionable_cells_++; + } + } + } + } } void OpenmcDriver::create_tallies(gsl::span materials)