Optimize find_cell on universes with many z-planes

This commit is contained in:
Sterling Harper 2019-03-31 10:55:26 -04:00
parent 49c49110b7
commit 4b76c28a3b
6 changed files with 165 additions and 2 deletions

View file

@ -23,6 +23,11 @@
namespace openmc {
int search_denominator1 {0};
int search_numerator1 {0};
int search_denominator2 {0};
int search_numerator2 {0};
void read_geometry_xml()
{
#ifdef DAGMC
@ -219,6 +224,28 @@ void finalize_geometry(std::vector<std::vector<double>>& nuc_temps,
// Determine number of nested coordinate levels in the geometry
model::n_coord_levels = maximum_levels(model::root_universe);
for (const auto& univ : model::universes) {
if (univ->cells_.size() > 10) {
std::unordered_set<int32_t> surf_inds;
for (auto i_cell : univ->cells_) {
for (auto token : model::cells[i_cell]->rpn_) {
if (token < OP_UNION) surf_inds.insert(std::abs(token) - 1);
}
}
int n_zplanes = 0;
for (auto i_surf : surf_inds) {
if (dynamic_cast<const SurfaceZPlane*>(model::surfaces[i_surf].get())) {
++n_zplanes;
if (n_zplanes > 5) {
univ->partitioner_ = std::make_unique<UniversePartitioner>(
UniversePartitioner(*univ));
break;
}
}
}
}
}
}
//==============================================================================
@ -519,6 +546,8 @@ maximum_levels(int32_t univ)
void
free_memory_geometry()
{
std::cout << "SEARCH EFFICIENCY = " << static_cast<double>(search_numerator1) / search_denominator1 << "\n";
std::cout << "SEARCH EFFICIENCY = " << static_cast<double>(search_numerator2) / search_denominator2 << "\n";
model::cells.clear();
model::cell_map.clear();