Setting options on matrices obtained from a DM

Barry Smith bsmith at mcs.anl.gov
Tue Jul 21 18:20:39 CDT 2009


     My eventual goal is to remove all "hidden" MatCreate()'s and  
instead have Mat's passed in
as arguments. So MatLoad() would take a Mat as an argument, as would  
DAGetMatrix()
One could then set as much or a as little as a Mat as they like before  
passing it in.
They could set the type, they could set the sizes, they could set the  
prefix.

    I think this is the direction you want? Will it satisfy all your  
needs?

    MatCreate().
    MatSetOptionsPrefix()
    MatSetFromOptions()
    DAGetMatrix()


    Barry

On Jul 21, 2009, at 5:54 PM, Jed Brown wrote:

> If I get a matrix from a DM, I usually do something like
>
>  PetscOptionsGetString(NULL,"-q1_mat_type",mtype,sizeof(mtype),NULL);
>  DMGetMatrix(dm,mtype,&Jp);
>
> so that the type can be changed on the command line (I frequently  
> switch
> between preconditioners that can use BAIJ and those that cannot).   
> But,
> MatSetFromOptions never gets called.  If I add
>
>  MatSetOptionsPrefix(Jp,"q1_");
>  MatSetFromOptions(Jp);
>
> after the above, then preallocation will be blown if I change anything
> on the command line.  This includes setting block size for AIJ formats
> (I think BAIJ should implement MatSetBlockSize and just confirm that  
> it
> matches, but that's a separate issue) so MatSetValuesBlocked cannot
> even assemble the correct matrix.
>
> To rectify this, I think that DMGetMatrix either must have enough
> information to call MatSetFromOptions (like the prefix) or  
> preallocation
> should be separated from setting the sizes (so the user can get the
> matrix, call MatSetFromOptions, and then ask the DM to preallocate).
> In the former case, we have functionality that is essentially
> inaccessible from code (PetscOptionsSetValue is a workaround).  The
> latter significantly complicates matters.
>
> Note that since the user may get multiple matrices from a DM, to be  
> used
> for different purposes, it's not okay to use the DM's prefix as the
> Mat's prefix.
>
> Any preferences here?  I'm happy with any solution in which the user
> doesn't have to do an inordinate amount of work to make the following
> work.
>
>  -q1_mat_type baij
>  -q1_mat_type aij -mat_no_inode
>  -q1_mat_type crl
>
>
> Jed
>




More information about the petsc-dev mailing list