From aba8af458c67c1ef0b281cee7d10c0a8fa314dc2 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 14 Jul 2020 23:02:07 -0500 Subject: [PATCH 1/6] Label DAG cells as simple to avoid superfluous surface normal calls. --- src/dagmc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 29c10dc136..2a8064a42f 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -196,6 +196,7 @@ void load_dagmc_geometry() // set cell ids using global IDs DAGCell* c = new DAGCell(); c->dag_index_ = i+1; + c->simple_ = true; 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 From 6d41c669b0f6d3c2f9c627a317c33f5ebfeb0f05 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 14 Jul 2020 23:02:52 -0500 Subject: [PATCH 2/6] Pass particle history into DAGMC for more efficient normal calls. --- include/openmc/position.h | 8 ++++++++ src/surface.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/openmc/position.h b/include/openmc/position.h index 2be72b27cb..aaf63d0003 100644 --- a/include/openmc/position.h +++ b/include/openmc/position.h @@ -63,6 +63,14 @@ struct Position { return std::sqrt(x*x + y*y + z*z); } + inline Position reflect(Position n) { + const double projection = n.dot(*this); + const double magnitude = n.dot(n); + + n *= (2.0 * projection / magnitude); + return *this -= n; + } + //! Rotate the position based on a rotation matrix Position rotate(const std::vector& rotation) const; diff --git a/src/surface.cpp b/src/surface.cpp index f5a7f9f5f3..f2faa3efee 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -172,11 +172,9 @@ Surface::reflect(Position r, Direction u, Particle* p) const // Determine projection of direction onto normal and squared magnitude of // normal. Direction n = normal(r); - const double projection = n.dot(u); - const double magnitude = n.dot(n); // Reflect direction according to normal. - return u -= (2.0 * projection / magnitude) * n; + return u.reflect(n); } Direction @@ -279,7 +277,13 @@ Direction DAGSurface::reflect(Position r, Direction u, Particle* p) const { Expects(p); p->history_.reset_to_last_intersection(); - p->last_dir_ = Surface::reflect(r, u, p); + moab::ErrorCode rval; + moab::EntityHandle surf = dagmc_ptr_->entity_by_index(2, dag_index_); + double pnt[3] = {r.x, r.y, r.z}; + double dir[3]; + rval = dagmc_ptr_->get_angle(surf, pnt, dir, &p->history_); + MB_CHK_ERR_CONT(rval); + p->last_dir_ = u.reflect(dir); return p->last_dir_; } From 4fa6fd4b8f1b421a71216c87882b5fb533aeeaf2 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 19 Aug 2020 23:32:15 -0500 Subject: [PATCH 3/6] Moving setting of simple attribute into the DAGCell constructor. --- src/cell.cpp | 2 +- src/dagmc.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index 6c2bbf6bd7..6ca39749fd 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -779,7 +779,7 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const // DAGMC Cell implementation //============================================================================== #ifdef DAGMC -DAGCell::DAGCell() : Cell{} {}; +DAGCell::DAGCell() : Cell{} { simple_ = true; }; std::pair DAGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) const diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 2a8064a42f..29c10dc136 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -196,7 +196,6 @@ void load_dagmc_geometry() // set cell ids using global IDs DAGCell* c = new DAGCell(); c->dag_index_ = i+1; - c->simple_ = true; 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 From 1bdc9ca87719dd1a702307f4a55fae495ea48fb0 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 19 Aug 2020 23:32:27 -0500 Subject: [PATCH 4/6] Removing blank line. --- include/openmc/position.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/openmc/position.h b/include/openmc/position.h index aaf63d0003..b27a0f10c3 100644 --- a/include/openmc/position.h +++ b/include/openmc/position.h @@ -66,7 +66,6 @@ struct Position { inline Position reflect(Position n) { const double projection = n.dot(*this); const double magnitude = n.dot(n); - n *= (2.0 * projection / magnitude); return *this -= n; } From ebca9a489d2d232f804cf04bfa24af46b0ecd3dd Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 24 Aug 2020 09:07:59 -0500 Subject: [PATCH 5/6] Update include/openmc/position.h Co-authored-by: Paul Romano --- include/openmc/position.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/openmc/position.h b/include/openmc/position.h index b27a0f10c3..643447ac2a 100644 --- a/include/openmc/position.h +++ b/include/openmc/position.h @@ -67,7 +67,7 @@ struct Position { const double projection = n.dot(*this); const double magnitude = n.dot(n); n *= (2.0 * projection / magnitude); - return *this -= n; + return *this - n; } //! Rotate the position based on a rotation matrix From d99b7aab51d16dd6548c0e033a5de03b5beb2266 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 24 Aug 2020 10:09:24 -0500 Subject: [PATCH 6/6] Moving definition of reflect method. --- include/openmc/position.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/openmc/position.h b/include/openmc/position.h index 643447ac2a..3046f61636 100644 --- a/include/openmc/position.h +++ b/include/openmc/position.h @@ -63,12 +63,10 @@ struct Position { return std::sqrt(x*x + y*y + z*z); } - inline Position reflect(Position n) { - const double projection = n.dot(*this); - const double magnitude = n.dot(n); - n *= (2.0 * projection / magnitude); - return *this - n; - } + //! Reflect a direction across a normal vector + //! \param[in] other Vector to reflect across + //! \result Reflected vector + Position reflect(Position n) const; //! Rotate the position based on a rotation matrix Position rotate(const std::vector& rotation) const; @@ -96,6 +94,13 @@ inline Position operator/(Position a, Position b) { return a /= b; } inline Position operator/(Position a, double b) { return a /= b; } inline Position operator/(double a, Position b) { return b /= a; } +inline Position Position::reflect(Position n) const { + const double projection = n.dot(*this); + const double magnitude = n.dot(n); + n *= (2.0 * projection / magnitude); + return *this - n; +} + inline bool operator==(Position a, Position b) {return a.x == b.x && a.y == b.y && a.z == b.z;}