diff --git a/include/openmc/cell.h b/include/openmc/cell.h index cb77d7e415..e2c3f400af 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -9,14 +9,14 @@ #include "hdf5.h" #include "pugixml.hpp" +#ifdef DAGMC +#include "DagMC.hpp" +#endif #include "openmc/constants.h" #include "openmc/neighbor_list.h" #include "openmc/position.h" - -#ifdef DAGMC -#include "DagMC.hpp" -#endif +#include "openmc/surface.h" namespace openmc { diff --git a/src/cell.cpp b/src/cell.cpp index 2a2bd82d6c..af77094c99 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -830,29 +830,25 @@ openmc_extend_cells(int32_t n, int32_t* index_start, int32_t* index_end) return 0; } +#ifdef DAGMC +int32_t next_cell(DAGCell* cur_cell, DAGSurface* surf_xed) +{ + moab::EntityHandle surf = + surf_xed->dagmc_ptr_->entity_by_id(2, surf_xed->id_); + moab::EntityHandle vol = + cur_cell->dagmc_ptr_->entity_by_id(3, cur_cell->id_); + + moab::EntityHandle new_vol; + cur_cell->dagmc_ptr_->next_vol(surf, vol, new_vol); + + return cur_cell->dagmc_ptr_->index_by_handle(new_vol); +} +#endif //============================================================================== // Fortran compatibility functions //============================================================================== -extern "C" { - int cells_size() { return model::cells.size(); } - - #ifdef DAGMC - int32_t next_cell(DAGCell* cur_cell, DAGSurface* surf_xed) - { - moab::EntityHandle surf = - surf_xed->dagmc_ptr_->entity_by_id(2, surf_xed->id_); - moab::EntityHandle vol = - cur_cell->dagmc_ptr_->entity_by_id(3, cur_cell->id_); - - moab::EntityHandle new_vol; - cur_cell->dagmc_ptr_->next_vol(surf, vol, new_vol); - - return cur_cell->dagmc_ptr_->index_by_handle(new_vol); - } - #endif -} - +extern "C" int cells_size() { return model::cells.size(); } } // namespace openmc diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 3af23bc467..a398c9f758 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -316,7 +316,7 @@ void load_dagmc_geometry() void read_geometry_dagmc() { // Check if dagmc.h5m exists - std::string filename = settings::path_input + "dagmc.h5m" + std::string filename = settings::path_input + "dagmc.h5m"; if (!file_exists(filename)) { fatal_error("Geometry DAGMC file '" + filename + "' does not exist!"); } @@ -324,7 +324,7 @@ void read_geometry_dagmc() write_message("Reading DAGMC geometry...", 5); load_dagmc_geometry(); - model::root_universe = find_root_universe() + model::root_universe = find_root_universe(); } void free_memory_dagmc() diff --git a/src/particle.cpp b/src/particle.cpp index 73ec98ce6c..4c39087ce2 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -581,17 +581,21 @@ Particle::cross_surface() #ifdef DAGMC if (settings::dagmc) { - int32_t i_cell = next_cell(model::cells[last_cell[0]], - model::surfaces[std::abs(surface)]); + auto cellp = dynamic_cast(model::cells[last_cell[0]]); + // TODO: off-by-one + auto surfp = dynamic_cast(model::surfaces[std::abs(surface) - 1]); + int32_t i_cell = next_cell(cellp, surfp) - 1; // save material and temp last_material = material; - last_sqrtkT = sqrtKT; + last_sqrtkT = sqrtkT; // set new cell value - coord[0].cell = i_cell + coord[0].cell = i_cell; cell_instance = 0; - material = model::cells[i_cell]->material[0]; - sqrtKT = model::cells[i_cell]->sqrtKT[0]; - return + // TODO: off-by-one + int mat = model::cells[i_cell]->material_[0]; + material = (mat == MATERIAL_VOID) ? mat : mat + 1; + sqrtkT = model::cells[i_cell]->sqrtkT_[0]; + return; } #endif