I forgot one thing in my earlier email: What about making 
MAT_NEW_NONZERO_LOCATION_ERR the default for DM matrices?


    Barry

On May 1, 2011, at 6:45 AM, Jed Brown wrote:

> On Sun, May 1, 2011 at 05:07, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
>   Jed,
> 
>      You pose several issues here.
> 
> 1) By default SBAIJ matrices generate an error if you set a value in the 
> lower triangular portion.
> 
>      I think this is the wrong default. I've changed it to ignore lower 
> triangular values unless you explicitly set the option.
> 
> Excellent
>  
> 
> 2) MatSetType(A,MATSBAIJ); and friends deletes the matrix and creates a new 
> one if the matrix is MATSEQSBAIJ or MATMPISBAIJ.
> 
>      This is silly. Given our model of setting types however there is no 
> trivial way to fix this. We could try to handle setting a heirarchy of types 
> properly (how to know if something is a subclass? etc?) or do something just 
> for Mat to handle the
>      rank = 1 and rank > 1 cases. I'm inclined to add a special Mat register 
> for example MatRegisterBaseName("SBAIJ","SeqSBAIJ","MPISBAIJ"); and have 
> MatSetType() first check if the type is in the BaseName list and if so grab 
> the correct
>      classname based on rank, then it will realize the matrix is not having a 
> type change and will not destroy it. Note that this means routines like 
> MatCreateSBAIJ() will disappear.
> 
> I think you mean MatCreate_SBAIJ(). I also think this is better because there 
> is a bit of duplicate code and you can never actually have an instance of 
> MATSBAIJ.
> 
> The lookup in the other direction would take more effort, but there is a lot 
> of PetscTypeCompare that ends up needing to always check for both the SEQ and 
> MPI variants. But I think managing a full type hierarchy is a very deep 
> rabbit hole so I'm not convinced it's worth it.
> 
> 
> 3) The general wordyness of setting up the matrix fill from the DM.
> 
>     My planned model for the future was to change DMGetMatrix() to 
> DMFillMatrix() and have code something like
> 
>     MatCreate(comm,&Ap);
>     MatSetOptionsPrefix(Ap,"Ap_");
>     MatSetFromOptions(Ap);
>     MatSetOption(Ap,MAT_SYMMETRIC,PETSC_TRUE);
>     DMFillMatrix(fsu,Ap);
> 
>     If is actually not any shorter but I think it is a better model.
> 
> This is much less wordy because all the code is in one place (no separate 
> part for PetscOptionsList) and there are no if statements. It would also be 
> possible to write a helper like
> 
> DMCreateMatWithOptions(fsu,"Ap_",MATSBAIJ,MAT_SPD,MAT_NEW_NONZERO_LOCATION_ERR,...,0,&Ap);
> 
> (or without variadic handling of options).
> 


Reply via email to