On Sun, Jun 24, 2012 at 12:40 PM, behzad baghapour <span dir="ltr"><<a href="mailto:behzad.baghapour@gmail.com" target="_blank">behzad.baghapour@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear developers,<br><br>I want to define matrix operation used in SNES as Matrix-Free kernel. Here is what I did:<br><br> MatCreateSNESMF( snes, &JMat ); <br> MatCreateShell( PETSC_COMM_SELF, nt, nt, nt, nt, (void*)&FC, &JMat );
<br> MatShellSetOperation( JMat, MATOP_MULT, (void(*)())&_petsc_matMultFree );
<br><br>Where FC is my context which saves the flow field data. In the matrix-Free kernel:<br><br>void solver::_petsc_matMultFree( Mat J, Vec x, Vec y )<br>{<br> MatShellGetContext( J, &FC );<br>// perturb the residual ( R -> R(x+eps) )<br>
// do matrix-vector kernel as: y := Mx = Mass/dt + ( R2 - R1 ) / eps<br>}<br></blockquote><div><br></div><div>This does not have the right signature (no return type).</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">
But I received the error at first subspace creation in KSP:<br><br>[0]PETSC ERROR: MatMult() line 2177 in src/mat/interface/matrix.c<br>[0]PETSC ERROR: PCApplyBAorAB() line 610 in src/ksp/pc/interface/precon.c<br>
[0]PETSC ERROR: GMREScycle() line 156 in src/ksp/ksp/impls/gmres/gmres.c<br>[0]PETSC ERROR: KSPSolve_GMRES() line 231 in src/ksp/ksp/impls/gmres/gmres.c<br>[0]PETSC ERROR: KSPSolve() line 423 in src/ksp/ksp/interface/itfunc.c<br>
[0]PETSC ERROR: SNES_KSPSolve() line 3396 in src/snes/interface/snes.c<br>[0]PETSC ERROR: SNESSolve_LS() line 190 in src/snes/impls/ls/ls.c<br>[0]PETSC ERROR: SNESSolve() line 2676 in src/snes/interface/snes.c<br>[0]PETSC ERROR: _petsc_NewtonTimeAdvance() line 151 in Newton.cpp<br>
<br>Would you please help me find my mistake ?<br><br>Thanks a lot,<br>BehZad<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>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<br>