[petsc-dev] The question about the PETSc example
Peter Brune
prbrune at gmail.com
Mon Sep 30 12:48:36 CDT 2013
This appears to be broken because whoever made this example was
demonstrating a very specific capability and didn't provide the sparsity
pattern. It's created as values are inserted. This is therefore unlikely
to work without some serious changes to the example, or calling the
Jacobian creation routine beforehand, as:
index 0a48162..466507e 100644
--- a/src/snes/examples/tutorials/ex28.c
+++ b/src/snes/examples/tutorials/ex28.c
@@ -415,6 +415,7 @@ int main(int argc, char *argv[])
ierr = DMCompositeRestoreAccess(pack,F,0,&Fk);CHKERRQ(ierr);
break;
case 2:
+ MatStructure flag;
ierr = DMCreateMatrix(pack,NULL,&B);CHKERRQ(ierr);
/* This example does not correctly allocate off-diagonal blocks. These
options allows new nonzeros (slow). */
ierr =
MatSetOption(B,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr);
@@ -434,6 +435,7 @@ int main(int argc, char *argv[])
* of splits, but it requires using a DM (perhaps your own
implementation). */
ierr = SNESSetDM(snes,pack);CHKERRQ(ierr);
}
+ ierr = FormJacobian_All(snes,X,&B,&B,&flag,user);CHKERRQ(ierr);
ierr = SNESSolve(snes,NULL,X);CHKERRQ(ierr);
break;
}
which will fill in the sparsity pattern.
- Peter
On Mon, Sep 30, 2013 at 8:38 AM, Peter Brune <prbrune at gmail.com> wrote:
> This is not the full FD Jacobian, but the one constructed by coloring.
> It's a hunch, but I'd bet DMComposite doesn't have a proper coloring in
> place. This should error out. I'll check out why not.
>
> You don't have to alter the source to do this. You can use
> -snes_fd_coloring or -snes_fd.
>
> - Peter
>
> - Peter
> On Sep 29, 2013 3:07 PM, "Lulu Liu" <lulu.liu at kaust.edu.sa> wrote:
>
>> Run the example /petsc/src/snes/examples/tutorials/ex28.c using the
>> following options(found in the makefile)
>>
>> ./ex28 -da_grid_x 20 -snes_converged_reason -snes_monitor_short
>> -problem_type 2
>>
>> It works using default analytic Jacobian to solve coupled system,
>> however, I comment
>>
>> Line 434 : ierr =
>> SNESSetJacobian(snes,B,B,FormJacobian_All,user);CHKERRQ(ierr);
>>
>> and run the code again using the same options (i.e., FD Jacobian instead
>> of analytic Jacobian), we will get the results:
>>
>> Nonlinear solve did not converge due to DIVERGED_MAX_IT iterations 50
>>
>> Could you explain why it does not work using FD Jacobian in this example?
>>
>> Thanks
>>
>>
>>
>> ------------------------------
>> This message and its contents, including attachments are intended solely
>> for the original recipient. If you are not the intended recipient or have
>> received this message in error, please notify me immediately and delete
>> this message from your computer system. Any unauthorized use or
>> distribution is prohibited. Please consider the environment before printing
>> this email.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130930/2c3a8aea/attachment.html>
More information about the petsc-dev
mailing list