Add diagonal() to KroneckerStencilMatrix#537
Merged
Merged
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Merged
…atch to MultipatchDiscreteDeRham
yguclu
requested changes
Nov 24, 2025
Member
yguclu
left a comment
There was a problem hiding this comment.
Good job @jowezarek!
I have just a couple of comments
campospinto
pushed a commit
that referenced
this pull request
Dec 12, 2025
We add a `diagonal(self, inverse=False, sqrt=False, out=None)` method to the class `KroneckerStencilMatrix`. Additionally, we fix the `diagonal` method of `StencilDiagonalMatrix`, both making it run in general, and also allowing for the kwarg `sqrt` which had been missing until now. This method comes in handy for the computation of the yet to be implemented LST preconditioners. For the computation of these, we compute 1D mass matrices which are the building blocks of 2D or 3D logical mass matrices. Additionally, we compute the diagonal of said 2D or 3D logical mass matrix. Thus, instead of having to assemble the entire 2D or 3D mass matrix, we can build them as `KroneckerStencilMatrices`, which is much cheaper, and then obtain the diagonal. This feature reduces the runtime of a yet to be implemented LST preconditioner test from 2 minutes down to 20 seconds. A very fast test for this new method is included in this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We add a
diagonal(self, inverse=False, sqrt=False, out=None)method to the classKroneckerStencilMatrix.Additionally, we fix the
diagonalmethod ofStencilDiagonalMatrix, both making it run in general, and also allowing for the kwargsqrtwhich had been missing until now.This method comes in handy for the computation of the yet to be implemented LST preconditioners.
For the computation of these, we compute 1D mass matrices which are the building blocks of 2D or 3D logical mass matrices. Additionally, we compute the diagonal of said 2D or 3D logical mass matrix.
Thus, instead of having to assemble the entire 2D or 3D mass matrix, we can build them as
KroneckerStencilMatrices, which is much cheaper, and then obtain the diagonal.This feature reduces the runtime of a yet to be implemented LST preconditioner test from 2 minutes down to 20 seconds.
A very fast test for this new method is included in this PR.