[petsc-users] Nonconforming object sizes with KSPSolve

Barry Smith bsmith at mcs.anl.gov
Fri Mar 8 19:17:09 CST 2013


  Mengda,

     Thanks for reporting this. You have found a bug triggered by the -ksp_final_residual  option, sorry about that. We are sloppy in the code and duplicate the solution vector to get a work vector for the computation but should have duplicated the right hand side vector.

      I have fixed the master copy of 3.3 and it will be in the next patch. For now just don't use the -ksp_final_residual  you get that information from -ksp_monitor anyways.

   Barry

On Mar 8, 2013, at 6:01 PM, Mengda Wu <wumengda at gmail.com> wrote:

> Hi all,
> 
>    I am trying to use KSPLSQR to solve an overdetermined system. I am NOT using MPI. I got an error "Nonconforming object sizes!" in KSPSolve. It is very weird because this happens after the iterations are converged. Please see the following messages. 
> 
> ==================================================================
> 159 KSP Residual norm 1.808481783605e-004
> Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 159
> [0]PETSC ERROR: --------------------- Error Message ----------------------------
> --------
> [0]PETSC ERROR: Nonconforming object sizes!
> [0]PETSC ERROR: Mat mat,Vec y: global dim 4012 1452!
> [0]PETSC ERROR: ----------------------------------------------------------------
> --------
> [0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 6, Mon Feb 11 12:26:34 CST 20
> 13
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR: ----------------------------------------------------------------
> --------
> [0]PETSC ERROR: MCMeshSeg on a arch-mswi named pcs by wmd00 Fri Mar
> 08 18:50:53 2013
> [0]PETSC ERROR: Libraries linked from /cygdrive/d/Library/PETSc/petsc-3.3-p6/arc
> h-mswin-c-opt/lib
> [0]PETSC ERROR: Configure run at Thu Feb 14 19:42:41 2013
> [0]PETSC ERROR: Configure options --with-cc=cl --with-fc=0 --with-cxx=cl --with-
> mpi=0 --with-debugging=0 --download-f2cblaslapack=/cygdrive/d/Library/PETSc/down
> load/f2cblaslapack-3.4.1.q.tar.gz --with-sowing=0 --with-c2html=0 -CFLAGS="-MD -
> wd4996" -CXXFLAGS="-MD -wd4996" --useThreads=0
> [0]PETSC ERROR: ----------------------------------------------------------------
> --------
> [0]PETSC ERROR: MatMult() line 2082 in src/mat/interface/D:\Library\PETSc\PETSC-
> ~2.3-P\src\mat\INTERF~1\matrix.c
> [0]PETSC ERROR: KSPSolve() line 632 in src/ksp/ksp/interface/D:\Library\PETSc\PE
> TSC-~2.3-P\src\ksp\ksp\INTERF~1\itfunc.c
> [0]PETSC ERROR: User provided function() line 1200 in "unknowndirectory/"..\..\g
> uiMeshSeg\MCMeshSeg.cpp
> 
> ==================================================================
> 
> I created the matrix and vector with the following code:
> int MatrixCreate(size_t row, size_t col, Vec& vecsol, Vec& vecrhs, Mat& matA, KSP& ksp)
> {
>     if( !isMeshLoaded ) return 1;
> 
>     if( !isSolverInitialized ) SolverInitialize();
> 
>     PetscErrorCode ierr;
> 
>     ierr = VecCreateSeq(PETSC_COMM_SELF,col,&vecsol);CHKERRQ(ierr);
>     ierr = VecCreateSeq(PETSC_COMM_SELF,row,&vecrhs);CHKERRQ(ierr);
>     ierr = MatCreateSeqAIJ(PETSC_COMM_SELF,row,col,10,PETSC_NULL,&matA);CHKERRQ(ierr);
> 
>     ierr = KSPCreate(PETSC_COMM_SELF,&ksp);CHKERRQ(ierr);
> 
>         ierr = KSPSetType(ksp,KSPLSQR);CHKERRQ(ierr);
>         PC pc;
>         ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
>         ierr = PCSetType(pc,PCNONE);CHKERRQ(ierr);
>         ierr = KSPSetTolerances(ksp,1.0e-6,PETSC_DEFAULT,PETSC_DEFAULT,5000);CHKERRQ(ierr);
>     
>     ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
> 
>     return 0;
> }
> 
> And I solved the system using:
>         ierr = KSPSetInitialGuessNonzero(ksp, PETSC_FALSE);CHKERRQ(ierr);
>         ierr = KSPSetOperators(ksp,matA,matA,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);
>         ierr = KSPSolve(ksp,vecrhs,vecsol);CHKERRQ(ierr);
>         ierr = VecGetArray(vecsol,&avecsol);CHKERRQ(ierr);
> 
> Where is the problem? 
> 
> Thanks,
> Mengda
> 



More information about the petsc-users mailing list