Updating error messages. Adding cell instance cells to our distribcell set.

This commit is contained in:
Patrick Shriwise 2021-07-29 10:53:14 -05:00
parent 058e5a9094
commit ca5dc796b9
4 changed files with 10 additions and 6 deletions

View file

@ -59,7 +59,7 @@ private:
std::unordered_map<CellInstance, gsl::index, CellInstanceHash> map_;
//! Level in the geometry to check for the cell instance
int32_t geom_level_ {-1};
int32_t geom_level_ {C_NONE};
};
} // namespace openmc

View file

@ -67,8 +67,8 @@ bool check_cell_overlap(Particle& p, bool error)
int cell_instance_at_level(const Particle& p, int level) {
// throw error if the requested level is too deep for the geometry
if (level > p.n_coord()) {
fatal_error(fmt::format("Cell instance at level {} requested, but only {} levels exist in the model.", level, p.n_coord()));
if (level > model::n_coord_levels) {
fatal_error(fmt::format("Cell instance at level {} requested, but only {} levels exist in the geometry.", level, p.n_coord()));
}
// determine the cell instance

View file

@ -319,9 +319,13 @@ prepare_distribcell()
std::unordered_set<int32_t> distribcells;
for (auto& filt : model::tally_filters) {
auto* distrib_filt = dynamic_cast<DistribcellFilter*>(filt.get());
auto* cell_inst_filt = dynamic_cast<CellInstanceFilter*>(filt.get());
if (distrib_filt) {
distribcells.insert(distrib_filt->cell());
}
if (cell_inst_filt) {
for (const auto& c_inst : cell_inst_filt->cell_instances()) distribcells.insert(c_inst.index_cell);
}
}
// By default, add material cells to the list of distributed cells

View file

@ -56,8 +56,8 @@ CellInstanceFilter::set_cell_instances(gsl::span<CellInstance> instances)
const auto& c {model::cells[x.index_cell]};
if (c->type_ != Fill::MATERIAL && geom_level_ < 0) {
throw std::invalid_argument{fmt::format(
"Cell {} is not filled with a material. Only material cells can be "
"used in a cell instance filter.", c->id_)};
"Cell {} is not filled with a material. A geometry level must be specified to"
"use cells filled with a universe or lattice.", c->id_)};
}
cell_instances_.push_back(x);
map_[x] = cell_instances_.size() - 1;
@ -82,7 +82,7 @@ CellInstanceFilter::get_all_bins(const Particle& p, TallyEstimator estimator,
if (geom_level_ >= 0) {
// if the particle has fewer levels than the cell we're looking for,
// return no bins
if (p.coord(geom_level_).cell == C_NONE) return;
if (p.n_coord() - 1 < geom_level_ || p.coord(geom_level_).cell == C_NONE) return;
// otherwise use the cell at the requested level
// and compute the cell instance for this particle's position