mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Applying a new stack to simplify parent cell traversal alg.
This commit is contained in:
parent
683a671d11
commit
0817a792d9
2 changed files with 38 additions and 13 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
|
|
@ -319,6 +320,33 @@ struct ParentCell {
|
|||
gsl::index lattice_index;
|
||||
};
|
||||
|
||||
struct ParentCellStack {
|
||||
|
||||
void push_back(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);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
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;
|
||||
}
|
||||
|
||||
int32_t current_univ() const { return model::cells[parent_cells_.back().cell_index]->universe_; }
|
||||
|
||||
bool empty() const { return parent_cells_.empty(); }
|
||||
|
||||
std::vector<ParentCell> parent_cells() { return parent_cells_; }
|
||||
|
||||
std::vector<ParentCell> parent_cells_;
|
||||
std::unordered_map<int32_t, std::set<ParentCell>> visited_cells_;
|
||||
};
|
||||
|
||||
struct ParentCellHash {
|
||||
std::size_t operator()(const ParentCell& p) const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue