Separate ElasticityKernel and Stokeslet#281
Conversation
|
|
||
| .. math:: | ||
|
|
||
| \Delta K(\mathbf{x}, \mathbf{y}) = \delta(\mathbf{x} - \mathbf{y}). |
There was a problem hiding this comment.
I think this is right, i.e. it's not
| 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) |
There was a problem hiding this comment.
Ideally these would be just viscosity_mu_name to match Helmholtz and Yukawa?
| @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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
StokesletKernelto inherit directly fromExpressionKerneland implement its own expression/scaling/args/pickling behavior. - Remove
__new__-based class substitution and introduceDeprecationWarnings for non-stringviscosity_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.
571c798 to
147cb43
Compare
This makes the
StokesletKernelanExpressionKernelinstead of inheriting fromElasticityKernel. Besides that, it also__new__implementations.viscosity_muandpoisson_ratioto match the existing scalar kernels.