From da9a8761850c499de5012f5fc6563623ad5e7663 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 1 Apr 2019 09:44:57 -0500 Subject: [PATCH] Some corrections to comments. Adding coincident to geometry header. --- include/openmc/geometry.h | 6 ++++++ src/lattice.cpp | 28 ++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/openmc/geometry.h b/include/openmc/geometry.h index 5feca2992a..43b595bc18 100644 --- a/include/openmc/geometry.h +++ b/include/openmc/geometry.h @@ -35,6 +35,12 @@ struct BoundaryInfo { std::array lattice_translation {}; //!< which way lattice indices will change }; +//============================================================================== +//! Check two distances by coincidence tolerance +//============================================================================== + +bool coincident(const double& d1, const double& d2); + //============================================================================== //! Check for overlapping cells at a particle's position. //============================================================================== diff --git a/src/lattice.cpp b/src/lattice.cpp index 2d3afbc8b2..73de243077 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -713,15 +713,11 @@ HexLattice::get_indices(Position r, Direction u) const // result variables int ix{}, ia{}, iz{}; - // The implementation for HexLattice currently doesn't use direction - // information. As a result, we move the position slightly forward to - // determine what lattice index the particle is most likely to be in. - // Offset the xyz by the lattice center. Position r_o {r.x - center_.x, r.y - center_.y, r.z}; if (is_3d_) {r_o.z -= center_.z;} - // Index the z direction. + // Index the z direction. Same as in RectLattice::get_indices. if (is_3d_) { double iz_ {r_o.z / pitch_[1] + 0.5 * n_axial_}; long iz_close {std::lround(iz_)}; @@ -752,14 +748,14 @@ HexLattice::get_indices(Position r, Direction u) const // computationally efficient than normal distances. // COINCIDENCE CHECK - // if a distance to center, d, is the same as the current minimum - // distance, d_min, the particle is on an edge or vertex. In this case, - // the dot product of the position vector and direction vector for the current - // indices, dp, and the dot product for the currently selected - // indices, dp_min, are compared. The cell the particle is moving into is kept - // (the cell with the lowest dot prouct as the vectors will be completely - // opposed if the particle is moving directly toward the center of the - // cell, i.e. dot product == -1) + // if a distance to center, d, is within the coincidence tolerance of the + // current minimum distance, d_min, the particle is on an edge or vertex. + // In this case, the dot product of the position vector and direction vector + // for the current indices, dp, and the dot product for the currently selected + // indices, dp_min, are compared. The cell which the particle is moving into + // is kept (i.e. the cell with the lowest dot prouct as the vectors will be + // completely opposed if the particle is moving directly toward the center of + // the cell). int ix_delta {}; int ia_delta {}; double d_min {INFTY}; @@ -774,11 +770,11 @@ HexLattice::get_indices(Position r, Direction u) const // check for coincidence bool on_boundary = std::abs(d - d_min) < FP_COINCIDENT; if (d < d_min || on_boundary) { - // find dot product + // normalize r_t and find dot product r_t /= std::sqrt(d); double dp = u.x * r_t.x + u.y * r_t.y; // do not update values if particle is on a - // bouncary and not moving into this cell + // boundary and not moving into this cell if (on_boundary && dp > dp_min) { continue; } // update values d_min = d; @@ -789,7 +785,7 @@ HexLattice::get_indices(Position r, Direction u) const } } - // update indices + // update outgoing indices ix += ix_delta; ia += ia_delta;