Skip to content

Add a SystemKernel wrapper#287

Open
alexfikl wants to merge 5 commits into
inducer:mainfrom
alexfikl:system-kernels
Open

Add a SystemKernel wrapper#287
alexfikl wants to merge 5 commits into
inducer:mainfrom
alexfikl:system-kernels

Conversation

@alexfikl

@alexfikl alexfikl commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This is very drafty at the moment.

However, the point is to:

  1. Rename Kernel to ScalarKernel
  2. Introduce a SystemKernel for things like Stokes. Currently, the SystemKernel is intentionally more barebones than a ScalarKernel because it cannot (and maybe will not?) be used for codegen.
  3. Implement and test the various kernels we have as SystemKernel.

@alexfikl alexfikl marked this pull request as ready for review June 12, 2026 12:40
@alexfikl alexfikl requested a review from Copilot June 12, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the kernel type hierarchy by splitting the previous Kernel concept into a ScalarKernel (codegen-capable scalar kernels) and a new, more barebones SystemKernel API for vector/tensor-valued PDE kernels (e.g. Stokes/Brinkman/Elasticity), while deprecating sumpy.kernel.Kernel.

Changes:

  • Renames most type usage/imports from Kernel to ScalarKernel across FMM/expansion/tooling and tests.
  • Introduces GenericKernel, SystemKernel, and ExpressionSystemKernel, and implements several concrete *SystemKernel PDE kernels.
  • Adds tests validating SystemKernel component structure and pickling behavior.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sumpy/toys.py Updates toy context typing/imports to ScalarKernel.
sumpy/tools.py Switches KernelLike and computation typing/docs to ScalarKernel.
sumpy/test/test_target_deriv.py Updates test typing/imports to ScalarKernel.
sumpy/test/test_misc.py Adds SystemKernel tests and updates kernel typing to ScalarKernel.
sumpy/test/test_m2m_coeffs.py Updates test typing/imports to ScalarKernel.
sumpy/test/test_l2l_coeffs.py Updates test typing/imports to ScalarKernel.
sumpy/test/test_kernels.py Updates test typing/imports to ScalarKernel.
sumpy/test/test_fmm.py Updates test typing/imports to ScalarKernel.
sumpy/p2p.py Updates docstrings to reference ScalarKernel.
sumpy/kernel.py Introduces new kernel interfaces + concrete *SystemKernel implementations and deprecates Kernel.
sumpy/fmm.py Updates FMM typing/imports to ScalarKernel.
sumpy/expansion/multipole.py Updates expansion interfaces typing to ScalarKernel.
sumpy/expansion/m2l.py Updates M2L factory typing to ScalarKernel.
sumpy/expansion/loopy.py Updates loopy kernel builders typing to ScalarKernel.
sumpy/expansion/local.py Updates local expansion typing to ScalarKernel.
sumpy/expansion/level_to_order.py Updates level-to-order typing to ScalarKernel.
sumpy/expansion/__init__.py Updates expansion base interfaces typing to ScalarKernel.
.basedpyright/baseline.json Updates the basedpyright baseline to match new typing outcomes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sumpy/kernel.py Outdated
Comment thread sumpy/kernel.py Outdated
Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py


@dataclass(frozen=True, repr=False)
class ScalarKernel(GenericKernel, ABC):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sudo get-me-a-system-kernel-and-index -f

Comment thread sumpy/kernel.py

for i in range(dim):
for j in range(i, dim):
components[i, j] = components[j, i] = ElasticityKernel(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Deprecate ElasticityKernel.
  • Rename to ElasticityComponentKernel.

?

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.

3 participants