[petsc-users] Implementing a new routine in PETSc.

Barry Smith bsmith at mcs.anl.gov
Fri Apr 1 18:18:07 CDT 2011


   You must install petsc-dev http://www.mcs.anl.gov/petsc/petsc-as/developers/index.html to develop this new code.

   The CG implementation has detailed information about what needs to be provided for a new Krylov method. Start by making a new directory src/ksp/ksp/impls/lsmr and copy over to it the files 
    src/ksp/ksp/impls/cg/ makefile cg.c cgimpl.h call them lsmr.c and lsmrimpl.h modify the copied over makefile to list the lsmr stuff instead of the cg

   In lsmrimpl.h put in the data structure you'll need to store all the vectors and other information needed by lsmr in lsmr.c go through the current code and change it all for the lsmr algorithm. You do not need to recompile all of PETSc to access the new solver, just run make in that new directory.

    You will also need to edit src/ksp/ksp/interface/itregis.c to register your new method.


   Join petsc-dev http://www.mcs.anl.gov/petsc/petsc-as/miscellaneous/mailing-lists.html to correspond with the petsc developers if questions/issues come up.

   Have fun,


   Barry

On Apr 1, 2011, at 6:02 PM, Gaurish Telang wrote:

> Hi,
> 
> I am planning to implement the LSMR algorithm in PETSc which does least squares and is supposed to have more favourable mathematical properties than LSQR which has already been implemented in PETSc.  
> 
> But I am not really sure how to go about this,  since the implementations of the standard KSP methods themselves look quite complicated. The manual does not seeem to say much 
> about how to go about  adding routines to the PETSc library.
> 
> Could you give me guidelines I should follow while implementing a KSP method? 
> 
> Also is it necessary to build the PETSc library again after implementing this routine. If so is it necessary to make any changes to makefiles ?
> 
> Regards



More information about the petsc-users mailing list