Skip to content

Commit

Permalink
Calculate number of fissionable cells in the OpenMC model to aid in e…
Browse files Browse the repository at this point in the history
…nsuring correct mappings. Refs enrico-dev#55
  • Loading branch information
aprilnovak committed Aug 5, 2019
1 parent 1e0ada0 commit 6ad771b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/enrico/openmc_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<CellInstance> cells_; //!< Array of cell instances
int n_fissionable_cells_; //!< Number of fissionable cells in model
};

} // namespace enrico
Expand Down
26 changes: 25 additions & 1 deletion src/openmc_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<int32_t> materials)
Expand Down

0 comments on commit 6ad771b

Please sign in to comment.