<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 8, 2014 at 5:44 AM, linjing bo <span dir="ltr"><<a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr">Sorry , forgot to attach file. Thanks in advance.<br>But does the elements in matrix really matters a lot ?</div></div></blockquote><div><br></div><div>Yes, unfortunately. The problem is that you have no diagonal element in row 0. I</div>
<div>do not think our factorization routine can handle this, but I will check with Hong. If</div><div>you put a 0 there, it should work fine.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"> <br><div><hr>Date: Thu, 8 May 2014 05:20:52 -0500<div><div class="h5"><br>Subject: Re: [petsc-users] VecValidValues() reports NaN found<br>
From: <a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a><br>To: <a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a><br>CC: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<br><div dir="ltr"><div><div>On Thu, May 8, 2014 at 2:49 AM, linjing bo <span dir="ltr"><<a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a>></span> wrote:<br>
<blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><div dir="ltr">
<div dir="ltr">Yes, I called KSPDestroy(). I have reproduce the problem using a small C code, this code with default ilu preconditioner will show an error</div></div></div></blockquote><div><br></div><div>Can you also send your matrix so I can run it?</div>
<div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div dir="ltr">
<div dir="ltr"> </div>
<div dir="ltr">[0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>[0]PETSC ERROR: Argument out of range!<br>[0]PETSC ERROR: Cannot log negative flops!<br>[0]PETSC ERROR: ------------------------------------------------------------------------<br>
[0]PETSC ERROR: Petsc Release Version 3.4.4, Mar, 13, 2014<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: ./bptest_c on a arch-linux2-c-debug named <a href="http://node2.indac.info" target="_blank">node2.indac.info</a> by jlin Thu May 8 15:43:13 2014<br>
[0]PETSC ERROR: Libraries linked from /opt/sfw/petsc/3.4.4/intel/openmpi/lib<br>[0]PETSC ERROR: Configure run at Sat Apr 26 20:19:41 2014<br>[0]PETSC ERROR: Configure options --prefix=/opt/sfw/petsc/3.4.4/intel/openmpi --with-mpi-dir=/opt/sfw/openmpi/1.6.3/intel --with-blas-lapack-dir=/opt/sfw/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 --with-mpiexec=mpiexec<br>
[0]PETSC ERROR: ------------------------------------------------------------------------<br>[0]PETSC ERROR: PetscLogFlops() line 204 in /tmp/petsc-3.4.4/include/petsclog.h<br>[0]PETSC ERROR: MatLUFactorNumeric_SeqAIJ() line 552 in /tmp/petsc-3.4.4/src/mat/impls/aij/seq/aijfact.c<br>
[0]PETSC ERROR: MatLUFactorNumeric() line 2889 in /tmp/petsc-3.4.4/src/mat/interface/matrix.c<br>[0]PETSC ERROR: PCSetUp_ILU() line 232 in /tmp/petsc-3.4.4/src/ksp/pc/impls/factor/ilu/ilu.c<br>[0]PETSC ERROR: PCSetUp() line 890 in /tmp/petsc-3.4.4/src/ksp/pc/interface/precon.c<br>
[0]PETSC ERROR: KSPSetUp() line 278 in /tmp/petsc-3.4.4/src/ksp/ksp/interface/itfunc.c<br>[0]PETSC ERROR: KSPSolve() line 399 in /tmp/petsc-3.4.4/src/ksp/ksp/interface/itfunc.c<br>[0]PETSC ERROR: main() line 46 in "unknowndirectory/"test.c<br>
</div><div dir="ltr">===================================================</div><div dir="ltr">Below is the code</div><div dir="ltr">-------------------------------------------------</div><div dir="ltr">static char help[] = "Solve";<br>
#include <petsc.h></div><div dir="ltr">int main(int argc, char **args){<br> Vec x,b,u;<br> Mat A;<br> KSP ksp;<br> PC pc;<br> PetscViewer fd;<br> PetscErrorCode ierr;<br> PetscReal tol=1.e-4;<br>
PetscScalar one = 1.0;<br> PetscInt n=1023;</div><div dir="ltr"> PetscInitialize(&argc,&args,(char*)0,help);</div><div dir="ltr"> ierr = VecCreate(PETSC_COMM_WORLD,&x);CHKERRQ(ierr);<br>
ierr = PetscObjectSetName((PetscObject) x, "Solution");CHKERRQ(ierr);<br> ierr = VecSetSizes(x,PETSC_DECIDE,n);CHKERRQ(ierr);<br> ierr = VecSetFromOptions(x);CHKERRQ(ierr);<br> ierr = VecDuplicate(x,&b);CHKERRQ(ierr);</div>
<div dir="ltr"> PetscViewerBinaryOpen(PETSC_COMM_WORLD, "tor0bp.bin", FILE_MODE_READ, &fd);<br> ierr = MatCreateAIJ(PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,n,n, \<br> 11,PETSC_NULL,11,PETSC_NULL,&A);<br>
ierr = MatLoad(A, fd);<br> PetscViewerDestroy(&fd);</div><div dir="ltr"> VecSet( b, one);<br> VecSet( x, one);<br> VecAssemblyBegin(b);<br> VecAssemblyEnd(b);<br> VecAssemblyBegin(x);<br>
VecAssemblyEnd(x);</div><div dir="ltr"> ierr = KSPCreate(PETSC_COMM_WORLD,&ksp);CHKERRQ(ierr);</div><div dir="ltr"> ierr = KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);</div>
<div dir="ltr">
ierr = KSPSetTolerances(ksp,1.e-5,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr);</div><div dir="ltr"> ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);</div><div dir="ltr"> ierr = KSPSetInitialGuessNonzero(ksp,PETSC_TRUE);CHKERRQ(ierr);</div>
<div dir="ltr"> ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);</div><div dir="ltr"> ierr = KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<br><br> KSPDestroy(&ksp);<br> VecDestroy(&x);<br>
VecDestroy(&b);<br> PetscFinalize();<br> return 0;<br>}</div><div dir="ltr">-----------------------------------------------------------<br><br></div><div dir="ltr"><hr>Date: Wed, 7 May 2014 05:52:13 -0500<br>
Subject: Re: [petsc-users] VecValidValues() reports NaN found<br>From: <a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a><br>To: <a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a><br>
CC: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br><br><div dir="ltr"><div><div>On Tue, May 6, 2014 at 10:53 PM, linjing bo <span dir="ltr"><<a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a>></span> wrote:<br>
<blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><div dir="ltr">The Valgrind shows memory leak in memalign() called by KSPSetup and PCSetup. Is that normal?</div></div></blockquote><div><br></div><div><br></div><div>Did you call KSPDestroy()?</div><div><br></div><div>
Matt </div><blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div dir="ltr"> <br>---------------------------------------------------------------------------------------------<br>
==31551== 136 bytes in 1 blocks are definitely lost in loss record 2,636 of 3,327<br>==31551== at 0x4A05458: memalign (vg_replace_malloc.c:727)<br>==31551== by 0x5498E79: PetscMallocAlign (mal.c:27)<br>==31551== by 0x5DE9D5E: KSPSetUp_GMRES (gmres.c:75)<br>
==31551== by 0x5E1C41F: KSPSetUp (itfunc.c:239)<br>==31551== by 0x5E1821D: KSPSolve (itfunc.c:399)<br>==31551== by 0x5CAD7F1: kspsolve_ (itfuncf.c:219)<br>==31551== by 0x8D9842: petsc_solver_defi_ (petsc_defi.F90:434)<br>
==31551== by 0x831618: field_solver_defi_ (field_defi.F90:57)<br>==31551== by 0x46CB4E: MAIN__ (main.F90:96)<br>==31551== by 0x41852B: main (in /home/jlin/defi_field/ftest/gtc)<br> <br>...<br> <br>==31551== 4,092 bytes in 1 blocks are definitely lost in loss record 3,113 of 3,327<br>
==31551== at 0x4A05458: memalign (vg_replace_malloc.c:727)<br>==31551== by 0x5498E79: PetscMallocAlign (mal.c:27)<br>==31551== by 0x5A085AE: MatDuplicateNoCreate_SeqAIJ (aij.c:4011)<br>==31551== by 0x5A2D24F: MatILUFactorSymbolic_SeqAIJ_ilu0 (aijfact.c:1655)<br>
==31551== by 0x5A2B7CB: MatILUFactorSymbolic_SeqAIJ (aijfact.c:1756)<br>==31551== by 0x573D152: MatILUFactorSymbolic (matrix.c:6240)<br>==31551== by 0x5CFB843: PCSetUp_ILU (ilu.c:204)<br>==31551== by 0x5D8BAA7: PCSetUp (precon.c:890)<br>
==31551== by 0x5E1C639: KSPSetUp (itfunc.c:278)<br>==31551== by 0x5E1821D: KSPSolve (itfunc.c:399)<br>==31551== by 0x5CAD7F1: kspsolve_ (itfuncf.c:219)<br>==31551== by 0x8D9842: petsc_solver_defi_ (petsc_defi.F90:434)<br>
==31551== by 0x831618: field_solver_defi_ (field_defi.F90:57)<br>==31551== by 0x46CB4E: MAIN__ (main.F90:96)<br>==31551== by 0x41852B: main (in /home/jlin/defi_field/ftest/gtc)<br><br>-------------------------------------------------------------------------------------------------<br>
<br> <br><div><hr>From: <a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a><br>To: <a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a><br>CC: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
Subject: RE: [petsc-users] VecValidValues() reports NaN found<br>Date: Mon, 5 May 2014 13:15:38 +0000<br><br>
<div dir="ltr">Ok, I will try it . Thanks for your advise. <br><br><div><hr>Date: Mon, 5 May 2014 08:12:05 -0500<br>Subject: Re: [petsc-users] VecValidValues() reports NaN found<br>From: <a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a><br>
To: <a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a><br>CC: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br><br><div dir="ltr"><div><div>On Mon, May 5, 2014 at 7:56 AM, linjing bo <span dir="ltr"><<a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a>></span> wrote:<br>
<blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><div dir="ltr">I use JACOBI. The message showed is with JACOBI. <br><br><br>Wired situation is that the backtrack information shows the location
is before actually apply PC, so I guess the rhs vec is not changed at
this point.<br><br>Another wired thing is : Because the original code is
to complex. I write out the A matrix in Ax=b, and write a small test
code to read in this matrix and solve it, no error showed. The KSP, PC
are all set to be the same.<br><br>When I try to using ILU, more wired error happens, the backtrack info shows it died in a Flops logging function:<br></div></div></blockquote><div><br></div><div>1) Run in serial until it works</div>
<div><br></div><div>2) It looks like you have memory overwriting problems. Run with valgrind</div><div><br></div><div> Matt</div><div> </div><blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><div dir="ltr">[2]PETSC ERROR: --------------------- Error Message ------------------------------------<br>[2]PETSC ERROR: Argument out of range! <br>[2]PETSC ERROR: Cannot log negative flops! <br>
[2]PETSC ERROR: ------------------------------------------------------------------------<br>[2]PETSC ERROR: Petsc Release Version 3.4.4, Mar, 13, 2014 <br>[2]PETSC ERROR: See docs/changes/index.html for recent updates. <br>
[2]PETSC ERROR: See docs/faq.html for hints about trouble shooting. <br>[2]PETSC ERROR: See docs/index.html for manual pages. <br>[2]PETSC ERROR: ------------------------------------------------------------------------<br>
[2]PETSC ERROR: ./gtc on a arch-linux2-c-debug named <a href="http://node2.indac.info" target="_blank">node2.indac.info</a> by jlin Mon May 5 20:51:27 2014 <br>
[2]PETSC ERROR: Libraries linked from /opt/sfw/petsc/3.4.4/intel/openmpi/lib <br>[2]PETSC ERROR: Configure run at Sat Apr 26 20:19:41 2014 <br>[2]PETSC ERROR: Configure options --prefix=/opt/sfw/petsc/3.4.4/intel/openmpi --with-mpi-dir=/opt/sfw/openmpi/1.6.3/intel --with-blas-lapack-dir=/opt/sfw/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 --with-mpiexec=mpiexec <br>
[2]PETSC ERROR: ------------------------------------------------------------------------ <br>[2]PETSC ERROR: PetscLogFlops() line 204 in /tmp/petsc-3.4.4/include/petsclog.h <br>[2]PETSC ERROR: MatLUFactorNumeric_SeqAIJ() line 552 in /tmp/petsc-3.4.4/src/mat/impls/aij/seq/aijfact.c <br>
[2]PETSC ERROR: MatLUFactorNumeric() line 2889 in /tmp/petsc-3.4.4/src/mat/interface/matrix.c <br>[2]PETSC ERROR: PCSetUp_ILU() line 232 in /tmp/petsc-3.4.4/src/ksp/pc/impls/factor/ilu/ilu.c <br>[2]PETSC ERROR: PCSetUp() line 890 in /tmp/petsc-3.4.4/src/ksp/pc/interface/precon.c <br>
[2]PETSC ERROR: KSPSetUp() line 278 in /tmp/petsc-3.4.4/src/ksp/ksp/interface/itfunc.c <br>[2]PETSC ERROR: KSPSolve() line 399 in /tmp/petsc-3.4.4/src/ksp/ksp/interface/itfunc.c <br><br><br><br><br>
<div><hr>Date: Mon, 5 May 2014 07:27:52 -0500<br>Subject: Re: [petsc-users] VecValidValues() reports NaN found<br>From: <a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a><br>To: <a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a><br>
CC: <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br><br><div dir="ltr"><div><div>On Mon, May 5, 2014 at 7:25 AM, linjing bo <span dir="ltr"><<a href="mailto:francium87@hotmail.com" target="_blank">francium87@hotmail.com</a>></span> wrote:<br>
<blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><div dir="ltr">
<div dir="ltr">Hi, I'm trying to use PETSc's ksp method to solve a linear system. When running, Error is reported by VecValidValues() that NaN or Inf is found with error message listed below <br><br><br>[3]PETSC ERROR: --------------------- Error Message ------------------------------------ <br>
[3]PETSC ERROR: Floating point exception! <br>[3]PETSC ERROR: Vec entry at local location 0 is not-a-number or infinite at beginning of function: Parameter number 2! <br>
[3]PETSC ERROR: ------------------------------------------------------------------------ <br>[3]PETSC ERROR: Petsc Release Version 3.4.4, Mar, 13, 2014 <br>[3]PETSC ERROR: See docs/changes/index.html for recent updates. <br>
[3]PETSC ERROR: See docs/faq.html for hints about trouble shooting. <br>[3]PETSC ERROR: See docs/index.html for manual pages. <br>[3]PETSC ERROR: ------------------------------------------------------------------------ <br>
[3]PETSC ERROR: ./gtc on a arch-linux2-c-debug named <a href="http://node2.indac.info" target="_blank">node2.indac.info</a> by jlin Mon May 5 20:03:20 2014 <br>
[3]PETSC ERROR: Libraries linked from /opt/sfw/petsc/3.4.4/intel/openmpi/lib <br>[3]PETSC ERROR: Configure run at Sat Apr 26 20:19:41 2014 <br>[3]PETSC ERROR: Configure options --prefix=/opt/sfw/petsc/3.4.4/intel/openmpi --with-mpi-dir=/opt/sfw/openmpi/1.6.3/intel --with-blas-lapack-dir=/opt/sfw/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 --with-mpiexec=mpiexec <br>
[3]PETSC ERROR: ------------------------------------------------------------------------ <br>[3]PETSC ERROR: VecValidValues() line 28 in /tmp/petsc-3.4.4/src/vec/vec/interface/rvector.c </div></div></div></blockquote>
<div><br></div><div>It looks like the vector after preconditioner application is bad. What is the preconditioner?</div><div><br></div><div> Matt</div><div> </div><blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><div dir="ltr"><div dir="ltr"> <br>[3]PETSC ERROR: PCApply() line 436 in /tmp/petsc-3.4.4/src/ksp/pc/interface/precon.c <br>[3]PETSC ERROR: KSP_PCApply() line 227 in /tmp/petsc-3.4.4/include/petsc-private/kspimpl.h <br>
[3]PETSC ERROR: KSPInitialResidual() line 64 in /tmp/petsc-3.4.4/src/ksp/ksp/interface/itres.c <br>[3]PETSC ERROR: KSPSolve_GMRES() line 239 in /tmp/petsc-3.4.4/src/ksp/ksp/impls/gmres/gmres.c <br>[3]PETSC ERROR: KSPSolve() line 441 in /tmp/petsc-3.4.4/src/ksp/ksp/interface/itfunc.c <br>
<br><br>After read the source code shown by backtrack informations, I realize the problem is in the right hand side vector. So I make a trial of set right hand side vector to ONE by VecSet, But the program still shows error message above, and using VecView or VecGetValue to investigate the first value of rhs vec shows the value is 1.0 as I set it to. Hope I clearly describe the problem. The code related is listed below<br>
<br>---------------------------Solver section--------------------------<br><br> call VecSet( pet_bp_b, one, ierr)<br><br> vecidx=[0,1]<br> call VecGetValues( pet_bp_b, 2, vecidx, first, ierr)<br> write(*,*) ' first two values ', first(1), first(2)<br>
<br> call KSPSetInitialGuessNonzero(solver_bp,Petsc_True,ierr)<br> call KSPSolve(solver_bp,pet_bp_b,pet_bp_x,ierr)<br> call KSPView(solver_bp, PETSC_VIEWER_STDOUT_SELF,ierr)<br> CHKERRQ(ierr)<br><br><br></div><span><font color="#888888">
</font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</font></span></font></span></div></div></div><span><font color="#888888"> </font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</font></span></font></span></div></div></div><span><font color="#888888"> </font></span></div></div><span><font color="#888888"> </font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</font></span></div></div></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div></div></div></div> </div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>