<div class="gmail_quote">On Wed, May 11, 2011 at 08:16, Tian(ICT) <span dir="ltr">&lt;<a href="mailto:rongtian@ncic.ac.cn">rongtian@ncic.ac.cn</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":1rw">-snes_mf_operator does not work:<br>
<br>
&quot;-pc_type<br>
lu -ksp_monitor_true_residual -snes_monitor -ksp_monitor -snes_ms_operator&quot;</div></blockquote></div><br><div>I assume you spelled that -snes_mf_operator (not -snes_ms_operator). Anyway, I think the problem is that the MFFD operator is not &quot;assembled&quot;. At the bottom of your FormJacobian(), you should have something like:</div>
<div><br></div><div><div>  ierr = MatAssemblyBegin(*B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div>  ierr = MatAssemblyEnd(*B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div>  if (*A != *B) {</div><div>    ierr = MatAssemblyBegin(*A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div>
<div>    ierr = MatAssemblyEnd(*A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div>  }</div></div><div><br></div><div>The second line resets the base vector when the Krylov operator A is different from the preconditioning matrix B. When you run with -snes_mf_operator, SNES internally changes A to be an MFFD matrix, and your original matrix is used for B, therefore that is the matrix you should call MatSetValues() on.</div>