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*)&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, &xx ); CHKERRQ( ierr );
<br> <br> for( c=0; c<ne; c++ ) for( p=0; p<tot; p++ )
<br> FC->e[c].Q[p] = xx[c*(noe*num)+p];<br><br> ierr = VecRestoreArray( x, &xx ); CHKERRQ( ierr );<br><br> interiorFlux( FC->flw, FC->e );
<br> faceFlux ( FC->flw, FC->f, FC->e );<br><br> ierr = VecGetArray( r, &rr ); CHKERRQ( ierr );<br><br> for( c=0; c<ne; c++ )
<br> {
<br> for( p=0; p<tot; p++ ) rr[c*tot+p] = FC->e[c].R[p];
<br> }<br><br> ierr = VecRestoreArray( r, &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>