<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "> ierr = MatCreateSeqAIJ(PETSC_COMM_SELF,N,N,10,PETSC_NULL,&J);CHKERRQ(ierr);<div><div> ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div> ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div><div> ierr = SNESComputeJacobian(ts_snes,CV_Y,&J,&J,&flag);CHKERRQ(ierr);</div><div> ierr = MatGetColoring(J,MATCOLORINGSL,&iscoloring);CHKERRQ(ierr);</div><div> ierr = MatFDColoringCreate(J,iscoloring,&matfdcoloring);CHKERRQ(ierr);</div><div> ierr = MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode (*)(void))f,(void*)&appctx);CHKERRQ(ierr);</div><div> ierr = MatFDColoringSetFromOptions(matfdcoloring);CHKERRQ(ierr);</div><div> ierr = TSSetRHSJacobian(ts,J,J,TSDefaultComputeJacobianColor,matfdcoloring);</div><div><div><br></div><div>These are the Jacobian related codes.</div></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><div>On Jul 7, 2010, at 1:51 PM, Satish Balay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><blockquote type="cite">total: nonzeros=1830<br></blockquote><blockquote type="cite">mallocs used during MatSetValues calls =1830<br></blockquote><br>Looks like you are zero-ing out the non-zero structure - before<br>assembling the matrix.<br><br>Are you calling MatZeroRows() or MatZeroEntries() or something else -<br>before assembling the matrix?<br><br>Satish<br><br>On Wed, 7 Jul 2010, Xuan YU wrote:<br><br><blockquote type="cite">I made a change: ierr =<br></blockquote><blockquote type="cite">MatCreateSeqAIJ(PETSC_COMM_SELF,N,N,5,PETSC_NULL,&J);CHKERRQ(ierr);<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Time of the code did not change much, and got the info:<br></blockquote><blockquote type="cite">Matrix Object:<br></blockquote><blockquote type="cite"> type=seqaij, rows=1830, cols=1830<br></blockquote><blockquote type="cite"> total: nonzeros=1830, allocated nonzeros=36600<br></blockquote><blockquote type="cite"> total number of mallocs used during MatSetValues calls =1830<br></blockquote><blockquote type="cite"> not using I-node routines<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Jul 7, 2010, at 12:51 PM, Satish Balay wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total: nonzeros=1830, allocated nonzeros=29280<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total number of mallocs used during MatSetValues calls =1830<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">There is something wrong with your preallocation or matrix<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">assembly. You should see zero mallocs for efficient assembly.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#efficient-assembly">http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#efficient-assembly</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">satish<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">On Wed, 7 Jul 2010, Xuan YU wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Hi,<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">I finite difference Jacobian approximation for my TS model. The size of<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">the<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">vector is 1830. I got the following info with(-ts_view):<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">type: beuler<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">maximum steps=50<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">maximum time=50<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">total number of nonlinear solver iterations=647<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">total number of linear solver iterations=647<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">SNES Object:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> type: ls<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> line search variant: SNESLineSearchCubic<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> alpha=0.0001, maxstep=1e+08, minlambda=1e-12<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> maximum iterations=50, maximum function evaluations=10000<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> tolerances: relative=1e-08, absolute=1e-50, solution=1e-08<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total number of linear solver iterations=50<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total number of function evaluations=51<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> KSP Object:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> type: gmres<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> GMRES: restart=30, using Classical (unmodified) Gram-Schmidt<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Orthogonalization with no iterative refinement<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> GMRES: happy breakdown tolerance 1e-30<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> maximum iterations=10000, initial guess is zero<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> tolerances: relative=1e-05, absolute=1e-50, divergence=10000<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> left preconditioning<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> using PRECONDITIONED norm type for convergence test<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> PC Object:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> type: ilu<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> ILU: out-of-place factorization<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> 0 levels of fill<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> tolerance for zero pivot 1e-12<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> using diagonal shift to prevent zero pivot<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> matrix ordering: natural<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> factor fill ratio given 1, needed 1<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Factored matrix follows:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Matrix Object:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> type=seqaij, rows=1830, cols=1830<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> package used to perform factorization: petsc<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total: nonzeros=1830, allocated nonzeros=1830<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total number of mallocs used during MatSetValues calls =0<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> not using I-node routines<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> linear system matrix = precond matrix:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Matrix Object:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> type=seqaij, rows=1830, cols=1830<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total: nonzeros=1830, allocated nonzeros=29280<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> total number of mallocs used during MatSetValues calls =1830<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> not using I-node routines<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">50 output time step takes me 11.877s. So I guess there is something not<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">appropriate with my Jacobian Matrix. Could you please tell me how to speed<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">up<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">my code?<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Thanks!<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Xuan YU<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><a href="mailto:xxy113@psu.edu">xxy113@psu.edu</a><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Xuan YU (俞烜)<br></blockquote><blockquote type="cite"><a href="mailto:xxy113@psu.edu">xxy113@psu.edu</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br><div apple-content-edited="true"> <div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Xuan YU (<span class="Apple-style-span" style="font-family: arial; font-size: 16px; white-space: pre; ">俞烜<span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; white-space: normal; ">)</span></span></div><div><a href="mailto:xxy113@psu.edu">xxy113@psu.edu</a></div><div><br></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"> </div><br></div></body></html>