Fix solver options for Real space#5144
Conversation
The matrix type of a Real function space is now 'python' instead of 'nest' and this was failing to hit a case when we built our default solver options.
|
It would simplify things to use |
We always intercept If we change the interface we are just going to make things very ambiguous, how does Where are we letting |
| # Might reasonably expect to get petsc defaults | ||
| skip.update({"pc_factor_mat_solver_type", "ksp_type"}) | ||
| if parameters.get("mat_type") in {"matfree", "nest"}: | ||
| if parameters.get("mat_type") in {"matfree", "nest", "python"}: |
There was a problem hiding this comment.
Whoever populated this dictionary with {"mat_type": A.type} within the adjoint should have set {"mat_type": "matfree" if A.type == "python" else A.type}.
Or more correclty, the matrix type should come from _SNESContext.mat_type
There was a problem hiding this comment.
I think the logic here could be responsible, but not 100% sure
Lines 22 to 27 in 2018173
There was a problem hiding this comment.
Yeah that's what I found. I think we should:
- Intercept
mat_type=python - Extract the Python context from the mat
- Use that to return
matfree,denserowetc
|
Maybe the logic failure here is that by having |
| if parameters.get("mat_type") in {"matfree", "nest", "python"}: | ||
| # Non-LU defaults. | ||
| ksp_defaults["ksp_type"] = "gmres" | ||
| ksp_defaults["pc_type"] = "jacobi" |
There was a problem hiding this comment.
This might be unrelated, but MUMPS supports MatNest when all blocks are aij. We shouldn't default to jacobi in that case.
There was a problem hiding this comment.
Yeah that's definitely unrelated to this. But we should open an issue for it at least.
The matrix type of a Real function space is now 'python' instead of 'nest' and this was failing to hit a case when we built our default solver options.
Fixes #5140
Note that we now appear to have two different mat types for matrix-free things:
"matfree"and"python". Do we want to try and deprecate one? @leo-collins WDYT?