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

Jed Brown jedbrown at mcs.anl.gov
Sun May 6 12:42:19 CDT 2012


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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120506/69dfe419/attachment.html>


More information about the petsc-dev mailing list