[petsc-users] PCSetup() changes between 3.0 and 3.1

Barry Smith bsmith at mcs.anl.gov
Wed Jan 19 07:22:02 CST 2011


On Jan 18, 2011, at 10:38 PM, Gaetan Kenway wrote:

> Hello 
> 
> I've run across a somewhat curious problem. I have included a snipped of
> code below, that is from a Newton-Krylov flow solver.  The code is from
> the "FormJacobian" function for a snes.  The code works fine with PETSc
> 3.1 but when I tried it with Petsc 3.0, I get a PETSc Error code 73:
> 
> "object in argument is in wrong state, e.g. unassembled mat "
> 
> on the PCSetup(pc,ierr) call. The subroutine setupNK_KSP_PC(dRdwPre)
> assembled the preconditioner matrix (dRdwPre) and performs the
> MatAssemblyBegin/End functions. I do realize, it is possible to just use
> PETSc 3.1, but I would like to know if its just a fluke that it works,
> or I've done something incorrect.

  You haven't done anything incorrectly. The order that options can be set for all the hierarchy of solvers in PETSc is tricky and may change over time. We strive to make it more flexible as time goes by, but sometimes you can only set things once the code has gotten into a certain state, like it knows the matrices are ready. Please just stick to 3.1 

   Barry


> I also realize, it is not typical to
> set options like this directly in code, but is is necessary for our
> code. I apologize I don't have a minimum representative example, but
> this section of code is quite buried and an example would have to be
> coded from scratch.
> 
> Any suggestions are greatly appreciated
> 
> Gaetan Kenway
> 
> 
> 
> *********** BEGIN CODE ****************
> 
>  ! Dummy assembly begin/end calls for the matrix-free Matrx
>  call MatAssemblyBegin(dRdw,MAT_FINAL_ASSEMBLY,ierr)
>  call EChk(ierr,__FILE__,__LINE__)
>  call MatAssemblyEnd(dRdw,MAT_FINAL_ASSEMBLY,ierr)
>  call EChk(ierr,__FILE__,__LINE__)
> 
>  ! Assemble the approximate PC
>  call setupNK_KSP_PC(dRdwPre)
> 
>  ! Setup the required options for the KSP solver
>  call SNESGetKSP(snes,ksp,ierr); 
>  call KSPSetType(ksp,ksp_solver_type,ierr);
>  call KSPGMRESSetRestart(ksp, ksp_subspace,ierr); 
>  call KSPSetPreconditionerSide(ksp,PC_RIGHT,ierr);
> 
>  ! Setup the required options for the Global PC
>  call KSPGetPC(ksp,pc,ierr);    
>  call PCSetType(pc,global_pc_type,ierr);
> 
>  if (trim(global_pc_type) == 'asm') then
>     call PCASMSetOverlap(pc,asm_overlap,ierr);
>     call PCSetup(pc,ierr);              
>     call PCASMGetSubKSP( pc, nlocal,  first, subksp, ierr );          
>  end if
> 
> ************** END CODE ****************
> 



More information about the petsc-users mailing list