trixi-framework / TrixiParticles.jl

TrixiParticles.jl: Particle-based multiphysics simulations in Julia
https://trixi-framework.github.io/TrixiParticles.jl/
MIT License
33 stars 10 forks source link

Remove `pinv` in correction matrix inversion step #526

Closed efaulhaber closed 6 months ago

efaulhaber commented 6 months ago

The SMatrix implementation of pinv is just falling back to the regular matrix definition, which is then causing allocations and is 400x slower than inv for an SMatrix. We found that the matrix is singular if and only if a particle and all neighbors are collinear (in 2D) or lie on the same plane (in 3D). This only happens when either two (in 2D) or three (in 3D) particles are isolated, or on the edges of a very deformed domain. So only in edge cases where the fluid itself has a singularity. In these cases, we now just disable the correction and use the uncorrected gradient instead. Also see the proof in the comments.

This PR fixes the failing tests in #434.

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 69.42%. Comparing base (228b86d) to head (f90e263).

Files Patch % Lines
src/general/corrections.jl 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #526 +/- ## ========================================== + Coverage 69.26% 69.42% +0.15% ========================================== Files 69 69 Lines 3979 3967 -12 ========================================== - Hits 2756 2754 -2 + Misses 1223 1213 -10 ``` | [Flag](https://app.codecov.io/gh/trixi-framework/TrixiParticles.jl/pull/526/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/trixi-framework/TrixiParticles.jl/pull/526/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework) | `69.42% <80.00%> (+0.15%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=trixi-framework#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.