Skip to content

Refactor of NearestNeighborProblem to improve readability#166

Open
djmallum wants to merge 6 commits into
Chrismarsh:developfrom
djmallum:Refactor/NearestNeighbourProblem/Extraction
Open

Refactor of NearestNeighborProblem to improve readability#166
djmallum wants to merge 6 commits into
Chrismarsh:developfrom
djmallum:Refactor/NearestNeighbourProblem/Extraction

Conversation

@djmallum
Copy link
Copy Markdown
Contributor

@djmallum djmallum commented May 5, 2026

In my effort to understand how NearestNeighborProblem works, I refactored its constructor for readability. I did change minor behaviour (point 3 below).

Three main changes:

  1. Added a template parameter to NearestNeighborProblem as a stand-in for domain. I did that because I was thinking of testing it, and with the concept called MeshObject, I enforce the functions needed at compile time by NearestNeighborProblem. Possibly not needed.

  2. Added several private helpers and structs to improve the length and readability of the constructor of NearestNeighborProblem.

  3. Introduced a _module_name member to the constructor of type std::string_view to allow the printing of the module name in case of throwing an exception. Previously had PBSM3D hard coded (for obvious reasons).

djmallum added 6 commits May 4, 2026 11:33
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant