Moving the compute_instance method to the ParentCellStack and adding some documentation there.

This commit is contained in:
Patrick Shriwise 2021-08-18 08:52:10 -05:00
parent 0bed3f53b2
commit 64e93c930c
2 changed files with 24 additions and 14 deletions

View file

@ -321,27 +321,42 @@ struct ParentCell {
gsl::index lattice_index;
};
struct ParentCellHash {
std::size_t operator()(const ParentCell& p) const
{
return 4096*p.cell_index + p.lattice_index;
}
};
struct ParentCellStack {
//! push method that adds to the parent_cells visited cells for this search universe
void push(int32_t search_universe, const ParentCell& pc) {
parent_cells_.push_back(pc);
// add parent cell to the set of cells we've visited for this search universe
visited_cells_[search_universe].insert(pc);
}
//! removes the last parent_cell and clears the visited cells for the popped cell's universe
void pop() {
visited_cells_[this->current_univ()].clear();
parent_cells_.pop_back();
}
bool visited(int32_t univ_idx, const ParentCell& parent_cell) {
return visited_cells_[univ_idx].count(parent_cell) != 0;
//! checks whether or not the parent cell has been visited already for this search universe
bool visited(int32_t search_universe, const ParentCell& parent_cell) {
return visited_cells_[search_universe].count(parent_cell) != 0;
}
//! return the next universe to search for a parent cell
int32_t current_univ() const { return model::cells[parent_cells_.back().cell_index]->universe_; }
//! indicates whether nor not parent cells are present on the stack
bool empty() const { return parent_cells_.empty(); }
//! compute an instance for the provided distribcell index
int32_t compute_instance(int32_t distribcell_index) const;
// Accessors
std::vector<ParentCell>& parent_cells() { return parent_cells_; }
const std::vector<ParentCell>& parent_cells() const { return parent_cells_; }
@ -351,13 +366,6 @@ struct ParentCellStack {
std::unordered_map<int32_t, std::set<ParentCell>> visited_cells_;
};
struct ParentCellHash {
std::size_t operator()(const ParentCell& p) const
{
return 4096*p.cell_index + p.lattice_index;
}
};
//==============================================================================
//! Define an instance of a particular cell
//==============================================================================