[petsc-dev] PC defaults when matrix is not available at PCSetFromOptions

Barry Smith bsmith at mcs.anl.gov
Sun May 6 12:47:43 CDT 2012


  I see. So if the Mat is not known when PCSetFromOptions() is called then PCSetFromOptions() generates a bad guess for the PC to use.

   Presumably this has always been true. 

   Presumably the PCSetFromOptions() has access to the DM? Can it inquire of the DM what PC to default to if the Mat is not available?


   Screw it, take out DM and we'll go back to the old model :-(

   Barry


On May 6, 2012, at 12:42 PM, Jed Brown wrote:

> On Sun, May 6, 2012 at 11:38 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> PetscErrorCode  PCSetUp(PC pc)
> {
>  PetscErrorCode ierr;
>  const char     *def;
> 
>  PetscFunctionBegin;
>  PetscValidHeaderSpecific(pc,PC_CLASSID,1);
>  if (!pc->mat) SETERRQ(((PetscObject)pc)->comm,PETSC_ERR_ARG_WRONGSTATE,"Matrix must be set first");
> 
> How can it be in there without a Mat? The Mat must be set before PCSetUp().
> 
> PetscErrorCode  PCSetFromOptions(PC pc)
> {
>   PetscErrorCode ierr;
>   char           type[256];
>   const char     *def;
>   PetscBool      flg;
> 
>   PetscFunctionBegin;
>   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
> 
>   if (!PCRegisterAllCalled) {ierr = PCRegisterAll(PETSC_NULL);CHKERRQ(ierr);}
>   ierr = PetscObjectOptionsBegin((PetscObject)pc);CHKERRQ(ierr);
>   if (!((PetscObject)pc)->type_name) {
>     ierr = PCGetDefaultType_Private(pc,&def);CHKERRQ(ierr);
> 
> 
> 
> 
> PetscErrorCode PCGetDefaultType_Private(PC pc,const char* type[])
> {
>   PetscErrorCode ierr;
>   PetscMPIInt    size;
>   PetscBool      flg1,flg2,set,flg3;
> 
>   PetscFunctionBegin;
>   ierr = MPI_Comm_size(((PetscObject)pc)->comm,&size);CHKERRQ(ierr);
>   if (pc->pmat) {
>     PetscErrorCode (*f)(Mat,MatReuse,Mat*);
>     ierr = PetscObjectQueryFunction((PetscObject)pc->pmat,"MatGetDiagonalBlock_C",(void (**)(void))&f);CHKERRQ(ierr);
> 




More information about the petsc-dev mailing list