Stokes/Elasticity using biharmonic/Laplace#162
Conversation
95a898d to
acc5ae0
Compare
pytential/symbolic/elasticity.py
Outdated
| @@ -0,0 +1,166 @@ | |||
| __copyright__ = "Copyright (C) 2021 Isuru Fernando" | |||
There was a problem hiding this comment.
I think it'd be good to have CalculusPatch tests to ensure that PDE rediual for Stokes and elasticity is zero.
There was a problem hiding this comment.
That's technically not testing the Stokes potential, it's testing pytential-computed derivatives thereof.
alexfikl
left a comment
There was a problem hiding this comment.
Added a bunch of nitpicks to pytential.symbolic.stokes (mostly based on how I've been using the new stuff). Many are ignorable, so feel free!
The main thing that bothered me while going through it was the nu_sym everywhere. It feels like that should be handled in elasticity so the user never gets a chance to pass nu_sym=3 from the Stokes wrappers.
fec9eab to
ee09dbd
Compare
alexfikl
left a comment
There was a problem hiding this comment.
Left a bunch more nitpicks in pde.system_utils this time around :D
This is looking very cool!
pytential/symbolic/elasticity.py
Outdated
| @@ -0,0 +1,166 @@ | |||
| __copyright__ = "Copyright (C) 2021 Isuru Fernando" | |||
There was a problem hiding this comment.
That's technically not testing the Stokes potential, it's testing pytential-computed derivatives thereof.
pytential/symbolic/elasticity.py
Outdated
| @@ -0,0 +1,166 @@ | |||
| __copyright__ = "Copyright (C) 2021 Isuru Fernando" | |||
There was a problem hiding this comment.
Pull the docs of this into like an "internals" chapter? internals.rst?
0f130b0 to
0dca616
Compare
f7b661d to
d34f787
Compare
|
This is ready for another round of reviews |
There was a problem hiding this comment.
Left a bunch of nitpicks while reading this again. I don't think any of them are stoppers of any sort, so go for it when you and @inducer are done! 🚀
Also, thanks for all this Stokes performance work! It's been immensely helpful in the past two-ish years!
748329d to
ae1333c
Compare
681b73d to
c4173e1
Compare
|
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
|
@inducer, ready for a review |
0c06602 to
d31b59a
Compare
d31b59a to
11d48fa
Compare
62c20a8 to
6046a29
Compare
e0f8b7d to
19415b4
Compare
19415b4 to
d1db7f6
Compare
d1db7f6 to
88cb6ca
Compare
c80cb49 to
0ff1e89
Compare
|
@inducer Went ahead and squashed this into a single commit to make it easier to rebase/merge from There seem to be some new and exciting test failures in there too (possibly because of a bad rebase). I'll look into those next week or so. |
2145138 to
503e373
Compare
a9f21ed to
3443fa6
Compare
There was a problem hiding this comment.
Pull request overview
This PR expands pytential’s symbolic Stokes/elasticity support by introducing alternative kernel representations (naive/Laplace/biharmonic) and adding infrastructure to rewrite IntG expressions in terms of a chosen base kernel, along with tests and docs updates.
Changes:
- Add new symbolic elasticity wrappers and refactor symbolic Stokes wrappers/operators to support multiple representation methods.
- Introduce
pytential.symbolic.pde.system_utilsto rewrite layer-potential expressions (including target-to-source transformation handling) and add unit tests for these transformations. - Add/adjust tests for new utilities (LU solve helper) and update convergence/robustness checks.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
pytential/symbolic/elasticity.py |
New elasticity wrapper framework (naive/Laplace/biharmonic) shared with Stokes. |
pytential/symbolic/stokes.py |
Major refactor of Stokes wrappers/operators to use the new wrapper framework and support method dispatch. |
pytential/symbolic/pde/system_utils.py |
New machinery for rewriting IntG expressions using a chosen base kernel and derivative relations. |
pytential/utils.py |
Adds symbolic utilities (chop, forward/back substitution, LU solve helper). |
pytential/symbolic/mappers.py |
Extends flattening behavior to rewrite IntG densities/kernel args when flattening. |
pytential/symbolic/primitives.py |
Adjusts Kernel imports/usage to avoid import-time issues and keep ambient_dim inference working. |
pytential/qbx/__init__.py |
Relaxes density type check to allow scalar densities (but current implementation has a runtime issue). |
test/test_tools.py |
Adds a unit test for solve_from_lu. |
test/test_stokes.py |
Expands Stokes tests to cover multiple methods/nu values and adds PDE-based verification tests. |
test/test_pde_system_utils.py |
New tests for target->source transformation and base-kernel rewriting utilities. |
test/test_linalg_skeletonization.py |
Makes a zero-comparison more robust via tolerance. |
doc/symbolic.rst |
Documents new elasticity module and system-utils rewriting utilities. |
doc/conf.py |
Adds Sphinx intersphinx mapping for ExpressionKernel. |
pyproject.toml |
Adds mis to typos dictionary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| L, U, perm = sym_mat.LUdecomposition() | ||
| except RewriteFailedError: | ||
| # symengine throws an error when rank deficient | ||
| # and sympy returns U with last row zero | ||
| failed = True | ||
|
|
||
| if not sp.USE_SYMENGINE and all(expr == 0 for expr in U[-1, :]): |
There was a problem hiding this comment.
The LUdecomposition() call is wrapped in except RewriteFailedError, but LUdecomposition will not raise RewriteFailedError here (and rank-deficient errors from symengine/sympy are different exception types). As written, rank-deficiency will escape the retry logic and crash. Catch the actual exceptions raised by LUdecomposition (or a broader exception type) and mark failed=True so the retry path is exercised.
| try: | |
| L, U, perm = sym_mat.LUdecomposition() | |
| except RewriteFailedError: | |
| # symengine throws an error when rank deficient | |
| # and sympy returns U with last row zero | |
| failed = True | |
| if not sp.USE_SYMENGINE and all(expr == 0 for expr in U[-1, :]): | |
| L = U = perm = None | |
| try: | |
| L, U, perm = sym_mat.LUdecomposition() | |
| except Exception: | |
| # symengine throws an error when rank deficient | |
| # and sympy returns U with last row zero | |
| failed = True | |
| if (not failed | |
| and not sp.USE_SYMENGINE | |
| and all(expr == 0 for expr in U[-1, :])): |
There was a problem hiding this comment.
This seems fair. The logic in _get_base_kernel_matrix_lu_factorization seems incomplete, but I'm not quite sure what to do there..
26b4b12 to
51787b9
Compare
Co-authored-by: Alex Fikl <alexfikl@gmail.com>
51787b9 to
e4bc444
Compare
|
Spent a bit more time debugging those errors, mainly in
EDIT:
|
f1d7343 to
193c1c7
Compare
Uh oh!
There was an error while loading. Please reload this page.