From 13b9061cf388fce4cd3d5b4f134a09497120c7e0 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 14 Mar 2019 20:47:43 -0500 Subject: [PATCH 1/3] Using entity_by_index and correcting entries in surface map. --- src/cell.cpp | 8 ++++---- src/dagmc.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index d4712b9d1d..2eec07d2ac 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_id(3, id_); + moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, model::cell_map[id_] + 1); 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_id(3, id_); + moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, model::cell_map[id_] + 1); 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_id(2, surf_xed->id_); + surf_xed->dagmc_ptr_->entity_by_index(2, model::surface_map[surf_xed->id_] + 1); moab::EntityHandle vol = - cur_cell->dagmc_ptr_->entity_by_id(3, cur_cell->id_); + cur_cell->dagmc_ptr_->entity_by_index(3, model::cell_map[cur_cell->id_] + 1); 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 34027ce7c9..54bf38ad96 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -303,7 +303,7 @@ void load_dagmc_geometry() // add to global array and map model::surfaces.emplace_back(s); - model::surface_map[s->id_] = s->id_; + model::surface_map[s->id_] = i; } return; From 23fc873a6962d93491ff403e48c5726144b600f4 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 15 Mar 2019 14:04:35 -0500 Subject: [PATCH 2/3] Using a normalized direction for plotting. --- src/plot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plot.cpp b/src/plot.cpp index 18103a1413..729b2db486 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -132,7 +132,7 @@ void create_ppm(Plot pl) break; } - Direction u {0.5, 0.5, 0.5}; + Direction u {0.7071, 0.7071, 0.0}; #pragma omp parallel { @@ -837,7 +837,7 @@ void create_voxel(Plot pl) Position ll = pl.origin_ - pl.width_ / 2.; // allocate and initialize particle - Direction u {0.5, 0.5, 0.5}; + Direction u {0.7071, 0.7071, 0.0}; Particle p; p.r() = ll; p.u() = u; From 1df5e95f66254ef3fca85f6bf1cf3fc117d1e204 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 15 Mar 2019 15:52:00 -0500 Subject: [PATCH 3/3] Using a DAGSurface/Cell class attribute to track DAGMC indices and contain +1's. --- include/openmc/cell.h | 1 + include/openmc/surface.h | 2 ++ src/cell.cpp | 8 ++++---- src/dagmc.cpp | 6 ++++-- src/surface.cpp | 6 +++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/openmc/cell.h b/include/openmc/cell.h index f436592cd8..d4c220635f 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 e1acefa23a..bebff35ee0 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 2eec07d2ac..c7b92c8294 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 54bf38ad96..1ccc72595d 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 bf03156985..f30b444310 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);