Direct LU solver

Satish Balay balay at mcs.anl.gov
Thu Feb 28 16:58:16 CST 2008


On Thu, 28 Feb 2008, Amit.Itagi at seagate.com wrote:

> Matt and Hong,
> 
> I will try to customize the example. However, since my application involves
> multiple ksp solvers (using different algorithms), I would really like to
> set the options with in the code, instead of on the command line. Is there
> a way of doing this ?

-ksp_type preonly -pc_type lu -mat_type superlu_dist

There are 2 ways of doing this.

One is within the code:

    MatCreate(&mat);
    MatSetType(mat,MATSUPERLU_DIST);
    MatSetFromOptions(mat);

    KSPSetType(ksp,KSPPREONLY);
    KSPGetPC(ksp,&pc);
    PCSetType(pc,PCLU);
    KSPSetFromOptions(ksp);

etc..

Another way is to give each object a prefix [if you have multiple
objects of the same type. You can use this prefix with the command
line options.

For eg:

    KSPCreate(&ksp1)
    KSPCreate(&ksp2)

    KSPSetOptionsPrefix(ksp1,"a_")
    KSPSetOptionsPrefix(ksp2,"b_")

Now you can use -a_ksp_type gmres -b_ksp_type cg

etc..

Satish




More information about the petsc-users mailing list