From c814b6f81edf33a19181cf9d0285ba344ddd527c Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 3 Apr 2019 21:42:40 -0500 Subject: [PATCH] Moving iz back. Expliciting initializing iz. --- src/lattice.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lattice.cpp b/src/lattice.cpp index dc1b1d8fe8..b16fecc6e3 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -715,6 +715,18 @@ HexLattice::get_indices(Position r, Direction u) const 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, accounting for coincidence + int iz = 0; + if (is_3d_) { + double iz_ {r_o.z / pitch_[1] + 0.5 * n_axial_}; + long iz_close {std::lround(iz_)}; + if (coincident(iz_, iz_close)) { + iz = (u.z > 0) ? iz_close : iz_close - 1; + } else { + iz = std::floor(iz_); + } + } + // Convert coordinates into skewed bases. The (x, alpha) basis is used to // find the index of the global coordinates to within 4 cells. double alpha = r_o.y - r_o.x / std::sqrt(3.0); @@ -726,18 +738,6 @@ HexLattice::get_indices(Position r, Direction u) const ix += n_rings_-1; ia += n_rings_-1; - // Index the z direction, accounting for coincidence - int iz{}; - if (is_3d_) { - double iz_ {r_o.z / pitch_[1] + 0.5 * n_axial_}; - long iz_close {std::lround(iz_)}; - if (coincident(iz_, iz_close)) { - iz = (u.z > 0) ? iz_close : iz_close - 1; - } else { - iz = std::floor(iz_); - } - } - // Calculate the (squared) distance between the particle and the centers of // the four possible cells. Regular hexagonal tiles form a Voronoi // tessellation so the xyz should be in the hexagonal cell that it is closest