[petsc-users] Problems about Matrix-Free and DM object
Yingjie Wu
yjwu16 at gmail.com
Thu Oct 11 10:37:41 CDT 2018
Dear Petsc developer:
Hi,
Thank you very much for your previous reply. I feel that I have learned a
lot about the matrix-free method.
I was studying the example /src/snes/example/tutorials/ex28.c recently. One
of its tests is as follows:
-u_da_grid_x 20 -snes_converged_reason -snes_monitor_short
-ksp_monitor_short -problem_type 2 -snes_mf_operator -pack_dm_mat_type
{{aij nest}} -pc_type fieldsplit -pc_fieldsplit_dm_splits
-pc_fieldsplit_type additive -fieldsplit_u_ksp_type gmres
-fieldsplit_k_pc_type jacobi
The example is calculated by the Matrix-free method, and the precondition
matrix is divided by FieldSplit. There are several questions in the
procedure that make me feel uncertain.
1. The program uses the Matrixfree method by the command
"-snes_mf_operator", but the form of Jacobian matrix is not defined as
MATMFFD in the program. Does the program automatically set the Jacobian
matrix to the form of MATMFFD after opening the command?
Both Jacobian matrix and precondition matrix are defined as B in the
program, and matrix elements are provided by Jacobian evaluation program.
But the Jacobian matrix in the Matrixfree method is in the form of MATMFFD.
You mentioned earlier that adding elements to the matrix with type MATMFFD
can cause program errors, but why does the program work in this example?
The procedures are as follows:
ierr = SNESSetFunction(snes,F,FormFunction_All,user);CHKERRQ(ierr);
ierr = SNESSetJacobian(snes,B,B,FormJacobian_All,user);CHKERRQ(ierr);
2.Can we use DMCompositeScatter to scatter ghost value into local vectors?
I didn't seem to mention the documentation. The program only uses the
following functions, but can use ghost value.
ierr = DMCompositeScatter(user->pack,X,Uloc,Kloc);CHKERRQ(ierr);
ierr = DMDAVecGetArray(dau,Uloc,&u);CHKERRQ(ierr);
ierr = DMDAVecGetArray(dak,Kloc,&k);CHKERRQ(ierr);
Greatly appreciated your reply and attention.
Thanks,
Yingjie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181011/12704c61/attachment-0001.html>
More information about the petsc-users
mailing list