diff --git a/src/kde/quick_index.cc b/src/kde/quick_index.cc index 7c6b6f28f..903c4ff94 100644 --- a/src/kde/quick_index.cc +++ b/src/kde/quick_index.cc @@ -30,6 +30,8 @@ namespace rtt_kde { * \param[in] max_window_size_ maximum supported window size * \param[in] bins_per_dimension_ number of bins in each dimension * \param[in] domain_decomposed_ + * \param[in] spherical_ bool operator to enable spherical transform + * \param[in] sphere_center_ origin of spherical transform */ quick_index::quick_index(const size_t dim_, const std::vector> &locations_, const double max_window_size_, const size_t bins_per_dimension_, @@ -563,8 +565,7 @@ auto get_window_bin = [](auto spherical, const auto dim, const auto &grid_bins, //------------------------------------------------------------------------------------------------// // Lambda for mapping the data auto map_data = [](auto &bias_cell_count, auto &data_count, auto &grid_data, auto &min_distance, - const auto &dim, const auto &map_type, const auto &data, - const auto &distance_to_bin_center, const auto &location, + const auto &map_type, const auto &data, const auto &distance_to_bin_center, const auto &local_window_bin, const auto &data_bin) { // regardless of map type if it is the first value to enter the bin it // gets set to that value @@ -704,8 +705,8 @@ void quick_index::map_data_to_grid_window( continue; // lambda for mapping the data - map_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type, local_data, - distance_to_bin_center, locations[l], local_window_bin, l); + map_data(bias_cell_count, data_count, grid_data, min_distance, map_type, local_data, + distance_to_bin_center, local_window_bin, l); } // end local point loop } // if valid local bin loop @@ -727,8 +728,8 @@ void quick_index::map_data_to_grid_window( continue; // lambda for mapping the data - map_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type, ghost_data, - distance_to_bin_center, local_ghost_locations[g], local_window_bin, g); + map_data(bias_cell_count, data_count, grid_data, min_distance, map_type, ghost_data, + distance_to_bin_center, local_window_bin, g); } // end ghost point loop } // if valid ghost bin } // if dd @@ -784,10 +785,9 @@ void quick_index::map_data_to_grid_window( //------------------------------------------------------------------------------------------------// // Lambda for mapping the vector data auto map_vector_data = [](auto &bias_cell_count, auto &data_count, auto &grid_data, - auto &min_distance, const auto &dim, const auto &map_type, - const auto &data, const auto &distance_to_bin_center, - const auto &location, const auto &local_window_bin, const auto &data_bin, - const auto &vsize) { + auto &min_distance, const auto &map_type, const auto &data, + const auto &distance_to_bin_center, const auto &local_window_bin, + const auto &data_bin, const auto &vsize) { // regardless of map type if it is the first value to enter the bin it gets set to that value if (data_count[local_window_bin] == 0) { bias_cell_count += 1.0; @@ -938,9 +938,8 @@ void quick_index::map_data_to_grid_window(const std::vector> if (!valid) continue; Check(local_window_bin < n_map_bins); - map_vector_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type, - local_data, distance_to_bin_center, locations[l], local_window_bin, l, - vsize); + map_vector_data(bias_cell_count, data_count, grid_data, min_distance, map_type, local_data, + distance_to_bin_center, local_window_bin, l, vsize); } // end local point loop } // if valid local bin loop if (domain_decomposed) { @@ -959,9 +958,8 @@ void quick_index::map_data_to_grid_window(const std::vector> // If the bin is outside the window continue to the next poin if (!valid) continue; - map_vector_data(bias_cell_count, data_count, grid_data, min_distance, dim, map_type, - ghost_data, distance_to_bin_center, local_ghost_locations[g], - local_window_bin, g, vsize); + map_vector_data(bias_cell_count, data_count, grid_data, min_distance, map_type, + ghost_data, distance_to_bin_center, local_window_bin, g, vsize); } // end ghost point loop } // if valid ghost bin } // if dd diff --git a/src/kde/quick_index.hh b/src/kde/quick_index.hh index 93bd635dc..9208d42cf 100644 --- a/src/kde/quick_index.hh +++ b/src/kde/quick_index.hh @@ -28,6 +28,7 @@ namespace rtt_kde { * Calculate a relative r theta and phi coordinate relative to a sphere center location from a * standard (x,y,z) or (r,z) coordinates * + * \param[in] dim used to ensure it is only used in valid dimension ranges * \param[in] sphere_center center of sphere in (x,y,z) or (r,z) coordinates * \param[in] locations (x,y,z) or (r,z) locations to transform to relative (r, theta, phi) space. * @@ -110,7 +111,7 @@ public: // Quick index initialization data const size_t dim; const bool domain_decomposed; - const double spherical; + const bool spherical; const std::array sphere_center; const size_t coarse_bin_resolution; const double max_window_size; diff --git a/src/kde/test/tstkde.cc b/src/kde/test/tstkde.cc index c546d7011..3ddeac126 100644 --- a/src/kde/test/tstkde.cc +++ b/src/kde/test/tstkde.cc @@ -34,8 +34,6 @@ void test_replication(ParallelUnitTest &ut) { { const bool spherical = true; const std::array sphere_center{0.0, -1.0, 0.0}; - const double max_radius = 1.0; - const double min_radius = 0.0; kde sphere_kde; // reflect on the theta boundary kde theta_reflected_sphere_kde({false, false, true, true, false, false}); @@ -1046,9 +1044,6 @@ void test_decomposition(ParallelUnitTest &ut) { const bool spherical = true; const size_t local_size = 24; const std::array sphere_center{0.0, -1.0, 0.0}; - const double max_radius = 1.0; - const double min_radius = 0.0; - const double shell_min_radius = 0.5; kde sphere_kde; // reflect on the theta boundary kde theta_reflected_sphere_kde({false, false, true, true, false, false}); diff --git a/src/kde/test/tstquick_index.cc b/src/kde/test/tstquick_index.cc index 3360e23e8..2228e6ffd 100644 --- a/src/kde/test/tstquick_index.cc +++ b/src/kde/test/tstquick_index.cc @@ -76,6 +76,11 @@ void test_replication(ParallelUnitTest &ut) { for (size_t i = 0; i < map.second.size(); i++) if (gold_map[map.first][i] != map.second[i]) ITFAILS; + + // Check non-spherical orthogonal distance calculation + auto distance = qindex.calc_orthogonal_distance({-1, -1, -1}, {1, 1, 1}, 10.0); + for (auto &val : distance) + FAIL_IF_NOT(rtt_dsxx::soft_equiv(val, 2.0)); } if (ut.numFails == 0) { @@ -142,6 +147,11 @@ void test_replication_sphere(ParallelUnitTest &ut) { for (size_t i = 0; i < map.second.size(); i++) if (gold_map[map.first][i] != map.second[i]) ITFAILS; + + // Check non-spherical orthogonal distance calculation + auto distance = qindex.calc_orthogonal_distance({-1, 0.5, -1}, {1, 1, 1}, 4.0); + for (auto &val : distance) + FAIL_IF_NOT(rtt_dsxx::soft_equiv(val, 2.0)); } if (ut.numFails == 0) { @@ -1501,9 +1511,6 @@ void test_decomposition_sphere(ParallelUnitTest &ut) { const size_t local_size = 4; const std::array sphere_center{0.0, 0.0, 0.0}; - const double max_radius = 1.0; - const double min_radius = 0.0; - const double shell_min_radius = 0.5; const std::array radial_edges{0.5, 1.0}; const std::array cosine_edges{-.99, 0, .99, -.99, 0, .99}; const size_t data_size = radial_edges.size() * cosine_edges.size(); @@ -1721,9 +1728,6 @@ void test_decomposition_sphere(ParallelUnitTest &ut) { const size_t local_size = 24; const std::array sphere_center{0.0, -1.0, 0.0}; - const double max_radius = 1.0; - const double min_radius = 0.0; - const double shell_min_radius = 0.5; const std::array radial_edges{0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0}; const std::array cosine_edges{-1.0, -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0}; const size_t data_size = radial_edges.size() * cosine_edges.size();