<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<font face="Ubuntu">Hi,<br>
<br>
I am solving a Poisson equation (cell-centered discretization)
with multigrid.<br>
</font><font face="Ubuntu">I am using </font>a 2D version of
ksp/ksp/examples/tutorials/ex34.c as a reference. <br>
The following code performs the same calculations as ex34:<br>
<br>
<font face="Ubuntu"> call
PetscInitialize(PETSC_NULL_CHARACTER,ierr)<br>
<br>
call DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE,
DMDA_BOUNDARY_NONE,&<br>
& DMDA_STENCIL_STAR, 16, 16, PETSC_DECIDE,
PETSC_DECIDE, &<br>
& 1, 1, PETSC_NULL_INTEGER,
PETSC_NULL_INTEGER,da,ierr)<br>
call DMDASetInterpolationType(da, DMDA_Q0, ierr);<br>
call DMCreateGlobalVector(da,b,ierr)<br>
call create_rhs(da,b)<br>
call DMCreateMatrix(da,'aij',A,ierr)<br>
call create_matrix(da,A)<br>
call VecDuplicate(b,x,ierr)<br>
<br>
! Create solver<br>
call KSPCreate(PETSC_COMM_WORLD,solver,ierr) <br>
call KSPSetDM(solver,da,ierr)<br>
call KSPSetDMActive(solver,PETSC_FALSE,ierr)<br>
call KSPSetOperators(solver,A,A,SAME_NONZERO_PATTERN,ierr)<br>
call KSPSetType(solver,'cg',ierr)<br>
call KSPSetNormType(solver,KSP_NORM_UNPRECONDITIONED,ierr)<br>
call KSPSetFromOptions(solver,ierr)<br>
call KSPSolve(solver,b,x,ierr) <br>
<br>
rerr = error(da,x)<br>
<br>
call PetscFinalize(ierr)<br>
<br>
<br>
Both ex34 and my code produce exactly the same results except when
I run with <br>
<br>
-ksp_view -ksp_monitor_true_residual -ksp_converged_reason
-ksp_type cg -pc_type mg -pc_mg_levels 4 <br>
<br>
In this case my code results in the following error, despite </font><font
face="Ubuntu"><font face="Ubuntu">KSPSetDMActive is used after </font></font><font
face="Ubuntu"><font face="Ubuntu"><font face="Ubuntu">KSPSetDM:<br>
<br>
</font></font>[0]PETSC ERROR: --------------------- Error
Message ------------------------------------<br>
[0]PETSC ERROR: Object is in wrong state!<br>
[0]PETSC ERROR: You called KSPSetDM() but did not use
DMKSPSetComputeOperators() or KSPSetDMActive(dm,PETSC_FALSE);!<br>
[0]PETSC ERROR:
------------------------------------------------------------------------<br>
[0]PETSC ERROR: Petsc Release Version 3.4.3, Oct, 15, 2013 <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>
[0]PETSC ERROR: ./test on a linux-gnu-dbg named enterprise-A by
mic Thu Nov 14 17:38:23 2013<br>
[0]PETSC ERROR: Libraries linked from
/opt/petsc/petsc-3.4.3/linux-gnu-dbg/lib<br>
[0]PETSC ERROR: Configure run at Tue Oct 29 22:43:45 2013<br>
[0]PETSC ERROR: Configure options --known-mpi-shared="0 "
--known-memcmp-ok --with-debugging="1 " --with-fortran-datatypes
--with-shared-libraries=0 --with-dynamic-loading=0
--with-mpi-compilers="1 " --download-blacs="1 "
--download-superlu_dist="1 " --download-metis="1 "
--download-parmetis="1 " --download-ml=1 PETSC_ARCH=linux-gnu-dbg<br>
[0]PETSC ERROR:
------------------------------------------------------------------------<br>
[0]PETSC ERROR: KSPSetUp() line 230 in
/opt/petsc/petsc-3.4.3/src/ksp/ksp/interface/itfunc.c<br>
[0]PETSC ERROR: PCSetUp_MG() line 730 in
/opt/petsc/petsc-3.4.3/src/ksp/pc/impls/mg/mg.c<br>
[0]PETSC ERROR: PCSetUp() line 890 in
/opt/petsc/petsc-3.4.3/src/ksp/pc/interface/precon.c<br>
[0]PETSC ERROR: KSPSetUp() line 278 in
/opt/petsc/petsc-3.4.3/src/ksp/ksp/interface/itfunc.c<br>
[0]PETSC ERROR: KSPSolve() line 399 in
/opt/petsc/petsc-3.4.3/src/ksp/ksp/interface/itfunc.c<br>
<br>
<br>
Am I missing anything?<br>
Thank you,<br>
<br>
Michele<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</font>
</body>
</html>