2D Tolerance Search and N-Dimension Uniform Grid#11
Closed
matthew-mccall wants to merge 17 commits intojacobmerson:developfrom
Closed
2D Tolerance Search and N-Dimension Uniform Grid#11matthew-mccall wants to merge 17 commits intojacobmerson:developfrom
matthew-mccall wants to merge 17 commits intojacobmerson:developfrom
Conversation
Updated `GridPointSearch` to use a templated design (`GridPointSearch<dim>`) and introduced `GridPointSearch2D` as a specific case for 2D point localization. This change ensures clearer extensibility for other dimensions and improves code maintainability by centralizing shared logic in a new base class (`PointLocalizationSearch`). Adjusted test cases, headers, and related implementations accordingly.
Replaced `std::optional` with `std::unique_ptr` for `search_` to better handle polymorphism and align with future extensions. Updated type aliasing and constructors accordingly to enhance code clarity and maintainability.
Introduced support for 3D point localization and grid intersection with a new `GridTriIntersectionFunctor3D`. Refactored 2D implementations for consistency, generalizing methods to handle dimensions dynamically. Added templates and utilities to support both 2D and 3D use cases effectively.
Replaced the local implementation of barycentric_from_global with Omega_h's standard implementation. Removed the custom function from both source and header files, and updated all calls to use Omega_h::barycentric_from_global<2, 2>. This change enhances code maintainability and aligns functionality with the Omega_h library.
Introduce bbox_verts_within_simplex to check if an AABBox's vertices are within a simplex using barycentric coordinates. Also, add a virtual destructor to the PointLocalizationSearch class for proper cleanup in derived classes.
Renamed `construct_intersection_map` to `construct_intersection_map_2d` and added `construct_intersection_map_3d` for 3D support. Introduced `GridPointSearch3D` class, extending point localization for 3D grids with associated functionality and data structures. Updated tests to reflect these changes.
Introduce a new REGION dimensionality to represent 3D regions in point search operations. Adjust loops and result assignment logic to incorporate this new dimension for improved handling of 3D cases.
Simplified indentation and adjusted line breaks in edge and vertex search loops for improved readability. Added constructor overloads to `GridPointSearch2D` for handling tolerances via a new `PointSearchTolerances` abstraction. Updated `PointLocalizationSearch` class with support for tolerances.
Previous algorithm checked edges then vertices. Now we check vertices, then edges.
Converted `PointSearchTolerances` to use `const` references for safer and more efficient handling. Added default tolerances initialization in 2D and 3D grid search constructors. Renamed `tri_id` to `element_id` in `Result` for improved clarity and consistency across dimensionalities.
…ces handling Revised result assignment logic to incorporate detailed checks for vertex, edge, and face proximity, using new tolerances-based conditions. Updated tests to reflect changes in dimensionality and result handling for improved accuracy verification.
Removed unused `edge_found` variable for cleaner logic in result assignment. Updated test cases to add new points and verify dimensionality, element IDs, and coordinates for various scenarios, enhancing accuracy and coverage.
Owner
|
/runtests |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the point search functionality to support both 2D and 3D meshes by introducing a templated base class hierarchy. The main changes include:
- Introduces a
PointLocalizationSearchbase class templated on dimension - Renames
GridPointSearchtoGridPointSearch2Dand addsGridPointSearch3Dimplementation - Updates the 2D point search algorithm to check for vertices and edges before faces
- Adds tolerance-based matching for vertices and edges
- Removes the
UniformGriddefault template parameter in favor of explicit specialization
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pcms/uniform_grid.h | Removes default template parameter and adds explicit 2D/3D type aliases |
| src/pcms/point_search.h | Introduces base class hierarchy and separate 2D/3D implementations |
| src/pcms/point_search.cpp | Implements 3D point search and refactors 2D algorithm with tolerance-based matching |
| test/test_point_search.cpp | Updates tests to use new class names and test new behavior |
| src/pcms/interpolator/adj_search.hpp | Updates references from GridPointSearch to GridPointSearch2D |
| src/pcms/adapter/omega_h/omega_h_field.h | Changes from std::optional to std::unique_ptr for polymorphic storage |
Comments suppressed due to low confidence (1)
src/pcms/point_search.cpp:656
- In the 3D constructor
GridPointSearch3D, queryingOmega_h::FACEtoOmega_h::EDGEandOmega_h::FACEtoOmega_h::VERTadjacencies is incorrect. For 3D tetrahedral meshes, the top-level elements areOmega_h::REGION(tetrahedra), notOmega_h::FACE. These should bemesh.ask_down(Omega_h::REGION, Omega_h::EDGE)andmesh.ask_down(Omega_h::REGION, Omega_h::VERT).
tris2edges_adj_ = mesh.ask_down(Omega_h::FACE, Omega_h::EDGE);
tris2verts_adj_ = mesh.ask_down(Omega_h::FACE, Omega_h::VERT);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
@matthew-mccall I started reviewing this, but I realized it's on my fork. Can you close this pull request and re-open it on SCOREC/pcms. Thanks! |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant generalization and refactoring of the point localization and search infrastructure, preparing the codebase for both 2D and 3D mesh support. The changes include replacing hardcoded 2D structures with dimension-agnostic templates, introducing new search classes and functors for 3D, and improving the robustness and clarity of the point search logic.
Generalization and Refactoring for Dimension-Agnostic Support:
simplex_bbox,within_bbox,bbox_verts_within_simplex, andsimplex_intersects_bboxto generalize bounding box and intersection logic for arbitrary dimensions, replacing 2D-specific implementations. [1] [2] [3] [4]GridTriIntersectionFunctor3Dand correspondingconstruct_intersection_map_3dto support 3D mesh intersection, alongside renaming and refactoring the 2D functor and intersection map construction for clarity.Search Infrastructure Modernization:
GridPointSearchtoGridPointSearch2Dand replacedstd::optionalwithstd::unique_ptrfor thesearch_member inOmegaHField, making the design ready for alternative search strategies and consistent with modern C++ practices. [1] [2] [3]Point Search Logic and API Improvements:
PointSearchTolerances) and improving the logic for nearest element detection and classification. [1] [2] [3]element_idinstead oftri_id,GridPointSearch2D::Result), and improved error checking and reporting. [1] [2] [3]These changes collectively make the codebase more extensible, robust, and ready for future 3D mesh support.