Conversation
Importantly this both sets the wrapper as initialized and instructs the wrapper not to destroy the PETSc matrix on exit Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…package Co-Authored-By: Claude <noreply@anthropic.com>
|
Still waiting on that MOOSE master merge to get those solid mechanics test fixes! |
|
|
||
| explicit PetscMFFDMatrix(const Parallel::Communicator & comm_in); | ||
|
|
||
| PetscMFFDMatrix & operator=(Mat m); |
There was a problem hiding this comment.
Let's keep this around for backwards compatibility? Pretty specialized so you can deprecate it if you want, but it's been around for two years and was never marked libmesh_experimental().
There was a problem hiding this comment.
Should the backwards compatibility include its undesirable behavior like _destroy_on_exit = true? 😢
There was a problem hiding this comment.
Did you want to deprecate this like @roystgnr suggested? Also, any reason that it became inlined when it wasn't before?
There was a problem hiding this comment.
I'll remove the inlining which will decrease the PR diff. I don't think I'll deprecate at this point because I think the new operator= behavior (through assign) is what we want
| void | ||
| PetscMatrixShellMatrix<T>::zero() | ||
| { | ||
| libmesh_error(); |
There was a problem hiding this comment.
Could we libmesh_error_msg("Called a method that is unimplemented for arbitrary shell matrices") or something, here and elsewhere in the new overloads?
|
|
||
| /** | ||
| * An optional matrix to use as the actual Jacobian operator (Amat), distinct from \p matrix | ||
| * (used as the preconditioning matrix, Pmat). See set_operator_matrix(). |
There was a problem hiding this comment.
This seems like the opposite of what I would have expected. implicit_system.h refers to its matrix as the "system matrix" in solves of "Ax=b" at one point, and as the Jacobian matrix at another. Shouldn't that stay "A", and "P" be the new matrix?
There was a problem hiding this comment.
For a nonlinear solver, it is very common to unseat the A matrix and replace it with matrix-free approximations of the Jacobian action via finite differencing of residual evaluations, whereas it is much less common to unseat the preconditioning matrix because you generally need an explicit matrix representation in order to form a preconditioner. Put another way, if we were to assert that the libmesh system matrix is the A matrix, that assertion would fail for perhaps more than 50% of MOOSE simulations because of use of PJFNK and -snes_mf_operator whereas if you were to assert that the libmesh system matrix is the P matrix then I'm not aware of any places where that assertion would fail. But I'm sure you could point me to a libmesh example that would fail 😄
There was a problem hiding this comment.
I want to do something similar as PETSc matrix-free finite-differencing, but use MATSHELL instead of MATMFFD where the shell matrix is owned by libMesh/MOOSE, not created and held by PETSc as the latter is done. Our shell matrix will define operations like MatGetDiagonal and MatMult
There was a problem hiding this comment.
It might be good if some of this discussion/clarification made it into a comment in the code regarding the colloquial naming conventions surrounding "Jacobian", "system", "Pmat" and "Amat".
There was a problem hiding this comment.
Ok I've added discussion in 01c924a but I'm not 100% sure this is the right place nor whether it helps reduce confusion
Co-Authored-By: Claude <noreply@anthropic.com>
Refs failures on libMesh/libmesh#4537
roystgnr
left a comment
There was a problem hiding this comment.
I think you've convinced me on this, but it's a big enough design decision that I'd like to give @jwpeterson some time to look too
jwpeterson
left a comment
There was a problem hiding this comment.
If I understand correctly, this is about adding better MATSHELL support for the nonlinear solver, which sounds useful. I also like that you added several tests.
|
|
||
| explicit PetscMFFDMatrix(const Parallel::Communicator & comm_in); | ||
|
|
||
| PetscMFFDMatrix & operator=(Mat m); |
There was a problem hiding this comment.
Did you want to deprecate this like @roystgnr suggested? Also, any reason that it became inlined when it wasn't before?
|
|
||
| /** | ||
| * An optional matrix to use as the actual Jacobian operator (Amat), distinct from \p matrix | ||
| * (used as the preconditioning matrix, Pmat). See set_operator_matrix(). |
There was a problem hiding this comment.
It might be good if some of this discussion/clarification made it into a comment in the code regarding the colloquial naming conventions surrounding "Jacobian", "system", "Pmat" and "Amat".
Co-Authored-By: Claude <noreply@anthropic.com>
I want to use MATSHELL for the Jacobian and possibly MATAIJ for the preconditioning matrix so need to develop some additional support for that use case