<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Oct 11, 2018 at 11:38 AM Yingjie Wu <<a href="mailto:yjwu16@gmail.com">yjwu16@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Dear Petsc developer: </div><div dir="ltr">Hi,</div><div dir="ltr">Thank you very much for your previous reply. I feel that I have learned a lot about the matrix-free method. </div><div dir="ltr">I was studying the example /src/snes/example/tutorials/ex28.c recently. One of its tests is as follows: <br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div dir="ltr"><div dir="ltr"><div>-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</div></div></div></blockquote>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.</div><div dir="ltr">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? </div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>If you give that option, PETSc will automatically create a MFFD Mat object and stick your nonlinear residual evaluation in it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">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:<br></div></div></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><div><div><div><div>ierr = SNESSetFunction(snes,F,FormFunction_All,user);CHKERRQ(ierr);</div></div></div></div></div></div><div><div><div><div><div><div>ierr = SNESSetJacobian(snes,B,B,FormJacobian_All,user);CHKERRQ(ierr);</div></div></div></div></div></div></blockquote></div></div></div></div></div></div></div></blockquote><div><br></div><div>Because the FoirmJacobian() function in ex28 only ever puts values into the preconditioning matrix. This is generally the right way to proceed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>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. </div><div><div> ierr = DMCompositeScatter(user->pack,X,Uloc,Kloc);CHKERRQ(ierr);</div><div> ierr = DMDAVecGetArray(dau,Uloc,&u);CHKERRQ(ierr);</div><div> ierr = DMDAVecGetArray(dak,Kloc,&k);CHKERRQ(ierr);</div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>DMCompositeScatter splits a vector up into the smaller vectors for each system. DMComposite is very specialized, and we do not</div><div>recommend using it except in special cases.</div><div><br></div><div>DMGlobalToLocal() and DMLocalToGlobal() communicate ghost values.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Greatly appreciated your reply and attention.</div><div>Thanks,</div><div>Yingjie <br></div><div><br></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>