Thanks for your help.<br><br>Here is my procedure:<br><br>1- Define context ( as in previous email )<br><br>2- Related the addresses ( as in previous email )<br><br>4- create the context<br>    FieldCtx FC;<br><br>3- call residual routine:<br>
    ierr = SNESSetFunction( snes, r, _petsc_residualVector, (void*)&amp;FC ); CHKERRQ( ierr );<br><br>4- define residual routine: ( x is solution and r is residual vector )<br>PetscErrorCode solver::_petsc_residualVector( SNES snes, Vec x, Vec r, void* ctx )<br>
{<br>    ierr = VecGetArray( x, &amp;xx ); CHKERRQ( ierr );
<br> <br>    for( c=0; c&lt;ne; c++ ) for( p=0; p&lt;tot; p++ )
<br>    FC-&gt;e[c].Q[p] = xx[c*(noe*num)+p];<br><br>    ierr = VecRestoreArray( x, &amp;xx ); CHKERRQ( ierr );<br><br>    interiorFlux( FC-&gt;flw, FC-&gt;e );
<br>    faceFlux    ( FC-&gt;flw, FC-&gt;f, FC-&gt;e );<br><br>    ierr = VecGetArray( r, &amp;rr ); CHKERRQ( ierr );<br><br>    for( c=0; c&lt;ne; c++ ) 
<br>    {
<br>        for( p=0; p&lt;tot; p++ ) rr[c*tot+p] = FC-&gt;e[c].R[p];
<br>    }<br><br>    ierr = VecRestoreArray( r, &amp;rr ); CHKERRQ( ierr );<br>}<br><br>5- same procedure for Jacobian<br><br>6- set opitions<br><br>7- solve with SNESSolve()<br><br>Is it look right with SNES ???<br><br>
Thanks again for your attention.<br><br><br><br><br>