[petsc-users] A number of questions about DMDA with SNES and Quasi-Newton methods
Smith, Barry F.
bsmith at mcs.anl.gov
Tue Oct 31 10:23:49 CDT 2017
> On Oct 30, 2017, at 9:32 PM, zakaryah . <zakaryah at gmail.com> wrote:
>
> You were right, of course. I fixed the problem with the function evaluation and the code seems to be working now, at least on small test problems.
>
> Is there a way to setup preallocation of the Jacobian matrix, with the entire first row and column non-zero?
No great way. What you need to do is copy the specific code that does the preallocation for your problem from src/dm/impls/da/fdda.c stick it in your code and modify it so that it does the full allocation as you need.
> I set the preallocation error flag to false, as you suggested several messages ago, and this was great for testing, but now the first assembly of the Jacobian is terribly slow due to allocating on the fly.
>
> Thanks!
>
> On Sun, Oct 29, 2017 at 7:07 PM, Matthew Knepley <knepley at gmail.com> wrote:
> On Sun, Oct 29, 2017 at 5:15 PM, zakaryah . <zakaryah at gmail.com> wrote:
> Good point, Jed - I feel silly for missing this.
>
> Can I use -snes_type test -snes_test_display with the Jacobian generated from a DMComposite? When I try, it looks like the finite difference Jacobian is missing all the elements in the row corresponding to the redundant variable, except the diagonal, which is wrong.
>
> Well, this leads me to believe the residual function is wrong. What the FD Jacobian does is just call the residual
> twice with different solutions. Thus if the residual is different when you perturb the redundant variable, you should
> have Jacobian entries there.
>
> I'm not sure my code for setting the submatrices is correct. I'm especially uncertain about the submatrix J_bh, where b is the redundant variable and h is the displacements. This submatrix has only one row, and all of its columns are non-zero. Can its values be set with MatSetValuesLocal, on all processors?
>
> Is there an example of manually coding a Jacobian with a DMRedundant?
>
> I don't think so. We welcome contributions.
>
> Matt
>
> --
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
>
More information about the petsc-users
mailing list