[petsc-users] Error using the same ksp with different operator sizes

Matthew Knepley knepley at gmail.com
Thu May 13 09:41:03 CDT 2010


On Thu, May 13, 2010 at 6:10 AM, Eloy Romero <elroal at upvnet.upv.es> wrote:

> Dear all,
>
> I have a code that using the same ksp, solves some matrices with different
> size in that way:
>
>  ierr = KSPCreate(PETSC_COMM_WORLD, &ksp);
>  ...
>  ierr = KSPSetOperators(ksp, A, A, DIFFERENT_NONZERO_PATTERN);
> CHKERRQ(ierr);
>  ierr = KSPSolve(ksp, v0, v1); CHKERRQ(ierr);
>  ...
>  ierr = KSPSetOperators(ksp, B, B, DIFFERENT_NONZERO_PATTERN);
> CHKERRQ(ierr);
>  ierr = KSPSolve(ksp, w0, w1); CHKERRQ(ierr);
>  ...
>
> The KSPSolve is called with vectors of appropriated length. However I
> obtain the following error in the second call to KSPSolve:
>
> [0]PETSC ERROR: --------------------- Error Message
> ------------------------------------
> [0]PETSC ERROR: Nonconforming object sizes!
> [0]PETSC ERROR: Mat mat,Vec x: global dim 1083 66!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 0, unknown
> [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: ./veccomp_ex2 on a linux-gnu named yah by eloy Thu May 13
> 11:27:31 2010
> [0]PETSC ERROR: Libraries linked from
> /usr/src/petsc-release-3.1/linux-gnu-c-debug/lib
> [0]PETSC ERROR: Configure run at Wed Mar 31 13:34:33 2010
> [0]PETSC ERROR: Configure options --with-blas-lapack-dir="[/usr/lib]"
> --with-clanguage=C --with-shared=0 --with-mpi=1 --with-cc=mpicc
> --with-cxx=mpicxx --download-hypre=ifneeded --with-hypre=1 --with-fc=mpif90
> --with-mumps --download-mumps=ifneeded --download-blacs=ifneeded
> --download-scalapack=ifneeded --download-parmetis=ifneeded
> --download-superlu_dist=ifneeded --with-superlu_dist --with-ml
> --download-ml=ifneeded --with-mpi-dir=/usr
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: MatMult() line 1889 in src/mat/interface/matrix.c
> [0]PETSC ERROR: PCApplyBAorAB() line 585 in src/ksp/pc/interface/precon.c
> [0]PETSC ERROR: GMREScycle() line 161 in src/ksp/ksp/impls/gmres/gmres.c
> [0]PETSC ERROR: KSPSolve_GMRES() line 241 in
> src/ksp/ksp/impls/gmres/gmres.c
> [0]PETSC ERROR: KSPSolve() line 396 in src/ksp/ksp/interface/itfunc.c
> [0]PETSC ERROR: main() line 59 in veccomp_ex2.c
>
> I don't find in the reference that one can or cannot use the ksp with
> matrices of different size, so I don't know if it is really a bug.
>

You can only use a KSP to solve one system size.


> In my application, a ksp configured by the user is given, and I would like
> to use that configuration for solving all the linear systems. Creating new
> ksps and configuring them with KSPSetFromOptions is not a complete solution
> because the user could modify the ksp by code.
>

You can replicate all the KSP settings in the new KSP. They are all
available by the API.

   Matt
-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100513/7ada555b/attachment.htm>


More information about the petsc-users mailing list