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