Refactor of NearestNeighborProblem to improve readability#166
Open
djmallum wants to merge 6 commits into
Open
Conversation
Switching from `typedef` to `using` in the `math::LinearAlgebra` namespace. `typedef` exists for C compatability, and `using` is more clear about which is the alias and which is the real type thanks to the `=` sign.
Constructor was long and difficult to reason about. Refactored into several specific functions and created some structs to make the data organized more cleanly. Also removed the reference to the `mesh` object and replaced with a template to enable easier testing.
Original implementation uses implementation details that Tpetra advises against, and instead recommends selecting the type from the map. Consideration is needed for if one should be using a unique orginal type for each Tpetra type. For example, `Tpetra::CrsGraph<>` has its own local and global ordinal types.
Now accepts (and excepts) a `const std::string&` for the name of the module using the class. It is stored internally as a `string_view` and used to print errors using the module name, previously used PBSM3D only. As a result, modified PBSM3D to pass the `module_base` member `ID` to the NearestNeighborProblem objects.
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.
In my effort to understand how
NearestNeighborProblemworks, I refactored its constructor for readability. I did change minor behaviour (point 3 below).Three main changes:
Added a template parameter to
NearestNeighborProblemas a stand-in fordomain. I did that because I was thinking of testing it, and with the concept calledMeshObject, I enforce the functions needed at compile time byNearestNeighborProblem. Possibly not needed.Added several private helpers and structs to improve the length and readability of the constructor of
NearestNeighborProblem.Introduced a
_module_namemember to the constructor of typestd::string_viewto allow the printing of the module name in case of throwing an exception. Previously had PBSM3D hard coded (for obvious reasons).