Refactor of DAGMC next_cell

This commit is contained in:
Patrick Shriwise 2022-06-09 17:42:32 -05:00 committed by Gavin Ridley
parent 5e47f9daa4
commit adf2047b6e
3 changed files with 17 additions and 19 deletions

View file

@ -168,8 +168,7 @@ private:
// Non-member functions
//==============================================================================
int32_t next_cell(
DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed);
int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ);
} // namespace openmc

View file

@ -728,19 +728,21 @@ void check_dagmc_root_univ()
}
}
int32_t next_cell(
DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed)
{
moab::EntityHandle surf =
surf_xed->dagmc_ptr()->entity_by_index(2, surf_xed->dag_index());
moab::EntityHandle vol =
cur_cell->dagmc_ptr()->entity_by_index(3, cur_cell->dag_index());
int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ) {
auto surfp = dynamic_cast<DAGSurface*>(model::surfaces[surf - 1].get());
auto cellp = dynamic_cast<DAGCell*>(model::cells[curr_cell].get());
auto univp = static_cast<DAGUniverse*>(model::universes[univ].get());
moab::EntityHandle surf_handle =
surfp->dagmc_ptr()->entity_by_index(2, surfp->dag_index());
moab::EntityHandle curr_vol =
cellp->dagmc_ptr()->entity_by_index(3, cellp->dag_index());
moab::EntityHandle new_vol;
cur_cell->dagmc_ptr()->next_vol(surf, vol, new_vol);
cellp->dagmc_ptr()->next_vol(surf_handle, curr_vol, new_vol);
return cur_cell->dagmc_ptr()->index_by_handle(new_vol) +
dag_univ->cell_idx_offset_;
return cellp->dagmc_ptr()->index_by_handle(new_vol) +
univp->cell_idx_offset_;
}
} // namespace openmc
@ -756,8 +758,11 @@ void read_dagmc_universes(pugi::xml_node node)
"with DAGMC");
}
};
void check_dagmc_root_univ() {};
int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ);
} // namespace openmc
#endif // DAGMC

View file

@ -433,13 +433,7 @@ void Particle::cross_surface()
#ifdef DAGMC
// in DAGMC, we know what the next cell should be
if (surf->geom_type_ == GeometryType::DAG) {
auto surfp = dynamic_cast<DAGSurface*>(surf);
auto cellp =
dynamic_cast<DAGCell*>(model::cells[cell_last(n_coord() - 1)].get());
auto univp = static_cast<DAGUniverse*>(
model::universes[coord(n_coord() - 1).universe].get());
// determine the next cell for this crossing
int32_t i_cell = next_cell(univp, cellp, surfp) - 1;
int32_t i_cell = next_cell(i_surface, cell_last(n_coord() - 1), lowest_coord().universe) - 1;
// save material and temp
material_last() = material();
sqrtkT_last() = sqrtkT();