diff --git a/include/openmc/cell.h b/include/openmc/cell.h index f436592cd..d4c220635 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -182,6 +182,7 @@ class DAGCell : public Cell public: moab::DagMC* dagmc_ptr_; DAGCell(); + int32_t dag_index_; bool contains(Position r, Direction u, int32_t on_surface) const; diff --git a/include/openmc/surface.h b/include/openmc/surface.h index e1acefa23..bebff35ee 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -131,6 +131,8 @@ class DAGSurface : public Surface public: moab::DagMC* dagmc_ptr_; DAGSurface(); + int32_t dag_index_; + double evaluate(Position r) const; double distance(Position r, Direction u, bool coincident) const; Direction normal(Position r) const; diff --git a/src/cell.cpp b/src/cell.cpp index 2eec07d2a..c7b92c829 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -601,7 +601,7 @@ std::pair DAGCell::distance(Position r, Direction u, int32_t on_surface) const { moab::ErrorCode rval; - moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, model::cell_map[id_] + 1); + moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_); moab::EntityHandle hit_surf; double dist; double pnt[3] = {r.x, r.y, r.z}; @@ -621,7 +621,7 @@ DAGCell::distance(Position r, Direction u, int32_t on_surface) const bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const { moab::ErrorCode rval; - moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, model::cell_map[id_] + 1); + moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_); int result = 0; double pnt[3] = {r.x, r.y, r.z}; @@ -830,9 +830,9 @@ openmc_extend_cells(int32_t n, int32_t* index_start, int32_t* index_end) int32_t next_cell(DAGCell* cur_cell, DAGSurface* surf_xed) { moab::EntityHandle surf = - surf_xed->dagmc_ptr_->entity_by_index(2, model::surface_map[surf_xed->id_] + 1); + surf_xed->dagmc_ptr_->entity_by_index(2, surf_xed->dag_index_); moab::EntityHandle vol = - cur_cell->dagmc_ptr_->entity_by_index(3, model::cell_map[cur_cell->id_] + 1); + cur_cell->dagmc_ptr_->entity_by_index(3, cur_cell->dag_index_); moab::EntityHandle new_vol; cur_cell->dagmc_ptr_->next_vol(surf, vol, new_vol); diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 54bf38ad9..1ccc72595 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -138,7 +138,8 @@ void load_dagmc_geometry() // set cell ids using global IDs DAGCell* c = new DAGCell(); - c->id_ = model::DAG->id_by_index(3, i+1); + c->dag_index_ = i+1; + c->id_ = model::DAG->id_by_index(3, c->dag_index_); c->dagmc_ptr_ = model::DAG; c->universe_ = dagmc_univ_id; // set to zero for now c->fill_ = C_NONE; // no fill, single universe @@ -261,7 +262,8 @@ void load_dagmc_geometry() // set cell ids using global IDs DAGSurface* s = new DAGSurface(); - s->id_ = model::DAG->id_by_index(2, i+1); + s->dag_index_ = i+1; + s->id_ = model::DAG->id_by_index(2, s->dag_index_); s->dagmc_ptr_ = model::DAG; // set BCs diff --git a/src/surface.cpp b/src/surface.cpp index bf0315698..f30b44431 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -241,7 +241,7 @@ double DAGSurface::distance(Position r, Direction u, bool coincident) const { moab::ErrorCode rval; - moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_); + moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_); moab::EntityHandle hit_surf; double dist; double pnt[3] = {r.x, r.y, r.z}; @@ -256,7 +256,7 @@ Direction DAGSurface::normal(Position r) const { moab::ErrorCode rval; Direction u; - moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_); + moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_); double pnt[3] = {r.x, r.y, r.z}; double dir[3] = {u.x, u.y, u.z}; rval = dagmc_ptr_->get_angle(surf, pnt, dir); @@ -267,7 +267,7 @@ Direction DAGSurface::normal(Position r) const BoundingBox DAGSurface::bounding_box() const { moab::ErrorCode rval; - moab::EntityHandle surf = dagmc_ptr_->entity_by_id(2, id_); + moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_); double min[3], max[3]; rval = dagmc_ptr_->getobb(surf, min, max); MB_CHK_ERR_CONT(rval);