refactor(basis): replace operator closures with functor types#64
Merged
refactor(basis): replace operator closures with functor types#64
Conversation
This refactoring addresses Issue #63 by introducing a unified constructor for RadialBasisOperator that uses keyword arguments, reducing code duplication across operator files. Changes: - Add unified `RadialBasisOperator(ℒ, data; eval_points, basis, k, adjl, hermite)` constructor in operators.jl - Refactor all operator files (laplacian, partial, custom, jacobian, gradient, directional, regridding) to use thin wrappers - Old positional constructors now delegate to the unified constructor - Maintain full backward compatibility with existing API - Add hermite keyword argument as NamedTuple alternative to positional args - Improve documentation with examples The new keyword-based API is now the primary interface: ```julia op = laplacian(data; basis=PHS(5), k=30) op = jacobian(data; eval_points=pts, hermite=(is_boundary=..., bc=..., normals=...)) ``` Closes #63 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ∂, ∇, ∂², ∇², D, D² functor structs in basis.jl - Replace closure-returning functions with callable structs - Update PHS, Gaussian, IMQ implementations - Use D functor in assembly.jl instead of dot(n, ∇(...)) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
Contributor
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Add H (Hessian) functor for all basis types to enable pre-construction of derivative operators outside hot loops in Hermite interpolation. Changes: - Add H struct to basis.jl for Hessian matrix computation - Implement H for PHS1, PHS3, PHS5, PHS7, Gaussian, IMQ - Add D² (directional second derivative) for Gaussian and IMQ - Add BasisOperators wrapper to bundle φ, ∇φ, Hφ operators - Update hermite_rbf_dispatch to use dot(n, ∇φ) and dot(ni, Hφ*nj) - Construct BasisOperators once before loop in _build_collocation_matrix! Performance: Avoids constructing D/D² functors per point pair in hot loop. Instead pre-constructs gradient and Hessian operators once and computes directional derivatives via dot products. Tests: Add Hessian and D² tests for all basis types verified against ForwardDiff. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f789293 to
f675246
Compare
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.
Summary
This PR addresses both Issue #62 and Issue #63.
Issue #62: Functor pattern for RBF operators
∂,∇,∂²,∇²,D,D²callable structs inbasis.jlDfunctor inassembly.jlinstead ofdot(n, ∇(...))Issue #63: Unified operator construction
RadialBasisOperator(ℒ, data; eval_points, basis, k, adjl, hermite)constructorhermitekeyword argument as NamedTuple alternativeBenefits:
Closes #62
Closes #63
Test plan
Dfunctor added (PHS, Gaussian, IMQ)🤖 Generated with Claude Code