Skip to content

Separate ElasticityKernel and Stokeslet#281

Draft
alexfikl wants to merge 6 commits intoinducer:mainfrom
alexfikl:stokeslet-refactor
Draft

Separate ElasticityKernel and Stokeslet#281
alexfikl wants to merge 6 commits intoinducer:mainfrom
alexfikl:stokeslet-refactor

Conversation

@alexfikl
Copy link
Copy Markdown
Collaborator

@alexfikl alexfikl commented May 9, 2026

This makes the StokesletKernel an ExpressionKernel instead of inheriting from ElasticityKernel. Besides that, it also

  1. Removes the __new__ implementations.
  2. Deprecates passing a non-string value for viscosity_mu and poisson_ratio to match the existing scalar kernels.

Comment thread sumpy/kernel.py

.. math::

\Delta K(\mathbf{x}, \mathbf{y}) = \delta(\mathbf{x} - \mathbf{y}).
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think this is right, i.e. it's not $-\Delta K = \delta$, but pointing it out just to make sure. 😁

Comment thread sumpy/kernel.py
Comment on lines 840 to +847
viscosity_mu: float | str | SpatialConstant = "mu",
poisson_ratio: float | str | SpatialConstant = "nu") -> None:
if isinstance(viscosity_mu, str):
mu = SpatialConstant(viscosity_mu)
else:
warn("Passing a non-str 'viscosity_mu' is deprecated. This will "
"raise a ValueError starting with Q1 2027.",
DeprecationWarning, stacklevel=2)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ideally these would be just viscosity_mu_name to match Helmholtz and Yukawa?

Comment thread sumpy/kernel.py
@override
def get_args(self) -> Sequence[KernelArgument]:
# TODO: remove this once we stop allowing non-str values for viscosity_mu
if isinstance(self.viscosity_mu, SpatialConstant):
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In ElasticityKernel, this uses sumpy.tools.get_all_variables, but it didn't see worth going through a DependencyMapper, since we know it's just a SpatialConstant. Should I change it there too?

Copy link
Copy Markdown

Copilot AI left a comment

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 PDE kernel hierarchy by separating StokesletKernel from ElasticityKernel, making StokesletKernel a standalone ExpressionKernel. It also removes custom __new__ behavior and introduces deprecations around passing non-string material parameters to align with other scalar kernels.

Changes:

  • Refactor StokesletKernel to inherit directly from ExpressionKernel and implement its own expression/scaling/args/pickling behavior.
  • Remove __new__-based class substitution and introduce DeprecationWarnings for non-string viscosity_mu / poisson_ratio.
  • Update misc tests to focus on pickle round-trips for elasticity-related kernels.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
sumpy/kernel.py Separates StokesletKernel from ElasticityKernel, adds deprecation warnings, and expands kernel docstrings/references.
sumpy/test/test_misc.py Updates a kernel test to validate pickling behavior after the refactor.

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

Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py
Comment thread sumpy/kernel.py
@alexfikl alexfikl force-pushed the stokeslet-refactor branch from 571c798 to 147cb43 Compare May 9, 2026 08:59
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.

2 participants